From 109a0cbe1d354fa4049ef7ab9b235c0ae5123929 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 12 Nov 2007 14:42:52 +0000 Subject: [PATCH] Modified test1 to use smarty git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7778 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ObjectListViewport.inc | 136 ++++++++++++-------------- tests/ListTest/1/index.php | 18 +++- tests/ListTest/2/index.php | 4 +- tests/ListTest/3/index.php | 4 +- tests/ListTest/ObjectListViewport.js | 2 +- tests/ListTest/ObjectListViewport.tpl | 39 ++++++++ 6 files changed, 121 insertions(+), 82 deletions(-) create mode 100644 tests/ListTest/ObjectListViewport.tpl diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index 08c5632bd..477fd4132 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -108,48 +108,48 @@ class ObjectListViewport implements 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; - } +#/*! \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; +#} /* TODO: replace this -> not our task */ @@ -247,14 +247,6 @@ class ObjectListViewport implements GOsaGuiElement { */ public function render() { - $header = $footer = ""; - if($this->displayHeaderFlag){ - $header = $this->renderHeadline(); - } - if($this->displayFooterFlag){ - $footer = $this->renderFooter(); - } - /* Apply current filter */ $entries = ""; $objects= new ObjectListFilterIterator($this->objects->getIterator()); @@ -262,31 +254,25 @@ class ObjectListViewport implements GOsaGuiElement { $entries .= $this->renderEntry($value); } - /* Generate fixed headline */ - $buffer = " - - - - -
- - ".$header." - - - - ".$footer." -
-
- - ".$entries." -
-
-
- -
-"; - - return ($buffer); + $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); + + /* Assign Headline values */ + $smarty->assign("OLV_Header_Enabled",$this->displayHeaderFlag); + $smarty->assign("OLV_Header",$this->headline); + + $buffer =""; + foreach($this->headline as $key => $value){ + $buffer .= "".$value['name']."\n"; + } + + return($smarty->fetch("ObjectListViewport.tpl")); } diff --git a/tests/ListTest/1/index.php b/tests/ListTest/1/index.php index e7d3430f9..79e7afcaf 100644 --- a/tests/ListTest/1/index.php +++ b/tests/ListTest/1/index.php @@ -23,14 +23,28 @@ function normalizePreg($input) } +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); +} + + /* Initiate autoloader... */ -require_once("../../include/autoload.inc"); +require_once("../../../include/autoload.inc"); restore_error_handler(); try { /* Get new test instance of the Configuration */ $cr= Registry::getInstance("ConfigManager"); - $cr->load("../../gosa.conf"); + $cr->load("../../../gosa.conf"); /* Get a new test instance of ObjectListViewports */ $vp= new ObjectListViewport("plugin/sample"); diff --git a/tests/ListTest/2/index.php b/tests/ListTest/2/index.php index df138401f..bd7b3d0ba 100644 --- a/tests/ListTest/2/index.php +++ b/tests/ListTest/2/index.php @@ -45,13 +45,13 @@ function normalizePreg($input) /* Initiate autoloader... */ -require_once("../../include/autoload.inc"); +require_once("../../../include/autoload.inc"); restore_error_handler(); try { /* Get new test instance of the Configuration */ $cr= Registry::getInstance("ConfigManager"); - $cr->load("../../gosa.conf"); + $cr->load("../../../gosa.conf"); /* Get a new test instance of ObjectListViewports */ $vp= new ObjectListViewport("plugin/sample"); diff --git a/tests/ListTest/3/index.php b/tests/ListTest/3/index.php index cb0134748..e4f58136a 100644 --- a/tests/ListTest/3/index.php +++ b/tests/ListTest/3/index.php @@ -45,13 +45,13 @@ function normalizePreg($input) /* Initiate autoloader... */ -require_once("../../include/autoload.inc"); +require_once("../../../include/autoload.inc"); restore_error_handler(); try { /* Get new test instance of the Configuration */ $cr= Registry::getInstance("ConfigManager"); - $cr->load("../../gosa.conf"); + $cr->load("../../../gosa.conf"); /* Get a new test instance of ObjectListViewports */ $vp1= new ObjectListViewport("plugin/sample"); diff --git a/tests/ListTest/ObjectListViewport.js b/tests/ListTest/ObjectListViewport.js index 9df1d33cc..3404deb2a 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(/[^0-9]*/,""); + list_id = all[i].id.replace(/^.*_/,"_"); /* 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 new file mode 100644 index 000000000..b3bfb5b03 --- /dev/null +++ b/tests/ListTest/ObjectListViewport.tpl @@ -0,0 +1,39 @@ + + + + +
+ + + + + + + + + + +
+ + + + {foreach from=$OLV_Header key=key item=item} + + {/foreach} + +
{$item.name}
+
+
+ + {$OLV_Entries} +
+
+
+
+ -- 2.30.2