public static function slugify($text) { $text = Doctrine_Inflector::unaccent($text); // replace all non letters or digits by - $text = preg_replace('/\\W+/', '-', $text); // trim and lowercase $text = strtolower(trim($text, '-')); return $text; /********************** // Remove all non url friendly characters with the unaccent function $text = Doctrine_Inflector::unaccent($this->get('title')); if (function_exists('mb_strtolower')) { $text = mb_strtolower($text); } else { $text = strtolower($text); } // Remove all none word characters $text = preg_replace('/\W/', ' ', $text); // More stripping. Get rid of all non-alphanumeric. $text = strtolower(preg_replace('/[^A-Z^a-z^0-9^\/]+/', '', $text)); return trim($text, '-'); */ }
public function analyze($text, $encoding = null) { static $stopwords; if (!isset($stopwords)) { $stopwords = array_flip(self::$_stopwords); } $text = preg_replace('/[\'`´"]/', '', $text); $text = Doctrine_Inflector::unaccent($text); $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text); $text = str_replace(' ', ' ', $text); $terms = explode(' ', $text); $ret = array(); if (!empty($terms)) { foreach ($terms as $i => $term) { if (empty($term)) { continue; } $lower = strtolower(trim($term)); if (isset($stopwords[$lower])) { continue; } $ret[$i] = $lower; } } return $ret; }
/** * @param $_query * @return Kebab_Controller_Helper_Search */ public function setQuery($_query) { $_query = strtolower(Doctrine_Inflector::unaccent($_query)); if ($_query !== false && is_string($_query)) { $this->_query = '*' . $_query . '*'; } return $this; }
/** * Return a string with html tags, special charecters and puctuation removed. * * @param string $string * @return string */ public static function getCleanedString($string) { $string = strip_tags($string); $string = preg_replace('/[\'`�"]/', '', $string); $string = Doctrine_Inflector::unaccent($string); $string = preg_replace('/[^A-Za-z0-9]/', ' ', $string); $string = preg_replace('/\\s\\s+/', ' ', trim($string)); $string = strtolower($string); return $string; }
static function urlize($text) { // Remove all non url friendly characters with the unaccent function $text = Doctrine_Inflector::unaccent($text); $text = str_replace("'", "", $text); // Remove all none word characters $text = preg_replace('/\\W/', ' ', $text); // More stripping. Replace spaces with dashes $text = preg_replace('/[^A-Z^a-z^0-9^\\/]+/', '-', preg_replace('/([a-z\\d])([A-Z])/', '\\1_\\2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1_\\2', preg_replace('/::/', '/', $text)))); return trim($text, '-'); }
public function getSlugize() { // Remove all non url friendly characters with the unaccent function $text = Doctrine_Inflector::unaccent($this->get('title')); if (function_exists('mb_strtolower')) { $text = mb_strtolower($text); } else { $text = strtolower($text); } // Remove all none word characters $text = preg_replace('/\\W/', ' ', $text); // More stripping. Get rid of all non-alphanumeric. $text = strtolower(preg_replace('/[^A-Z^a-z^0-9^\\/]+/', '', $text)); return trim($text, '-'); }
public function analyze($text) { $text = preg_replace('/[\'`´"]/', '', $text); $text = Doctrine_Inflector::unaccent($text); $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text); $text = str_replace(' ', ' ', $text); $terms = explode(' ', $text); $ret = array(); if (!empty($terms)) { foreach ($terms as $i => $term) { if (empty($term)) { continue; } $lower = strtolower(trim($term)); if (in_array($lower, self::$_stopwords)) { continue; } $ret[$i] = $lower; } } return $ret; }