HtmlHelper.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 0.9.1
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Tools\View\Helper;
  16. use Cake\Core\Configure;
  17. use Cake\Network\Response;
  18. use Cake\View\Helper\HtmlHelper as CoreHtmlHelper;
  19. use Cake\View\StringTemplateTrait;
  20. use Cake\View\View;
  21. /**
  22. * Html Helper class for easy use of HTML widgets.
  23. *
  24. * HtmlHelper encloses all methods needed while working with HTML pages.
  25. *
  26. * @link http://book.cakephp.org/3.0/en/views/helpers/html.html
  27. */
  28. class HtmlHelper extends CoreHtmlHelper {
  29. /**
  30. * Creates a reset HTML link.
  31. * The prefix and plugin params are resetting to default false.
  32. *
  33. * ### Options
  34. *
  35. * - `escape` Set to false to disable escaping of title and attributes.
  36. * - `escapeTitle` Set to false to disable escaping of title. Takes precedence
  37. * over value of `escape`)
  38. * - `confirm` JavaScript confirmation message.
  39. *
  40. * @param string $title The content to be wrapped by <a> tags.
  41. * @param string|array|null $url URL or array of URL parameters, or
  42. * external URL (starts with http://)
  43. * @param array $options Array of options and HTML attributes.
  44. * @return string An `<a />` element.
  45. */
  46. public function resetLink($title, $url = null, array $options = []) {
  47. if (is_array($url)) {
  48. $url += ['prefix' => false, 'plugin' => false];
  49. }
  50. return parent::link($title, $url, $options);
  51. }
  52. /**
  53. * Keep query string params for pagination/filter for this link,
  54. * e.g. after edit action.
  55. *
  56. * ### Options
  57. *
  58. * - `escape` Set to false to disable escaping of title and attributes.
  59. * - `escapeTitle` Set to false to disable escaping of title. Takes precedence
  60. * over value of `escape`)
  61. * - `confirm` JavaScript confirmation message.
  62. *
  63. * @param string $title The content to be wrapped by <a> tags.
  64. * @param string|array|null $url URL or array of URL parameters, or
  65. * external URL (starts with http://)
  66. * @param array $options Array of options and HTML attributes.
  67. * @return string An `<a />` element.
  68. * @return string Link
  69. */
  70. public function completeLink($title, $url = null, array $options = []) {
  71. if (is_array($url)) {
  72. // Add query strings
  73. if (!isset($url['?'])) {
  74. $url['?'] = [];
  75. }
  76. $url['?'] += $this->request->query;
  77. }
  78. return parent::link($title, $url, $options);
  79. }
  80. /**
  81. * Event listeners.
  82. *
  83. * @return array
  84. */
  85. public function implementedEvents()
  86. {
  87. return [];
  88. }
  89. }