From: hickert Date: Wed, 19 May 2010 13:07:34 +0000 (+0000) Subject: Updated class listing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8655766710a8612c0100294ae99e5c0476561b89;p=gosa.git Updated class listing -Allow to load strings too, instead of onyl files. This allow us to modify the xml content before parsing. -I've used this to display the available services in the server service menu. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18552 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc index 3a4f6f994..225509525 100644 --- a/gosa-core/include/class_listing.inc +++ b/gosa-core/include/class_listing.inc @@ -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'])) {