Skip to content

Commit

Permalink
Changes in export
Browse files Browse the repository at this point in the history
git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@347 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
torinfo committed May 10, 2012
1 parent 2c24274 commit 0274708
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 171 deletions.
20 changes: 9 additions & 11 deletions languages/en-GB/website_code/php/properties/export_template.inc
Expand Up @@ -12,27 +12,25 @@

define("EXPORT_TITLE","Export");

define("EXPORT_DESCRIPTION","There are four ways to export a project");
define("EXPORT_DESCRIPTION","There are several ways to export a project. An exported project is packaged, but not deleted, into a zip file for you to share with another user, to deploy on the web, or to import into a SCORM compliant LMS or VLE. You can choose whether to export all of the project's files, or just those files used by the project.</p><p>Export:");

define("EXPORT_ZIP","A zip file export will package (but not delete) your project into one zip file. If you then open this file, the contents can be used to deploy your project on any webpage.</p><p>Click on zip export to get your file - ");
define("EXPORT_ZIP_FULL_LINK","Archive Zip with all files from the project.");

define("EXPORT_ZIP_LINK","Zip export");
define("EXPORT_ZIP_LINK","Deployment Zip with just the necessary files used in the project.");

define("EXPORT_ZIP_LOCAL","As above, but with references to web based files altered - ");

define("EXPORT_ZIP_LOCAL_LINK","Zip (local) export");
define("EXPORT_ZIP_LOCAL_LINK","Deployment zip as 2. above, but with references to web based files altered.");

/*
define("EXPORT_SCORM","A SCORM 1.2 file export will package (but not delete) your project into one zip file. This zip file can then be imported by most VLEs to become part of an online course. This file will be SCORM 1.2 compliant.</p><p>Click on SCORM 1.2 export to get this package - ");
define("EXPORT_SCORM_LINK","SCORM 1.2 export");
*/

define("EXPORT_SCORM_METADATA","As above, but with richer SCORM metadata - ");

define("EXPORT_SCORM_METADATA_LINK","SCORM + metadata export");
define("SCORM_DESCRIPTION", "If you want to export a SCORM package, you can choose to export SCORM 1.2 or SCORM 2004 packages. If you don’t know which version of SCORM you need, the SCORM 1.2 package will work in most LMS and VLE systems.</p><p>Export:");

define("EXPORT_SCORM_2004","A SCORM 2004 3rd Ed file export will package (but not delete) your project into one zip file. This zip file can then be imported by most VLEs to become part of an online course. This file will be SCORM 2004 3rd Edition compliant.</p><p>Click on SCORM 2004 3rd Ed export to get this package - ");
define("EXPORT_SCORM_METADATA_LINK","SCORM 1.2 package");

define("EXPORT_SCORM_2004_LINK","SCORM 2004 3rd Ed export");
define("EXPORT_SCORM_2004_LINK","SCORM 2004 3rd Ed package");

define("EXPORT_FAIL","Sorry you do not have rights to this template");

Expand Down
2 changes: 2 additions & 0 deletions setup/htaccess.conf
Expand Up @@ -29,6 +29,8 @@ rewriteRule ^peerreview_([A-Za-z0-9]+)$ */peer.php?template_id=$1

rewriteRule ^export_([0-9]+)$ */website_code/php/scorm/export.php?template_id=$1&scorm=false

rewriteRule ^export_full_([0-9]+)$ */website_code/php/scorm/export.php?full=true&template_id=$1&scorm=false

rewriteRule ^export_local_([0-9]+)$ */website_code/php/scorm/export.php?template_id=$1&local=true&scorm=false

rewriteRule ^scorm2004_([0-9]+)$ */website_code/php/scorm/export.php?template_id=$1&scorm=2004
Expand Down
20 changes: 10 additions & 10 deletions website_code/php/properties/export_template.php
Expand Up @@ -32,16 +32,16 @@
echo "<p class=\"header\"><span>" . EXPORT_TITLE . "</span></p>";

