You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Being one of CkTools' core features, CkToolsHelper provides many useful functionalities, most of them aimed at generating powerful view elements such as form- and navigation buttons, often with as much as one line of code. Here's an overview of its actions. See `CkToolsHelper.php` for further details.
60
60
@@ -75,11 +75,11 @@ Creates a mailto link to the email address given in `$email`. `$options` include
Renders an edit button for given database record `$entity`. By defailt, this button will link to the entity's Controller's edit action but this can be overwritten using the `'url'` field of the `$options` array.
78
+
Renders an edit button for given database record `$entity`. By default, this button will link to the entity's Controller's edit action but this can be overwritten using the `'url'` field of the `$options` array.
Renders a details button for given database record `$entity`. By defailt, this button will link to the entity's Controller's view action but this can be overwritten using the `'url'` field of the `$options` array.
82
+
Renders a details button for given database record `$entity`. By default, this button will link to the entity's Controller's view action but this can be overwritten using the `'url'` field of the `$options` array.
83
83
@return string
84
84
85
85
-`addButton($title = null, array $options = [])`
@@ -111,7 +111,7 @@ Renders a nested list. The param `$data` holds the data to be displayed in assoc
111
111
@return string
112
112
113
113
-`historyBackButton(array $options = [])`
114
-
Renders a div with an onclick-hanlder which uses the history API of the Browser.
114
+
Renders a div with an onclick handler which uses the history API of the Browser.
@@ -122,7 +122,7 @@ Display an array in human-readable format. The `'$options'` array includes a fie
122
122
Rercursively converts an array to an unordered list.
123
123
@return string
124
124
125
-
###2. MenuHelper
125
+
###2. MenuHelper
126
126
127
127
The MenuHelper aims at config-based rendering of hierarchical navigation menus in the UI. Here's an overview of its actions. See `MenuHelper.php` for further details.
128
128
@@ -144,7 +144,7 @@ Uses CakePHP's AuthComponent to check if given array of items 'children' contain
144
144
Compares the current URL with given menu item to determine wether it should be highlighted or not.
145
145
@return bool
146
146
147
-
####`config.php` - a closer look
147
+
####`config.php` - a closer look
148
148
Here's an example of what `config.php` could look like, explaining more possibilities:
149
149
150
150
```
@@ -181,23 +181,23 @@ $config = [
181
181
'action' => 'actionBar'
182
182
]
183
183
],
184
-
// furhter sub-items for menu item 'examples'
184
+
// further sub-items for menu item 'examples'
185
185
]
186
186
],
187
-
// furter menu items
187
+
// further menu items
188
188
```
189
189
190
-
##Manage files with TinyMCE and Moxiemanager
190
+
##Manage files with TinyMCE and Moxiemanager
191
191
Moxiemanager is a powerful media manager which can be used in combination with the web-based JavaScript editor TinyMCE. CkTools provides a CakePHP-friendly integration for these features.
192
192
Get them here:
193
193
194
-
-[Moxiemanager](http://www.moxiemanager.com/getit/) - Note that you need to purchase a licence
194
+
-[Moxiemanager](http://www.moxiemanager.com/getit/) - Note that you need to purchase a license
195
195
-[TinyMCE](https://www.tinymce.com/download/)
196
196
197
-
###Setting up TinyMceHelper using Cake Frontend Bridge
197
+
###Setting up TinyMceHelper using Cake Frontend Bridge
198
198
We strongly suggest to use our [Cake Frontend Bridge Plugin](https://github.com/scherersoftware/cake-frontend-bridge) to make using TinyMCE and MoxieManager as convenient as possible. Here's how to setup these features in your project using the Frontend Bridge.
199
199
200
-
####app.php
200
+
####app.php
201
201
```
202
202
'CkTools' => [
203
203
'moxiemanager' => [
@@ -208,7 +208,7 @@ We strongly suggest to use our [Cake Frontend Bridge Plugin](https://github.com/
208
208
]
209
209
```
210
210
211
-
####Appcontroller.php
211
+
####Appcontroller.php
212
212
**`$helpers`**
213
213
214
214
```
@@ -217,7 +217,7 @@ public $helpers = [
217
217
]
218
218
```
219
219
220
-
####app_controller.js (using Frontend Bridge)
220
+
####app_controller.js (using Frontend Bridge)
221
221
222
222
If you choose to use the Frontend Bridge Plugin, here's how to configure it in a way that makes using MoxiePicker in a View file super easy. Of course, using another kind of PageController is possible as well.
223
223
@@ -245,7 +245,7 @@ this.TinyMce.setConfig({
245
245
});
246
246
```
247
247
248
-
####view.ctp
248
+
####view.ctp
249
249
250
250
The TinyMce helper provides a wrapper for FormHelper::input() and will generate an input field with a button to choose a file from Moxiemanager. The relative path of the chosen file will be set as the value of the text field.
251
251
@@ -261,13 +261,13 @@ Add an input element using MoxiePicker:
You can create a plugin, e.g. "Api" to include all your API controller code. Using an API greatly simplifies backend-communication using JavaScript. If you have an Api plugin, make sure you set 'bootstrap' => true when loading the plugin in your bootstrap.
267
267
268
268
Use the following configuration to make sure errors in the api are always returned as JSON.
269
269
270
-
####bootstrap.php
270
+
####bootstrap.php
271
271
272
272
```
273
273
if (substr(env('REQUEST_URI'), 0, 5) === '/api/') {
-`$array $data`: Data for the `'data'` key of the response
@@ -320,11 +320,11 @@ This call will return an `application/json` response with the HTTP Status Code `
320
320
{"code": "success","data":{"hello":"world"}}
321
321
```
322
322
323
-
##Create a PDF using CakePHP Views
323
+
##Create a PDF using CakePHP Views
324
324
325
325
CkTools includes a simple wrapper for the [MPDF library](http://www.mpdf1.com/mpdf/index.php). For detailed instructions on how to use it, see the github repository here: [https://github.com/mpdf/mpdf](https://github.com/mpdf/mpdf)
326
326
327
-
####Usage
327
+
####Usage
328
328
Here's an example use in a Cake Controller but you can use this feature wherever you want. See `/cake-cktools/src/Lib/PdfGenerator.php` for a closer look at the functionalities used.
329
329
330
330
```
@@ -362,7 +362,7 @@ $mpdf->WriteHTML("This is page 2");
362
362
```
363
363
364
364
## Sort table fields with SortableBehavior
365
-
CkTools provides a behavior that allows manipulation of the (displayed) order of the records of a table. If you change the position of one field, the behavior will automatically change all the other fields' positions accordingly. To manipulate the positions you can use an ordinary form field or for example the Cake Frontend Bridge to enable js-based drag-and-drop interaction in the browser UI.
365
+
CkTools provides a behavior that allows manipulation of the (displayed) order of the records of a table. If you change the position of one field, the behavior will automatically change all the other fields' positions accordingly. To manipulate the positions you can use an ordinary form field or for example the Cake Frontend Bridge to enable JavaScript-based drag-and-drop interaction in the browser UI.
366
366
367
367
## Strict Passwords with StrictPasswordBehavior
368
368
Activate the strict password requirements by setting the StrictPasswordBehavior in UsersTable; default Configuration is set in this example
##Manipulate database records with TableUtilitiesTrait
411
+
##Manipulate database records with TableUtilitiesTrait
412
412
The TableUtilitiesTrait contains an action that allows for manually updating the value of a field in a table. Using `updateField()` bypasses cake validation and patching of the object. The given value is directly written to the database via a SQL query.
413
413
414
-
####Setting up a Model
414
+
####Setting up a Model
415
415
Add the Trait in **`YourTable.php`**:
416
416
417
417
```
@@ -432,10 +432,10 @@ Now you can use the `updateField()` action to directly manipulate a record. Let'
432
432
-`$field`: the name of the field you want to change
433
433
-`$value = null`: the new value you want to save to the database
434
434
435
-
##Handle type constants with TypeAwareTrait
436
-
Entities with type constants can be very useful, for example if you wish to grant different rights to different kinds of users such as Admins, regular Users, External users etc. With CkTools' TypeAwareTrait, setting up and using such constants becames fast and simple.
435
+
##Handle type constants with TypeAwareTrait
436
+
Entities with type constants can be very useful, for example if you wish to grant different rights to different kinds of users such as Admins, regular Users, External users etc. With CkTools' TypeAwareTrait, setting up and using such constants becomes fast and simple.
437
437
438
-
####Setting up a Model:
438
+
####Setting up a Model:
439
439
Let's prepare an example use case where you want to assign different roles to different groups of users in your application. Set up your **User.php** like so:
440
440
441
441
```
@@ -494,10 +494,10 @@ Example: in a Cake View file for Model **Cars**:
494
494
<?php endif; ?>
495
495
```
496
496
497
-
##Identify users with UserToken
497
+
##Identify users with UserToken
498
498
CkTools provides a utility class that generates serialized, encrypted and base64-encoded for identifying users, usually for usage in an URL. This is very handy for 'forgot password' links so if you have a LoginController, using UserToken there is most advisable.
499
499
500
-
####Usage
500
+
####Usage
501
501
Here's how to use **UserToken** in any class you like:
502
502
503
503
```
@@ -528,20 +528,20 @@ decrypts given token and only returns the encrypted user_id.
528
528
529
529
See `cake-cktools/src/Utility/UserToken.php` for further information about these actions.
530
530
531
-
##I18nShell
531
+
##I18nShell
532
532
533
533
CkTools provides a helper shell for i18n related tasks.
534
534
535
-
###Update .po and .mo files from catalog
535
+
###Update .po and .mo files from catalog
536
536
537
537
To automate the updating of .po/.mo files from available translation strings from the catalog (.pot) file, use the `updateFromCatalog` command.
538
538
539
539
This is done using the excellent [oscarotero/Gettext](https://github.com/oscarotero/Gettext) library.
540
540
541
-
Example usage:
541
+
#### Usage
542
542
543
543
1. Update all default.po and default.mo files found in `src/Locale/*` with translation strings from `src/Locale/default.pot`. The shell will list the files it will touch and asks for confirmation.
544
-
544
+
545
545
bin/cake CkTools.I18n updateFromCatalog
546
546
547
547
2. Update all default.po and default.mo files found in `src/Locale/*` with translation strings from `src/Locale/default.pot`. The shell will overwrite files without interaction.
@@ -551,7 +551,62 @@ Example usage:
551
551
3. Update all default.po and default.mo files found in `src/Locale/*` with translation strings from `src/Locale/default.pot`. The shell will overwrite files without interaction. Also, it will strip all references, meaning the filenames and lines where the translation was used from the resulting .po and .mo files.
4. Update all cake.po and cake.mo files found in `src/Locale/*` with translation strings from `src/Locale/default.pot`. The shell will list the files it will touch and asks for confirmation.
// bool config value to set X-Frame-Options header to "DENY" if true
605
+
'denyFraming' => true
606
+
]
607
+
],
608
+
```
609
+
610
+
The X-Frame-Options header set by 'denyFraming' is superceded by the Content Security Policy's frame-ancestors directive, but as frame-ancestors is not yet supported in IE11 and older, Edge, Safari 9.1 (desktop), and Safari 9.2 (iOS), it is recommended that sites employ X-Frame-Options in addition to using CSP.
611
+
612
+
If you wish to exclude any header, simply set its value to something falsy or omit the array key completely.
0 commit comments