dereuromark 9 年 前
コミット
1814f26fc9
4 ファイル変更98 行追加7 行削除
  1. 47 0
      docs/Helper/Html.md
  2. 19 7
      docs/README.md
  3. 32 0
      docs/Url/Url.md
  4. 0 0
      sniff

+ 47 - 0
docs/Helper/Html.md

@@ -0,0 +1,47 @@
+# Html Helper
+
+An enhanced HtmlHelper
+- imageFromBlob()
+- resetLink() and completeLink()
+
+## Usage
+Attach it to your controllers like so:
+```php
+public $helpers = ['Tools.Html'];
+```
+It will replace the CakePHP core one everywhere.
+
+### Image from Blob
+Sometimes you might want to directly output images inside the HTML without external files involved.
+The image, like a small 16x16 icon, could also directly come from the database.
+
+```php
+$blobImage = file_get_contents($path . 'my-image.png');
+// or from somewhere else
+
+echo $this->Html->imageFromBlob($blobImage);
+```
+The output will be a base64 encoded embedded image.
+
+Bear in mind that this does not work with all (especially older) browsers.
+
+### Reset and Complete Links
+In some cases you want to display the links without the plugin and prefix automatically being taken from the current URL.
+This is especially important with navigation menu or layout elements, as those will be outputted on every page, even outside of the current plugin or prefix scope.
+
+You can then either manually and verbosely always set both to `false`, or just use the convenience method:
+```php
+echo $this->Html->resetLink(['controller' => 'Foo', 'action' => 'bar']);
+```
+
+Inside `/admin/plugin-name/example/action` the linked URL would normally become `/admin/plugin-name/foo/bar`.
+With the resetLink() method it will become the desired: `/foo/bar`.
+
+In both cases, however, the query strings are not passed on. If you want that, you can use the other convenience method:
+```php
+echo $this->Html->completeLink(['controller' => 'Foo', 'action' => 'bar']);
+```
+Now if there was a query string `?q=x` on the current action, it would also be passed along as `/foo/bar?q=x`.
+
+
+See also [Url helper](/docs/Url/Url.md).

+ 19 - 7
docs/README.md

@@ -12,16 +12,28 @@ This cake3 branch only works for **CakePHP3.x** - please use the master branch f
 * [Upgrade guide from 2.x to 3.x](Upgrade.md)
 
 ## Detailed Documentation - Quicklinks
+
+Routing:
+* [Url](Url/Url.md)
+
+ErrorHandler
 * [ErrorHandler](Error/ErrorHandler.md)
-* [Behavior/Jsonable](Behavior/Jsonable.md)
-* [Behavior/Passwordable](Behavior/Passwordable.md)
-* [Behavior/Slugged](Behavior/Slugged.md)
-* [Behavior/Bitmasked](Behavior/Bitmasked.md)
-* [Behavior/Reset](Behavior/Reset.md)
-* [Behavior/String](Behavior/String.md)
-* [View/Rss](View/Rss.md)
+
+Testing
 * [Testing](TestSuite/Testing.md)
 
+Helpers:
+* [Html](Helper/Html.md)
+* [Form](Helper/Form.md)
+
+Behaviors:
+* [Jsonable](Behavior/Jsonable.md)
+* [Passwordable](Behavior/Passwordable.md)
+* [Slugged](Behavior/Slugged.md)
+* [Bitmasked](Behavior/Bitmasked.md)
+* [Reset](Behavior/Reset.md)
+* [String](Behavior/String.md)
+
 ## Basic enhancements of the core
 
 ### Model

+ 32 - 0
docs/Url/Url.md

@@ -0,0 +1,32 @@
+# Url component and helper 
+
+There is both a component and helper that help to work around some URL issues.
+
+### Defaults
+If you need to merge in defaults to your URLs, you can get the information from the `defaults()` method:
+
+```php
+// From inside a plugin controller
+$$this->redirect(['controller' => 'Main', 'action' => 'index'] + $this->Url->defaults());
+```
+It will basically add in `'prefix' => false, 'plugin' => false`.
+
+### Reset
+You can in that case also just use the convenience method:
+```php
+$url = $this->Url->reset(['controller' => 'Main', 'action' => 'overview']);
+```
+
+Inside `/admin/plugin-name/example/action` the URL to redirect to would normally become `/admin/plugin-name/main/overview`.
+With the reset() method it will become the desired: `/main/overview`.
+
+### Complete
+In both cases, however, the query strings are not passed on. If you want that, you can use the other convenience method:
+```php
+$url = $this->Url->complete(['controller' => 'Main', 'action' => 'overview']);
+```
+Now if there was a query string `?q=x` on the current action, it would also be passed along as `/main/overview?q=x`.
+
+
+### Generating links
+For generating links for those cases please see [Html helper](/docs/Helper/Html).

+ 0 - 0
sniff