Skip to content

Commit

Permalink
Fix for including the logo in the export and scorm packages and inser…
Browse files Browse the repository at this point in the history
…ting the <img> tag - issue #1120
  • Loading branch information
JohnSmith-LT committed Jun 28, 2022
1 parent 7b8fa61 commit cebe3c1
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
30 changes: 27 additions & 3 deletions modules/xerte/export.php
Expand Up @@ -403,6 +403,30 @@ function create_offline_file($varname, $sourcefile, $destfile)
export_folder_loop($xerte_toolkits_site->root_file_path . "mediaViewer/");
copy_extra_files();
}
/*
* export logo
*/
$LO_base_path = 'USER-FILES/' . $row['template_id'] . '-' . $row['username'] . '-' . $row['template_name'] . '/';
$LO_icon_path = $xml->getIcon()->url;
if (strpos($LO_icon_path, "FileLocation + '") !== false) {
$LO_icon_path = str_replace("FileLocation + '" , $LO_base_path, $LO_icon_path);
$LO_icon_path = rtrim($LO_icon_path, "'");
}
$theme_base_path = 'themes/' . $row['parent_template'] . '/' . $xml->getTheme();
$default_path = 'modules/' . $row['template_framework'] . "/parent_templates/" . $row['parent_template'] . '/';
$export_logo = get_logo_file($LO_icon_path, $theme_base_path, $default_path);
if ($export_logo) {
copy($export_logo, $dir_path . basename($export_logo));
array_push($delete_file_array, $dir_path . basename($export_logo));
$export_logo = $dir_path . basename($export_logo);
if (file_exists($dir_path . basename($export_logo) )) {
$export_logo = '<img class="x_icon" src="' . basename($export_logo) . '" alt="" />';
}
else {
$export_logo = '';
}
}

/*
* documentation
*/
Expand Down Expand Up @@ -443,15 +467,15 @@ function create_offline_file($varname, $sourcefile, $destfile)
if ($useflash) {
scorm_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $rlo_file, $lo_name, $xml->getLanguage());
} else {
scorm_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url);
scorm_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url, $export_logo);
}
} else if ($scorm == "2004") {
$useflash = ($export_flash && !$export_html5);
lmsmanifest_2004_create($row['zipname'], $useflash, $lo_name);
if ($export_flash && !$export_html5) {
scorm2004_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $rlo_file, $lo_name, $xml->getLanguage());
} else {
scorm2004_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url);
scorm2004_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'], $lo_name, $xml->getLanguage(), $row['date_modified'], $row['date_created'], $need_download_url, $export_logo);
}
} else if($xAPI)
{
Expand All @@ -462,7 +486,7 @@ function create_offline_file($varname, $sourcefile, $destfile)
basic_html_page_create($_GET['template_id'], $row['template_name'], $row['template_framework'], $rlo_file, $lo_name);
}
if ($export_html5) {
basic_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'],$lo_name, $row['date_modified'], $row['date_created'], $tsugi, $export_offline, $offline_includes, $need_download_url);
basic_html5_page_create($_GET['template_id'], $row['template_framework'], $row['parent_template'],$lo_name, $row['date_modified'], $row['date_created'], $tsugi, $export_offline, $offline_includes, $need_download_url, $export_logo);
}
}

Expand Down
30 changes: 29 additions & 1 deletion website_code/php/scorm/scorm2004_library.php
Expand Up @@ -34,6 +34,32 @@
}


function get_logo_file($LO_icon_path, $theme_path, $template_path) {
$extensions = ['svg', 'png', 'jpg', 'gif'];

// First the author logo
if (strlen(trim($LO_icon_path)) > 0) {
return trim($LO_icon_path);
}

// Secondly check the theme logo
//return $theme_path . '/logo.svg';
foreach($extensions as $ext) {
if (file_exists('../../../' . $theme_path . '/logo.' . $ext)) {
return '../../../' . $theme_path . '/logo.'. $ext;
}
}

// Lastly check the default location
foreach($extensions as $ext) {
if (file_exists('../../../' . $template_path . 'common_html5/logo.' . $ext)) {
return '../../../' . $template_path . 'common_html5/logo.' . $ext;
}
}

return;
}

