Skip to content

Commit

Permalink
MDL-9138; Edited lib/xmlize.php to return false when the passed file …
Browse files Browse the repository at this point in the history
…doesn't return any entries (when it's not valid XML or is empty). Also made it much clearer that glossary/import requires an XML file, not just any old file.
  • Loading branch information
nicolasconnault committed Apr 4, 2007
1 parent 1cad7ef commit 86b3314
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lang/en_utf8/glossary.php
Expand Up @@ -92,6 +92,7 @@
$string['entrysaved'] = 'This entry has been saved';
$string['entryupdated'] = 'This entry has been updated';
$string['entryusedynalink'] = 'This entry should be automatically linked';
$string['errorparsingxml'] = 'Errors occurred while parsing the file. Make sure it is valid XML syntax.';
$string['explainaddentry'] = 'Add a new entry to the current glossary.<br />Concept and definition are mandatory fields.';
$string['explainall'] = 'Shows ALL entries on one page';
$string['explainalphabet'] = 'Browse the glossary using this index';
Expand Down Expand Up @@ -125,6 +126,7 @@
$string['importedcategories'] = 'Imported categories';
$string['importedentries'] = 'Imported entries';
$string['importentries'] = 'Import entries';
$string['importentriesfromxml'] = 'Import entries from XML file';
$string['isglobal'] = 'Is this glossary global?';
$string['linkcategory'] = 'Automatically link this category';
$string['linking'] = 'Auto-linking';
Expand Down
7 changes: 6 additions & 1 deletion lib/xmlize.php
Expand Up @@ -54,6 +54,11 @@ function xmlize($data, $WHITE=1, $encoding='UTF-8') {
xml_parser_free($parser);

$i = 0;

if (empty($vals)) {
// XML file is invalid or empty, return false
return false;
}

$tagname = $vals[$i]['tag'];
if ( isset ($vals[$i]['attributes'] ) )
Expand Down Expand Up @@ -186,4 +191,4 @@ function traverse_xmlize($array, $arrName = 'array', $level = 0) {

}

?>
?>
4 changes: 2 additions & 2 deletions mod/glossary/import.php
Expand Up @@ -43,7 +43,7 @@
$strsearchconcept = get_string("searchconcept", "glossary");
$strsearchindefinition = get_string("searchindefinition", "glossary");
$strsearch = get_string("search");
$strimportentries = get_string('importentries', 'glossary');
$strimportentries = get_string('importentriesfromxml', 'glossary');

print_header_simple(format_string($glossary->name), "",
"<a href=\"index.php?id=$course->id\">$strglossaries</a> -> " .
Expand Down Expand Up @@ -363,7 +363,7 @@
}
print_box_end();
} else {
notify("Error while trying to read the file.");
notice(get_string('errorparsingxml', 'glossary'));
}

/// Finish the page
Expand Down

0 comments on commit 86b3314

Please sign in to comment.