1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

install packaging now working

This commit is contained in:
CaMer0n
2009-09-05 23:02:23 +00:00
parent e2aa59c25e
commit 2cdae5662c
4 changed files with 148 additions and 62 deletions

View File

@@ -9,13 +9,15 @@
* Administration - Database Utilities * Administration - Database Utilities
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $
* $Revision: 1.28 $ * $Revision: 1.29 $
* $Date: 2009-09-04 14:35:00 $ * $Date: 2009-09-05 23:02:23 $
* $Author: e107coders $ * $Author: e107coders $
* *
*/ */
require_once ("../class2.php"); require_once ("../class2.php");
$theme = e107::getPref('sitetheme');
define("EXPORT_PATH","{e_THEME}".$theme."/install/");
if(!getperms('0')) if(!getperms('0'))
{ {
@@ -68,14 +70,18 @@ if(isset($_POST['verify_sql']) || varset($_GET['mode'])=='verify_sql')
if(isset($_POST['exportXmlFile'])) if(isset($_POST['exportXmlFile']))
{ {
exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],TRUE); if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables']))
exit(); {
$emessage = eMessage::getInstance();
$emessage->add(LAN_SUCCESS, E_MESSAGE_SUCCESS);
}
} }
require_once ("auth.php"); require_once ("auth.php");
require_once (e_HANDLER."form_handler.php"); require_once (e_HANDLER."form_handler.php");
$frm = new e_form(); $frm = new e_form();
$emessage = &eMessage::getInstance(); //nothing wrong with doing it twice
/* No longer needed after XML feature added. /* No longer needed after XML feature added.
@@ -335,11 +341,11 @@ class system_tools
*/ */
private function exportXmlForm() private function exportXmlForm()
{ {
$emessage = eMessage::getInstance();
$frm = e107::getSingleton('e_form'); $frm = e107::getSingleton('e_form');
//TODO LANs //TODO LANs
$text = "<form method='post' action='".e_SELF."' id='core-db-export-form'> $text = "<form method='post' action='".e_SELF."?".e_QUERY."' id='core-db-export-form'>
<fieldset id='core-db-export'> <fieldset id='core-db-export'>
<legend class='e-hideme'>Export Options</legend> <legend class='e-hideme'>Export Options</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'> <table cellpadding='0' cellspacing='0' class='adminlist'>
@@ -359,21 +365,23 @@ class system_tools
"; ";
$pref_types = e107::getConfig()->aliases; $pref_types = e107::getConfig()->aliases;
$exclusions = array('core_old','core_backup'); unset($pref_types['core_old'],$pref_types['core_backup']);
// $exclusions = array('core_old'=>1,'core_backup'=>1);
// $filteredprefs = array_diff($pref_types,$exclusions);
foreach($pref_types as $key=>$description) foreach($pref_types as $key=>$description)
{ {
if(!in_array($key,$exclusions)) $checked = ($_POST['xml_prefs'][$key] == $key) ? 1: 0;
{
$text .= "<tr> $text .= "<tr>
<td> <td>
".$frm->checkbox("xml_prefs[".$key."]", $key)." ".$frm->checkbox("xml_prefs[".$key."]", $key, $checked)."
".LAN_PREFS.": ".$key."</td> ".LAN_PREFS.": ".$key."</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr>"; </tr>";
}
} }
$text .= "</tbody> $text .= "</tbody>
</table> </table>
@@ -396,10 +404,11 @@ class system_tools
$tables = table_list(); $tables = table_list();
foreach($tables as $name=>$count) foreach($tables as $name=>$count)
{ {
$checked = ($_POST['xml_tables'][$name] == $name) ? 1: 0;
$text .= "<tr> $text .= "<tr>
<td> <td>
".$frm->checkbox("xml_tables[".$name."]", $name)." Table Data: ".$name." ".$frm->checkbox("xml_tables[".$name."]", $name, $checked)." Table Data: ".$name."
</td> </td>
<td class='right'>$count</td> <td class='right'>$count</td>
</tr>"; </tr>";
@@ -423,9 +432,10 @@ class system_tools
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td colspan='2'> <td colspan='2'>";
".$frm->checkbox("package_images",'package_images')." Convert Image-paths and package images. $checked = (vartrue($_POST['package_images'])) ? 1: 0;
Destination Path: <input type='text' name='package_path' value='' /> (not functional) $text .= $frm->checkbox("package_images",'package_images', $checked)." Convert paths and package images and xml into: <i>".e107::getParser()->replaceConstants(EXPORT_PATH)."</i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -438,7 +448,7 @@ class system_tools
</form> "; </form> ";
e107::getRender()->tablerender("Export Options", $text); e107::getRender()->tablerender("Export Options",$emessage->render(). $text);
} }
@@ -703,15 +713,47 @@ function db_adminmenu()
function exportXmlFile($prefs,$tables,$debug=FALSE) function exportXmlFile($prefs,$tables,$debug=FALSE)
{ {
$xml = e107::getSingleton('xmlClass'); $xml = e107::getSingleton('xmlClass');
$tp = e107::getParser();
$emessage = eMessage::getInstance();
if(vartrue($_POST['package_images']) && vartrue($_POST['package_path'])) if(vartrue($_POST['package_images']))
{ {
// TODO Conversion of Image paths - in xml-class and e_parse_class?
// $xml->convertImagePaths = TRUE; $xml->convertFilePaths = TRUE;
// $xml->destinationPath = $_POST['package_path']; $xml->filePathDestination = EXPORT_PATH;
$desinationFolder = $tp->replaceConstants($xml->filePathDestination);
if(!is_writable($desinationFolder))
{
$emessage->add($desinationFolder."is not writable", E_MESSAGE_ERROR);
return ;
}
} }
$xml->e107Export($prefs,$tables,FALSE); //TODO LANs
if($xml->e107Export($prefs,$tables,$debug))
{
$emessage->add("Created: ".$desinationFolder."install.xml", E_MESSAGE_SUCCESS);
if(varset($xml->fileConvertLog))
{
foreach($xml->fileConvertLog as $oldfile)
{
$file = basename($oldfile);
$newfile = $desinationFolder.$file;
if(copy($oldfile,$newfile))
{
$emessage->add("Copied: ".$newfile, E_MESSAGE_SUCCESS);
}
else
{
$emessage->add("Couldn't copy: ".$newfile, E_MESSAGE_ERROR);
}
}
}
}
} }
@@ -721,7 +763,6 @@ function table_list()
// grab default language lists. // grab default language lists.
//TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php. //TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php.
global $mySQLdefaultdb;
$exclude = array(); $exclude = array();
$exclude[] = "core"; $exclude[] = "core";
$exclude[] = "rbinary"; $exclude[] = "rbinary";
@@ -731,36 +772,26 @@ function table_list()
$exclude[] = "upload"; $exclude[] = "upload";
$exclude[] = "user_extended_country"; $exclude[] = "user_extended_country";
$exclude[] = "plugin"; $exclude[] = "plugin";
$coreTables = e107::getDb()->db_TableList('nolan');
$tables = mysql_list_tables($mySQLdefaultdb); $tables = array_diff($coreTables,$exclude);
while (list($temp) = mysql_fetch_array($tables))
{ foreach($tables as $e107tab)
{
e107::getDB()->db_Rows(); $count = e107::getDb()->db_Select_gen("SELECT * FROM #".$e107tab);
$t = mysql_query("SELECT * FROM ".$temp);
$e107tab = str_replace(MPREFIX, "", $temp); if($count)
$count = mysql_num_rows($t);
if($count && (strpos($temp,$prefix)!==TRUE) && !in_array($e107tab,$exclude))
{ {
$tabs[$e107tab] = mysql_num_rows($t); $tabs[$e107tab] = $count; // mysql_num_rows($t);
} }
$prefix = MPREFIX."lan_";
$match = array();
// if(preg_match('/^'.$prefix.'(.*)/', $temp, $match))
{
// $e107tab = str_replace(MPREFIX, "", $temp);
// $pos = strrpos($match[1],"_")+1;
// $core = substr(str_replace("lan_","",$e107tab),$pos);
// if (str_replace($exclude, "", $e107tab))
// {
// $tabs[$core] = $e107tab;
// }
}
} }
return $tabs; return $tabs;
} }
/* Still needed? /* Still needed?
function backup_core() function backup_core()

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/includes/infopanel.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/includes/infopanel.php,v $
| $Revision: 1.9 $ | $Revision: 1.10 $
| $Date: 2009-09-04 14:35:01 $ | $Date: 2009-09-05 23:02:23 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -250,11 +250,13 @@ function render_infopanel_menu_options()
$frm = e107::getSingleton('e_form'); $frm = e107::getSingleton('e_form');
$text = ""; $text = "";
$menu_qry = 'SELECT * FROM #menus WHERE menu_id!= 0 GROUP BY menu_name ORDER BY menu_name'; $menu_qry = 'SELECT * FROM #menus WHERE menu_id!= 0 GROUP BY menu_name ORDER BY menu_name';
$settings = varset($user_pref['core-infopanel-menus'],array());
if (e107::getDb()->db_Select_gen($menu_qry)) if (e107::getDb()->db_Select_gen($menu_qry))
{ {
while ($row = e107::getDb()->db_Fetch()) while ($row = e107::getDb()->db_Fetch())
{ {
$checked = (in_array($row['menu_name'], $user_pref['core-infopanel-menus'])) ? true : false; $checked = (in_array($row['menu_name'], $settings)) ? true : false;
$text .= "<div class='left f-left list field-spacer' style='display:block;height:24px;width:200px;'>"; $text .= "<div class='left f-left list field-spacer' style='display:block;height:24px;width:200px;'>";
$text .= $frm->checkbox("e-mymenus[]", $row['menu_name'], $checked); $text .= $frm->checkbox("e-mymenus[]", $row['menu_name'], $checked);
$text .= $row['menu_name']; $text .= $row['menu_name'];

View File

@@ -9,8 +9,8 @@
* mySQL Handler * mySQL Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
* $Revision: 1.46 $ * $Revision: 1.47 $
* $Date: 2009-09-05 18:58:56 $ * $Date: 2009-09-05 23:02:23 $
* $Author: e107coders $ * $Author: e107coders $
*/ */
@@ -61,7 +61,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
* MySQL Abstraction class * MySQL Abstraction class
* *
* @package e107 * @package e107
* @version $Revision: 1.46 $ * @version $Revision: 1.47 $
* @author $Author: e107coders $ * @author $Author: e107coders $
*/ */
class db { class db {
@@ -838,8 +838,10 @@ class db {
function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '') function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '')
{ {
$this->tabset = FALSE; $this->tabset = FALSE;
$query .= " "; // temp fix for failing regex below, when there is no space after the table name;
if(strpos($query,'`#') !== FALSE) if(strpos($query,'`#') !== FALSE)
{ {
$query = preg_replace_callback("/\s`#([\w]*?)`\W/", array($this, 'ml_check'), $query); $query = preg_replace_callback("/\s`#([\w]*?)`\W/", array($this, 'ml_check'), $query);
} }
elseif(strpos($query,'#') !== FALSE) elseif(strpos($query,'#') !== FALSE)
@@ -865,7 +867,7 @@ class db {
} }
function ml_check($matches) function ml_check($matches)
{ {
$table = $this->db_IsLang($matches[1]); $table = $this->db_IsLang($matches[1]);
if($this->tabset == false) if($this->tabset == false)
{ {

View File

@@ -9,8 +9,8 @@
* Simple XML Parser * Simple XML Parser
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $
* $Revision: 1.21 $ * $Revision: 1.22 $
* $Date: 2009-09-03 22:27:32 $ * $Date: 2009-09-05 23:02:23 $
* $Author: e107coders $ * $Author: e107coders $
*/ */
@@ -27,6 +27,7 @@ if (!defined('e107_INIT')) { exit; }
*/ */
class xmlClass class xmlClass
{ {
/** /**
* Loaded XML string * Loaded XML string
* *
@@ -65,6 +66,19 @@ class xmlClass
*/ */
public $stripComments = true; public $stripComments = true;
/**
* Log of all paths replaced.
* @var
*/
public $fileConvertLog = array();
public $convertFilePaths = FALSE;
public $filePathDestination = FALSE;
public $convertFileTypes = array("jpg","gif","png","jpeg");
/** /**
* Add root element to the result array * Add root element to the result array
* Exmple: * Exmple:
@@ -121,6 +135,10 @@ class xmlClass
*/ */
protected $_optValueKey = '@value'; protected $_optValueKey = '@value';
/** /**
* Constructor - set defaults * Constructor - set defaults
* *
@@ -526,9 +544,26 @@ class xmlClass
return false; return false;
} }
function replaceFilePaths($text)
{
$fullpath = e107::getParser()->replaceConstants($text[1]);
$this->fileConvertLog[] = $fullpath;
$file = basename($fullpath);
return $this->filePathDestination.$file;
}
private function e107ExportValue($val) private function e107ExportValue($val)
{ {
if($this->convertFilePaths)
{
$types = implode("|",$this->convertFileTypes);
$val = preg_replace_callback("#({e_.*?\.(".$types."))#i", array($this,'replaceFilePaths'), $val);
}
if(is_array($val)) if(is_array($val))
{ {
return "<![CDATA[".e107::getArrayStorage()->WriteArray($val,FALSE)."]]>"; return "<![CDATA[".e107::getArrayStorage()->WriteArray($val,FALSE)."]]>";
@@ -604,17 +639,33 @@ class xmlClass
if($debug==TRUE) if($debug==TRUE)
{ {
echo "<pre>".htmlentities($text)."</pre>"; echo "<pre>".htmlentities($text)."</pre>";
return TRUE;
} }
else else
{ {
if(!$text)
{
return FALSE;
}
$path = e107::getParser()->replaceConstants($this->filePathDestination);
if($path)
{
file_put_contents($path."install.xml",$text,FILE_TEXT);
return true;
}
header('Content-type: application/xml', TRUE); header('Content-type: application/xml', TRUE);
header("Content-disposition: attachment; filename= e107Export_" . date("Y-m-d").".xml"); header("Content-disposition: attachment; filename= e107Export_" . date("Y-m-d").".xml");
header("Cache-Control: max-age=30"); header("Cache-Control: max-age=30");
header("Pragma: public"); header("Pragma: public");
echo $text; echo $text;
exit; exit;
} }
} }
/** /**