Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Better fix for spaces in file names (media and quota, export)
- A similar problem also occurs when the filename has foreign characters
  like ñ, é, etc
- And of course the encoding is different for images/media placed in the
  editor, or placed through the media option in the wizard
- Solution is to decode the xml string (which results in invalid xml, but
  works for this purpose.
  • Loading branch information
torinfo committed Oct 18, 2015
1 parent c6e8a04 commit 64b0d0c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
19 changes: 14 additions & 5 deletions website_code/php/properties/media_and_quota_template.php
Expand Up @@ -49,14 +49,23 @@
* @author Patrick Lockley
*/

function in_use($file_name){
function in_use($file_name)
{

global $xmlpath, $previewpath;
$file_name2 = str_replace("&", "&", $file_name);
$file_name2 = str_replace(" ", "%20", $file_name);
if(!strpos(file_get_contents($xmlpath),$file_name)&&!strpos(file_get_contents($previewpath),$file_name)&&!strpos(file_get_contents($xmlpath),$file_name2)&&!strpos(file_get_contents($previewpath),$file_name2)){

$preview = file_get_contents($previewpath);
// Decode all filenames in preview
$preview2 = rawurldecode($preview);
$preview3 = html_entity_decode($preview2);
$data = file_get_contents($xmlpath);
// Decode all filenames in data
$data2 = rawurldecode($data);
$data3 = html_entity_decode($data2);
if (strpos($data3, $file_name) === false && strpos($preview3, $file_name) === false)
{
return false;
}else{
} else {
return true;
}

Expand Down
7 changes: 6 additions & 1 deletion website_code/php/scorm/scorm_library.php
Expand Up @@ -477,7 +477,12 @@ function xerte_zip_files($fullArchive = false, $dir_path) {
/* only add file if used */
$string = str_replace($dir_path, "", $file[0]);

if (strpos(file_get_contents($dir_path . "data.xml"), $string) !== false) {
$data = file_get_contents($dir_path . "data.xml");
// Decode all filenames in data
$data2 = rawurldecode($data);
$data3 = html_entity_decode($data2);

if (strpos($data3, $string) !== false) {
$zipfile->add_files($string);
}
} else {
Expand Down

0 comments on commit 64b0d0c

Please sign in to comment.