mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Truncate Generated SEF-URLs to an acceptable length.
This commit is contained in:
@@ -4278,9 +4278,16 @@ class eHelper
|
|||||||
*/
|
*/
|
||||||
public static function title2sef($title, $type = null)
|
public static function title2sef($title, $type = null)
|
||||||
{
|
{
|
||||||
$title = preg_replace('/[^\w\pL\s.,]/u', '', strip_tags(e107::getParser()->toHTML($title, TRUE)));
|
$title = str_replace(array("&",",","(",")"),'',$title);
|
||||||
|
$title = preg_replace('/[^\w\pL\s.]/u', '', strip_tags(e107::getParser()->toHTML($title, TRUE)));
|
||||||
$title = trim(preg_replace('/[\s]+/', ' ', str_replace('_', ' ', $title)));
|
$title = trim(preg_replace('/[\s]+/', ' ', str_replace('_', ' ', $title)));
|
||||||
|
|
||||||
|
$words = str_word_count($title,1);
|
||||||
|
|
||||||
|
$limited = array_slice($words, 0, 14); // Limit number of words to 14. - any more and it ain't friendly.
|
||||||
|
|
||||||
|
$title = implode(" ",$limited);
|
||||||
|
|
||||||
if(null === $type)
|
if(null === $type)
|
||||||
{
|
{
|
||||||
$type = e107::getPref('url_sef_translate');
|
$type = e107::getPref('url_sef_translate');
|
||||||
|
Reference in New Issue
Block a user