From 3c7ca20d94b00963eefe928c940d55310be77ee7 Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 2 Nov 2007 15:22:01 +0000 Subject: [PATCH] Added filter iterrator, corrected objectlists git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7721 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/autoload-data.inc | 2 +- include/class_ObjectList.inc | 52 +++------------------- include/class_ObjectListFilterIterator.inc | 26 +++++++++++ include/class_ObjectListViewport.inc | 27 +++++++---- 4 files changed, 51 insertions(+), 56 deletions(-) create mode 100644 include/class_ObjectListFilterIterator.inc diff --git a/include/autoload-data.inc b/include/autoload-data.inc index f8e01599f..38a326835 100644 --- a/include/autoload-data.inc +++ b/include/autoload-data.inc @@ -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 diff --git a/include/class_ObjectList.inc b/include/class_ObjectList.inc index 51d59ec51..a0ca9e4c9 100644 --- a/include/class_ObjectList.inc +++ b/include/class_ObjectList.inc @@ -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 index 000000000..c71bcda91 --- /dev/null +++ b/include/class_ObjectListFilterIterator.inc @@ -0,0 +1,26 @@ + + \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: +?> diff --git a/include/class_ObjectListViewport.inc b/include/class_ObjectListViewport.inc index e7ed7911e..568ea0477 100644 --- a/include/class_ObjectListViewport.inc +++ b/include/class_ObjectListViewport.inc @@ -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); } -- 2.30.2