From cbc6beb78931c139a25efb0e6f4c7accf47fba69 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 24 Dec 2016 09:34:00 -0800 Subject: [PATCH] Preparations for plugin-pref export support. --- e107_admin/db.php | 107 +++++++++++++++++++++++++++++++----- e107_handlers/xml_class.php | 14 +++-- 2 files changed, 104 insertions(+), 17 deletions(-) diff --git a/e107_admin/db.php b/e107_admin/db.php index e7a893da8..82900b207 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -192,7 +192,7 @@ class system_tools if(isset($_POST['delplug'])) { - $this->delete_plugin_entry($_POST['pref_type']); + $this->delete_plugin_entry(); // $_POST['pref_type'] } if(isset($_POST['upload'])) @@ -1057,6 +1057,8 @@ class system_tools e107::getCache()->clear(); } + return null; + } private function delete_plugin_entry() @@ -1066,7 +1068,7 @@ class system_tools $sql = e107::getDb(); $del = array_keys($_POST['delplug']); - if($sql->db_Delete("plugin", "plugin_id='".intval($del[0])."'")) + if($sql->delete("plugin", "plugin_id='".intval($del[0])."'")) { $mes->add(LAN_DELETED, E_MESSAGE_SUCCESS); } @@ -1080,11 +1082,11 @@ class system_tools /** * Render Options - * @return none + * @return null */ private function render_options() { - $frm = e107::getForm(); + $mes = e107::getMessage(); $text = " @@ -1124,12 +1126,14 @@ class system_tools "; */ e107::getRender()->tablerender(DBLAN_10, $mes->render().$text); + + return null; } /** * Import XML Form - * @return none + * @return null */ private function importForm() { @@ -1173,11 +1177,12 @@ class system_tools e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_59, $mes->render().$text); + return null; } /** * Export XML Dump - * @return none + * @return null */ private function exportXmlForm() { @@ -1202,7 +1207,6 @@ class system_tools "; - //TODO Add support for plugin Prefs. $pref_types = e107::getConfig()->aliases; unset($pref_types['core_old'], $pref_types['core_backup']); @@ -1211,17 +1215,58 @@ class system_tools foreach($pref_types as $key=>$description) { + $data = e107::getConfig($key)->getPref(); + + $rows = count($data); + $checked = (vartrue($_POST['xml_prefs'][$key]) == $key) ? 1: 0; $text .= " ".$frm->checkbox("xml_prefs[".$key."]", $key, $checked, array('label'=>LAN_PREFS.": ".$key))." -   + ".intval($rows)." "; } + + + // Plugin Preferences ---------------------------- + $pluglist = e107::pref('core','plug_installed'); + + $text .= " + ".$frm->checkbox_toggle('check-all-verify', 'xml_plugprefs')."  Plugin ".LAN_PREFS." + ".DBLAN_98." + + "; + + ksort($pluglist); + + foreach($pluglist as $plug=>$ver) + { + $data = e107::getPlugConfig($plug)->getPref(); + + $key = $plug; + + $checked = false; + + if(!empty($data)) + { + $rows = count($data); + + $text .= " + + ".$frm->checkbox("xml_plugprefs[".$key."]",$key, $checked, array('label'=>LAN_PREFS.": ".$key))." + + ".$rows." + + "; + } + } + + + $text .= " @@ -1284,14 +1329,40 @@ class system_tools "; + // display differences between default and core prefs. +/* + $corePrefs = e107::pref('core'); + + $defaultArray = e107::getXml()->loadXMLfile(e_CORE."xml/default_install.xml", 'advanced'); + $defaultPrefs = e107::getXml()->e107ImportPrefs($defaultArray); + + $text .= "
"; + foreach($defaultPrefs as $k=> $val) + { + if($val == $corePrefs[$k] || substr($k,-5) === '_list' || substr($k,0,9) == 'sitetheme') + { + continue; + } + + + $text .= " + + + "; + + } + $text .= "
".$k."".print_a($val,true)."".print_a($corePrefs[$k],true)."
"; +*/ + + e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_102,$mes->render(). $text); - + return null; } /** * Import XML Dump - * @return none + * @return null */ private function importXmlFile() { @@ -1306,11 +1377,14 @@ class system_tools { e107::getMessage()->addError(DBLAN_104." $table"); } + + return null; } /** * Optimize SQL - * @return none + * @param $mySQLdefaultdb + * @return null */ private function optimizesql($mySQLdefaultdb) { @@ -1324,10 +1398,13 @@ class system_tools $mes->addSuccess(e107::getParser()->lanVars(DBLAN_11, $mySQLdefaultdb)); e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_7, $mes->render()); + + return null; } /** * Preferences Editor + * @param string $type * @return string text for display */ private function pref_editor($type='core') @@ -1652,7 +1729,7 @@ function exportXmlFile($prefs,$tables,$package=FALSE,$debug=FALSE) { $message = str_replace('[folder]', $desinationFolder, DBLAN_107); $mes->add($message, E_MESSAGE_ERROR); - return ; + return false ; } } @@ -1676,8 +1753,10 @@ function exportXmlFile($prefs,$tables,$package=FALSE,$debug=FALSE) } } } + } + return null; } @@ -1697,10 +1776,12 @@ function table_list() $exclude[] = "user_extended_country"; $exclude[] = "plugin"; - $coreTables = e107::getDb()->db_TableList('nolan'); + $coreTables = e107::getDb()->tables('nolan'); $tables = array_diff($coreTables,$exclude); + $tabs = array(); + foreach($tables as $e107tab) { $count = e107::getDb()->gen("SELECT * FROM #".$e107tab); diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 667615046..0a7a26fac 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -872,9 +872,9 @@ class xmlClass * @param boolean $debug [optional] * @return string text / file for download */ - public function e107Export($xmlprefs, $tables, $debug = FALSE) + public function e107Export($xmlprefs, $tables, $mode = false) { - error_reporting(0); + // error_reporting(0); $e107info = array(); require_once(e_ADMIN."ver.php"); @@ -904,7 +904,7 @@ class xmlClass { continue; } - elseif($debug == true) + elseif($mode === 'debug') { echo "
Original/Modiied ".$key.""; var_dump($default[$key],$val); @@ -958,7 +958,13 @@ class xmlClass $text .= ""; - if($debug==TRUE) + + if($mode === 'return') + { + return $text; + } + + if($mode === 'debug') { echo "
".htmlentities($text)."
"; return TRUE;