| @@ 957-996 (lines=40) @@ | ||
| 954 | * @return string Le texte à utiliser pour l'url |
|
| 955 | * Note, some parts are from Solo's code |
|
| 956 | */ |
|
| 957 | public static function makeSeoUrl($content, $urw = 1) |
|
| 958 | { |
|
| 959 | $s = "ÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÇÌÍÎÏÙÚÛÜÑàáâãäåòóôõöøèéêëçìíîïùúûüÿñ '()"; |
|
| 960 | $r = 'AAAAAAOOOOOOEEEECIIIIUUUUYNaaaaaaooooooeeeeciiiiuuuuyn----'; |
|
| 961 | $content = static::unhtml($content); // First, remove html entities |
|
| 962 | $content = strtr($content, $s, $r); |
|
| 963 | $content = strip_tags($content); |
|
| 964 | $content = strtolower($content); |
|
| 965 | $content = htmlentities($content); // TODO: Vérifier |
|
| 966 | $content = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/', '$1', $content); |
|
| 967 | $content = html_entity_decode($content); |
|
| 968 | $content = preg_replace('/quot/i', ' ', $content); |
|
| 969 | $content = preg_replace("/'/i", ' ', $content); |
|
| 970 | $content = preg_replace('/-/i', ' ', $content); |
|
| 971 | $content = preg_replace('/[[:punct:]]/i', '', $content); |
|
| 972 | ||
| 973 | // Selon option mais attention au fichier .htaccess ! |
|
| 974 | // $content = eregi_replace('[[:digit:]]','', $content); |
|
| 975 | $content = preg_replace('/[^a-z|A-Z|0-9]/', '-', $content); |
|
| 976 | ||
| 977 | $words = explode(' ', $content); |
|
| 978 | $keywords = ''; |
|
| 979 | foreach ($words as $word) { |
|
| 980 | if (strlen($word) >= $urw) { |
|
| 981 | $keywords .= '-' . trim($word); |
|
| 982 | } |
|
| 983 | } |
|
| 984 | if (!$keywords) { |
|
| 985 | $keywords = '-'; |
|
| 986 | } |
|
| 987 | // Supprime les tirets en double |
|
| 988 | $keywords = str_replace('---', '-', $keywords); |
|
| 989 | $keywords = str_replace('--', '-', $keywords); |
|
| 990 | // Supprime un éventuel tiret à la fin de la chaine |
|
| 991 | if (substr($keywords, strlen($keywords) - 1, 1) == '-') { |
|
| 992 | $keywords = substr($keywords, 0, strlen($keywords) - 1); |
|
| 993 | } |
|
| 994 | ||
| 995 | return $keywords; |
|
| 996 | } |
|
| 997 | ||
| 998 | /** |
|
| 999 | * Create the meta keywords based on the content |
|
| @@ 1100-1139 (lines=40) @@ | ||
| 1097 | * @return string Le texte à utiliser pour l'url |
|
| 1098 | * Note, some parts are from Solo's code |
|
| 1099 | */ |
|
| 1100 | public static function makeSeoUrl($content, $urw = 1) |
|
| 1101 | { |
|
| 1102 | $s = "ÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÇÌÍÎÏÙÚÛÜÑàáâãäåòóôõöøèéêëçìíîïùúûüÿñ '()"; |
|
| 1103 | $r = 'AAAAAAOOOOOOEEEECIIIIUUUUYNaaaaaaooooooeeeeciiiiuuuuyn----'; |
|
| 1104 | $content = self::unhtml($content); // First, remove html entities |
|
| 1105 | $content = strtr($content, $s, $r); |
|
| 1106 | $content = strip_tags($content); |
|
| 1107 | $content = strtolower($content); |
|
| 1108 | $content = htmlentities($content); // TODO: Vérifier |
|
| 1109 | $content = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/', '$1', $content); |
|
| 1110 | $content = html_entity_decode($content); |
|
| 1111 | $content = preg_replace('/quot/i', ' ', $content); |
|
| 1112 | $content = preg_replace("/'/i", ' ', $content); |
|
| 1113 | $content = preg_replace('/-/i', ' ', $content); |
|
| 1114 | $content = preg_replace('/[[:punct:]]/i', '', $content); |
|
| 1115 | ||
| 1116 | // Selon option mais attention au fichier .htaccess ! |
|
| 1117 | // $content = eregi_replace('[[:digit:]]','', $content); |
|
| 1118 | $content = preg_replace('/[^a-z|A-Z|0-9]/', '-', $content); |
|
| 1119 | ||
| 1120 | $words = explode(' ', $content); |
|
| 1121 | $keywords = ''; |
|
| 1122 | foreach ($words as $word) { |
|
| 1123 | if (strlen($word) >= $urw) { |
|
| 1124 | $keywords .= '-' . trim($word); |
|
| 1125 | } |
|
| 1126 | } |
|
| 1127 | if (!$keywords) { |
|
| 1128 | $keywords = '-'; |
|
| 1129 | } |
|
| 1130 | // Supprime les tirets en double |
|
| 1131 | $keywords = str_replace('---', '-', $keywords); |
|
| 1132 | $keywords = str_replace('--', '-', $keywords); |
|
| 1133 | // Supprime un éventuel tiret à la fin de la chaine |
|
| 1134 | if (substr($keywords, strlen($keywords) - 1, 1) == '-') { |
|
| 1135 | $keywords = substr($keywords, 0, strlen($keywords) - 1); |
|
| 1136 | } |
|
| 1137 | ||
| 1138 | return $keywords; |
|
| 1139 | } |
|
| 1140 | ||
| 1141 | /** |
|
| 1142 | * Create the meta keywords based on the content |
|