From 23a1f952ff19c52bf65c423845e6163ac8b016c7 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sun, 6 Sep 2009 01:02:01 +0000 Subject: [PATCH] More export tweaks --- e107_admin/db.php | 31 +++++++++++++++++++------------ e107_handlers/xml_class.php | 21 ++++++++++++++++----- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/e107_admin/db.php b/e107_admin/db.php index abe93d002..57322d1cf 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -9,8 +9,8 @@ * Administration - Database Utilities * * $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $ - * $Revision: 1.29 $ - * $Date: 2009-09-05 23:02:23 $ + * $Revision: 1.30 $ + * $Date: 2009-09-06 01:02:01 $ * $Author: e107coders $ * */ @@ -70,7 +70,7 @@ if(isset($_POST['verify_sql']) || varset($_GET['mode'])=='verify_sql') if(isset($_POST['exportXmlFile'])) { - if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'])) + if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],$_POST['package_images'])) { $emessage = eMessage::getInstance(); $emessage->add(LAN_SUCCESS, E_MESSAGE_SUCCESS); @@ -709,14 +709,22 @@ function db_adminmenu() } - -function exportXmlFile($prefs,$tables,$debug=FALSE) +/** + * Export XML File and Copy Images. + * @param object $prefs + * @param object $tables + * @param object $debug [optional] + * @return + */ +function exportXmlFile($prefs,$tables,$package=FALSE,$debug=FALSE) { $xml = e107::getSingleton('xmlClass'); $tp = e107::getParser(); $emessage = eMessage::getInstance(); - if(vartrue($_POST['package_images'])) + //TODO LANs + + if(vartrue($package)) { $xml->convertFilePaths = TRUE; @@ -725,14 +733,13 @@ function exportXmlFile($prefs,$tables,$debug=FALSE) $desinationFolder = $tp->replaceConstants($xml->filePathDestination); if(!is_writable($desinationFolder)) - { - - $emessage->add($desinationFolder."is not writable", E_MESSAGE_ERROR); + { + $emessage->add($desinationFolder." is not writable", E_MESSAGE_ERROR); return ; } } - //TODO LANs + if($xml->e107Export($prefs,$tables,$debug)) { $emessage->add("Created: ".$desinationFolder."install.xml", E_MESSAGE_SUCCESS); @@ -742,7 +749,7 @@ function exportXmlFile($prefs,$tables,$debug=FALSE) { $file = basename($oldfile); $newfile = $desinationFolder.$file; - if(copy($oldfile,$newfile)) + if($oldfile == $newfile || (copy($oldfile,$newfile))) { $emessage->add("Copied: ".$newfile, E_MESSAGE_SUCCESS); } @@ -783,7 +790,7 @@ function table_list() if($count) { - $tabs[$e107tab] = $count; // mysql_num_rows($t); + $tabs[$e107tab] = $count; } } diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index a459762d4..c0b8276ae 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -9,8 +9,8 @@ * Simple XML Parser * * $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $ - * $Revision: 1.22 $ - * $Date: 2009-09-05 23:02:23 $ + * $Revision: 1.23 $ + * $Date: 2009-09-06 01:02:01 $ * $Author: e107coders $ */ @@ -544,7 +544,12 @@ class xmlClass return false; } - function replaceFilePaths($text) + /** + * Convert file path for inclusion in XML file. + * @param callback function $text - see e107ExportValue() + * @return converted file path + */ + private function replaceFilePaths($text) { $fullpath = e107::getParser()->replaceConstants($text[1]); $this->fileConvertLog[] = $fullpath; @@ -555,7 +560,11 @@ class xmlClass } - + /** + * Process data values for XML file. If $this->convertFilePaths is TRUE, convert paths - see replaceFilePaths() + * @param mixed $val + * @return mixed + */ private function e107ExportValue($val) { if($this->convertFilePaths) @@ -579,13 +588,15 @@ class xmlClass /** * Create an e107 Export File in XML format + * Note: If $this->filePathDestination has a value, then the file will be saved there. * @param array $prefs - see e_core_pref $aliases (eg. core, ipool etc) - * @param array $tables - table names with the prefix + * @param array $tables - table names without the prefix * @param boolean $debug [optional] * @return text / file for download */ public function e107Export($xmlprefs,$tables,$debug=FALSE) { + require_once(e_ADMIN."ver.php"); $text = "\n";