> HtmlHelper */ App::import( 'helper', 'Html' ); /** * Extended HTML helper * */ class XhtmlHelper extends HtmlHelper { /** * Extends the HTML Helper that created link. This version accepts KEYWORDS for url parameters. The ffg urls are accepted * c OR 0 > controller * a OR 1 > action * p OR 2 > plugin * * @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 $htmlAttributes Array of HTML attributes. * @param string $confirmMessage JavaScript confirmation message. * @param boolean $escapeTitle Whether or not $title should be HTML escaped. * @return string An element. * @package CakePHP 1.2 */ function link( $title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true ) { $this->__link_param_change( $url, 'c|0', 'controller' ); $this->__link_param_change( $url, 'a|1', 'action' ); $this->__link_param_change( $url, 'p|2', 'plugin' ); return parent::link( $title, $url, $htmlAttributes, $confirmMessage, $escapeTitle ); } /** * Change the short_key names as follows * c OR 0 > controller * a OR 1 > action * p OR 2 > plugin * * @param string &$string * @param string $short_keys * multiple keys are separated by pipe (|) * @param string $long_key */ private function __link_param_change( &$string, $short_keys, $long_key ) { $array_keys = explode( '|', $short_keys ); foreach ( $array_keys as $short_key ) { if ( isset( $string[$short_key] ) ) { $string[$long_key] = $string[$short_key]; unset( $string[$short_key] ); break; } } } } ?>