mirror of
https://github.com/e107inc/e107.git
synced 2025-10-17 15:56:25 +02:00
URL condig rebuild routine on various places,
Import prefs fix - arrays wasn't imported, Mislogic of some preference handler methods
This commit is contained in:
@@ -437,7 +437,6 @@ class eDispatcher
|
||||
{
|
||||
case 'plugin':
|
||||
if(!$plugin) return null;
|
||||
$location = $tmp[1];
|
||||
return $sc ? '{e_PLUGIN}'.$plugin.'/controllers/' : e_PLUGIN.$plugin.'/controllers/';
|
||||
break;
|
||||
|
||||
@@ -1036,6 +1035,7 @@ class eRouter
|
||||
{
|
||||
$ret['plugin'][] = $plugin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Register only those who don't need install and may be dispatchable
|
||||
@@ -1066,6 +1066,19 @@ class eRouter
|
||||
}
|
||||
}
|
||||
sort($ret['override']);
|
||||
|
||||
// remove not installed plugin locations, possible only for 'all' type
|
||||
if($type == 'all')
|
||||
{
|
||||
foreach ($ret['override'] as $i => $l)
|
||||
{
|
||||
// it's a plugin override, but not listed in current plugin array - remove
|
||||
if(in_array($l, $plugins) && !in_array($l, $ret['plugin']))
|
||||
{
|
||||
unset($ret['override'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
@@ -277,9 +277,10 @@ class e107plugin
|
||||
// echo "Updated: ".$plug_path."<br />";
|
||||
}
|
||||
}
|
||||
if ($sp && vartrue($p_installed))
|
||||
if ($sp/* && vartrue($p_installed)*/)
|
||||
{
|
||||
e107::getConfig('core')->setPref('plug_installed', $p_installed);
|
||||
$this->rebuildUrlConfig();
|
||||
e107::getConfig('core')->save();
|
||||
}
|
||||
}
|
||||
@@ -1074,6 +1075,30 @@ class e107plugin
|
||||
$notify_prefs->save(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild URL configuration values
|
||||
* Note - new core system pref values will be set, but not saved
|
||||
* e107::getConfig()->save() is required outside after execution of this method
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildUrlConfig()
|
||||
{
|
||||
|
||||
$modules = eRouter::adminReadModules(); // get all available locations, non installed plugins will be ignored
|
||||
$config = eRouter::adminBuildConfig(e107::getPref('url_config'), $modules); // merge with current config
|
||||
$locations = eRouter::adminBuildLocations($modules); // rebuild locations pref
|
||||
$aliases = eRouter::adminSyncAliases(e107::getPref('url_aliases'), $config); // rebuild aliases
|
||||
|
||||
// set new values, changes should be saved outside this methods
|
||||
e107::getConfig()
|
||||
->set('url_aliases', $aliases)
|
||||
->set('url_config', $config)
|
||||
->set('url_modules', $modules)
|
||||
->set('url_locations', $locations);
|
||||
|
||||
eRouter::clearCache();
|
||||
}
|
||||
|
||||
function displayArray(&$array, $msg = '')
|
||||
{
|
||||
$txt = ($msg ? $msg.'<br />' : '');
|
||||
@@ -1283,7 +1308,7 @@ class e107plugin
|
||||
$p_installed[$plug['plugin_path']] = $plug_vars['@attributes']['version'];
|
||||
|
||||
e107::getConfig('core')->setPref('plug_installed', $p_installed);
|
||||
e107::getConfig('core')->save();
|
||||
//e107::getConfig('core')->save(); - save triggered below
|
||||
}
|
||||
|
||||
if ($function == 'uninstall')
|
||||
@@ -1293,6 +1318,8 @@ class e107plugin
|
||||
e107::getConfig('core')->setPref('plug_installed', $p_installed);
|
||||
|
||||
}
|
||||
|
||||
$this->rebuildUrlConfig();
|
||||
|
||||
e107::getConfig('core')->save();
|
||||
|
||||
@@ -1870,7 +1897,11 @@ class e107plugin
|
||||
$p_installed = e107::getPref('plug_installed', array()); // load preference;
|
||||
$p_installed[$plug['plugin_path']] = $plug['plugin_version'];
|
||||
|
||||
e107::getConfig('core')->setPref('plug_installed', $p_installed)->save();
|
||||
e107::getConfig('core')->setPref('plug_installed', $p_installed);
|
||||
|
||||
$this->rebuildUrlConfig();
|
||||
|
||||
e107::getConfig('core')->save();
|
||||
|
||||
$text .= (isset($eplug_done) ? "<br />{$eplug_done}" : "<br />".LAN_INSTALL_SUCCESSFUL);
|
||||
if ($eplug_conffile)
|
||||
|
@@ -195,11 +195,11 @@ class e_pref extends e_front_model
|
||||
public function set($pref_name, $value)
|
||||
{
|
||||
global $pref;
|
||||
if(empty($pref_name))
|
||||
if(empty($pref_name) || !is_string($pref_name))
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
parent::set((string) $pref_name, $value, false);
|
||||
$this->_data[$pref_name] = $value;
|
||||
|
||||
//BC
|
||||
if($this->alias === 'core')
|
||||
@@ -220,11 +220,11 @@ class e_pref extends e_front_model
|
||||
public function update($pref_name, $value)
|
||||
{
|
||||
global $pref;
|
||||
if(empty($pref_name))
|
||||
if(empty($pref_name) || !is_string($pref_name))
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
parent::set((string) $pref_name, $value, true);
|
||||
if(isset($this->_data[$pref_name])) $this->_data[$pref_name] = $value;
|
||||
|
||||
//BC
|
||||
if($this->alias === 'core')
|
||||
@@ -249,8 +249,13 @@ class e_pref extends e_front_model
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->addData($pref_name, $value);
|
||||
if(!isset($this->_data[$pref_name])) $this->_data[$pref_name] = $value;
|
||||
|
||||
//BC
|
||||
if($this->alias === 'core')
|
||||
{
|
||||
$pref = $this->getData();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -633,7 +638,7 @@ class e_pref extends e_front_model
|
||||
* @param boolean $runtime clear runtime cache as well ($this->pref_cache)
|
||||
* @return e_pref
|
||||
*/
|
||||
protected function clearPrefCache($cache_name = '', $runtime = true)
|
||||
public function clearPrefCache($cache_name = '', $runtime = true)
|
||||
{
|
||||
if($runtime)
|
||||
{
|
||||
|
@@ -807,13 +807,20 @@ class xmlClass
|
||||
return array();
|
||||
}
|
||||
|
||||
$mes = eMessage::getInstance();
|
||||
//$mes = eMessage::getInstance();
|
||||
|
||||
$pref = array();
|
||||
foreach($XMLData['prefs'][$prefType] as $val)
|
||||
{
|
||||
$name = $val['@attributes']['name'];
|
||||
$value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value'];
|
||||
// if(strpos($val['@value'], 'array (') === 0)
|
||||
// {
|
||||
// echo '<pre>'.$val['@value'];
|
||||
// echo "\n";
|
||||
// var_dump(e107::getArrayStorage()->ReadArray($val['@value']));
|
||||
// echo $val['@value'].'</pre>';
|
||||
// }
|
||||
$value = strpos($val['@value'], 'array (') === 0 ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value'];
|
||||
$pref[$name] = $value;
|
||||
|
||||
// $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG);
|
||||
@@ -839,30 +846,30 @@ class xmlClass
|
||||
|
||||
if($debug)
|
||||
{
|
||||
// $message = print_r($xmlArray);
|
||||
// echo "<pre>".print_r($xmlArray,TRUE)."</pre>";
|
||||
//$message = print_r($xmlArray);
|
||||
echo "<pre>".var_export($xmlArray,TRUE)."</pre>";
|
||||
return;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
//FIXME - doesn't work from install_.php.
|
||||
|
||||
if(vartrue($xmlArray['prefs'])) // Save Core Prefs
|
||||
{
|
||||
foreach($xmlArray['prefs'] as $type=>$array)
|
||||
{
|
||||
|
||||
$pArray = $this->e107ImportPrefs($xmlArray,$type);
|
||||
|
||||
if($mode == 'replace')
|
||||
|
||||
if($mode == 'replace') // merge with existing, add new
|
||||
{
|
||||
e107::getConfig($type)->setPref($pArray);
|
||||
}
|
||||
else // 'add'
|
||||
else // 'add' only new prefs
|
||||
{
|
||||
foreach ($pArray as $pname => $pval)
|
||||
{
|
||||
e107::getConfig($type)->add($pname, $pval); // don't parse x/y/z
|
||||
}
|
||||
// e107::getConfig($type)->addPref($pArray);
|
||||
}
|
||||
|
||||
if($debug == FALSE)
|
||||
|
Reference in New Issue
Block a user