Code

We're html5, right?
[gosa.git] / gosa-core / include / class_listing.inc
index 3a4f6f9948b1a57772b1f70283a8b483784972e3..225509525ad1420ae3c3b97d4b2ddb220d2473ec 100644 (file)
@@ -57,7 +57,7 @@ class listing {
   var $baseSelector;
 
 
-  function listing($filename)
+  function listing($source, $isString = FALSE)
   {
     global $config;
     global $class_mapping;
@@ -65,8 +65,14 @@ class listing {
     // Initialize pid
     $this->pid= preg_replace("/[^0-9]/", "", microtime(TRUE));
 
-    if (!$this->load($filename)) {
-      die("Cannot parse $filename!");
+    if($isString){
+        if(!$this->loadString($source)){
+            die("Cannot parse $source!");
+        }
+    }else{
+        if (!$this->loadFile($source)) {
+            die("Cannot parse $source!");
+        }
     }
 
     // Set base for filter
@@ -148,10 +154,13 @@ class listing {
     return false;
   }
 
+  function loadFile($filename)
+  {
+    return($this->loadString(file_get_contents($filename)));
+  }
 
-  function load($filename)
+  function loadString($contents)
   {
-    $contents = file_get_contents($filename);
     $this->xmlData= xml::xml2array($contents, 1);
 
     if (!isset($this->xmlData['list'])) {