From ae88472a137e3017eb6e40b9c2b255b24178ad48 Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 13 Aug 2009 13:16:20 +0000 Subject: [PATCH] Updated filters git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14048 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_filter.inc | 6 +-- gosa-core/include/class_listing.inc | 57 +++++++++++++++++------------ 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index d32499147..e1b16a58b 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -158,11 +158,7 @@ class filter { } // Handle translations - if (is_array($value['set'])) { - $result.= ""; - } else { - $result.= ""; - } + $result.= ""; } // Use autocompleter for additional data diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc index 0457005b5..ec72b9259 100644 --- a/gosa-core/include/class_listing.inc +++ b/gosa-core/include/class_listing.inc @@ -14,7 +14,7 @@ class listing { var $colprops= array(); var $filters= array(); var $pid; - static $objectTypes; + var $objectTypes; function listing($filename) @@ -24,16 +24,16 @@ class listing { } // Register build in filters - $this->registerFilter("objectType", "listing::filterObjectType"); - $this->registerFilter("link", "listing::filterLink"); - $this->registerFilter("actions", "listing::filterActions"); + $this->registerElementFilter("objectType", "listing::filterObjectType"); + $this->registerElementFilter("link", "listing::filterLink"); + $this->registerElementFilter("actions", "listing::filterActions"); // Initialize pid $this->pid= preg_replace("/[^0-9]/", "", microtime(TRUE)); } - function registerFilter($name, $call) + function registerElementFilter($name, $call) { if (!isset($this->filters[$name])) { $this->filters[$name]= $call; @@ -66,7 +66,7 @@ class listing { // Fill objectTypes if (isset($this->xmlData['definition']['objectType'])) { foreach ($this->xmlData['definition']['objectType'] as $index => $otype) { - listing::$objectTypes[$otype['objectClass']]= $this->xmlData['definition']['objectType'][$index]; + $this->objectTypes[$otype['objectClass']]= $this->xmlData['definition']['objectType'][$index]; } } @@ -77,8 +77,8 @@ class listing { $this->header= array(); if (isset($this->xmlData['table']['column'])){ foreach ($this->xmlData['table']['column'] as $index => $config) { - if (isset($config['header'])) { - $this->header[$index]= "colprops[$index].">".xml::getLocalizedAttribute($config['header'], $GLOBALS['t_language']).""; + if (isset($config['label'])) { + $this->header[$index]= "colprops[$index].">"._($config['label']).""; } else { $this->header[$index]= "colprops[$index]."> "; } @@ -86,7 +86,7 @@ class listing { } // Assign headline/module - $this->headline= xml::getLocalizedAttribute($this->xmlData['definition']['headline'], $GLOBALS['t_language']); + $this->headline= _($this->xmlData['definition']['label']); $this->module= $this->xmlData['definition']['module']; return true; @@ -95,7 +95,7 @@ class listing { function render() { -echo "action menu, sorting, department browsing, filter base handling, bottom list info, copy'n paste handler
"; +echo "filter for images, action menu, sorting, department browsing, filter base handling, bottom list info, copy'n paste handler, snapshot handler
"; // Initialize list $result= ""; @@ -254,6 +254,14 @@ echo "action menu, sorting, department browsing, filter base handling, bottom li } // Watch out for filters and prepare to execute them + $data= $this->processElementFilter($data, $config, $row); + + return $data; + } + + + function processElementFilter($data, $config, $row) + { preg_match_all("/%\{filter:([^(]+)\((.*)\)\}/", $data, $matches, PREG_SET_ORDER); foreach ($matches as $match) { @@ -301,28 +309,34 @@ echo "action menu, sorting, department browsing, filter base handling, bottom li } // Replace information - $data= preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($cl, $method), $params), $data); + if ($cl == "listing") { + // Non static call - seems to result in errors + $data= @preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($this, "$method"), $params), $data); + } else { + // Static call + $data= preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($cl, $method), $params), $data); + } } return $data; } - static function filterObjectType($dn, $classes) + function filterObjectType($dn, $classes) { // Walk thru classes and return on first match $result= " "; $prio= 99; foreach ($classes as $objectClass) { - if (isset(listing::$objectTypes[$objectClass])){ - if (!isset(listing::$objectTypes[$objectClass]["priority"])){ - $result= ""; + if (isset($this->objectTypes[$objectClass])){ + if (!isset($this->objectTypes[$objectClass]["priority"])){ + $result= ""; return $result; } - if (listing::$objectTypes[$objectClass]["priority"] < $prio){ - $prio= listing::$objectTypes[$objectClass]["priority"]; - $result= ""; + if ($this->objectTypes[$objectClass]["priority"] < $prio){ + $prio= $this->objectTypes[$objectClass]["priority"]; + $result= ""; } } } @@ -331,7 +345,7 @@ echo "action menu, sorting, department browsing, filter base handling, bottom li } - static function filterLink() + function filterLink() { $result= " "; @@ -469,11 +483,6 @@ echo "action menu, sorting, department browsing, filter base handling, bottom li return $result; } - - static function filterActions() - { - return "TBD"; - } } ?> -- 2.30.2