Skip to content

Commit

Permalink
Import of a template zip did not work due to typo on line 167 (causin…
Browse files Browse the repository at this point in the history
…g a php error)

Also create a wizards folder for new templates 

git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@420 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
torinfo committed Sep 2, 2012
1 parent fe4a909 commit 579088d
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions website_code/php/import/import_template.php
Expand Up @@ -97,6 +97,8 @@ function copy_loop($path){

_load_language_file("/website_code/php/import_template.inc");

_debug("Trying to import template " . $_FILES['filenameuploaded']['name']);

$this_dir = rand() . "/";

$end_dir = $this_dir;
Expand All @@ -107,6 +109,7 @@ function copy_loop($path){

$new_file_name = $xerte_toolkits_site->import_path . $_FILES['filenameuploaded']['name'];

_debug(" 1. Moving " . $_FILES['filenameuploaded']['tmp_name'] . " to " . new_file_name);
if(@move_uploaded_file($_FILES['filenameuploaded']['tmp_name'], $new_file_name)){

require_once dirname(__FILE__)."/dUnzip2.inc.php";
Expand All @@ -119,6 +122,8 @@ function copy_loop($path){

$zip->unzipAll($xerte_toolkits_site->import_path . $this_dir);

_debug(" 2. Unzip...");

}

$zip->close();
Expand All @@ -131,6 +136,7 @@ function copy_loop($path){
* We are replacing, so delete files
*/

_debug(" 3. Replacing...");
delete_loop($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $_POST['folder'] . "/");
delete_loop($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $_POST['folder'] . "/");

Expand All @@ -141,10 +147,12 @@ function copy_loop($path){
}

}else{
_debug(" 3. Installing in " . $xerte_toolkits_site->import_path . $this_dir . substr($_FILES['filenameuploaded']['name'],0,strlen($_FILES['filenameuploaded']['name'])-4));

$dir = opendir($xerte_toolkits_site->import_path . $this_dir . substr($_FILES['filenameuploaded']['name'],0,strlen($_FILES['filenameuploaded']['name'])-4));

if($dir===false){
_debug(" Failed....");

delete_loop($xerte_toolkits_site->import_path . $this_dir);

Expand All @@ -156,14 +164,15 @@ function copy_loop($path){

rmdir($xerte_toolkits_site->import_path . $this_dir);

echo IMPORT_TEMPLATE_ZIP_FAIL "****";
echo IMPORT_TEMPLATE_ZIP_FAIL . "****";

die();

}

$rlt_not_found = false;
$rlt_not_found = true;

_debug(" 4. Searching template.rlt");
while($filename = readdir($dir)){

/*
Expand Down Expand Up @@ -198,16 +207,18 @@ function copy_loop($path){

$desc = substr(substr($string, strpos($string, "description=")+13),0,strpos(substr($string, strpos($string, "description=")+13),"\""));

$rlt_not_found = true;
$rlt_not_found = false;
_debug(" 5. Installing to " . $folder . " with name " . $name);

}

}

}

if(!$rlt_not_found){
if($rlt_not_found){

_debug(" Failed....");
delete_loop($xerte_toolkits_site->import_path . $this_dir);

while($file_to_delete = array_pop($delete_file_array)){
Expand Down Expand Up @@ -242,13 +253,15 @@ function copy_loop($path){
@mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/common/");
@mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/thumbs/");
@mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/models/");
@mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/wizards/");
@mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/");
@mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/media/");

@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/",0777);
@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/common/",0777);
@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/thumbs/",0777);
@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/models/",0777);
@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/wizards/",0777);
@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/",0777);
@chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/media/",0777);

Expand Down Expand Up @@ -331,6 +344,22 @@ function copy_loop($path){

}

copy_loop($xerte_toolkits_site->import_path . $this_dir . "wizards");

while($file_to_copy = array_pop($copy_file_array)){

@rename($xerte_toolkits_site->import_path . $this_dir . "wizards/" . $file_to_copy, $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/wizards/" . $file_to_copy);

}

delete_loop($xerte_toolkits_site->import_path . $this_dir . "wizards");

while($file_to_delete = array_pop($delete_file_array)){

@unlink($file_to_delete);

}

rename($xerte_toolkits_site->import_path . $this_dir . "template.rlt", $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/" . $folder . ".rlt");

rename($xerte_toolkits_site->import_path . $this_dir . "template.xml", $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/data.xml");
Expand All @@ -349,6 +378,7 @@ function copy_loop($path){
rmdir($xerte_toolkits_site->import_path . $this_dir . "media");
rmdir($xerte_toolkits_site->import_path . $this_dir . "thumbs");
rmdir($xerte_toolkits_site->import_path . $this_dir . "models");
rmdir($xerte_toolkits_site->import_path . $this_dir . "wizards");

if($_POST['folder']==""){

Expand Down

0 comments on commit 579088d

Please sign in to comment.