1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Theme preferences import/export added to 'database' admin area.

This commit is contained in:
Cameron
2019-07-09 12:08:52 -07:00
parent 4465182852
commit f5317e329f
4 changed files with 110 additions and 8 deletions

View File

@@ -68,7 +68,7 @@ if(isset($_POST['exportXmlFile']))
{ {
if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],$_POST['xml_plugprefs'], $_POST['package_images'], false)) if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],$_POST['xml_plugprefs'],$_POST['xml_themeprefs'], $_POST['package_images'], false))
{ {
$mes = e107::getMessage(); $mes = e107::getMessage();
$mes->add(LAN_CREATED, E_MESSAGE_SUCCESS); $mes->add(LAN_CREATED, E_MESSAGE_SUCCESS);
@@ -1203,6 +1203,42 @@ class system_tools
} }
// theme preferences
$sitetheme = e107::pref('core','sitetheme'); // currently just sitetheme, but could easily be expanded.
$themelist = array($sitetheme);
$text .= "</tbody><thead><tr>
<th class='form-inline'>".$frm->checkbox_toggle('check-all-verify', 'xml_plugprefs')." &nbsp;Theme ".LAN_PREFS."</th>
<th class='right'>".DBLAN_98."</th>
</tr></thead><tbody>";
// ksort($themelist);
foreach($themelist as $plug)
{
$data = e107::getThemeConfig($plug)->getPref();
$key = $plug;
$checked = false;
if(!empty($data))
{
$rows = count($data);
$text .= "<tr>
<td>
".$frm->checkbox("xml_themeprefs[".$key."]",$key, $checked, array('label'=>LAN_PREFS.": ".$key))."
</td>
<td class='text-right'>".$rows."</td>
</tr>";
}
}
$text .= "</tbody> $text .= "</tbody>
</table> </table>
@@ -1642,7 +1678,7 @@ function db_adminmenu() //FIXME - has problems when navigation is on the LEFT in
* @param object $debug [optional] * @param object $debug [optional]
* @return bool|null * @return bool|null
*/ */
function exportXmlFile($prefs,$tables=array(),$plugPrefs, $package=FALSE,$debug=FALSE) function exportXmlFile($prefs,$tables=array(),$plugPrefs=array(), $themePrefs=array(), $package=FALSE,$debug=FALSE)
{ {
$xml = e107::getXml(); $xml = e107::getXml();
$tp = e107::getParser(); $tp = e107::getParser();
@@ -1673,7 +1709,7 @@ function exportXmlFile($prefs,$tables=array(),$plugPrefs, $package=FALSE,$debug=
$mode = ($debug === true) ? array( "debug" =>1) : null; $mode = ($debug === true) ? array( "debug" =>1) : null;
if($xml->e107Export($prefs,$tables,$plugPrefs, $mode)) if($xml->e107Export($prefs,$tables,$plugPrefs, $themePrefs, $mode))
{ {
$mes->add(DBLAN_108." ".$desinationFolder."install.xml", E_MESSAGE_SUCCESS); $mes->add(DBLAN_108." ".$desinationFolder."install.xml", E_MESSAGE_SUCCESS);
if(varset($xml->fileConvertLog)) if(varset($xml->fileConvertLog))

View File

@@ -4112,7 +4112,7 @@ class e_admin_tree_model extends e_front_tree_model
$filename = "e107Export_" .$this->getModelTable()."_". date("YmdHi").".xml"; $filename = "e107Export_" .$this->getModelTable()."_". date("YmdHi").".xml";
$query = $this->getFieldIdName().' IN ('.$idstr.') '; // ORDER BY '.$this->getParam('db_order') ; $query = $this->getFieldIdName().' IN ('.$idstr.') '; // ORDER BY '.$this->getParam('db_order') ;
e107::getXML()->e107Export(null,$table,null,array('file'=>$filename,'query'=>$query)); e107::getXml()->e107Export(null,$table,null,null, array('file'=>$filename,'query'=>$query));
return null; return null;

View File

@@ -798,7 +798,7 @@ final class e_core_pref extends e_pref
'menu' => 'menu_pref', 'menu' => 'menu_pref',
'search' => 'search_prefs', 'search' => 'search_prefs',
'notify' => 'notify_prefs', 'notify' => 'notify_prefs',
'history' => 'history_prefs' 'history' => 'history_prefs',
); );
/** /**

View File

@@ -825,7 +825,7 @@ class xmlClass
} }
if ($parse) if ($parse)
{ {
return $this->parseXML('', ($parse === true)); return $this->parseXml('', ($parse === true));
} }
else else
{ {
@@ -903,7 +903,7 @@ class xmlClass
* @param array $options [optional] debug, return, query * @param array $options [optional] debug, return, query
* @return string text / file for download * @return string text / file for download
*/ */
public function e107Export($xmlprefs, $tables, $plugPrefs, $options = array()) public function e107Export($xmlprefs, $tables, $plugPrefs=null, $themePrefs=null, $options = array())
{ {
// error_reporting(0); // error_reporting(0);
// $e107info = array(); // $e107info = array();
@@ -975,6 +975,28 @@ class xmlClass
$text .= "\t</pluginPrefs>\n"; $text .= "\t</pluginPrefs>\n";
} }
if(!empty($themePrefs))
{
$text .= "\t<themePrefs>\n";
foreach($themePrefs as $plug)
{
$prefs = e107::getThemeConfig($plug)->getPref();
foreach($prefs as $key=>$val)
{
if(isset($val))
{
$text .= "\t\t<".$plug." name=\"".$key."\">".$this->e107ExportValue($val)."</".$plug.">\n";
}
}
}
$text .= "\t</themePrefs>\n";
}
@@ -1071,7 +1093,22 @@ class xmlClass
public function e107ImportPrefs($XMLData, $prefType='core', $mode='core') public function e107ImportPrefs($XMLData, $prefType='core', $mode='core')
{ {
$key = ($mode === 'core') ? 'prefs' : 'pluginPrefs'; switch($mode)
{
case "plugin":
$key = 'pluginPrefs';
break;
case "theme":
$key = 'themePrefs';
break;
case "core":
default:
$key = 'core';
}
// $key = ($mode === 'core') ? 'prefs' : 'pluginPrefs';
if(!vartrue($XMLData[$key][$prefType])) if(!vartrue($XMLData[$key][$prefType]))
{ {
@@ -1191,6 +1228,35 @@ class xmlClass
} }
} }
// --------------- Save Theme Prefs ---------------------
if(!empty($xmlArray['themePrefs']))
{
foreach($xmlArray['themePrefs'] as $type=>$array)
{
$pArray = $this->e107ImportPrefs($xmlArray,$type, 'theme');
if($mode == 'replace') // merge with existing, add new
{
e107::getThemeConfig($type)->setPref($pArray);
}
else // 'add' only new prefs
{
foreach ($pArray as $pname => $pval)
{
e107::getThemeConfig($type)->add($pname, $pval); // don't parse x/y/z
}
}
if($debug == false)
{
e107::getThemeConfig($type)
->setParam('nologs', $noLogs)
->save(FALSE,TRUE);
}
}
}