function lmsmanifest_2004_create($name, $flash, $lo_name){

global $dir_path, $delete_file_array, $zipfile;
Expand Down Expand Up @@ -182,7 +208,7 @@ function scorm2004_html_page_create($id, $name, $type, $rlo_file, $lo_name, $lan

}

function scorm2004_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false){
function scorm2004_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false, $logo=''){

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile, $youtube_api_key;

Expand All @@ -193,8 +219,10 @@ function scorm2004_html5_page_create($id, $type, $parent_name, $lo_name, $langua

$scorm_html_page_content = str_replace("%LANGUAGE", $language_ISO639_1code, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%VERSION%", $version , $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TWITTERCARD%", "",$scorm_html_page_content);
$scorm_html_page_content = str_replace("%VERSION_PARAM%", "" , $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TITLE%",$lo_name,$scorm_html_page_content);
$scorm_html_page_content = str_replace("%LOGO%", $logo, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TEMPLATEID%", $id, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TEMPLATEPATH%","",$scorm_html_page_content);
$scorm_html_page_content = str_replace("%XMLPATH%","",$scorm_html_page_content);
Expand Down
9 changes: 6 additions & 3 deletions website_code/php/scorm/scorm_library.php
Expand Up @@ -208,7 +208,7 @@ function scorm_html_page_create($id, $name, $type, $rlo_file, $lo_name, $languag
* @version 1.0
* @author Patrick Lockley
*/
function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modified, $date_created, $tsugi=false, $offline=false, $offline_includes="", $need_download_url=false) {
function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modified, $date_created, $tsugi=false, $offline=false, $offline_includes="", $need_download_url=false, $logo='') {

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile;

Expand All @@ -218,11 +218,12 @@ function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modif

$buffer = file_get_contents($xerte_toolkits_site->basic_template_path . $type . "/player_html5/rloObject.htm");


$buffer = str_replace("%TWITTERCARD%", "",$buffer);
$buffer = str_replace("%VERSION%", $version, $buffer);
$buffer = str_replace("%LANGUAGE%", $language_ISO639_1code, $buffer);
$buffer = str_replace("%VERSION_PARAM%", "", $buffer);
$buffer = str_replace("%TITLE%", $lo_name, $buffer);
$buffer = str_replace("%LOGO%", $logo, $buffer);
$buffer = str_replace("%TEMPLATEPATH%", "", $buffer);
$buffer = str_replace("%TEMPLATEID%", $id, $buffer);
$buffer = str_replace("%XMLPATH%", "", $buffer);
Expand Down Expand Up @@ -266,6 +267,7 @@ function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modif
array_push($delete_file_array, $dir_path . $index);
}


/**
*
* Function scorm html page create
Expand All @@ -275,7 +277,7 @@ function basic_html5_page_create($id, $type, $parent_name, $lo_name, $date_modif
* @version 1.0
* @author Patrick Lockley
*/
function scorm_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false) {
function scorm_html5_page_create($id, $type, $parent_name, $lo_name, $language, $date_modified, $date_created, $need_download_url=false, $logo='') {

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile, $youtube_api_key;

Expand All @@ -288,6 +290,7 @@ function scorm_html5_page_create($id, $type, $parent_name, $lo_name, $language,
$scorm_html_page_content = str_replace("%LANGUAGE%", $language_ISO639_1code, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%VERSION_PARAM%", "", $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TITLE%", $lo_name, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%LOGO%", $logo, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TEMPLATEPATH%", "", $scorm_html_page_content);
$scorm_html_page_content = str_replace("%TEMPLATEID%", $id, $scorm_html_page_content);
$scorm_html_page_content = str_replace("%XMLPATH%", "", $scorm_html_page_content);
Expand Down
3 changes: 2 additions & 1 deletion website_code/php/xAPI/xAPI_library.php
Expand Up @@ -17,7 +17,7 @@ function CheckLearningLocker($lrs)
return $lrs;
}

function xAPI_html_page_create($id, $template_name, $type, $lo_name, $language, $date_modified) {
function xAPI_html_page_create($id, $template_name, $type, $lo_name, $language, $date_modified, $logo='') {

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile, $youtube_api_key;

Expand All @@ -30,6 +30,7 @@ function xAPI_html_page_create($id, $template_name, $type, $lo_name, $language,
$xapi_html_page_content = str_replace("%VERSION%", $version , $xapi_html_page_content);
$xapi_html_page_content = str_replace("%VERSION_PARAM%", "", $xapi_html_page_content);
$xapi_html_page_content = str_replace("%TITLE%",$lo_name,$xapi_html_page_content);
$xapi_html_page_content = str_replace("%LOGO%", $logo, $xapi_html_page_content);
$xapi_html_page_content = str_replace("%TEMPLATEPATH%","",$xapi_html_page_content);
$xapi_html_page_content = str_replace("%XMLPATH%","",$xapi_html_page_content);
$xapi_html_page_content = str_replace("%TEMPLATEID%", $id, $xapi_html_page_content);
Expand Down

0 comments on commit cebe3c1

Please sign in to comment.