1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +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
*
* $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $
* $Revision: 1.28 $
* $Date: 2009-09-04 14:35:00 $
* $Revision: 1.29 $
* $Date: 2009-09-05 23:02:23 $
* $Author: e107coders $
*
*/
require_once ("../class2.php");
$theme = e107::getPref('sitetheme');
define("EXPORT_PATH","{e_THEME}".$theme."/install/");
if(!getperms('0'))
{
@@ -68,14 +70,18 @@ if(isset($_POST['verify_sql']) || varset($_GET['mode'])=='verify_sql')
if(isset($_POST['exportXmlFile']))
{
exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],TRUE);
exit();
if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables']))
{
$emessage = eMessage::getInstance();
$emessage->add(LAN_SUCCESS, E_MESSAGE_SUCCESS);
}
}
require_once ("auth.php");
require_once (e_HANDLER."form_handler.php");
$frm = new e_form();
$emessage = &eMessage::getInstance(); //nothing wrong with doing it twice
/* No longer needed after XML feature added.
@@ -335,11 +341,11 @@ class system_tools
*/
private function exportXmlForm()
{
$emessage = eMessage::getInstance();
$frm = e107::getSingleton('e_form');
//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'>
<legend class='e-hideme'>Export Options</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>
@@ -360,20 +366,22 @@ class system_tools
";
$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)
{
if(!in_array($key,$exclusions))
{
$text .= "<tr>
$checked = ($_POST['xml_prefs'][$key] == $key) ? 1: 0;
$text .= "<tr>
<td>
".$frm->checkbox("xml_prefs[".$key."]", $key)."
".$frm->checkbox("xml_prefs[".$key."]", $key, $checked)."
".LAN_PREFS.": ".$key."</td>
<td>&nbsp;</td>
</tr>";
}
}
$text .= "</tbody>
</table>
@@ -397,9 +405,10 @@ class system_tools
foreach($tables as $name=>$count)
{
$checked = ($_POST['xml_tables'][$name] == $name) ? 1: 0;
$text .= "<tr>
<td>
".$frm->checkbox("xml_tables[".$name."]", $name)." Table Data: ".$name."
".$frm->checkbox("xml_tables[".$name."]", $name, $checked)." Table Data: ".$name."
</td>
<td class='right'>$count</td>
</tr>";
@@ -423,9 +432,10 @@ class system_tools
</thead>
<tbody>
<tr>
<td colspan='2'>
".$frm->checkbox("package_images",'package_images')." Convert Image-paths and package images.
Destination Path: <input type='text' name='package_path' value='' /> (not functional)
<td colspan='2'>";
$checked = (vartrue($_POST['package_images'])) ? 1: 0;
$text .= $frm->checkbox("package_images",'package_images', $checked)." Convert paths and package images and xml into: <i>".e107::getParser()->replaceConstants(EXPORT_PATH)."</i>
</td>
</tr>
</tbody>
@@ -438,7 +448,7 @@ class system_tools
</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)
{
$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->destinationPath = $_POST['package_path'];
$xml->convertFilePaths = TRUE;
$xml->filePathDestination = EXPORT_PATH;
$desinationFolder = $tp->replaceConstants($xml->filePathDestination);
if(!is_writable($desinationFolder))
{
$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);
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);
}
}
}
}
$xml->e107Export($prefs,$tables,FALSE);
}
@@ -721,7 +763,6 @@ function table_list()
// grab default language lists.
//TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php.
global $mySQLdefaultdb;
$exclude = array();
$exclude[] = "core";
$exclude[] = "rbinary";
@@ -732,35 +773,25 @@ function table_list()
$exclude[] = "user_extended_country";
$exclude[] = "plugin";
$tables = mysql_list_tables($mySQLdefaultdb);
while (list($temp) = mysql_fetch_array($tables))
$coreTables = e107::getDb()->db_TableList('nolan');
$tables = array_diff($coreTables,$exclude);
foreach($tables as $e107tab)
{
$count = e107::getDb()->db_Select_gen("SELECT * FROM #".$e107tab);
e107::getDB()->db_Rows();
$t = mysql_query("SELECT * FROM ".$temp);
$e107tab = str_replace(MPREFIX, "", $temp);
$count = mysql_num_rows($t);
if($count && (strpos($temp,$prefix)!==TRUE) && !in_array($e107tab,$exclude))
if($count)
{
$tabs[$e107tab] = 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;
// }
$tabs[$e107tab] = $count; // mysql_num_rows($t);
}
}
return $tabs;
}
/* Still needed?
function backup_core()

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/includes/infopanel.php,v $
| $Revision: 1.9 $
| $Date: 2009-09-04 14:35:01 $
| $Revision: 1.10 $
| $Date: 2009-09-05 23:02:23 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -250,11 +250,13 @@ function render_infopanel_menu_options()
$frm = e107::getSingleton('e_form');
$text = "";
$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))
{
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 .= $frm->checkbox("e-mymenus[]", $row['menu_name'], $checked);
$text .= $row['menu_name'];

View File

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

View File

@@ -9,8 +9,8 @@
* Simple XML Parser
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $
* $Revision: 1.21 $
* $Date: 2009-09-03 22:27:32 $
* $Revision: 1.22 $
* $Date: 2009-09-05 23:02:23 $
* $Author: e107coders $
*/
@@ -27,6 +27,7 @@ if (!defined('e107_INIT')) { exit; }
*/
class xmlClass
{
/**
* Loaded XML string
*
@@ -65,6 +66,19 @@ class xmlClass
*/
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
* Exmple:
@@ -121,6 +135,10 @@ class xmlClass
*/
protected $_optValueKey = '@value';
/**
* Constructor - set defaults
*
@@ -526,9 +544,26 @@ class xmlClass
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)
{
if($this->convertFilePaths)
{
$types = implode("|",$this->convertFileTypes);
$val = preg_replace_callback("#({e_.*?\.(".$types."))#i", array($this,'replaceFilePaths'), $val);
}
if(is_array($val))
{
return "<![CDATA[".e107::getArrayStorage()->WriteArray($val,FALSE)."]]>";
@@ -605,16 +640,32 @@ class xmlClass
if($debug==TRUE)
{
echo "<pre>".htmlentities($text)."</pre>";
return TRUE;
}
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-disposition: attachment; filename= e107Export_" . date("Y-m-d").".xml");
header("Cache-Control: max-age=30");
header("Pragma: public");
echo $text;
exit;
}
}
/**