echo "<p>" . EXPORT_DESCRIPTION . "</p>";

echo "<p>" . EXPORT_ZIP . "<a href='" . $xerte_toolkits_site->site_url . url_return("export" , $_POST['template_id']) . "'>" . EXPORT_ZIP_LINK . "</a></p>";

echo "<p>" . EXPORT_ZIP_LOCAL . "<a href='" . $xerte_toolkits_site->site_url . url_return("export_local" , $_POST['template_id']) . "'>" . EXPORT_ZIP_LOCAL_LINK . "</a></p>";

echo "<p>" . EXPORT_SCORM . "<a href='" . $xerte_toolkits_site->site_url . url_return("scorm" , $_POST['template_id']) . "'>" . EXPORT_SCORM_LINK . "</a></p>";

echo "<p>" . EXPORT_SCORM_METADATA . "<a href='" . $xerte_toolkits_site->site_url . url_return("scorm_rich" , $_POST['template_id']) . "'>" . EXPORT_SCORM_METADATA_LINK . "</a></p>";

echo "<p>" . EXPORT_SCORM_2004 . "<a href='" . $xerte_toolkits_site->site_url . url_return("scorm2004" , $_POST['template_id']) . "'>" . EXPORT_SCORM_2004_LINK . "</a></p>";
echo "<ol type='1' start='1'>";
echo "<li>" . "<a href='" . $xerte_toolkits_site->site_url . url_return("export_full" , $_POST['template_id']) . "'>" . EXPORT_ZIP_FULL_LINK . "</a></li>";
echo "<li>" . "<a href='" . $xerte_toolkits_site->site_url . url_return("export" , $_POST['template_id']) . "'>" . EXPORT_ZIP_LINK . "</a></li>";
echo "<li>" . "<a href='" . $xerte_toolkits_site->site_url . url_return("export_local" , $_POST['template_id']) . "'>" . EXPORT_ZIP_LOCAL_LINK . "</a></li>";
echo "</ol>";
echo "<p>" . SCORM_DESCRIPTION . "</p>";
echo "<ol type='1' start='4'>";
echo "<li>" . "<a href='" . $xerte_toolkits_site->site_url . url_return("scorm_rich" , $_POST['template_id']) . "'>" . EXPORT_SCORM_METADATA_LINK . "</a></li>";
echo "<li>" . "<a href='" . $xerte_toolkits_site->site_url . url_return("scorm2004" , $_POST['template_id']) . "'>" . EXPORT_SCORM_2004_LINK . "</a></li>";
echo "</ol>";

}else{

Expand Down
84 changes: 58 additions & 26 deletions website_code/php/scorm/export.php
Expand Up @@ -24,6 +24,7 @@
$file_array = array();
$delete_file_array = array();
$delete_folder_array = array();
$fullArchive = false;

ini_set('max_execution_time', 300);

Expand All @@ -39,6 +40,13 @@
}

