From 76cd77d6fd37222cce6dd0551c272828a3aaf44c Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 13 Nov 2007 10:12:59 +0000 Subject: [PATCH] Added Checkboxes for multiselect git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7787 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ObjectListViewport.inc | 69 ++------- tests/ListTest/2/index.php | 16 +++ tests/ListTest/3/index.php | 16 +++ tests/ListTest/ObjectListViewport.css | 3 +- tests/ListTest/ObjectListViewport.js | 199 ++++++++++++++------------ tests/ListTest/ObjectListViewport.tpl | 16 +++ 6 files changed, 172 insertions(+), 147 deletions(-) diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index 60b11d294..966294243 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -38,7 +38,7 @@ class ObjectListViewport extends GOsaGuiElement { protected $displayHeaderFlag= TRUE; protected $displayFooterFlag= TRUE; - private $numberOfCols= 0; + private $numberOfColumns= 0; /*! \brief Container for objects @@ -96,50 +96,6 @@ class ObjectListViewport extends GOsaGuiElement { } -#/*! \brief Renders headline into a string -# -# Gets the headline description from the ObjectList object and renders it. -# -# \return HTML rendered headline -# */ -#private function renderHeadline(){ -# $tpl =" -# -# -# -# {content} -# -#
-# -# "; -# $buffer =""; -# foreach($this->headline as $key => $value){ -# $buffer .= "".$value['name']."\n"; -# } -# return(preg_replace("/\{content\}/", $buffer,$tpl)); -#} - - -#/*! \brief Renders footer into a string -# -# Gets the footer description from the ObjectList object and renders it. -# -# \return HTML rendered footer -# */ -#private function renderFooter(){ -# $buffer =" -# -# -# -# -# -# -# -# "; -# return $buffer; -#} - - /* FIXME: replace this -> not our task */ private function getEntryIcon($entry,$alt = ""){ return("".$alt.""); @@ -183,16 +139,16 @@ class ObjectListViewport extends GOsaGuiElement { $tmp = split("\|",trim($buffer,"|")); $cols = array(); - for($i= 0; $i < $this->numberOfCols; $i++){ + for($i= 0; $i < $this->numberOfColumns; $i++){ /* If current entry is the last to appen, then skip adding styles */ - if($i == ($this->numberOfCols-1)){ - $cols[$i]['style1'] = $this->headline[$i]['style']; + if($i == ($this->numberOfColumns-1)){ + $cols[$i]['style1'] = $this->columnInformation[$i]['style']; $cols[$i]['style2'] = "width:100%;overflow:hidden;"; $cols[$i]['value'] = $tmp[$i]; }else{ - $cols[$i]['style1'] = $this->headline[$i]['style']; - $cols[$i]['style2'] = "width:100%;overflow:hidden;".$this->headline[$i]['style']; + $cols[$i]['style1'] = $this->columnInformation[$i]['style']; + $cols[$i]['style2'] = "width:100%;overflow:hidden;".$this->columnInformation[$i]['style']; $cols[$i]['value'] = $tmp[$i]; } } @@ -249,15 +205,16 @@ class ObjectListViewport extends GOsaGuiElement { $smarty = get_smarty(); $smarty->assign("OLV_Entries",$entries); $smarty->assign("OLV_List_Id",$this->id); + $smarty->assign("OLV_Multiselect_Enabled",$this->multiselect); /* Footer variables */ $smarty->assign("OLV_Footer_Enabled",$this->displayFooterFlag); $smarty->assign("OLV_Footer_Message",$this->footer); - $smarty->assign("OLV_Num_Cols",$this->numberOfCols); + $smarty->assign("OLV_Num_Cols",$this->numberOfColumns); /* Assign Headline values */ $smarty->assign("OLV_Header_Enabled",$this->displayHeaderFlag); - $smarty->assign("OLV_Header",$this->headline); + $smarty->assign("OLV_Header",$this->columnInformation); return($smarty->fetch("ObjectListViewport.tpl")); } @@ -272,8 +229,8 @@ class ObjectListViewport extends GOsaGuiElement { /* Each cell definition is seperated by | * split by and go through each definition */ - $this->headline= array(); - $this->numberOfCols= 0; + $this->columnInformation= array(); + $this->numberOfColumns= 0; $tmp= split("\|", trim($data, "|")); $cell_formats= array(); @@ -322,9 +279,9 @@ class ObjectListViewport extends GOsaGuiElement { } $cell_formats[$key]= array("name" => $name, "width" => $width, "alignment" => $alignment, "style" => $style); - $this->numberOfCols++; + $this->numberOfColumns++; } - $this->headline= $cell_formats; + $this->columnInformation= $cell_formats; } } diff --git a/tests/ListTest/2/index.php b/tests/ListTest/2/index.php index bd7b3d0ba..d7043ab94 100644 --- a/tests/ListTest/2/index.php +++ b/tests/ListTest/2/index.php @@ -37,6 +37,22 @@ /* This is good for testing... */ error_reporting (E_ALL | E_STRICT); + +function get_smarty() +{ + echo "Smarty fake in each ./tests/ListTest[1-9]/index.php"; + date_default_timezone_set("europe/berlin"); + $smarty = new smarty; + /* Set template compile directory */ + $smarty->compile_dir= '/var/spool/gosa/'; + $smarty->template_dir = '../'; + $smarty->caching= false; + $smarty->php_handling= SMARTY_PHP_REMOVE; + return($smarty); +} + + + /* Escape all preg_* relevant characters */ function normalizePreg($input) { diff --git a/tests/ListTest/3/index.php b/tests/ListTest/3/index.php index e4f58136a..9ffc3c3c1 100644 --- a/tests/ListTest/3/index.php +++ b/tests/ListTest/3/index.php @@ -37,6 +37,22 @@ /* This is good for testing... */ error_reporting (E_ALL | E_STRICT); + +function get_smarty() +{ + echo "Smarty fake in each ./tests/ListTest[1-9]/index.php"; + date_default_timezone_set("europe/berlin"); + $smarty = new smarty; + /* Set template compile directory */ + $smarty->compile_dir= '/var/spool/gosa/'; + $smarty->template_dir = '../'; + $smarty->caching= false; + $smarty->php_handling= SMARTY_PHP_REMOVE; + return($smarty); +} + + + /* Escape all preg_* relevant characters */ function normalizePreg($input) { diff --git a/tests/ListTest/ObjectListViewport.css b/tests/ListTest/ObjectListViewport.css index 3f483cf8b..ef4b866fc 100644 --- a/tests/ListTest/ObjectListViewport.css +++ b/tests/ListTest/ObjectListViewport.css @@ -142,4 +142,5 @@ tr.ObjectListViewport_Entry_Row2:hover{ height: 22px; } - +.ObjectListViewport_Entry_Checkbox { +} diff --git a/tests/ListTest/ObjectListViewport.js b/tests/ListTest/ObjectListViewport.js index 3327ce1b9..dc42d5ff4 100644 --- a/tests/ListTest/ObjectListViewport.js +++ b/tests/ListTest/ObjectListViewport.js @@ -1,105 +1,124 @@ - /* Register resize event to force redraw of all * displayed lists */ window.onload = updateObjectListViewportSize; window.onresize = updateObjectListViewportSize; - function updateObjectListViewportSize() { - - var header = 0; - var footer = 0; - var viewport = 0; - var viewport_w = 0; - var all = new Array(); - var i = 0; - var list_id = ""; - var calc = 0; - - /* Somehow IE do not need to be resized - * So skip the following part if the client uses ie - */ - if(document.all && !window.opera){ - all = getElementsByStyleClass('ObjectListViewport_Entry_Cover'); - for (i = 0; i < all.length; ++i){ - document.getElementById(all[i].id).style.height= "100%"; - } - return; - } - - all = getElementsByStyleClass('ObjectListViewport'); - for (i = 0; i < all.length; ++i){ - - list_id = all[i].id.replace(/^ObjectListViewport/,""); - - /* Set Viewport to min height, to ensure - * that resize will work correctly in konqueror - */ - document.getElementById('ObjectListViewport_Entry_Cover' + list_id).style.height= "50px"; - - /* Get values of displayed header and footer heights to be - * able to recalculate the Viewport - */ - viewport = getObjectHeight('ObjectListViewport_Table' + list_id); - - /* Get Header height for ViewPort height calculation */ - if(document.getElementById('ObjectListViewport_TD_Header' + list_id)){ - header = getObjectHeight('ObjectListViewport_TD_Header' + list_id); - }else{ - header =0; - } - - /* Get Footer height for ViewPort height calculation */ - if(document.getElementById('ObjectListViewport_TD_Footer' + list_id)){ - footer = getObjectHeight('ObjectListViewport_TD_Footer' + list_id); - }else{ - footer = 0 - } - - /* Calculate the new visible entry part height. */ - calc = (viewport - ( header + footer )); - document.getElementById('ObjectListViewport_Entry_Cover' + list_id).style.height = calc; - - /* Reduce width of entry list, we need some space to - * display the scrollbar without breaking the layout - * Only required if a header is shown. - */ - if(document.getElementById('ObjectListViewport_TD_Header' + list_id)){ - viewport_w = getObjectWidth('ObjectListViewport_Table' + list_id); - document.getElementById('ObjectListViewport_Entry_Table' + list_id).style.width = (viewport_w - 18) + 'px'; - document.getElementById('ObjectListViewport_Header_Table' + list_id).style.width = (viewport_w - 18) + 'px'; - } - } +function toggle_all_(regex,state_object) +{ + state = document.getElementById(state_object).checked; + chk_set_all(regex, state); +} + +/* Toggle checkbox that matches regex */ +function chk_set_all(regex,value) +{ + var all = getElementsByStyleClass('ObjectListViewport_Entry_Checkbox'); + for (var i = 0; i < all.length; ++i){ + if(document.getElementById(all[i].id) && all[i].id.match(regex)){ + document.getElementById(all[i].id).checked= value; + } } +} + + +function updateObjectListViewportSize() { + var header = 0; + var footer = 0; + var viewport = 0; + var viewport_w = 0; + var all = new Array(); + var i = 0; + var list_id = ""; + var calc = 0; - /* Return all elements of a specific class */ - function getElementsByStyleClass (className) { - var all = document.all ? document.all : document.getElementsByTagName('*'); - var elements = new Array(); - for (var e = 0; e < all.length; e++) - if (all[e].className == className) - elements[elements.length] = all[e]; - return elements; + /* Somehow IE do not need to be resized + * So skip the following part if the client uses ie + */ + if(document.all && !window.opera){ + all = getElementsByStyleClass('ObjectListViewport_Entry_Cover'); + for (i = 0; i < all.length; ++i){ + document.getElementById(all[i].id).style.height= "100%"; } + return; + } + + all = getElementsByStyleClass('ObjectListViewport'); + for (i = 0; i < all.length; ++i){ + + list_id = all[i].id.replace(/^ObjectListViewport/,""); + + /* Set Viewport to min height, to ensure + * that resize will work correctly in konqueror + */ + document.getElementById('ObjectListViewport_Entry_Cover' + list_id).style.height= "50px"; + + /* Get values of displayed header and footer heights to be + * able to recalculate the Viewport + */ + viewport = getObjectHeight('ObjectListViewport_Table' + list_id); + /* Get Header height for ViewPort height calculation */ + if(document.getElementById('ObjectListViewport_TD_Header' + list_id)){ + header = getObjectHeight('ObjectListViewport_TD_Header' + list_id); + }else{ + header =0; + } - /* Return integer value of style attribute width for specified ID */ - function getObjectWidth(obj){ - if(document.getElementById(obj)){ - obj = getComputedStyle(document.getElementById(obj),"").width; - return(parseInt(obj.replace(/px/,''))); - }else{ - return(0); - } + /* Get Footer height for ViewPort height calculation */ + if(document.getElementById('ObjectListViewport_TD_Footer' + list_id)){ + footer = getObjectHeight('ObjectListViewport_TD_Footer' + list_id); + }else{ + footer = 0 } - /* Return integer value of style attribute height for specified ID */ - function getObjectHeight(obj){ - if(document.getElementById(obj)){ - obj = getComputedStyle(document.getElementById(obj),"").height; - return(parseInt(obj.replace(/px/,''))); - }else{ - return(0); - } + /* Calculate the new visible entry part height. */ + calc = (viewport - ( header + footer )); + document.getElementById('ObjectListViewport_Entry_Cover' + list_id).style.height = calc; + + /* Reduce width of entry list, we need some space to + * display the scrollbar without breaking the layout + * Only required if a header is shown. + */ + if(document.getElementById('ObjectListViewport_TD_Header' + list_id)){ + viewport_w = getObjectWidth('ObjectListViewport_Table' + list_id); + document.getElementById('ObjectListViewport_Entry_Table' + list_id).style.width = (viewport_w - 18) + 'px'; + document.getElementById('ObjectListViewport_Header_Table' + list_id).style.width = (viewport_w - 18) + 'px'; } + } +} + + +/* Return all elements of a specific class */ +function getElementsByStyleClass (className) { + var all = document.all ? document.all : document.getElementsByTagName('*'); + var elements = new Array(); + for (var e = 0; e < all.length; e++) + if (all[e].className == className) + elements[elements.length] = all[e]; + return elements; +} + + +/* Return integer value of style attribute width for specified ID */ +function getObjectWidth(obj){ + if(document.getElementById(obj)){ + obj = getComputedStyle(document.getElementById(obj),"").width; + return(parseInt(obj.replace(/px/,''))); + }else{ + return(0); + } +} + +/* Return integer value of style attribute height for specified ID */ +function getObjectHeight(obj){ + if(document.getElementById(obj)){ + obj = getComputedStyle(document.getElementById(obj),"").height; + return(parseInt(obj.replace(/px/,''))); + }else{ + return(0); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/tests/ListTest/ObjectListViewport.tpl b/tests/ListTest/ObjectListViewport.tpl index 5619ce35e..c5f96f7a5 100644 --- a/tests/ListTest/ObjectListViewport.tpl +++ b/tests/ListTest/ObjectListViewport.tpl @@ -6,6 +6,15 @@ + {if $OLV_Multiselect_Enabled} + + {/if} {foreach from=$OLV_Header key=key item=item} {/foreach} @@ -19,6 +28,13 @@
+ + {$item.name}
{foreach from=$OLV_Entries key=key item=item} + {if $OLV_Multiselect_Enabled} + + {/if} {foreach from=$item.cols key=key2 item=item2}
+ +
-- 2.30.2