From 900290aef5eb96ada4b916e35d8f7d974f0f7051 Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 14 Aug 2009 13:08:13 +0000 Subject: [PATCH] Added foot line git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14067 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_listing.inc | 85 +++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc index 8a85b5016..217adbf40 100644 --- a/gosa-core/include/class_listing.inc +++ b/gosa-core/include/class_listing.inc @@ -15,14 +15,20 @@ class listing { var $filters= array(); var $pid; var $objectTypes; + var $objectTypeCount= array(); function listing($filename) { + global $config; + if (!$this->load($filename)) { die("Cannot parse $filename!"); } + // Move footer information + $this->showFooter= ($config->get_cfg_value("listSummary") == "true"); + // Register build in filters $this->registerElementFilter("objectType", "listing::filterObjectType"); $this->registerElementFilter("link", "listing::filterLink"); @@ -66,7 +72,7 @@ class listing { // Fill objectTypes if (isset($this->xmlData['definition']['objectType'])) { foreach ($this->xmlData['definition']['objectType'] as $index => $otype) { - $this->objectTypes[$otype['objectClass']]= $this->xmlData['definition']['objectType'][$index]; + $this->objectTypes[]= $this->xmlData['definition']['objectType'][$index]; } } @@ -95,7 +101,7 @@ class listing { function render() { -echo "sorting, department browsing, filter base handling, bottom list info, copy'n paste handler, snapshot handler
"; +echo "sorting, department browsing, filter base handling, copy'n paste handler, snapshot handler
"; // Initialize list $result= ""; @@ -140,23 +146,40 @@ echo "sorting, department browsing, filter base handling, bottom list info, copy } // Need to fill the list if it's not full (nobody knows why this is 22 ;-)) + $emptyListStyle= (count($this->entries) == 0)?"border:0;":""; if (count($this->entries) < 22) { $result.= ""; for ($i= 0; $i<$num_cols; $i++) { if ($i == 0) { - $result.= " "; + $result.= " "; continue; } if ($i != $num_cols-1) { - $result.= " "; + $result.= " "; } else { - $result.= " "; + $result.= " "; } } $result.= ""; } - $result.= ""; + $result.= ""; + + // Add the footer if requested + if ($this->showFooter) { + $result.= "
"; + + foreach ($this->objectTypes as $objectType) { + if (isset($this->objectTypeCount[$objectType['label']])) { + $label= _($objectType['label']); + $result.= "$label ".$this->objectTypeCount[$objectType['label']]."    "; + } + } + + $result.= " 
"; + } + + $result.= ""; $smarty= get_smarty(); $smarty->assign("FILTER", $this->filter->render()); @@ -322,25 +345,51 @@ echo "sorting, department browsing, filter base handling, bottom list info, copy } + function getObjectType($types, $classes) + { + // Walk thru types and see if there's something matching + foreach ($types as $objectType) { + $ocs= $objectType['objectClass']; + if (!is_array($ocs)){ + $ocs= array($ocs); + } + + $found= true; + foreach ($ocs as $oc){ + if (preg_match('/^!(.*)$/', $oc, $match)) { + $oc= $match[1]; + if (in_array($oc, $classes)) { + $found= false; + } + } else { + if (!in_array($oc, $classes)) { + $found= false; + } + } + } + + if ($found) { + return $objectType; + } + } + + return null; + } + + function filterObjectType($dn, $classes) { // Walk thru classes and return on first match $result= " "; - $prio= 99; - foreach ($classes as $objectClass) { - if (isset($this->objectTypes[$objectClass])){ - if (!isset($this->objectTypes[$objectClass]["priority"])){ - $result= ""; - return $result; - } - if ($this->objectTypes[$objectClass]["priority"] < $prio){ - $prio= $this->objectTypes[$objectClass]["priority"]; - $result= ""; - } + $objectType= $this->getObjectType($this->objectTypes, $classes); + if ($objectType) { + $result= ""; + if (!isset($this->objectTypeCount[$objectType['label']])) { + $this->objectTypeCount[$objectType['label']]= 0; } + $this->objectTypeCount[$objectType['label']]++; } - return $result; } -- 2.30.2