mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 11:50:30 +02:00
Support for e_url.php aliases added. (see faqs or rss_menu)
This commit is contained in:
@@ -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 = "<small class='e-tip admin-multilanguage-field' style='cursor:help; padding-left:10px' title='Multi-language field'>".$tp->toGlyph('fa-language')."</small>";
|
||||
|
||||
$home = "<small>".SITEURL.'</small>';
|
||||
|
||||
foreach($eUrl as $plug=>$val)
|
||||
{
|
||||
$text .= "<h5>".$plug."</h5>";
|
||||
$text .= "<table class='table table-striped table-bordered'>";
|
||||
$text .= "<tr><th>Key</th><th>Regular Expression</th>
|
||||
<th>Alias</th>
|
||||
|
||||
<th>".LAN_URL."</th>
|
||||
</tr>";
|
||||
|
||||
foreach($val as $k=>$v)
|
||||
{
|
||||
$text .= "<tr><td style='width:20%'>".$k."</td><td style='width:40%'>".$v['regex']."</td><td style='width:40%'>".$v['redirect']."</td></tr>";
|
||||
|
||||
$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 : '<small class="muted">Not available</small>';
|
||||
|
||||
$text .= "<tr>
|
||||
<td style='width:5%'>".$k."</td>
|
||||
<td style='width:20%'><span class='e-tip' title='".SITEURL.$sefurl."'>".$regex."</span></td>
|
||||
<td class='form-inline' style='width:30%'>".$aliasForm."</td>
|
||||
<td style='width:30%'>". $v['redirect']."</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
|
||||
$text .= "</table>";
|
||||
}
|
||||
|
||||
|
||||
$text .= "<div class='buttons-bar center'>".$frm->button('saveSimpleSef',LAN_SAVE." (".e_LANGUAGE.")",'submit')."</div>";
|
||||
$text .= $frm->close();
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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'
|
||||
);
|
||||
|
||||
|
@@ -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',
|
||||
);
|
||||
|
||||
|
10
index.php
10
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: <b>".$alias."</b>");
|
||||
$v['regex'] = str_replace('{alias}', $alias, $v['regex']);
|
||||
}
|
||||
|
||||
|
||||
$regex = '#'.$v['regex'].'#';
|
||||
|
||||
|
Reference in New Issue
Block a user