From 35dc5265a9304887f348d9796dff48ff04e8c373 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Nov 2007 14:29:09 +0000 Subject: [PATCH] Added coloring of rows git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7758 594d385d-05f5-0310-b6e9-bd551577e9d8 --- ListTest/ObjectListViewport.css | 13 +++- include/class_ObjectListViewport.inc | 98 ++++++++++++++-------------- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/ListTest/ObjectListViewport.css b/ListTest/ObjectListViewport.css index ab1dfe6e0..3f483cf8b 100644 --- a/ListTest/ObjectListViewport.css +++ b/ListTest/ObjectListViewport.css @@ -58,8 +58,19 @@ overflow:auto; height:100px; } +tr.ObjectListViewport_Entry_Row1{ + background-color: #F0F0F0; +} +tr.ObjectListViewport_Entry_Row2{ + background-color: #FFFFFF; +} +tr.ObjectListViewport_Entry_Row1:hover{ + background-color: #D8D8D8; +} +tr.ObjectListViewport_Entry_Row2:hover{ + background-color: #D8D8D8; +} .ObjectListViewport_Entry_Cell { - background-color: white; background-image: none; background-repeat: repeat; background-attachment: scroll; diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index c2619af28..9f3aec6e7 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -92,14 +92,20 @@ class ObjectListViewport { \return HTML rendered headline */ private function renderHeadline(){ - $buffer ="\n"; - $buffer.="\n"; + $tpl =" + + "; + $buffer =""; foreach($this->headline as $key => $value){ $buffer .= "\n"; } - $buffer.="\n"; - $buffer.="
+ + + {content} + +
+
".$value['name']."
\n"; - return $buffer; + return(preg_replace("/\{content\}/", $buffer,$tpl)); } @@ -110,11 +116,15 @@ class ObjectListViewport { \return HTML rendered footer */ private function renderFooter(){ - $buffer ="\n"; - $buffer.="\n"; - $buffer.= "\n"; - $buffer.="\n"; - $buffer.="\n"; + $buffer =" + + + + + + + + "; return $buffer; } @@ -128,7 +138,7 @@ class ObjectListViewport { Gets the entry descriptions from the ObjectList object and renders them. \return HTML rendered list entries */ - private function renderEntry($entry){ + private function renderEntry($entry,$entry_id){ /* Copy template */ $buffer= $this->entryFormat; @@ -156,41 +166,39 @@ class ObjectListViewport { } #TODO: Make $buffer a proper HTML table output - $tmp = split("\|",trim($buffer,"|")); - - $buffer="\n"; -// foreach($tmp as $key => $value){ -// $buffer .= "". -// "
". -// $value. -// "
". -// "\n"; -// } + /* 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->i_numberOfCols ; $i ++){ - - $value = $tmp[$i]; - if($i == ($this->i_numberOfCols -1 )){ - $buffer .= "". - "
". - $value. - "
". - "\n"; + /* If current entry is the last to appen, then skip adding styles */ + if($i == ($this->i_numberOfCols -1 )){ + $buffer.= preg_replace( $attrs, + array($this->headline[$i]['style'],"width:100%;overflow:hidden;",$tmp[$i]),$tpl); }else{ - $buffer .= "". - "
". - $value. - "
". - "\n"; + $buffer.= preg_replace( $attrs, + array($this->headline[$i]['style'],"width:100%;overflow:hidden;".$this->headline[$i]['style'],$tmp[$i]),$tpl); } } + if($entry_id % 2){ + $a = "class='ObjectListViewport_Entry_Row1'"; + }else{ + $a = "class='ObjectListViewport_Entry_Row2'"; + } - $buffer.="\n"; - - return $buffer."\n"; + return "".$buffer."\n"; } @@ -216,25 +224,17 @@ class ObjectListViewport { $header = $footer = ""; if($this->b_displayHeader){ - $header =" - - ".$this->renderHeadline()." - - "; + $header = $this->renderHeadline(); } if($this->b_displayFooter){ - $footer =" - - ".$this->renderFooter()." - - "; + $footer = $this->renderFooter(); } /* Apply current filter */ $entries = ""; $objects= new ObjectListFilterIterator($this->objects->getIterator()); - foreach ($objects as $value){ - $entries .= $this->renderEntry($value); + foreach ($objects as $key => $value){ + $entries .= $this->renderEntry($value,$key); } /* Generate fixed headline */ -- 2.30.2