function show_preview_code($row)
{
    global $xerte_toolkits_site;
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
    $xmlfile = $string_for_flash . "preview.xml";
    $xmlFixer = new XerteXMLInspector();
    $xmlFixer->loadTemplateXML($xmlfile);
    if (strlen($xmlFixer->getName()) > 0) {
        $title = $xmlFixer->getName();
    } else {
        $title = XERTE_PREVIEW_TITLE;
    }
    $string_for_flash_xml = $xmlfile . "?time=" . time();
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
    $template_path_string = "modules/decision/parent_templates/" . $row['template_name'] . "/";
    require_once "config.php";
    _load_language_file("/modules/decision/preview.inc");
    // $engine is assumed to be html5 if flash is NOT set
    $page_content = file_get_contents($xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/player_html5/rloObject.htm");
    $page_content = str_replace("%TITLE%", $title, $page_content);
    $page_content = str_replace("%TEMPLATEPATH%", $template_path_string, $page_content);
    $page_content = str_replace("%XMLPATH%", $string_for_flash, $page_content);
    $page_content = str_replace("%XMLFILE%", $string_for_flash_xml, $page_content);
    echo $page_content;
}
function show_preview_code2($row, $row_username)
{
    global $xerte_toolkits_site, $youtube_api_key;
    _load_language_file("/modules/xerte/preview.inc");
    $template_dir = $xerte_toolkits_site->users_file_area_full . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
    /*
     * Format the XML strings to provide data to the engine
     */
    if (!file_exists($template_dir . '/preview.xml')) {
        $buffer = file_get_contents($template_dir . "/data.xml");
        $fp = fopen($template_dir . "/preview.xml", "x");
        fwrite($fp, $buffer);
        fclose($fp);
    }
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row_username['username'] . "-" . $row['template_name'] . "/";
    $xmlfile = $string_for_flash . "preview.xml";
    $xmlFixer = new XerteXMLInspector();
    $xmlFixer->loadTemplateXML($xmlfile);
    if (strlen($xmlFixer->getName()) > 0) {
        $title = $xmlFixer->getName();
    } else {
        $title = XERTE_PREVIEW_TITLE;
    }
    $string_for_flash_xml = $xmlfile . "?time=" . time();
    $flash_js_dir = "modules/" . $row['template_framework'] . "/";
    $template_path = "modules/" . $row['template_framework'] . "/parent_templates/" . $row['template_name'] . "/";
    $rlo_file = $template_path . $row['template_name'] . ".rlt";
    list($x, $y) = explode("~", get_template_screen_size($row['template_name'], $row['template_framework']));
    // determine the correct engine to use
    $engine = 'flash';
    $extra_flags = explode(";", $row['extra_flags']);
    foreach ($extra_flags as $flag) {
        $parameter = explode("=", $flag);
        switch ($parameter[0]) {
            case 'engine':
                $engine = $parameter[1];
                break;
        }
    }
    // If given as a parameter, force this engine
    // If given as a parameter, force this engine
    if (isset($_REQUEST['engine'])) {
        if ($_REQUEST['engine'] == 'other') {
            if ($engine == 'flash') {
                $engine = 'javascript';
            } else {
                $engine = 'flash';
            }
        } else {
            $engine = $_REQUEST['engine'];
        }
    }
    if ($engine == 'flash') {
        $page_content = file_get_contents($xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/player/rloObject.htm");
        $page_content = str_replace("%WIDTH%", $x, $page_content);
        $page_content = str_replace("%HEIGHT%", $y, $page_content);
        $page_content = str_replace("%TITLE%", $title, $page_content);
        $page_content = str_replace("%RLOFILE%", $rlo_file, $page_content);
        $page_content = str_replace("%JSDIR%", $flash_js_dir, $page_content);
        $page_content = str_replace("%XMLPATH%", $string_for_flash, $page_content);
        $page_content = str_replace("%XMLFILE%", $string_for_flash_xml, $page_content);
        $page_content = str_replace("%SITE%", $xerte_toolkits_site->site_url, $page_content);
        $tracking = "<script type=\"text/javascript\" src=\"" . $flash_js_dir . "js/xttracking_noop.js\"></script>";
        $page_content = str_replace("%TRACKING_SUPPORT%", $tracking, $page_content);
    } else {
        // $engine is assumed to be html5 if flash is NOT set
        $page_content = file_get_contents($xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/player_html5/rloObject.htm");
        $page_content = str_replace("%TITLE%", $title, $page_content);
        $page_content = str_replace("%TEMPLATEPATH%", $template_path, $page_content);
        $page_content = str_replace("%XMLPATH%", $string_for_flash, $page_content);
        $page_content = str_replace("%XMLFILE%", $string_for_flash_xml, $page_content);
        $page_content = str_replace("%THEMEPATH%", $xerte_toolkits_site->site_url . "themes/" . $row['template_name'] . "/", $page_content);
        // Handle offline variables
        $page_content = str_replace("%OFFLINESCRIPTS%", "", $page_content);
        $page_content = str_replace("%OFFLINEINCLUDES%", "", $page_content);
        $page_content = str_replace("%MATHJAXPATH%", "//cdn.mathjax.org/mathjax/latest/", $page_content);
        $tracking = "<script type=\"text/javascript\" src=\"" . $template_path . "common_html5/js/xttracking_noop.js\"></script>";
        $page_content = str_replace("%TRACKING_SUPPORT%", $tracking, $page_content);
        $page_content = str_replace("%YOUTUBEAPIKEY%", $youtube_api_key, $page_content);
    }
    echo $page_content;
}
function show_preview_code($row)
{
    global $xerte_toolkits_site;
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
    $xmlfile = $string_for_flash . "preview.xml";
    $xmlFixer = new XerteXMLInspector();
    $xmlFixer->loadTemplateXML($xmlfile);
    $string_for_flash_xml = $xmlfile . "?time=" . time();
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
    $template_path_string = "modules/site/parent_templates/" . $row['template_name'];
    require_once "config.php";
    _load_language_file("/modules/site/preview.inc");
    ?>


	<!DOCTYPE html>
	<html xmlns:fb="http://ogp.me/ns/fb#">
		<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta charset="utf-8">
		<title><?php 
    echo SITE_PREVIEW_TITLE;
    ?>
</title>
		<link rel="icon" href="favicon.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">

		<!--jquery-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/jquery.js"></script>

		<!--styles -->
		<link href="<?php 
    echo $template_path_string;
    ?>
/common/css/bootstrap.css" rel="stylesheet">
		<link href="<?php 
    echo $template_path_string;
    ?>
/common/css/bootstrap-responsive.css" rel="stylesheet">

		<!--custom styles for this template-->
		<link href="<?php 
    echo $template_path_string;
    ?>
/common/css/custom.css" rel="stylesheet">

		<!--support for IE < 6-8 -->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/html5shiv.js"></script>

		<!--media element and initialisation-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/mediaelement/mediaelement-and-player.min.js"></script>
		<link rel="stylesheet" href="<?php 
    echo $template_path_string;
    ?>
/common/mediaelement/mediaelementplayer.min.css" />

		<script type="text/javascript">

			var FileLocation = "<?php 
    echo $string_for_flash;
    ?>
";
			var templateLocation = "<?php 
    echo $template_path_string;
    ?>
/";
			var projectXML = "<?php 
    echo $string_for_flash_xml;
    ?>
/"; //this is the file to read, not the xml

		</script>

		<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML-full"></script>

	</head>

	<body data-twttr-rendered="true" data-spy="scroll" data-target="#contentTable" onunload="window.opener.innerWidth +=2;window.opener.innerWidth -=2;">

		<!--facebookAPI-->
		<div id="fb-root"></div>
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/initFB.js" defer></script>

		<div class="navbar navbar-inverse navbar-fixed-top">
			<div class="navbar-inner">

				<div class="container">

					<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>

					<div class="nav-collapse collapse">
						<ul class="nav" id="nav">
							<!--<li class=""><a href="./index.html">Home</a></li>-->
						</ul>
					</div>
				</div>
			</div>
		</div>

		<!--Learning Object Title-->
		<header class="jumbotron" id="overview">
			<div class="container">
				<h1 id="pageTitle">Learning Object Title</h1>
				<p id="pageSubTitle" class="lead">Overview title for the content below</p>
			</div>
		</header>

		<!--main page content: nav bar and sections-->
		<div class="container">
			<div class="row-fluid">
				<!--navigation-->
				<div class="span3 bs-docs-sidebar" id="contentTable">

					<ul class="nav nav-list bs-docs-sidenav affix" id="toc">
						<!--<li><a href="#section1ID">Section 1</a></li>-->
					</ul>
				</div>

				<!--content-->
				<div class="span9" id="mainContent">

				</div>
			</div>
		</div>

		<footer class="footer">
			<div class="container">
				<div class="row-fluid">
					<div class="span12">

						<div class="addthis_toolbox addthis_default_style ">
							<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
							<a class="addthis_button_tweet"></a>
							<a class="addthis_button_google_plusone"></a>
							<a class="addthis_button_linkedin_counter"></a>
							<a class="addthis_button_pinterest_pinit"></a>
							<a class="addthis_counter addthis_pill_style"></a>
						</div>

						<!--<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>-->
						<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-50f40a8436e8c4c5" defer></script>

					</div>
				</div>
			</div>
		</footer>

		<!--bootstrap script-->

		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/bootstrap.min.js"></script>

		<!--initialise the application specific code-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/application.js"></script>

	<script type="text/javascript">


	<?php 
    echo "</script></body></html>";
}
if (isset($_REQUEST['flash'])) {
    $export_flash = $_REQUEST['flash'] == 'true' ? true : false;
}
if (!$export_html5 && !$export_flash) {
    $export_html5 = true;
}
/*
 * Make the zip
 */
$zipfile = new zip_file("example_zipper_new" . time() . ".zip");
$zipfile->set_options(array('basedir' => $dir_path, 'prepand' => "", 'inmemory' => 1, 'recurse' => 1, 'storepaths' => 1));
/*
 * Copy the core files over from the parent folder
 */
copy($dir_path . "data.xml", $dir_path . "template.xml");
$xml = new XerteXMLInspector();
$xml->loadTemplateXML($dir_path . 'template.xml');
if ($fullArchive) {
    _debug("Full archive");
    export_folder_loop($parent_template_path);
} else {
    _debug("Deployment archive");
    if ($export_flash) {
        _debug("  use flash");
        $models = $xml->getUsedModels();
        foreach ($models as $model) {
            _debug("copy model " . $parent_template_path . "models/" . $model . ".rlm");
            array_push($file_array, array($parent_template_path . "models/" . $model . ".rlm", ""));
        }
        /* Always add menu.rlm */
        _debug("copy model " . $parent_template_path . "models/menu.rlm");
function show_template($row_play)
{
    global $xerte_toolkits_site;
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row_play['template_id'] . "-" . $row_play['username'] . "-" . $row_play['template_name'] . "/";
    $xmlfile = $string_for_flash . "data.xml";
    $xmlFixer = new XerteXMLInspector();
    $xmlFixer->loadTemplateXML($xmlfile);
    $string_for_flash_xml = $xmlfile . "?time=" . time();
    $template_path_string = "modules/xerte/parent_templates/" . $row_play['template_name'];
    list($x, $y) = explode("~", get_template_screen_size($row_play['template_name'], $row_play['template_framework']));
    _load_language_file("/modules/xerte/preview.inc");
    ?>
	<!DOCTYPE html>
	<html xmlns:fb="http://ogp.me/ns/fb#">
		<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta charset="utf-8">
		<title><?php 
    echo XERTE_PREVIEW_TITLE;
    ?>
</title>
		<link rel="icon" href="favicon.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">

		<!--jquery-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/jquery.js"></script>

		<!--styles -->
		<link href="<?php 
    echo $template_path_string;
    ?>
/common/css/bootstrap.css" rel="stylesheet">
		<link href="<?php 
    echo $template_path_string;
    ?>
/common/css/bootstrap-responsive.css" rel="stylesheet">

		<!--custom styles for this template-->
		<link href="<?php 
    echo $template_path_string;
    ?>
/common/css/custom.css" rel="stylesheet">

		<!--support for IE < 6-8 -->
		<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

		<!--media element and initialisation-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/mediaelement/mediaelement-and-player.min.js"></script>
		<link rel="stylesheet" href="<?php 
    echo $template_path_string;
    ?>
/common/mediaelement/mediaelementplayer.min.css" />

		<script type="text/javascript">

			var FileLocation = "<?php 
    echo $string_for_flash;
    ?>
";
			var templateLocation = "<?php 
    echo $template_path_string;
    ?>
/";
			var projectXML = "<?php 
    echo $string_for_flash_xml;
    ?>
/"; //this is the file to read, not the xml

		</script>

	</head>

	<body data-twttr-rendered="true" data-spy="scroll" data-target=".bs-docs-sidebar">

		<!--facebookAPI-->
		<div id="fb-root"></div>
		<script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";		  fjs.parentNode.insertBefore(js, fjs);		}(document, 'script', 'facebook-jssdk'));</script>

		<div class="navbar navbar-inverse navbar-fixed-top">
			<div class="navbar-inner">

				<div class="container">

					<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>

					<div class="nav-collapse collapse">
						<ul class="nav"id="nav">
							<!--<li class=""><a href="./index.html">Home</a></li>-->
						</ul>
					</div>
				</div>
			</div>
		</div>

		<!--Learning Object Title-->
		<header class="jumbotron" id="overview">
			<div class="container">
				<h1 id="pageTitle">Learning Object Title</h1>
				<p id="pageSubTitle" class="lead">Overview title for the content below</p>
			</div>
		</header>

		<!--main page content: nav bar and sections-->
		<div class="container">
			<div class="row-fluid">
				<!--navigation-->
				<div class="span3 bs-docs-sidebar">
					<ul class="nav nav-list bs-docs-sidenav affix" id="toc">
						<!--<li><a href="#section1ID">Section 1</a></li>-->
					</ul>
				</div>

				<!--content-->
				<div class="span9" id="mainContent">

				</div>
			</div>
		</div>

		<footer class="footer">
			<div class="container">
				<div class="row-fluid">
					<div class="span12">

						<div class="addthis_toolbox addthis_default_style ">
							<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
							<a class="addthis_button_tweet"></a>
							<a class="addthis_button_google_plusone"></a>
							<a class="addthis_button_linkedin_counter"></a>
							<a class="addthis_button_pinterest_pinit"></a>
							<a class="addthis_counter addthis_pill_style"></a>
						</div>

						<!--<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>-->
						<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-50f40a8436e8c4c5"></script>

						<img src="<?php 
    echo $template_path_string;
    ?>
/common/footer/cc-by-nc-sa.png">
						<strong><small>© 2013 The Univeristy of Nottingham</small></strong>

					</div>
				</div>
			</div>
		</footer>

		<!--bootstrap script-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/bootstrap.min.js"></script>

		<!--initialise the application specific code-->
		<script src="<?php 
    echo $template_path_string;
    ?>
/common/js/application.js"></script>

	<script type="text/javascript" language="JavaScript">


	<?php 
    "</script></body></html>";
}
Exemple #6
0
function show_template_page($row, $datafile = "")
{
    global $xerte_toolkits_site;
    _load_language_file("/modules/xerte/preview.inc");
    $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
    if (strlen($datafile) > 0) {
        $xmlfile = $string_for_flash . $datafile;
    } else {
        $xmlfile = $string_for_flash . "data.xml";
    }
    $xmlFixer = new XerteXMLInspector();
    $xmlFixer->loadTemplateXML($xmlfile);
    if (strlen($xmlFixer->getName()) > 0) {
        $title = $xmlFixer->getName();
    } else {
        $title = XERTE_PREVIEW_TITLE;
    }
    $string_for_flash_xml = $xmlfile . "?time=" . time();
    $flash_js_dir = "modules/" . $row['template_framework'] . "/";
    $template_path = "modules/" . $row['template_framework'] . "/parent_templates/" . $row['template_name'] . "/";
    $rlo_file = $template_path . $row['template_name'] . ".rlt";
    list($x, $y) = explode("~", get_template_screen_size($row['template_name'], $row['template_framework']));
    // determine the correct engine to use
    $engine = 'flash';
    $extra_flags = explode(";", $row['extra_flags']);
    foreach ($extra_flags as $flag) {
        $parameter = explode("=", $flag);
        switch ($parameter[0]) {
            case 'engine':
                $engine = $parameter[1];
                break;
        }
    }
    // If given as a parameter, force this engine
    if (isset($_REQUEST['engine'])) {
        if ($_REQUEST['engine'] == 'other') {
            if ($engine == 'flash') {
                $engine = 'javascript';
            } else {
                $engine = 'flash';
            }
        } else {
            $engine = $_REQUEST['engine'];
        }
    }
    if ($engine == 'flash') {
        $page_content = file_get_contents($xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/player/rloObject.htm");
        $page_content = str_replace("%WIDTH%", $x, $page_content);
        $page_content = str_replace("%HEIGHT%", $y, $page_content);
        $page_content = str_replace("%TITLE%", $title, $page_content);
        $page_content = str_replace("%RLOFILE%", $rlo_file, $page_content);
        $page_content = str_replace("%JSDIR%", $flash_js_dir, $page_content);
        $page_content = str_replace("%XMLPATH%", $string_for_flash, $page_content);
        $page_content = str_replace("%XMLFILE%", $string_for_flash_xml, $page_content);
        $page_content = str_replace("%SITE%", $xerte_toolkits_site->site_url, $page_content);
        $tracking = "<script type=\"text/javascript\" src=\"" . $flash_js_dir . "js/xttracking_noop.js\"></script>";
        $page_content = str_replace("%TRACKING_SUPPORT%", $tracking, $page_content);
    } else {
        if ($engine == 'xml') {
            // Just return the raw xml
            $page_content = file_get_contents($xmlfile);
            // Replace "FileLocation + '" with $xerte_toolkits_site->site_url . $string_for_flash
            // NOTE: also get rid of the closing '
            return preg_replace("#FileLocation\\s*\\+\\s*'([^']+)'#", $xerte_toolkits_site->site_url . $string_for_flash . "\$1", $page_content);
        } else {
            // $engine is assumed to be javascript if flash is NOT set
            $page_content = file_get_contents($xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/player_html5/rloObject.htm");
            $page_content = str_replace("%TITLE%", $title, $page_content);
            $page_content = str_replace("%TEMPLATEPATH%", $template_path, $page_content);
            $page_content = str_replace("%XMLPATH%", $string_for_flash, $page_content);
            $page_content = str_replace("%XMLFILE%", $string_for_flash_xml, $page_content);
            $tracking = "<script type=\"text/javascript\" src=\"" . $template_path . "common_html5/js/xttracking_noop.js\"></script>";
            $page_content = str_replace("%TRACKING_SUPPORT%", $tracking, $page_content);
        }
    }
    return $page_content;
}
 */
$dir_path = $xerte_toolkits_site->users_file_area_full . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
$parent_template_path = $xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/parent_templates/" . $row['template_name'] . "/";
$js_path = $xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/js/";
/*
 * Make the zip
 */
$zipfile_tmpname = tempnam(sys_get_temp_dir(), 'xerteExport');
_debug("Temporary zip file is : {$zipfile_tmpname}");
$options = array('basedir' => $dir_path, 'prepand' => "", 'inmemory' => 0, 'overwrite' => 1, 'recurse' => 1, 'storepaths' => 1);
$zipfile = Xerte_Zip_Factory::factory($zipfile_tmpname, $options);
/*
 * Copy the core files over from the parent folder
 */
copy($dir_path . "data.xml", $dir_path . "template.xml");
$xml = new XerteXMLInspector();
$xml->loadTemplateXML($dir_path . 'template.xml');
if ($fullArchive) {
    _debug("Full archive");
} else {
    _debug("Deployment archive");
}
export_folder_loop($parent_template_path);
copy_parent_files();
export_folder_loop($dir_path);
/*
 * Get the name of the learning object
 */
$lo_name = $xml->getName();
/*
 * Create basic HTML page