mirror of
https://github.com/e107inc/e107.git
synced 2025-04-13 00:52:07 +02:00
Support for root namespaces using e_url addon configuration.
This commit is contained in:
parent
c581b89aa1
commit
0935f7b858
@ -207,7 +207,7 @@ class eurl_admin_ui extends e_admin_controller_ui
|
||||
protected function simplePage()
|
||||
{
|
||||
// $this->addTitle("Simple Redirects");
|
||||
$eUrl =e107::getAddonConfig('e_url');
|
||||
$eUrl =e107::getUrlConfig();
|
||||
$frm = e107::getForm();
|
||||
$tp = e107::getParser();
|
||||
$cfg = e107::getConfig();
|
||||
@ -315,8 +315,17 @@ class eurl_admin_ui extends e_admin_controller_ui
|
||||
{
|
||||
// main module pref dropdown
|
||||
$this->prefs['url_main_module']['writeParms'][''] = 'None';
|
||||
|
||||
// e_url.php aliases
|
||||
$tmp = e107::getUrlConfig('alias');
|
||||
foreach($tmp as $plugin=>$alias)
|
||||
{
|
||||
$this->prefs['url_main_module']['writeParms'][$alias] = eHelper::labelize($plugin);
|
||||
}
|
||||
|
||||
// legacy URL (news, pages )
|
||||
$modules = e107::getPref('url_config', array());
|
||||
ksort($modules);
|
||||
|
||||
foreach ($modules as $module => $location)
|
||||
{
|
||||
$labels = array();
|
||||
@ -326,10 +335,11 @@ class eurl_admin_ui extends e_admin_controller_ui
|
||||
if(!$config || !vartrue($config['config']['allowMain'])) continue;
|
||||
$admin = $obj->admin();
|
||||
$labels = vartrue($admin['labels'], array());
|
||||
|
||||
|
||||
|
||||
$this->prefs['url_main_module']['writeParms'][$module] = vartrue($section['name'], eHelper::labelize($module));
|
||||
}
|
||||
|
||||
ksort($this->prefs['url_main_module']['writeParms']);
|
||||
|
||||
// title2sef transform type pref
|
||||
$types = explode('|', 'none|dashl|dashc|dash|underscorel|underscorec|underscore|plusl|plusc|plus');
|
||||
|
@ -2416,6 +2416,73 @@ class e107
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the e_url config - new v2.1.6
|
||||
* @return array
|
||||
*/
|
||||
public static function getUrlConfig($mode='config')
|
||||
{
|
||||
$new_addon = array();
|
||||
|
||||
$filename = 'e_url';
|
||||
$elist = self::getPref($filename.'_list');
|
||||
$className = substr($filename, 2); // remove 'e_'
|
||||
$methodName = 'config';
|
||||
|
||||
$profile = null; // for future use.
|
||||
|
||||
if(!empty($elist))
|
||||
{
|
||||
foreach(array_keys($elist) as $key)
|
||||
{
|
||||
if(is_readable(e_PLUGIN.$key.'/'.$filename.'.php'))
|
||||
{
|
||||
include_once(e_PLUGIN.$key.'/'.$filename.'.php');
|
||||
|
||||
$class_name = $key.'_'.$className;
|
||||
|
||||
if(is_object($class_name))
|
||||
{
|
||||
$obj = $class_name;
|
||||
$class_name = get_class($obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj = new $class_name;
|
||||
}
|
||||
|
||||
if($mode === 'alias')
|
||||
{
|
||||
if(!empty($obj->alias))
|
||||
{
|
||||
$new_addon[$key] = $obj->alias;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$array = self::callMethod($obj, $methodName,$profile);
|
||||
|
||||
if($array)
|
||||
{
|
||||
foreach($array as $k=>$v)
|
||||
{
|
||||
if(empty($v['alias']) && !empty($obj->alias))
|
||||
{
|
||||
$v['alias'] = $obj->alias;
|
||||
}
|
||||
$new_addon[$key][$k] = $v;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $new_addon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get theme name or path.
|
||||
@ -3157,7 +3224,7 @@ class e107
|
||||
|
||||
if(!$tmp = self::getRegistry('core/e107/addons/e_url'))
|
||||
{
|
||||
$tmp = self::getAddonConfig('e_url');
|
||||
$tmp = self::getUrlConfig();
|
||||
self::setRegistry('core/e107/addons/e_url',$tmp);
|
||||
}
|
||||
|
||||
@ -3165,6 +3232,8 @@ class e107
|
||||
|
||||
$pref = self::getPref('e_url_alias');
|
||||
$sefActive = self::getPref('e_url_list');
|
||||
$rootNamespace = self::getPref('url_main_module');
|
||||
|
||||
|
||||
if(is_string($options)) // backwards compat.
|
||||
{
|
||||
@ -3185,12 +3254,22 @@ class e107
|
||||
$options['fragment'] = '#' . $options['fragment'];
|
||||
}
|
||||
|
||||
if(varset($tmp[$plugin][$key]['sef']))
|
||||
if(!empty($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']);
|
||||
|
||||
if(!empty($rootNamespace) && $rootNamespace === $plugin)
|
||||
{
|
||||
$replaceAlias = array('{alias}\/','{alias}/');
|
||||
$tmp[$plugin][$key]['sef'] = str_replace($replaceAlias, '', $tmp[$plugin][$key]['sef']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp[$plugin][$key]['sef'] = str_replace('{alias}', $alias, $tmp[$plugin][$key]['sef']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
23
index.php
23
index.php
@ -95,7 +95,8 @@
|
||||
}
|
||||
else*/
|
||||
{
|
||||
$tmp = e107::getAddonConfig('e_url');
|
||||
// $tmp = e107::getAddonConfig('e_url');
|
||||
$tmp = e107::getUrlConfig();
|
||||
// e107::getCache()->set('Addon_url',e107::serialize($tmp,'json'),true,true,true);
|
||||
}
|
||||
|
||||
@ -104,6 +105,8 @@
|
||||
|
||||
if(count($tmp))
|
||||
{
|
||||
$rootNamespace = e107::getPref('url_main_module');
|
||||
$replaceAlias = array('{alias}\/?','{alias}/?','{alias}\/','{alias}/',);
|
||||
|
||||
foreach($tmp as $plug=>$cfg)
|
||||
{
|
||||
@ -127,7 +130,15 @@
|
||||
{
|
||||
$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']);
|
||||
if(!empty($rootNamespace) && $rootNamespace === $plug)
|
||||
{
|
||||
$v['regex'] = str_replace($replaceAlias, '', $v['regex']);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$v['regex'] = str_replace('{alias}', $alias, $v['regex']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -163,7 +174,15 @@
|
||||
}
|
||||
elseif(getperms('0'))
|
||||
{
|
||||
require_once(HEADERF);
|
||||
echo "<div class='alert alert-warning'>";
|
||||
echo "<h3>SEF Debug Info</h3>";
|
||||
echo "File missing: ".$file;
|
||||
echo "<br />Matched key: <b>".$k."</b>";
|
||||
|
||||
print_a($v);
|
||||
echo "</div>";
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user