From c079140f23455557fa7206bc0c2559e6293e5353 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 30 Mar 2015 13:00:28 -0700 Subject: [PATCH] Truncate Generated SEF-URLs to an acceptable length. --- e107_handlers/application.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 2ac0499ca..59646b85f 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -4278,9 +4278,16 @@ class eHelper */ 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))); - + + $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) { $type = e107::getPref('url_sef_translate');