'', 'metalink' => '', 'link' => '%s', 'mailto' => '%s', 'form' => '
', 'formend' => '
', 'input' => '', 'textarea' => '', 'hidden' => '', 'checkbox' => '', 'checkboxmultiple' => '', 'radio' => '%s', 'selectstart' => '', 'selectempty' => '', 'selectoption' => '', 'selectend' => '', 'optiongroup' => '', 'optiongroupend' => '', 'checkboxmultiplestart' => '', 'checkboxmultipleend' => '', 'password' => '', 'file' => '', 'file_no_model' => '', 'submit' => '', 'submitimage' => '', 'button' => '%s', 'image' => '', 'tableheader' => '%s', 'tableheaderrow' => '%s', 'tablecell' => '%s', 'tablerow' => '%s', 'block' => '%s', 'blockstart' => '', 'blockend' => '', 'tag' => '<%s%s>%s', 'tagstart' => '<%s%s>', 'tagend' => '', 'tagselfclosing' => '<%s%s/>', 'para' => '%s

', 'parastart' => '', 'label' => '', 'fieldset' => '%s', 'fieldsetstart' => '
%s', 'fieldsetend' => '
', 'legend' => '%s', 'css' => '', 'style' => '', 'charset' => '', 'ul' => '%s', 'ol' => '%s', 'li' => '%s', 'error' => '%s', 'javascriptblock' => '', 'javascriptstart' => '', 'javascriptend' => '' ); /** * Breadcrumbs. * * @var array */ protected $_crumbs = array(); /** * Names of script files that have been included once * * @var array */ protected $_includedScripts = array(); /** * Options for the currently opened script block buffer if any. * * @var array */ protected $_scriptBlockOptions = array(); /** * Document type definitions * * @var array */ protected $_docTypes = array( 'html4-strict' => '', 'html4-trans' => '', 'html4-frame' => '', 'html5' => '', 'xhtml-strict' => '', 'xhtml-trans' => '', 'xhtml-frame' => '', 'xhtml11' => '' ); /** * Constructor * * ### Settings * * - `configFile` A file containing an array of tags you wish to redefine. * * ### Customizing tag sets * * Using the `configFile` option you can redefine the tag HtmlHelper will use. * The file named should be compatible with HtmlHelper::loadConfig(). * * @param View $View The View this helper is being attached to. * @param array $settings Configuration settings for the helper. */ public function __construct(View $View, $settings = array()) { parent::__construct($View, $settings); if (is_object($this->_View->response)) { $this->response = $this->_View->response; } else { $this->response = new CakeResponse(array('charset' => Configure::read('App.encoding'))); } if (!empty($settings['configFile'])) { $this->loadConfig($settings['configFile']); } } /** * Adds a link to the breadcrumbs array. * * @param string $name Text for link * @param string $link URL for link (if empty it won't be a link) * @param mixed $options Link attributes e.g. array('id' => 'selected') * @return void * @see HtmlHelper::link() for details on $options that can be used. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper */ public function addCrumb($name, $link = null, $options = null) { $this->_crumbs[] = array($name, $link, $options); } /** * Returns a doctype string. * * Possible doctypes: * * - html4-strict: HTML4 Strict. * - html4-trans: HTML4 Transitional. * - html4-frame: HTML4 Frameset. * - html5: HTML5. Default value. * - xhtml-strict: XHTML1 Strict. * - xhtml-trans: XHTML1 Transitional. * - xhtml-frame: XHTML1 Frameset. * - xhtml11: XHTML1.1. * * @param string $type Doctype to use. * @return string Doctype string * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::docType */ public function docType($type = 'html5') { if (isset($this->_docTypes[$type])) { return $this->_docTypes[$type]; } return null; } /** * Creates a link to an external resource and handles basic meta tags * * Create a meta tag that is output inline: * * `$this->Html->meta('icon', 'favicon.ico'); * * Append the meta tag to `$scripts_for_layout`: * * `$this->Html->meta('description', 'A great page', array('inline' => false));` * * Append the meta tag to custom view block: * * `$this->Html->meta('description', 'A great page', array('block' => 'metaTags'));` * * ### Options * * - `inline` Whether or not the link element should be output inline. Set to false to * have the meta tag included in `$scripts_for_layout`, and appended to the 'meta' view block. * - `block` Choose a custom block to append the meta tag to. Using this option * will override the inline option. * * @param string $type The title of the external resource * @param mixed $url The address of the external resource or string for content attribute * @param array $options Other attributes for the generated tag. If the type attribute is html, * rss, atom, or icon, the mime-type is returned. * @return string A completed `` element. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::meta */ public function meta($type, $url = null, $options = array()) { $options += array('inline' => true, 'block' => null); if (!$options['inline'] && empty($options['block'])) { $options['block'] = __FUNCTION__; } unset($options['inline']); if (!is_array($type)) { $types = array( 'rss' => array('type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => $type, 'link' => $url), 'atom' => array('type' => 'application/atom+xml', 'title' => $type, 'link' => $url), 'icon' => array('type' => 'image/x-icon', 'rel' => 'icon', 'link' => $url), 'keywords' => array('name' => 'keywords', 'content' => $url), 'description' => array('name' => 'description', 'content' => $url), ); if ($type === 'icon' && $url === null) { $types['icon']['link'] = $this->webroot('favicon.ico'); } if (isset($types[$type])) { $type = $types[$type]; } elseif (!isset($options['type']) && $url !== null) { if (is_array($url) && isset($url['ext'])) { $type = $types[$url['ext']]; } else { $type = $types['rss']; } } elseif (isset($options['type']) && isset($types[$options['type']])) { $type = $types[$options['type']]; unset($options['type']); } else { $type = array(); } } elseif ($url !== null) { $inline = $url; } $options = array_merge($type, $options); $out = null; if (isset($options['link'])) { if (isset($options['rel']) && $options['rel'] === 'icon') { $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'), ' ', ' ')); $options['rel'] = 'shortcut icon'; } else { $options['link'] = $this->url($options['link'], true); } $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'), ' ', ' ')); } else { $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('block', 'type'), ' ', ' ')); } if (empty($options['block'])) { return $out; } else { $this->_View->append($options['block'], $out); } } /** * Returns a charset META-tag. * * @param string $charset The character set to be used in the meta tag. If empty, * The App.encoding value will be used. Example: "utf-8". * @return string A meta tag containing the specified character set. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::charset */ public function charset($charset = null) { if (empty($charset)) { $charset = strtolower(Configure::read('App.encoding')); } return sprintf($this->_tags['charset'], (!empty($charset) ? $charset : 'utf-8')); } /** * Creates an HTML link. * * If $url starts with "http://" this is treated as an external link. Else, * it is treated as a path to controller/action and parsed with the * HtmlHelper::url() method. * * If the $url is empty, $title is used instead. * * ### Options * * - `escape` Set to false to disable escaping of title and attributes. * - `confirm` JavaScript confirmation message. * * @param string $title The content to be wrapped by tags. * @param mixed $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) * @param array $options Array of HTML attributes. * @param string $confirmMessage JavaScript confirmation message. * @return string An `` element. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::link */ public function link($title, $url = null, $options = array(), $confirmMessage = false) { $escapeTitle = true; if ($url !== null) { $url = $this->url($url); } else { $url = $this->url($title); $title = h(urldecode($url)); $escapeTitle = false; } if (isset($options['escape'])) { $escapeTitle = $options['escape']; } if ($escapeTitle === true) { $title = h($title); } elseif (is_string($escapeTitle)) { $title = htmlentities($title, ENT_QUOTES, $escapeTitle); } if (!empty($options['confirm'])) { $confirmMessage = $options['confirm']; unset($options['confirm']); } if ($confirmMessage) { $confirmMessage = str_replace("'", "\'", $confirmMessage); $confirmMessage = str_replace('"', '\"', $confirmMessage); $options['onclick'] = "return confirm('{$confirmMessage}');"; } elseif (isset($options['default']) && $options['default'] == false) { if (isset($options['onclick'])) { $options['onclick'] .= ' event.returnValue = false; return false;'; } else { $options['onclick'] = 'event.returnValue = false; return false;'; } unset($options['default']); } return sprintf($this->_tags['link'], $url, $this->_parseAttributes($options), $title); } /** * Creates a link element for CSS stylesheets. * * ### Usage * * Include one CSS file: * * `echo $this->Html->css('styles.css');` * * Include multiple CSS files: * * `echo $this->Html->css(array('one.css', 'two.css'));` * * Add the stylesheet to the `$scripts_for_layout` layout var: * * `$this->Html->css('styles.css', null, array('inline' => false));` * * Add the stylesheet to a custom block: * * `$this->Html->css('styles.css', null, array('block' => 'layoutCss'));` * * ### Options * * - `inline` If set to false, the generated tag will be appended to the 'css' block, * and included in the `$scripts_for_layout` layout variable. Defaults to true. * - `block` Set the name of the block link/style tag will be appended to. This overrides the `inline` * option. * - `plugin` False value will prevent parsing path as a plugin * * @param mixed $path The name of a CSS style sheet or an array containing names of * CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot * of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css. * @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported. * @param array $options Array of HTML attributes. * @return string CSS or