Skip to content

Commit

Permalink
Add Nottingham models plugin structure
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed Aug 15, 2022
1 parent 8e0c406 commit adcd23f
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 7 deletions.
2 changes: 2 additions & 0 deletions modules/xerte/edithtml.php
Expand Up @@ -98,6 +98,8 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
$xwd_file_url = $xwd_url . "data.xwd";
}
}
$xwd_file_url = $xwd_url . "wizards/getXwd.php";

$module_url = "modules/" . $row_edit['template_framework'] . "/";

$jqgridlangfile = "editor/js/vendor/jqgrid/js/i18n/grid.locale-en.js";
Expand Down
Expand Up @@ -2610,6 +2610,10 @@ function x_changePageStep6() {
builtPage.hide();
builtPage.fadeIn();

// get short page type var
var pt = x_pageInfo[x_currentPage].type;
if (pt == "text") pt = 'simpleText'; // errors if you just call text.pageChanged()

if (!x_isMenu() && x_currentPageXML.getAttribute("script") != undefined && x_currentPageXML.getAttribute("script") != "" && x_currentPageXML.getAttribute("run") == "all") {
$("#x_pageScript").remove();
$("#x_page" + x_currentPage).append('<script id="x_pageScript">' + x_currentPageXML.getAttribute("script") + '</script>');
Expand All @@ -2636,10 +2640,6 @@ function x_changePageStep6() {

x_setUpPage();

// get short page type var
var pt = x_pageInfo[x_currentPage].type;
if (pt == "text") pt = 'simpleText'; // errors if you just call text.pageChanged()

// calls function in current page model (if it exists) which does anything needed to reset the page (if it needs to be reset)
if (typeof window[pt].pageChanged === "function") window[pt].pageChanged();

Expand Down Expand Up @@ -3019,13 +3019,24 @@ function x_pageLoaded() {

if (!x_isMenu()) {
x_setUpLightBox();


// plugin files are loaded after page is loaded
if (plugins[pt] != undefined) {
if (plugins[pt].script != undefined && plugins[pt].script != "" && $("#x_pagePluginScript").length == 0) {
$("#x_page" + x_currentPage).append('<script id="x_pagePluginScript">' + plugins[pt].script + '</script>');
// calls function in current page model (if it exists) which does anything needed to reset the page (if it needs to be reset)
if (typeof window[pt].initPlugin === "function") window[pt].initPlugin();
}
if (plugins[pt].css != undefined && plugins[pt].css != "" && $("#x_pagePluginCSS").length == 0) {
$("#x_page" + x_currentPage).append('<style type="text/css" id="x_pagePluginCSS">' + plugins[pt].css + '</style>');
}
}
// script & style optional properties for each page added after page is otherwise set up
if (x_currentPageXML.getAttribute("script") != undefined && x_currentPageXML.getAttribute("script") != "") {
$("#x_page" + x_currentPage).append('<script id="x_pageScript">' + x_currentPageXML.getAttribute("script") + '</script>');
}
if (x_currentPageXML.getAttribute("styles") != undefined && x_currentPageXML.getAttribute("styles") != "") {
$("#x_page" + x_currentPage).append('<style type="text/css">' + x_currentPageXML.getAttribute("styles") + '</style>');
if (x_currentPageXML.getAttribute("styles") != undefined && x_currentPageXML.getAttribute("styles") != "" && $("#x_pageCSS").length == 0) {
$("#x_page" + x_currentPage).append('<style type="text/css" id="x_pageCSS">' + x_currentPageXML.getAttribute("styles") + '</style>');
}
}

Expand Down
76 changes: 76 additions & 0 deletions modules/xerte/parent_templates/Nottingham/wizards/getXwd.php
@@ -0,0 +1,76 @@
<?php
/**
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
* The Apereo Foundation licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

require_once ("../../../../../config.php");

// Get the parent folder of the given path
function getParentPath($path)
{

}

$xwd_path = dirname(__DIR__) .'/';

if (file_exists($xwd_path . "wizards/" . $_SESSION['toolkits_language'] . "/data.xwd" ))
{
$xwd_file_path = $xwd_path . "wizards/" . $_SESSION['toolkits_language'] . "/data.xwd";
}
else if (file_exists($xwd_path . "wizards/en-GB/data.xwd" ))
{
$xwd_file_path = $xwd_path . "wizards/en-GB/data.xwd";
}
else if (file_exists($xwd_path . "data.xwd"))
{
$xwd_file_path = $xwd_path . "data.xwd";
}

// Check if there are any custom files and merge those in.
$plugin_path = "";
if (file_exists($xwd_path . "wizards/plugins/" . $_SESSION['toolkits_language']))
{
$plugin_path = $xwd_path . "wizards/plugins/" . $_SESSION['toolkits_language'];
}
else if (file_exists($xwd_path . "wizards/plugins/en-Gb"))
{
$plugin_path = $xwd_path . "wizards/plugins/en-GB";
}

if ($custom_path != "")
{
require_once ("../../../../../website_code/php/mergexml.php");
$merged = new MergeXML();
$merged->addFile($xwd_file_path);
$plugin_files = scandir($custom_path);
foreach ($plugin_files as $plugin_file)
{
if (substr($plugin_file, -4) == ".xwd")
{
// Merge the custom file into the main file.
$merged->addFile($plugin_path . "/" . $plugin_file);
}
}
echo $merged->get(1);

}
else
{
echo file_get_contents($xwd_file_path);
}

22 changes: 22 additions & 0 deletions modules/xerte/play.php
Expand Up @@ -120,6 +120,27 @@ function show_template_page($row, $datafile="", $xapi_enabled = false)
}
}
}

// Get plugins
$pluginfiles = scandir($template_path . "plugins/");
$plugins = array();
foreach($pluginfiles as $pluginfile) {
// get base name of plugin
$plugininfo = pathinfo($pluginfile);
if ($plugininfo['basename'] == '.' || $plugininfo['basename'] == '..') {
continue;
}
if (!isset($plugins[$plugininfo['filename']]))
{
$plugins[$plugininfo['filename']] = new stdClass();
}
if ($plugininfo['extension'] == 'js') {
$plugins[$plugininfo['filename']]->script = file_get_contents($template_path . "plugins/" . $pluginfile);
}
if ($plugininfo['extension'] == 'css') {
$plugins[$plugininfo['filename']]->css = file_get_contents($template_path . "plugins/" . $pluginfile);
}
}
$rlo_object_file = "rloObject.htm";
if ($engine == 'flash')
{
Expand Down Expand Up @@ -240,6 +261,7 @@ function show_template_page($row, $datafile="", $xapi_enabled = false)
$page_content = str_replace("%XMLFILE%", $string_for_flash_xml, $page_content);
$page_content = str_replace("%THEMEPATH%", "themes/" . $row['parent_template'] . "/",$page_content);
$page_content = str_replace("%USE_URL%", "", $page_content);
$page_content = str_replace("%PLUGINS%", 'var plugins=' . json_encode($plugins), $page_content);

//twittercard
$xml = new XerteXMLInspector();
Expand Down
1 change: 1 addition & 0 deletions modules/xerte/player_html5/rloObject.htm
Expand Up @@ -147,6 +147,7 @@ <h2 aria-live="assertive"> </h2>
dateCreated: x_dateCreatedLocale,
numViews: x_numPlays
};
%PLUGINS%;
%EMBED_SUPPORT%
</script>
</body>
Expand Down

0 comments on commit adcd23f

Please sign in to comment.