From 60f178fdc7a7a05b0baeaba0e461897d232f815c Mon Sep 17 00:00:00 2001 From: Patrick Lockley Date: Tue, 24 Jul 2012 22:10:20 +0000 Subject: [PATCH] git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@407 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641 --- .../en-GB/website_code/php/import/import.inc | 2 ++ website_code/php/import/import.php | 29 ++++++++++++++++--- workspaceproperties.php | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/languages/en-GB/website_code/php/import/import.inc b/languages/en-GB/website_code/php/import/import.inc index f2aa549ed8..a5519d4bc7 100644 --- a/languages/en-GB/website_code/php/import/import.inc +++ b/languages/en-GB/website_code/php/import/import.inc @@ -27,6 +27,8 @@ define("IMPORT_ZIP_FAIL","You can only import Zip Files"); define("IMPORT_XERTE_ONLY","Only Xerte templates are currently imported"); + + define("IMPORT_ZIP_FOLDER_LEVEL","The files in your zip folder need to be in the main folder, not within another folder in the zip."); ?> \ No newline at end of file diff --git a/website_code/php/import/import.php b/website_code/php/import/import.php index a6c9b19b0c..ac8e229dbf 100644 --- a/website_code/php/import/import.php +++ b/website_code/php/import/import.php @@ -134,6 +134,7 @@ function make_new_template($type,$zip_path){ }else{ + receive_message($_SESSION['toolkits_logon_username'], "ADMIN", "CRITICAL", "Failed to create new template record for the database", $query_for_template_rights); @@ -185,6 +186,10 @@ function replace_existing_template($path_to_copy_from, $template_id){ array_splice($delete_folder_array,0); delete_loop($path_to_copy_from); + + echo "HELLO****"; + + die(); while($delete_folder = array_pop($delete_folder_array)){ @@ -362,7 +367,7 @@ function folder_loop($path){ if(@move_uploaded_file($_FILES['filenameuploaded']['tmp_name'], $new_file_name)){ - require_once dirname(__FILE__)."/dUnzip2.inc.php"; + require_once dirname(__FILE__) . "/dUnzip2.inc.php"; $zip = new dUnzip2($new_file_name); @@ -382,6 +387,12 @@ function folder_loop($path){ foreach($x as $y){ + if(count(explode("/",$y))==3){ + + die(IMPORT_ZIP_FOLDER_LEVEL . "****"); + + } + if(!(strpos($y,"media/")===false)){ $string = $zip->unzip($y, false, 0777); @@ -392,7 +403,7 @@ function folder_loop($path){ } - if(!(strpos($y,".rlt")===false)){ + if((strpos($y,".rlt")!==false)){ $string = $zip->unzip($y, false, 0777); @@ -422,6 +433,8 @@ function folder_loop($path){ * Look for an xml file linked to the RLO */ + echo $template_data_equivalent . "
"; + if($template_data_equivalent!=null){ foreach($zip->compressedList as $x){ @@ -436,7 +449,15 @@ function folder_loop($path){ array_push($file_data,$temp_array); - } + }else if($y==="preview.xml"){ + + $preview_xml = $zip->unzip($y, false, 0777); + + $temp_array = array("preview.xml",$preview_xml,null); + + array_push($file_data,$temp_array); + + } } @@ -622,7 +643,7 @@ function folder_loop($path){ unlink($xerte_toolkits_site->import_path . $this_dir . $rlt_name); - $preview_xml = file_get_contents($xerte_toolkits_site->import_path . $this_dir . "data.xml"); + $preview_xml = file_get_contents(str_replace("\\","/",$xerte_toolkits_site->import_path . $this_dir) . "preview.xml"); $fh = fopen($xerte_toolkits_site->import_path . $this_dir . "preview.xml", "w"); diff --git a/workspaceproperties.php b/workspaceproperties.php index cb5a0b6869..89d7022666 100644 --- a/workspaceproperties.php +++ b/workspaceproperties.php @@ -52,7 +52,7 @@ --> - +