Code

Added filter iterrator, corrected objectlists
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 2 Nov 2007 15:22:01 +0000 (15:22 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 2 Nov 2007 15:22:01 +0000 (15:22 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7721 594d385d-05f5-0310-b6e9-bd551577e9d8

include/autoload-data.inc
include/class_ObjectList.inc
include/class_ObjectListFilterIterator.inc [new file with mode: 0644]
include/class_ObjectListViewport.inc

index f8e01599fc244de277d168fd8282a9729efc83f3..38a3268358d9cc013ab7837c58baa72badc506a7 100644 (file)
@@ -6,9 +6,9 @@ $class_mapping= array(
                 "AutoloadException" => "include/autoload.inc",
                 "ObjectListException" => "include/class_ObjectList.inc",
                 "ObjectList" => "include/class_ObjectList.inc",
+                "ObjectListFilterIterator" => "include/class_ObjectListFilterIterator.inc",
                 "ObjectListViewportException" => "include/class_ObjectListViewport.inc",
                 "ObjectListViewport" => "include/class_ObjectListViewport.inc",
-                "ObjectListIteratorException" => "include/class_ObjectListIterator.inc",
                 "ObjectListIterator" => "include/class_ObjectListIterator.inc",
 );
 ?>
\ No newline at end of file
index 51d59ec51aeed61d84627eccd2dc8cfb3539deb6..a0ca9e4c9ecbf9da8cb350f1dca2ee2ce247c4c2 100644 (file)
@@ -34,24 +34,6 @@ class ObjectList implements IteratorAggregate {
    */
        private $objects;
 
-  /*!
-    \brief List headline
-
-    String that keeps the desired headline. Returned by ObjectList::getHeadline.
-
-    \sa ObjectList::getHeadline
-   */
-  private $headline;
-
-  /*!
-    \brief List footer
-
-    String that keeps the desired footer. Returned by ObjectList::getFooter.
-
-    \sa ObjectList::getFooter
-   */
-  private $footer;
-
   /*!
     \brief Config
 
@@ -87,12 +69,12 @@ class ObjectList implements IteratorAggregate {
         */
        private function load(){
     # Crap filling
-    $this->objects= array( array("i", "Testobjekt mit was auch immer", "UPS"),
-                           array("i", "Noch ein Testobjekt", "UPS"),
-                           array("d", "Ein drittes Testobjekt", "UL"));
-    $this->headline= "|{16px}|{90%}Name|{64px}Actions|";
-
-    $this->footer= "Statistical footer";
+    $this->objects= array(
+                            array("dn" => "cn=Demo client,ou=systems,dc=gonicus,dc=de", "cn" => "Demo client", "_icon" => "s_terminal.png", "_actions" => "ED"),
+                            array("dn" => "cn=Demo client2,ou=systems,dc=gonicus,dc=de", "cn" => "Demo client2", "_icon" => "s_terminal.png", "_actions" => "ED"),
+                            array("dn" => "cn=Printer,ou=systems,dc=gonicus,dc=de", "cn" => "Printer", "_icon" => "s_printer.png", "_actions" => "ED"),
+                            array("dn" => "cn=Server,ou=systems,dc=gonicus,dc=de", "cn" => "Server", "_icon" => "s_server.png", "_actions" => "ED"),
+                           );
        }
 
 
@@ -117,28 +99,6 @@ class ObjectList implements IteratorAggregate {
     return new ObjectListIterator($this->objects);
   }
 
-
-       /*! \brief Function to get the desired headline
-
-      Return the property of headline to the public world.
-
-      \return headline for current list
-        */
-  public function getHeadline() {
-    return $this->headline;
-  }
-
-
-       /*! \brief Function to get the desired footer
-
-      Return the property of footer to the public world.
-
-      \return headline for current list
-        */
-  public function getFooter() {
-    return $this->footer;
-  }
-
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/include/class_ObjectListFilterIterator.inc b/include/class_ObjectListFilterIterator.inc
new file mode 100644 (file)
index 0000000..c71bcda
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+/*! \brief   Implements a list filter for ObjectList objects
+    \author  Cajus Pollmeier <pollmeier@gonicus.de>
+    \version 1.00
+    \date    2007/11/02
+
+    This class handles filtering of ObjectList iterators.
+ */
+class ObjectListFilterIterator extends FilterIterator {
+  private $filter;
+  public function __construct(ObjectListIterator $objectListIterator, $filter) {
+    parent::__construct($objectListIterator);
+    $this->filter = $filter;
+  }
+  public function accept() {
+    $current = $this->getInnerIterator()->current();
+    return TRUE;
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index e7ed7911e2cce8d63cf8eb38faafed981b17790b..568ea0477b707e157780f4b9eb6e5d48f96fcf96 100644 (file)
@@ -25,6 +25,11 @@ class ObjectListViewportException extends Exception {
  */
 class ObjectListViewport {
 
+  # DUMMY values ---->
+  private $headline= "|{16px}|{90%}Name|{64px}Actions|";
+  private $footer= "Statistics with no information currently";
+  # <--- DUMMY values.
+
   /*!
     \brief Container for objects
 
@@ -63,7 +68,10 @@ class ObjectListViewport {
       \return HTML rendered headline
         */
   private function renderHeadline(){
-    return $this->objects->getHeadline()."\n";
+    # Dummy implementation. Use pre-defined headline.
+    $buffer= $this->headline."\n";
+
+    return $buffer;
   }
 
 
@@ -74,7 +82,9 @@ class ObjectListViewport {
       \return HTML rendered footer
         */
   private function renderFooter(){
-    return $this->objects->getFooter()."\n";
+    # Dummy implementation. Use pre-defined footer.
+    $buffer= $this->footer;
+    return "|".$buffer."|\n";
   }
 
 
@@ -85,13 +95,11 @@ class ObjectListViewport {
       \return HTML rendered list entries
         */
   private function renderEntry($entry){
-    $buffer= "|";
-    foreach ($entry as $column){
-      $buffer.= "$column|";
-    }
-    $buffer.= "\n";
 
-    return $buffer;
+    # Dummy implenetation. It is interested in icon, cn and action
+    $buffer= "|".$entry['_icon']."|".$entry['cn']."|".$entry['_actions']."|";
+
+    return $buffer."\n";
   }
 
 
@@ -103,7 +111,8 @@ class ObjectListViewport {
     /* Generate fixed headline */
     $buffer= $this->renderHeadline();
 
-    /* Generate scrollable contents */
+    /* Apply current filter */
+    $filterIterator = new ObjectListFilterIterator($this->objects->getIterator(), 'dummy');
     foreach ($this->objects as $value){
       $buffer.= $this->renderEntry($value);
     }