X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_listing.inc;h=ab6d5944354bdf8f56ebf12bbe5a68886a6d80a5;hb=37a863af6c001e5760070adb1d74dc77e4df61f9;hp=d1436fce5d16987e4f34dde4c23c67ca25d77193;hpb=d2a161f9f7292cc4a250a182a628861cce73012d;p=gosa.git diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc index d1436fce5..ab6d59443 100644 --- a/gosa-core/include/class_listing.inc +++ b/gosa-core/include/class_listing.inc @@ -45,12 +45,14 @@ class listing { var $pid; var $objectTypes= array(); var $objectTypeCount= array(); + var $objectDnMapping= array(); var $copyPasteHandler= null; var $snapshotHandler= null; var $exporter= array(); var $exportColumns= array(); var $useSpan= false; var $height= 0; + var $scrollPosition= 0; function listing($filename) @@ -255,6 +257,7 @@ class listing { } } + function render() { // Check for exeeded sizelimit @@ -262,33 +265,47 @@ class listing { return($message); } + // Some browsers don't have the ability do do scrollable table bodies, filter them + // here. + $switch= false; + if (preg_match('/(Opera|Konqueror|Safari|msie)/i', $_SERVER['HTTP_USER_AGENT'])){ + $switch= true; + } + // Initialize list $result= "\n"; + $result.= "\n"; $height= 450; if ($this->height != 0) { $result.= "\n"; $height= $this->height; } - $result.= "
\n"; - $result.= " -"; // Add the footer if requested if ($this->showFooter) { - $result.= ""; + $result.= ""; } - $result.= "
\n"; + $result.= "
\n"; - - // New table for the real list contents - $result.= ""; + // Close list body + $result.= "
\n"; + + $height= ""; + if ($switch){ + $height= "height:100%;"; + } + $result.= "\n"; $this->numColumns= count($this->colprops) + ($this->multiSelect?1:0); // Build list header - $result.= "\n"; + $result.= "\n"; if ($this->multiSelect) { - $result.= "\n"; + $width= "24px"; + if (preg_match('/Konqueror/i', $_SERVER['HTTP_USER_AGENT'])){ + $width= "28px"; + } + $result.= "\n"; } foreach ($this->header as $header) { $result.= $header; } + $result.= "\n"; - // Add 13px for scroller - $result.= "
 
\n"; + // Build list body + $result.= "\n"; // No results? Just take an empty colspanned row if (count($this->entries) + count($this->departments) == 0) { @@ -309,7 +326,7 @@ class listing { // Render multi select if needed if ($this->multiSelect) { - $result.=""; + $result.=""; } // Render defined department columns, fill the rest with some stuff @@ -389,11 +406,12 @@ class listing { $result.= ""; } - $result.= "
  
"; + $result.= "
"; foreach ($this->objectTypes as $objectType) { if (isset($this->objectTypeCount[$objectType['label']])) { @@ -402,10 +420,18 @@ class listing { } } - $result.= " 
"; + // Close list + $result.= ""; + $result.= $switch?"":""; + + // Add scroll positioner + $result.= ''; $smarty= get_smarty(); $smarty->assign("usePrototype", "true"); @@ -429,7 +455,15 @@ class listing { // Assign summary $smarty->assign("HEADLINE", $this->headline); - return ($smarty->fetch(get_template_path($this->xmlData['definition']['template'], true))); + // Try to load template from plugin the folder first... + $file = get_template_path($this->xmlData['definition']['template'], true); + + // ... if this fails, try to load the file from the theme folder. + if(!file_exists($file)){ + $file = get_template_path($this->xmlData['definition']['template']); + } + + return ($smarty->fetch($file)); } @@ -438,17 +472,23 @@ class listing { global $config; $ui= get_userinfo(); - // Reset object counter + // Reset object counter / DN mapping $this->objectTypeCount= array(); + $this->objectDnMapping= array(); // Do not do anything if this is not our PID if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) { return; } + // Save position if set + if (isset($_POST['position_'.$this->pid]) && is_numeric($_POST['position_'.$this->pid])) { + $this->scrollPosition= $_POST['position_'.$this->pid]; + } + // Save base if (isset($_POST['BASE']) && $this->baseMode) { - $base= validate($_POST['BASE']); + $base= get_post('BASE'); if (isset($this->bases[$base])) { $this->base= $base; session::global_set("CurrentMainBase", $this->base); @@ -460,6 +500,7 @@ class listing { if (preg_match('/^department_([0-9]+)$/', validate($_GET['act']), $match)){ if (isset($this->departments[$match[1]])){ $this->base= $this->departments[$match[1]]['dn']; + session::global_set("CurrentMainBase", $this->base); } } } @@ -553,32 +594,38 @@ class listing { $layout= preg_replace("/^\|/", "", $layout); $layout= preg_replace("/\|$/", "", $layout); $cols= split("\|", $layout); + foreach ($cols as $index => $config) { if ($config != "") { + $res= ""; $components= split(';', $config); - $config= ""; foreach ($components as $part) { if (preg_match("/^r$/", $part)) { - $config.= "text-align:right;"; + $res.= "text-align:right;"; continue; } if (preg_match("/^l$/", $part)) { - $config.= "text-align:left;"; + $res.= "text-align:left;"; continue; } if (preg_match("/^c$/", $part)) { - $config.= "text-align:center;"; + $res.= "text-align:center;"; continue; } if (preg_match("/^[0-9]+(|px|%)$/", $part)) { - $config.= "width:$part;"; + $res.= "width:$part;min-width:$part;"; continue; } } - $result[$index]= " style='$config' "; + // Add minimum width for scalable columns + if (!preg_match('/width:/', $res)){ + $res.= "min-width:200px;"; + } + + $result[$index]= " style='$res' "; } else { - $result[$index]= null; + $result[$index]= " style='min-width:100px'"; } } @@ -636,8 +683,10 @@ class listing { $selected= " selected"; $found= true; } - $result.= ""; + $key = htmlentities($key,ENT_QUOTES); + $result.= "\n"; } + $result.= ""; // Reset the currently used base to the first DN we found if there @@ -655,11 +704,18 @@ class listing { preg_match_all("/%\{filter:([^(]+)\((.*)\)\}/", $data, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - if (!isset($this->filters[$match[1]])) { - continue; + $cl= ""; + $method= ""; + if (preg_match('/::/', $match[1])) { + $cl= preg_replace('/::.*$/', '', $match[1]); + $method= preg_replace('/^.*::/', '', $match[1]); + } else { + if (!isset($this->filters[$match[1]])) { + continue; + } + $cl= preg_replace('/::.*$/', '', $this->filters[$match[1]]); + $method= preg_replace('/^.*::/', '', $this->filters[$match[1]]); } - $cl= preg_replace('/::.*$/', '', $this->filters[$match[1]]); - $method= preg_replace('/^.*::/', '', $this->filters[$match[1]]); // Prepare params for function call $params= array(); @@ -669,16 +725,31 @@ class listing { // Row is replaced by the row number if ($param == "row") { $params[]= $row; + continue; } // pid is replaced by the current PID if ($param == "pid") { $params[]= $this->pid; + continue; + } + + // base is replaced by the current base + if ($param == "base") { + $params[]= $this->getBase(); + continue; } // Fixie with "" is passed directly if (preg_match('/^".*"$/', $param)){ $params[]= preg_replace('/"/', '', $param); + continue; + } + + // Move dn if needed + if ($param == "dn") { + $params[]= LDAP::fix($config["dn"]); + continue; } // LDAP variables get replaced by their objects @@ -689,13 +760,9 @@ class listing { unset($values['count']); } $params[]= $values; + break; } } - - // Move dn if needed - if ($param == "dn") { - $params[]= LDAP::fix($config["dn"]); - } } // Replace information @@ -751,12 +818,14 @@ class listing { $objectType= $this->getObjectType($this->objectTypes, $classes); if ($objectType) { + $this->objectDnMapping[$dn]= $objectType["objectClass"]; $result= ""; if (!isset($this->objectTypeCount[$objectType['label']])) { $this->objectTypeCount[$objectType['label']]= 0; } $this->objectTypeCount[$objectType['label']]++; } + return $result; } @@ -806,11 +875,16 @@ class listing { $result.= " "; continue; } - } else { + } elseif (is_string($objectclass)) { if(!in_array($objectclass, $classes)) { $result.= " "; continue; } + } elseif (is_array($objectclass)) { + if(count(array_intersect($objectclass, $classes)) != count($objectclass)){ + $result.= " "; + continue; + } } } @@ -833,7 +907,9 @@ class listing { } if ($action['type'] == "copypaste") { - $result.= $this->renderCopyPasteActions($row, $this->entries[$row]['dn'], $category, $class); + $copy = !isset($action['copy']) || $action['copy'] == "true"; + $cut = !isset($action['cut']) || $action['cut'] == "true"; + $result.= $this->renderCopyPasteActions($row, $this->entries[$row]['dn'], $category, $class,$copy,$cut); } else { $result.= $this->renderSnapshotActions($row, $this->entries[$row]['dn'], $category, $class); } @@ -948,6 +1024,11 @@ class listing { return; } + // Save position if set + if (isset($_POST['position_'.$this->pid]) && is_numeric($_POST['position_'.$this->pid])) { + $this->scrollPosition= $_POST['position_'.$this->pid]; + } + $result= array("targets" => array(), "action" => ""); // Filter GET with "act" attributes @@ -1076,6 +1157,12 @@ class listing { if (isset($action['label'])){ $result.= "$img"._($action['label'])." "; } + + // Ensure we've an array of actions, this enables sub menus with only one action. + if(isset($action['action']['type'])){ + $action['action'] = array($action['action']); + } + $result.= $this->recurseActions($action['action']).""; $level--; $separator= ""; @@ -1090,7 +1177,9 @@ class listing { // Check for special types switch ($action['type']) { case 'copypaste': - $result.= $this->renderCopyPasteMenu($separator); + $cut = !isset($action['cut']) || $action['cut'] != "false"; + $copy = !isset($action['copy']) || $action['copy'] != "false"; + $result.= $this->renderCopyPasteMenu($separator, $copy , $cut); break; case 'snapshot': @@ -1448,6 +1537,26 @@ class listing { return $result; } + + function getEntry($dn) + { + foreach ($this->entries as $entry) { + if (isset($entry['dn']) && strcasecmp($dn, $entry['dn']) == 0){ + return $entry; + } + } + return null; + } + + + function getType($dn) + { + if (isset($this->objectDnMapping[$dn])) { + return $this->objectDnMapping[$dn]; + } + return null; + } + } ?>