--- restore_cc.php.original 2010-08-04 10:24:20.000000000 -0500
+++ restore_cc.php 2010-08-04 10:27:58.000000000 -0500
@@ -63,11 +63,15 @@
}
echo get_string('cc2moodle_checking_schema', 'imscc') . '
';
-
+
+ $libxml_error_state = libxml_use_internal_errors(true);
+
$cc_manifest = new DOMDocument();
if ($cc_manifest->load($manifest_file)) {
if ($cc_manifest->schemaValidate($schema_file)) {
+ libxml_use_internal_errors($libxml_error_state); //restore state
+
echo get_string('cc2moodle_valid_schema', 'imscc') . '
';
$cc2moodle = new cc2moodle($manifest_file);
@@ -80,12 +84,16 @@
}
} else {
+ cc_convert_errors_notify(cc_convert_errors());
notify(get_string('cc2moodle_invalid_schema', 'imscc'));
+ libxml_use_internal_errors($libxml_error_state); //restore state
return false;
}
} else {
+ cc_convert_errors_notify(cc_convert_errors());
notify(get_string('cc2moodle_manifest_dont_load', 'imscc'));
+ libxml_use_internal_errors($libxml_error_state); //restore state
return false;
}
}
@@ -94,6 +102,24 @@
return true;
}
+function cc_convert_errors (){
+ $errors = libxml_get_errors();
+ $result = array();
+ foreach($errors as $error){
+ $result[ $error->level] [] = $error;
+ }
+ krsort($result);
+ return $result;
+}
+
+function cc_convert_errors_notify($errors){
+ foreach($errors as $level => $level_errors){
+ foreach($level_errors as $error){
+ notify("File: $error->file Line: $error->line Column: $error->column Level: $error->level
\nError: $error->message", "notifyproblem imscc_level_$level", 'left');
+ }
+ }
+}
+
function detect_requirements () {
if (floor(phpversion()) >= 5) {