From: hickert Date: Tue, 13 Nov 2007 08:01:50 +0000 (+0000) Subject: Smarty Template for List generation X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=53083cfa6cd189d552a8d4b983ee9f76aed071fc;p=gosa.git Smarty Template for List generation git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7783 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_ObjectList.inc b/include/class_ObjectList.inc index f9f7dd3bd..a82eef461 100644 --- a/include/class_ObjectList.inc +++ b/include/class_ObjectList.inc @@ -79,7 +79,7 @@ class ObjectList implements IteratorAggregate { ''; # Crap filling - $this->objects= array( + $tmp= array( array("dn" => "cn=1aherbertskiste,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de", "cn" => "1aherbertskiste", @@ -357,6 +357,15 @@ class ObjectList implements IteratorAggregate { "objectClass" => array('gotoWorkstation')) ); + + $tmp2 = array(); + foreach($tmp as $entry){ + $id = uniqid(); + $entry['id']= $id; + $tmp2[] = $entry; + } + + $this->objects = $tmp2; } diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index eb454a53f..60b11d294 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -181,39 +181,31 @@ class ObjectListViewport extends GOsaGuiElement { #TODO: Make $buffer a proper HTML table output $tmp = split("\|",trim($buffer,"|")); + $cols = array(); - /* Define entry template */ - $tpl = " -
- {content} -
- - "; - /* Template vriables to replace */ - $attrs = array("/\{style_1\}/","/\{style_2\}/","/\{content\}/"); - - /* Append template for each given col */ - $buffer =""; for($i= 0; $i < $this->numberOfCols; $i++){ /* If current entry is the last to appen, then skip adding styles */ if($i == ($this->numberOfCols-1)){ - $buffer.= preg_replace( $attrs, - array($this->headline[$i]['style'],"width:100%;overflow:hidden;",$tmp[$i]),$tpl); + $cols[$i]['style1'] = $this->headline[$i]['style']; + $cols[$i]['style2'] = "width:100%;overflow:hidden;"; + $cols[$i]['value'] = $tmp[$i]; }else{ - $buffer.= preg_replace( $attrs, - array($this->headline[$i]['style'],"width:100%;overflow:hidden;".$this->headline[$i]['style'],$tmp[$i]),$tpl); + $cols[$i]['style1'] = $this->headline[$i]['style']; + $cols[$i]['style2'] = "width:100%;overflow:hidden;".$this->headline[$i]['style']; + $cols[$i]['value'] = $tmp[$i]; } } /* Add class depending on given id, to alternate background colors */ if($this->colorAlternator++ & 1){ - $a = "class='ObjectListViewport_Entry_Row1'"; + $data['row']['class'] = "ObjectListViewport_Entry_Row1"; }else{ - $a = "class='ObjectListViewport_Entry_Row2'"; + $data['row']['class'] = "ObjectListViewport_Entry_Row2"; } - return "\n".$buffer."\n"; + $data['cols'] = $cols; + return($data); } @@ -241,10 +233,9 @@ class ObjectListViewport extends GOsaGuiElement { $entries = ""; $objects= new ObjectListFilterIterator($this->objects->getIterator()); foreach ($objects as $value){ - $entries .= $this->renderEntry($value); + $entries[] = $this->renderEntry($value); } - return "README ;-)\n"; #Fabian: _POST/_GET Variablen bitte mit $this->createVariable('name'); # erstellen. @@ -255,20 +246,20 @@ class ObjectListViewport extends GOsaGuiElement { # smarty eingebunden, dann kann Sie nach einem _POST oder _GET via # $this->getRequestVariable_cn() wieder abgefragt werden. - #$smarty = get_smarty(); - #$smarty->assign("OLV_Entries",array("Doesn't work" => "Does not work."));//$objects); - #$smarty->assign("OLV_List_Id",$this->id); + $smarty = get_smarty(); + $smarty->assign("OLV_Entries",$entries); + $smarty->assign("OLV_List_Id",$this->id); - #/* Footer variables */ - #$smarty->assign("OLV_Footer_Enabled",$this->displayFooterFlag); - #$smarty->assign("OLV_Footer_Message",$this->footer); - #$smarty->assign("OLV_Num_Cols",$this->numberOfCols); + /* Footer variables */ + $smarty->assign("OLV_Footer_Enabled",$this->displayFooterFlag); + $smarty->assign("OLV_Footer_Message",$this->footer); + $smarty->assign("OLV_Num_Cols",$this->numberOfCols); - #/* Assign Headline values */ - #$smarty->assign("OLV_Header_Enabled",$this->displayHeaderFlag); - #$smarty->assign("OLV_Header",$this->headline); + /* Assign Headline values */ + $smarty->assign("OLV_Header_Enabled",$this->displayHeaderFlag); + $smarty->assign("OLV_Header",$this->headline); - #return($smarty->fetch("ObjectListViewport.tpl")); + return($smarty->fetch("ObjectListViewport.tpl")); } diff --git a/tests/ListTest/ObjectListViewport.js b/tests/ListTest/ObjectListViewport.js index 3404deb2a..3327ce1b9 100644 --- a/tests/ListTest/ObjectListViewport.js +++ b/tests/ListTest/ObjectListViewport.js @@ -30,7 +30,7 @@ window.onresize = updateObjectListViewportSize; all = getElementsByStyleClass('ObjectListViewport'); for (i = 0; i < all.length; ++i){ - list_id = all[i].id.replace(/^.*_/,"_"); + list_id = all[i].id.replace(/^ObjectListViewport/,""); /* Set Viewport to min height, to ensure * that resize will work correctly in konqueror diff --git a/tests/ListTest/ObjectListViewport.tpl b/tests/ListTest/ObjectListViewport.tpl index 1c529f84e..5619ce35e 100644 --- a/tests/ListTest/ObjectListViewport.tpl +++ b/tests/ListTest/ObjectListViewport.tpl @@ -1,43 +1,51 @@ - - - - - - -
- - -
- - - - {foreach from=$OLV_Header key=key item=item} - - {/foreach} + + + +
{$item.name}
+ + + + + + - - - + + + + +
+ + + {foreach from=$OLV_Header key=key item=item} + + {/foreach} + +
{$item.name}
+
+
+ + {foreach from=$OLV_Entries key=key item=item} + + {foreach from=$item.cols key=key2 item=item2} + + {/foreach} -
+
+ {$item2.value} +
+
-
-
- + {/foreach} +
+
+
+
-
- -
- - -