Code

Modified test1 to use smarty
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 12 Nov 2007 14:42:52 +0000 (14:42 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 12 Nov 2007 14:42:52 +0000 (14:42 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7778 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_ObjectListViewport.inc
tests/ListTest/1/index.php
tests/ListTest/2/index.php
tests/ListTest/3/index.php
tests/ListTest/ObjectListViewport.js
tests/ListTest/ObjectListViewport.tpl [new file with mode: 0644]

index 08c5632bdca412137155109729f7d8171aedb5b4..477fd41321dc98b6470c9df43fec309c602fcb8d 100644 (file)
@@ -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 =" <tr>
-              <td class='ObjectListViewport_TD_Header' id='ObjectListViewport_TD_Header_".$this->id."'>
-                <table class='ObjectListViewport_Header_Table' id='ObjectListViewport_Header_Table_".$this->id."'>
-                  <tr>
-                    {content}
-                  </tr>
-                </table>
-             </td>
-           </tr>";
-    $buffer ="";
-    foreach($this->headline as $key => $value){
-      $buffer .= "<td class='ObjectListViewport_Header_Cell' style='".$value['style']."'>".$value['name']."</td>\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 ="<tr>
-              <td class='ObjectListViewport_TD_Footer' id='ObjectListViewport_TD_Footer_".$this->id."'>
-                <table class='ObjectListViewport_Footer_Table'>
-                  <tr>
-                    <td class='ObjectListViewport_Footer_Cell' colspan='".count($this->headline)."'>".$this->footer."</td>
-                  </tr>
-                </table>     
-              </td>
-           </tr>";
-    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 =" <tr>
+#            <td class='ObjectListViewport_TD_Header' id='ObjectListViewport_TD_Header_".$this->id."'>
+#              <table class='ObjectListViewport_Header_Table' id='ObjectListViewport_Header_Table_".$this->id."'>
+#                <tr>
+#                  {content}
+#                </tr>
+#              </table>
+#           </td>
+#         </tr>";
+#  $buffer ="";
+#  foreach($this->headline as $key => $value){
+#    $buffer .= "<td class='ObjectListViewport_Header_Cell' style='".$value['style']."'>".$value['name']."</td>\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 ="<tr>
+#            <td class='ObjectListViewport_TD_Footer' id='ObjectListViewport_TD_Footer_".$this->id."'>
+#              <table class='ObjectListViewport_Footer_Table'>
+#                <tr>
+#                  <td class='ObjectListViewport_Footer_Cell' colspan='".count($this->headline)."'>".$this->footer."</td>
+#                </tr>
+#              </table>     
+#            </td>
+#         </tr>";
+#  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 = "
-    <table class='ObjectListViewport' id='ObjectListViewport_".$this->id."' cellspacing=0 cellpadding=0>
-      <tr>
-        <td>
-              <table class='ObjectListViewport_Table' id='ObjectListViewport_Table_".$this->id."' cellpadding=0 cellspacing=0 >
-                ".$header."
-                <tr>
-                  <td class='ObjectListViewport_TD_Entries' id='ObjectListViewport_TD_Entries_".$this->id."'>
-                    <div class='ObjectListViewport_Entry_Cover' id='ObjectListViewport_Entry_Cover_".$this->id."'> 
-                      <table class='ObjectListViewport_Entry_Table' id='ObjectListViewport_Entry_Table_".$this->id."'>
-                        ".$entries."
-                      </table> 
-                    </div>
-                  </td>
-                </tr>
-                ".$footer."
-              </table>
-
-        </td>
-      </tr>
-    </table>
-";
-
-    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 .= "<td class='ObjectListViewport_Header_Cell' style='".$value['style']."'>".$value['name']."</td>\n";
+    }
+
+    return($smarty->fetch("ObjectListViewport.tpl"));
   }
 
 
index e7d3430f9dec5661ffbc5d2b06bc7c5e5a766506..79e7afcaff5c82551f018271ec70607e4134922a 100644 (file)
@@ -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");
index df138401f9d0c5590b0c9be4b94f390fed8515ec..bd7b3d0ba8e5cd70f9c73ef76bb920ab2aa38297 100644 (file)
@@ -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");
index cb0134748b59dcd7b35a15402cb0863b0d4dc15c..e4f58136a0642d81031db71ad974af3115d10926 100644 (file)
@@ -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");
index 9df1d33cc3dadc62b852fba71d49017f95dc3895..3404deb2a6e1ca2721d1aa7267ee047aa8f8ec6a 100644 (file)
@@ -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 (file)
index 0000000..b3bfb5b
--- /dev/null
@@ -0,0 +1,39 @@
+<table class='ObjectListViewport' id='ObjectListViewport_{$OLV_List_Id}' cellspacing=0 cellpadding=0>
+      <tr>
+        <td>
+                 <table class='ObjectListViewport_Table' id='ObjectListViewport_Table_{$OLV_List_Id}' cellpadding=0 cellspacing=0 >
+                       <tr>
+              <td class='ObjectListViewport_TD_Header' id='ObjectListViewport_TD_Header_{$OLV_List_Id}'>
+                <table class='ObjectListViewport_Header_Table' id='ObjectListViewport_Header_Table_{$OLV_List_Id}'>
+                  <tr>
+
+                                       {foreach from=$OLV_Header key=key item=item}
+                                               <td class='ObjectListViewport_Header_Cell' style='{$item.style}'>{$item.name}</td>
+                                       {/foreach}
+                  </tr>
+                </table>
+              </td>
+            </tr>
+                       <tr>
+                         <td class='ObjectListViewport_TD_Entries' id='ObjectListViewport_TD_Entries_{$OLV_List_Id}'>
+                               <div class='ObjectListViewport_Entry_Cover' id='ObjectListViewport_Entry_Cover_{$OLV_List_Id}'>
+                                 <table class='ObjectListViewport_Entry_Table' id='ObjectListViewport_Entry_Table_{$OLV_List_Id}'>
+                                       {$OLV_Entries}
+                                 </table>
+                               </div>
+                         </td>
+                       </tr>
+                       <tr>
+              <td class='ObjectListViewport_TD_Footer' id='ObjectListViewport_TD_Footer_{$OLV_List_Id}'>
+                <table class='ObjectListViewport_Footer_Table'>
+                  <tr>
+                    <td class='ObjectListViewport_Footer_Cell' colspan='{$OLV_Num_Cols}'>{$OLV_Footer_Message}</td>
+                  </tr>
+                </table>
+              </td>
+            </tr>
+                 </table>
+        </td>
+      </tr>
+    </table>
+