From: cajus Date: Tue, 11 Aug 2009 16:17:20 +0000 (+0000) Subject: Updated filter, added i18n to xml and added list X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=26f16620dc7257018c358e1317db4c2fe415cbbe;p=gosa.git Updated filter, added i18n to xml and added list git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14033 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_filter.inc b/gosa-core/include/class_filter.inc index dd3c9b335..9d4d9384e 100644 --- a/gosa-core/include/class_filter.inc +++ b/gosa-core/include/class_filter.inc @@ -59,6 +59,11 @@ class filter { $this->initial= true; } + // Transfer category + if (isset($this->xmlData['definition']['category'])){ + $this->category= $this->xmlData['definition']['category']; + } + // Generate formular data if (isset($this->xmlData['element'])) { if (!isset($this->xmlData['element'][0])){ @@ -149,28 +154,7 @@ class filter { // Handle translations if (is_array($value['set'])) { - $li= null; - - // Get language index if available - $lang= preg_replace('/_.*$/', '', $GLOBALS['t_language']); - $mapper= array(); - foreach($value['set'] as $index => $lv){ - if (preg_match('/_attr$/', $index) && isset($lv['xml:lang']) && $lv['xml:lang'] == $lang) { - $li= preg_replace('/_attr$/', '', $index); - if (isset($mapper[$li])) { - unset($mapper[$li]); - } - } else { - $mapper[$index]= $index; - } - } - - // Use some default if no index is available - if (!$li) { - $li= array_shift($mapper); - } - - $result.= ""; + $result.= ""; } else { $result.= ""; } @@ -229,11 +213,6 @@ class filter { } - function setCategory($category) { - $this->category= $category; - } - - function setCurrentBase($base) { $this->base= $base; } @@ -313,7 +292,7 @@ class filter { } - function renderFilter() + function render() { $smarty= get_smarty(); $smarty->assign("ALPHABET", $this->renderAlphabet()); diff --git a/gosa-core/include/class_listing.inc b/gosa-core/include/class_listing.inc new file mode 100644 index 000000000..aab36da18 --- /dev/null +++ b/gosa-core/include/class_listing.inc @@ -0,0 +1,179 @@ +load($filename)) { + die("Cannot parse $filename!"); + } + } + + + function load($filename) + { + $contents = file_get_contents($filename); + $this->xmlData= xml::xml2array($contents, 1); + + if (!isset($this->xmlData['list'])) { + return false; + } + + $this->xmlData= $this->xmlData["list"]; + + // Load some definition values + foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect") as $token) { + if (isset($this->xmlData['definition'][$token]) && + $this->xmlData['definition'][$token] == "true"){ + $this->$token= true; + } + } + + // Parse layout per column + $this->colprops= $this->parseLayout($this->xmlData['table']['layout']); + + // Prepare table headers + $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']).""; + } else { + $this->header[$index]= "colprops[$index]."> "; + } + } + } + + return true; + } + + + function render() + { + #print_a($this->xmlData); + #print_a($this->entries); +echo "Fill summary, handle empty lists differently, alternating
"; + $summary= "empty"; + + // Initialize list + $result= " +"; + + // New table for the real list contents + $result.= "
"; + $num_cols= count($this->colprops) + ($this->multiSelect?1:0); + + // Build list header + $result.= ""; + if ($this->multiSelect) { + $result.= ""; + } + foreach ($this->header as $header) { + $result.= $header; + } + + // Add 13px for scroller + $result.= "
 
"; + + // Fill with contents + $first= true; + foreach ($this->entries as $entry){ + $result.=""; + foreach ($this->xmlData['table']['column'] as $config) { + if ($first) { + + } else { + } + } + $first= false; + } +# for ($i= 0; $i<10; $i++) { +# $result.=""; +# $result.=""; +# $result.=""; +# $result.=""; +# $result.=""; +# $result.=""; +# $result.=""; +# } + + // Need to fill the list if it's not full (nobody knows why this is 22 ;-)) + if (count($this->entries) < 22) { + $result.= ""; + for ($i= 0; $i<=$num_cols; $i++) { + if ($i == 0) { + $result.= ""; + continue; + } + if ($i != $num_cols-1) { + $result.= ""; + } else { + $result.= ""; + } + } + $result.= ""; + } + + $result.= "
 Administrativa - [Funktionelle Daten]  
   
"; + + return $result; + } + + + function setEntries($entries) + { + $this->entries= &$entries; + } + + + function parseLayout($layout) + { + $result= array(); + $layout= preg_replace("/^\|/", "", $layout); + $layout= preg_replace("/\|$/", "", $layout); + $cols= split("\|", $layout); + foreach ($cols as $index => $config) { + if ($config != "") { + $components= split(';', $config); + $config= ""; + foreach ($components as $part) { + if (preg_match("/^r$/", $part)) { + $config.= "text-align:right;"; + continue; + } + if (preg_match("/^l$/", $part)) { + $config.= "text-align:left;"; + continue; + } + if (preg_match("/^c$/", $part)) { + $config.= "text-align:center;"; + continue; + } + if (preg_match("/^[0-9]+(|px|%)$/", $part)) { + $config.= "width:$part;"; + continue; + } + } + + $result[$index]= " style='$config' "; + } else { + $result[$index]= null; + } + } + + return $result; + } + +} + +?> diff --git a/gosa-core/include/utils/class_xml.inc b/gosa-core/include/utils/class_xml.inc index 690ee7f2c..096bb0973 100644 --- a/gosa-core/include/utils/class_xml.inc +++ b/gosa-core/include/utils/class_xml.inc @@ -143,4 +143,35 @@ class xml { return($xml_array); } + + + static function getLocalizedAttribute($attribute, $lang) + { + // Return directly if there's no lang code + if (!is_array($attribute)) { + return($attribute); + } + + // Get language index if available + $lang= preg_replace('/_.*$/', '', $lang); + $mapper= array(); + foreach($attribute as $index => $lv){ + if (preg_match('/_attr$/', $index) && isset($lv['xml:lang']) && $lv['xml:lang'] == $lang) { + $li= preg_replace('/_attr$/', '', $index); + if (isset($mapper[$li])) { + unset($mapper[$li]); + } + } else { + $mapper[$index]= $index; + } + } + + // Use some default if no index is available + if (!$li) { + $li= array_shift($mapper); + } + + return $attribute[$li]; + } + }