if($proceed){
if (isset($_GET['full'])){
if($_GET['full']=="true"){
$fullArchive = true;
}

}
_debug("Full archive: " . $fullArchive);
$mysql_id=database_connect("Scorm export database connect success","Scorm export database connect failed");

/*
Expand Down Expand Up @@ -66,8 +74,25 @@
/*
* Copy the core files over from the parent folder
*/
folder_loop($parent_template_path);
copy($dir_path . "data.xml",$dir_path . "template.xml");
$xml = new XerteXMLInspector();
$xml->loadTemplateXML($dir_path . 'template.xml');
if ($fullArchive){
_debug("Full archive");
folder_loop($parent_template_path);
}
else /* Only copy used models and the common folder */
{
_debug("Deployment archive");
$models = $xml->getUsedModels();
foreach($models as $model)
{
_debug("copy model " . $parent_template_path . "models/" . $model . ".rlm");
array_push($file_array, $parent_template_path . "models/" . $model . ".rlm");
}
array_push($file_array, $parent_template_path . $row['template_name'] . ".rlt");
folder_loop($parent_template_path . "common/");
}
if(isset($_GET['local'])){
if($_GET['local']=="true"){
$string = file_get_contents($dir_path . "/template.xml");
Expand All @@ -83,7 +108,7 @@
* Language support
*/

folder_loop($xerte_toolkits_site->root_file_path . 'languages', false, '.xml');
folder_loop($xerte_toolkits_site->root_file_path . 'languages/', false, '.xml');
copy_extra_files();

/*
Expand All @@ -104,7 +129,7 @@
array_push($delete_file_array, $dir_path . "XMLEngine.swf");

/*
* If scorm copy the scorn files as well
* If scorm copy the scorm files as well
*/
$scorm=mysql_real_escape_string($_GET['scorm']);
if($scorm=="true"){
Expand All @@ -124,10 +149,38 @@
unlink($dir_path . $row['template_name'] . ".rlt");
array_push($delete_file_array, $dir_path . "learningobject.rlt");
}
/*
* if used copy extra folders
*/
/*
* jmol
*/
if ($xml->modelUsed("jmol"))
{
folder_loop($xerte_toolkits_site->root_file_path . "JMolViewer/");
copy_extra_files();
}
/*
* mapstraction
*/
if ($xml->modelUsed("mapstraction"))
{
folder_loop($xerte_toolkits_site->root_file_path . "mapstraction/");
copy_extra_files();
}
/*
* mediaViewer
*/
if ($xml->mediaIsUsed())
{
folder_loop($xerte_toolkits_site->root_file_path . "mediaViewer/");
copy_extra_files();
}

folder_loop($dir_path);

/*
* Create scorm manifests of a basic HTML page
* Create scorm manifests or a basic HTML page
*/

if($scorm=="true"){
Expand Down Expand Up @@ -159,32 +212,11 @@
basic_html_page_create($row['template_name'],$row['template_framework']);
}

/*
* if used copy extra folders
*/
$xml = new XerteXMLInspector();
$xml->loadTemplateXML($dir_path . 'template.xml');
/*
* jmol
*/
if ($xml->modelUsed("jmol"))
{
folder_loop($xerte_toolkits_site->root_file_path . "JMolViewer");
copy_extra_files();
}
/*
* mapstraction
*/
if ($xml->modelUsed("mapstraction"))
{
folder_loop($xerte_toolkits_site->root_file_path . "mapstraction");
copy_extra_files();
}

/*
* Add the files to the zip file, create the archive, then send it to the user
*/
xerte_zip_files();
xerte_zip_files($fullArchive);
$zipfile->create_archive();
$zipfile->download_file($row['zipname']);

Expand Down
9 changes: 6 additions & 3 deletions website_code/php/scorm/scorm_library.php
Expand Up @@ -316,23 +316,26 @@ function copy_scorm_files(){
* @author Patrick Lockley
*/

function xerte_zip_files(){
function xerte_zip_files($fullArchive=false){
global $file_array, $zipfile, $dir_path;
_debug("Zipping up: " . $fullArchive);
while($file = array_pop($file_array)){
if(($file!="data.xwd")||($file!="data.xml")){
if(($file!="data.xwd")||($file!="data.xml")||$file!="preview.xml"){
/* Check if this is a media file */
if (strpos($file, "/media/") !== false)
if (!$fullArchive && strpos($file, "/media/") !== false)
{
/* only add file if used */
$string = str_replace($dir_path, "", $file);
if (strpos(file_get_contents($dir_path . "template.xml"), $string) !== false)
{
_debug(" add " . $string);
$zipfile->add_files($string);
}
}
else
{
$string = str_replace($dir_path, "", $file);
_debug(" add " . $string);
$zipfile->add_files($string);
}
}
Expand Down

0 comments on commit 0274708

Please sign in to comment.