Code

Added playground
[gosa.git] / include / class_ObjectListViewport.inc
1 <?php
3 /*! \brief   Exception implementation for ObjectListViewport
4     \author  Cajus Pollmeier <pollmeier@gonicus.de>
5     \version 1.00
6     \date    2007/11/02
8     This class handles the exceptions occuring in ObjectListViewport.
9  */
10 class ObjectListViewportException extends Exception {
11         public function __construct($message, $code = 0) {
12                 parent::__construct($message, $code);
13         }
14 }
15  
17 /*! \brief   Implementation for ObjectListViewport
18     \author  Cajus Pollmeier <pollmeier@gonicus.de>
19     \version 1.00
20     \date    2007/11/02
22     This class handles painting of ObjectList objects.
24     \sa ObjectList
25  */
26 class ObjectListViewport {
28   /*!
29     \brief Container for objects
31     This variable stores the ObjectList object to be displayed.
32    */
33         private $objects;
36   /*! \brief ObjectListViewport constructor
38     The ObjectListViewport class renders/handles the ObjectList defined by $config.
40     \param config Config section that is used to configure this ObjectListViewport
41    */
42         public function __construct($config){
44     /* Load and instanciate classes, extract filter, icons, view hooks, etc. */
45     $this->objects= new ObjectList($config);
46   }
48         /*! \brief Handles _POST / _GET events
50             Processes the list of registered plugins to do their eventHandler and adapt
51       internal objectlist according to this.
52          */
53   public function eventHandler(){
54     /* Reloads the list if things have changed interally */
55     $this->objects->reload();
56   }
59         /*! \brief Renders headline into a string
61             Gets the headline description from the ObjectList object and renders it.
63       \return HTML rendered headline
64          */
65   private function renderHeadline(){
66     return $this->objects->getHeadline()."\n";
67   }
70         /*! \brief Renders footer into a string
72             Gets the footer description from the ObjectList object and renders it.
74       \return HTML rendered footer
75          */
76   private function renderFooter(){
77     return $this->objects->getFooter()."\n";
78   }
81         /*! \brief Renders entries from the ObjectList iterator into a string
83             Gets the entry descriptions from the ObjectList object and renders them.
85       \return HTML rendered list entries
86          */
87   private function renderEntry($entry){
88     $buffer= "|";
89     foreach ($entry as $column){
90       $buffer.= "$column|";
91     }
92     $buffer.= "\n";
94     return $buffer;
95   }
98         /*! \brief Renders complete ObjectList into a string
100       \return HTML rendered list
101          */
102   public function render() {
103     /* Generate fixed headline */
104     $buffer= $this->renderHeadline();
106     /* Generate scrollable contents */
107     foreach ($this->objects as $value){
108       $buffer.= $this->renderEntry($value);
109     }
111     /* Generate footer */
112     $buffer.= $this->renderFooter();
114     return ($buffer);
115   }
119 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
120 ?>