mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Plugin Pref import routine.
This commit is contained in:
@@ -1023,12 +1023,16 @@ class xmlClass
|
|||||||
* Return an Array of core preferences from e107 XML Dump data
|
* Return an Array of core preferences from e107 XML Dump data
|
||||||
*
|
*
|
||||||
* @param array $XMLData Raw XML e107 Export Data
|
* @param array $XMLData Raw XML e107 Export Data
|
||||||
* @param string $prefType [optional] the type of core pref: core|emote|ipool|menu etc.
|
* @param string $prefType [optional] the type of core pref: core|emote|ipool|menu etc or plugin-folder name
|
||||||
|
* @param string $mode core|plugin
|
||||||
* @return array preference array equivalent to the old $pref global;
|
* @return array preference array equivalent to the old $pref global;
|
||||||
*/
|
*/
|
||||||
public function e107ImportPrefs($XMLData, $prefType='core')
|
public function e107ImportPrefs($XMLData, $prefType='core', $mode='core')
|
||||||
{
|
{
|
||||||
if(!vartrue($XMLData['prefs'][$prefType]))
|
|
||||||
|
$key = ($mode === 'core') ? 'prefs' : 'pluginPrefs';
|
||||||
|
|
||||||
|
if(!vartrue($XMLData[$key][$prefType]))
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@@ -1036,7 +1040,7 @@ class xmlClass
|
|||||||
//$mes = eMessage::getInstance();
|
//$mes = eMessage::getInstance();
|
||||||
|
|
||||||
$pref = array();
|
$pref = array();
|
||||||
foreach($XMLData['prefs'][$prefType] as $val)
|
foreach($XMLData[$key][$prefType] as $val)
|
||||||
{
|
{
|
||||||
$name = $val['@attributes']['name'];
|
$name = $val['@attributes']['name'];
|
||||||
// if(strpos($val['@value'], 'array (') === 0)
|
// if(strpos($val['@value'], 'array (') === 0)
|
||||||
@@ -1084,7 +1088,9 @@ class xmlClass
|
|||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
if(vartrue($xmlArray['prefs'])) // Save Core Prefs
|
// ----------------- Save Core Prefs ---------------------
|
||||||
|
|
||||||
|
if(!empty($xmlArray['prefs']))
|
||||||
{
|
{
|
||||||
foreach($xmlArray['prefs'] as $type=>$array)
|
foreach($xmlArray['prefs'] as $type=>$array)
|
||||||
{
|
{
|
||||||
@@ -1112,6 +1118,40 @@ class xmlClass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --------------- Save Plugin Prefs ---------------------
|
||||||
|
|
||||||
|
if(!empty($xmlArray['pluginPrefs']))
|
||||||
|
{
|
||||||
|
foreach($xmlArray['pluginPrefs'] as $type=>$array)
|
||||||
|
{
|
||||||
|
|
||||||
|
$pArray = $this->e107ImportPrefs($xmlArray,$type, 'plugin');
|
||||||
|
|
||||||
|
if($mode == 'replace') // merge with existing, add new
|
||||||
|
{
|
||||||
|
e107::getPlugConfig($type)->setPref($pArray);
|
||||||
|
}
|
||||||
|
else // 'add' only new prefs
|
||||||
|
{
|
||||||
|
foreach ($pArray as $pname => $pval)
|
||||||
|
{
|
||||||
|
e107::getPlugConfig($type)->add($pname, $pval); // don't parse x/y/z
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($debug == false)
|
||||||
|
{
|
||||||
|
e107::getPlugConfig($type)
|
||||||
|
->setParam('nologs', $noLogs)
|
||||||
|
->save(FALSE,TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(vartrue($xmlArray['database']))
|
if(vartrue($xmlArray['database']))
|
||||||
{
|
{
|
||||||
foreach($xmlArray['database']['dbTable'] as $val)
|
foreach($xmlArray['database']['dbTable'] as $val)
|
||||||
|
Reference in New Issue
Block a user