]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9138; Edited lib/xmlize.php to return false when the passed file doesn't return...
authornicolasconnault <nicolasconnault>
Wed, 4 Apr 2007 03:35:23 +0000 (03:35 +0000)
committernicolasconnault <nicolasconnault>
Wed, 4 Apr 2007 03:35:23 +0000 (03:35 +0000)
lang/en_utf8/glossary.php
lib/xmlize.php
mod/glossary/import.php

index bc7f66cfd70d35637f9b7ae04102e23b9a32d1fa..4fba94447ce815332db4d76dc09a37b35a9d5dfb 100644 (file)
@@ -92,6 +92,7 @@ $string['entryleveldefaultsettings'] = 'Entry Level Default Settings';
 $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';
@@ -125,6 +126,7 @@ $string['importcategories'] = 'Import categories';
 $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';
index 8493d2c1db7aedc73d13582bfbc24cefab2ae3f8..34f29dfcf1cf67f87fa04b09c00495fbed850cde 100644 (file)
@@ -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'] ) )
@@ -186,4 +191,4 @@ function traverse_xmlize($array, $arrName = 'array', $level = 0) {
 
 }
 
-?>
\ No newline at end of file
+?>
index 281be0a0d1b7d6618643765a8e7edd876d024727..0a83eef4d2a515051684eb183898942ab24151b5 100644 (file)
@@ -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> -> " .
         }
         print_box_end();
     } else {
-        notify("Error while trying to read the file.");
+        notice(get_string('errorparsingxml', 'glossary'));
     }
 
 /// Finish the page