diff --git a/e107_admin/eurl.php b/e107_admin/eurl.php index fa6e8fdcd..7041119fa 100644 --- a/e107_admin/eurl.php +++ b/e107_admin/eurl.php @@ -179,32 +179,71 @@ class eurl_admin_ui extends e_admin_controller_ui { // $this->addTitle("Simple Redirects"); $eUrl =e107::getAddonConfig('e_url'); - + $frm = e107::getForm(); + $tp = e107::getParser(); + $cfg = e107::getConfig(); + + if(!empty($_POST['saveSimpleSef'])) + { + if(is_string($this->getConfig()->get('e_url_alias'))) + { + $cfg->setPostedData('e_url_alias', array(e_LAN => $_POST['e_url_alias']), false); + } + else + { + $cfg->setPref('e_url_alias/'.e_LAN, $_POST['e_url_alias']); + } + + $cfg->save(true, true, true); + + } + + $pref = e107::getPref('e_url_alias'); + if(empty($eUrl)) { return; } - $text = ""; - + $text = $frm->open('simpleSef'); + + $multilan = "".$tp->toGlyph('fa-language').""; + + $home = "".SITEURL.''; + foreach($eUrl as $plug=>$val) { $text .= "
".$plug."
"; $text .= ""; $text .= " + + "; foreach($val as $k=>$v) { - $text .= ""; + + $alias = vartrue($pref[e_LAN][$plug][$k], $v['alias']); + $regex = (!empty($alias)) ? str_replace('{alias}', $alias, $v['regex']) : $v['regex']; + $sefurl = (!empty($alias)) ? str_replace('{alias}', $alias, $v['sef']) : $v['sef']; + $aliasForm = (!empty($alias)) ? $home.$frm->text('e_url_alias['.$plug.']['.$k.']', $alias).$multilan : 'Not available'; + + $text .= " + + + + + "; } $text .= "
KeyRegular ExpressionAlias".LAN_URL."
".$k."".$v['regex']."".$v['redirect']."
".$k."".$regex."".$aliasForm."". $v['redirect']."
"; } - + + $text .= "
".$frm->button('saveSimpleSef',LAN_SAVE." (".e_LANGUAGE.")",'submit')."
"; + $text .= $frm->close(); return $text; } diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index a70bcb1d6..93d5d971b 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2628,10 +2628,16 @@ class e107 $tmp = e107::getAddonConfig('e_url'); $tp = e107::getParser(); - + $pref = self::getPref('e_url_alias'); if(varset($tmp[$plugin][$key]['sef'])) { + if(!empty($tmp[$plugin][$key]['alias'])) + { + $alias = (!empty($pref[e_LAN][$plugin][$key])) ? $pref[e_LAN][$plugin][$key] : $tmp[$plugin][$key]['alias']; + $tmp[$plugin][$key]['sef'] = str_replace('{alias}', $alias, $tmp[$plugin][$key]['sef']); + } + preg_match_all('#{([a-z_]*)}#', $tmp[$plugin][$key]['sef'],$matches); diff --git a/e107_plugins/faqs/e_url.php b/e107_plugins/faqs/e_url.php index 00aa8be20..f76446735 100644 --- a/e107_plugins/faqs/e_url.php +++ b/e107_plugins/faqs/e_url.php @@ -27,37 +27,42 @@ class faqs_url // plugin-folder + '_url' $config = array(); $config['index'] = array( - 'regex' => '^faqs/?$', // matched against url, and if true, redirected to 'redirect' below. - 'sef' => 'faqs', // used by e107::url(); to create a url from the db table. + 'alias' => 'faqs', + 'regex' => '^{alias}/?$', // matched against url, and if true, redirected to 'redirect' below. + 'sef' => '{alias}', // used by e107::url(); to create a url from the db table. 'redirect' => '{e_PLUGIN}faqs/faqs.php', // file-path of what to load when the regex returns true. ); $config['item'] = array( - 'regex' => '^faqs/(\d*)-(.*)$', - 'sef' => 'faqs/{faq_id}-{faq_sef}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); + 'alias' => 'faqs', + 'regex' => '^{alias}/(\d*)-(.*)$', + 'sef' => '{alias}/{faq_id}-{faq_sef}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); 'redirect' => '{e_PLUGIN}faqs/faqs.php?id=$1' ); $config['search'] = array( - 'regex' => '^faqs/\?srch=(.*)$', // matched against url, and if true, redirected to 'redirect' below. - 'sef' => 'faqs/', // used by e107::url(); to create a url from the db table. + 'alias' => 'faqs', + 'regex' => '^{alias}/\?srch=(.*)$', // matched against url, and if true, redirected to 'redirect' below. + 'sef' => '{alias}/', // used by e107::url(); to create a url from the db table. 'redirect' => '{e_PLUGIN}faqs/faqs.php?srch=$1', // file-path of what to load when the regex returns true. ); $config['tag'] = array( - 'regex' => '^faqs/tag/(.*)$', - 'sef' => 'faqs/tag/{tag}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); + 'alias' => 'faqs', + 'regex' => '^{alias}/tag/(.*)$', + 'sef' => '{alias}/tag/{tag}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); 'redirect' => '{e_PLUGIN}faqs/faqs.php?tag=$1' ); $config['category'] = array( - 'regex' => '^faqs/(.*)$', - 'sef' => 'faqs/{faq_info_sef}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); + 'alias' => 'faqs', + 'regex' => '^{alias}/(.*)$', + 'sef' => '{alias}/{faq_info_sef}', // {faq_info_sef} is substituted with database value when parsed by e107::url(); 'redirect' => '{e_PLUGIN}faqs/faqs.php?cat=$1' ); diff --git a/e107_plugins/rss_menu/e_url.php b/e107_plugins/rss_menu/e_url.php index 751185b9a..7003e1afc 100644 --- a/e107_plugins/rss_menu/e_url.php +++ b/e107_plugins/rss_menu/e_url.php @@ -19,20 +19,23 @@ class rss_menu_url // plugin-folder + '_url' $config = array(); $config['rss'] = array( - 'regex' => '^feed/(.*)/rss/?([\d]*)?$', - 'sef' => 'feed/{rss_url}/rss/{rss_topicid}', + 'alias' => 'feed', + 'regex' => '^{alias}/(.*)/rss/?([\d]*)?$', + 'sef' => '{alias}/{rss_url}/rss/{rss_topicid}', 'redirect' => '{e_PLUGIN}rss_menu/rss.php?cat=$1&type=2&topic=$2' ); $config['atom'] = array( - 'regex' => '^feed/(.*)/atom/?([\d]*)?$', - 'sef' => 'feed/{rss_url}/atom/{rss_topicid}', + 'alias' => 'feed', + 'regex' => '^{alias}/(.*)/atom/?([\d]*)?$', + 'sef' => '{alias}/{rss_url}/atom/{rss_topicid}', 'redirect' => '{e_PLUGIN}rss_menu/rss.php?cat=$1&type=4&topic=$2' ); $config['index'] = array( - 'regex' => '^feed/?$', - 'sef' => 'feed', + 'alias' => 'feed', + 'regex' => '^{alias}/?$', + 'sef' => '{alias}', 'redirect' => '{e_PLUGIN}rss_menu/rss.php', ); diff --git a/index.php b/index.php index 103df8a35..c690e80ab 100644 --- a/index.php +++ b/index.php @@ -88,7 +88,7 @@ $sql->db_Mark_Time("Start Simple URL-ReWrite Routine"); $tmp = e107::getAddonConfig('e_url'); - + $req = (e_HTTP === '/') ? ltrim(e_REQUEST_URI,'/') : str_replace(e_HTTP,'', e_REQUEST_URI) ; if(count($tmp)) @@ -99,6 +99,14 @@ foreach($cfg as $k=>$v) { + + if(!empty($v['alias'])) + { + $alias = (!empty($pref['e_url_alias'][e_LAN][$plug][$k])) ? $pref['e_url_alias'][e_LAN][$plug][$k] : $v['alias']; + e107::getMessage()->addDebug("e_url alias found: ".$alias.""); + $v['regex'] = str_replace('{alias}', $alias, $v['regex']); + } + $regex = '#'.$v['regex'].'#';