Code

Applied in_array strict patches from trunk
[gosa.git] / gosa-core / include / utils / class_xml.inc
index 713d099308d441ad4fa5af35fd346fa85166715f..bb79e33e326444cc5249ae4557be4d459a55171e 100644 (file)
@@ -25,29 +25,29 @@ class xml {
     // Enable user error handling
     libxml_use_internal_errors(true);
     
-    $xml = new DOMDocument();
+    $xml= new DOMDocument();
     $xml->load($file);
     
     if (!$xml->schemaValidate($schema)) {
       $errors = libxml_get_errors();
       foreach ($errors as $error) {
-        $str= "";
+        $estr= "";
         switch ($error->level) {
             case LIBXML_ERR_WARNING:
-                $str= _("Warning")." ".$error->code.": ";
+                $estr= _("Warning")." ".$error->code.":";
                 break;
             case LIBXML_ERR_ERROR:
-                $str= _("Error")." ".$error->code.": ";
+                $estr= _("Error")." ".$error->code.":";
                 break;
             case LIBXML_ERR_FATAL:
-                $str= _("Fatal error")." ".$error->code.": ";
+                $estr= _("Fatal error")." ".$error->code.":";
                 break;
         }
-        $str.= trim($error->message);
         if ($error->file) {
-            $str.= " "._("in")." ".$error->file;
+          $str= sprintf("%s %s in %s", $estr, trim($error->message), $error->file);
+        } else {
+          $str= sprintf("%s %s in %s on line %s", $estr, trim($error->message), $error->file, $error->line);
         }
-        $str.= " "._("on line")." ".$error->line;
         msg_dialog::display(_("XML error"), $str, ERROR_DIALOG);
       }
       libxml_clear_errors();
@@ -109,7 +109,7 @@ class xml {
         //See tag status and do the needed.
         if($type == "open") {//The starting of the tag '<tag>'
             $parent[$level-1] = &$current;
-            if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
+            if(!is_array($current) or (!in_array_strict($tag, array_keys($current)))) { //Insert New tag
                 $current[$tag] = $result;
                 if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
                 $repeated_tag_index[$tag.'_'.$level] = 1;
@@ -179,34 +179,4 @@ class xml {
     return($xml_array);
   }
 
-
-  static function getLocalizedAttribute($attribute, $lang)
-  {
-    // Return directly if there's no lang code
-    if (!is_array($attribute)) {
-      return($attribute);
-    }
-
-    // Get language index if available
-    $lang= preg_replace('/_.*$/', '', $lang);
-    $mapper= array();
-    foreach($attribute as $index => $lv){
-      if (preg_match('/_attr$/', $index) && isset($lv['xml:lang']) && $lv['xml:lang'] == $lang) {
-        $li= preg_replace('/_attr$/', '', $index);
-        if (isset($mapper[$li])) {
-          unset($mapper[$li]);
-        }
-      } else {
-        $mapper[$index]= $index;
-      }
-    }
-
-    // Use some default if no index is available
-    if (!$li) {
-      $li= array_shift($mapper);
-    }
-
-    return $attribute[$li];
-  }
-
 }