#3492: Inflector slug method should support latin characters ----------------------------+----------------------------------------------- Reporter: faemino | Owner: jperras Type: Enhancement | Status: new Priority: Medium | Milestone: 1.3.x.x Component: Core Libs | Version: Severity: Normal | Resolution: Keywords: | Php_version: n/a Cake_version: | ----------------------------+----------------------------------------------- Comment (by majklovec):
Added latin - czech characters + possibility to expand map via parameter user_map for ex.: {{{ echo '<li>'.$html->link($item, array('controller' => 'pages', 'action' => 'display', Inflector::slug($item, '-', array('/k/' => 'h')))).'</li>'; }}} changed function slug: {{{ /** * Returns a string with all spaces converted to $replacement and non word characters removed. * * @param string $string * @param string $replacement * @param array $user_map * @return string * @access public * @static */ function slug($string, $replacement = '_', $user_map = array()) { if (!class_exists('String')) { require LIBS . 'string.php'; } $map = array( '/º|°/' => 0, '/¹/' => 1, '/²/' => 2, '/³/' => 3, '/À|Á|Å|Â|Ã|Ä/' => 'A', '/Æ/' => 'Ae', '/à|á|å|â|ã|ä|ª/' => 'a', '/@/' => 'at', '/æ/' => 'ae', '/©/' => 'C', '/č|ç|¢/' => 'c', '/ĎÐ/' => 'D', '/ď/' => 'd', '/È|É|Ê|Ë/' => 'E', '/è|é|ê|ẽ|ë/' => 'e', '/ƒ/' => 'f', '/Ì|Í|Î|Ï/' => 'I', '/ì|í|î|ï/' => 'i', '/Ñ/' => 'N', '/ñ/' => 'n', '/Ò|Ó|Ô|Ø|Õ|Ö/' => 'O', '/Œ/' => 'OE', '/ò|ó|ô|ø|õ|ö|ð/' => 'o', '/œ/' => 'oe', '/Ř®/' => 'R', '/ř/' => 'r', '/Š/' => 'S', '/š/' => 's', '/ť/' => 't', '/ß/' => 'ss', '/™/' => 'TM', '/Ù|Ú|Û|Ü/' => 'U', '/Ü/' => 'Ue', '/ù|ú|ů|û|µ|ü/' => 'u', '/×/' => 'x', '/¥/' => 'Y', '/ÿ|ý/' => 'y', '/Ž/' => 'Z', '/ž/' => 'z', '/[^\w\s]/' => ' ', '/\\s+/' => $replacement, String::insert('/^[:replacement]+|[:replacement]+$/', array('replacement' => preg_quote($replacement, '/'))) => '', ); $map = am($map, $user_map); $string = preg_replace(array_keys($map), array_values($map), $string); return $string; } } }}} -- Ticket URL: <https://trac.cakephp.org/ticket/3492#comment:11> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---