index 568ea0477b707e157780f4b9eb6e5d48f96fcf96..da9b985084f882b25c048ac7fdce62874a24887e 100644 (file)
*/
class ObjectListViewport {
*/
class ObjectListViewport {
- # DUMMY values ---->
- private $headline= "|{16px}|{90%}Name|{64px}Actions|";
- private $footer= "Statistics with no information currently";
- # <--- DUMMY values.
+ /* Dummy here ----> */
+ private $headline;
+ private $footer;
+ private $entryFormat;
+ private $attributes= array('cn', '_icon', '_actions', 'dn');
+ /* <---- Dummy here */
/*!
\brief Container for objects
/*!
\brief Container for objects
*/
private $objects;
*/
private $objects;
+ /*!
+ \brief Switch to handle multiselect or not
+ */
+ private $multiselect;
+
/*! \brief ObjectListViewport constructor
/*! \brief ObjectListViewport constructor
\param config Config section that is used to configure this ObjectListViewport
*/
\param config Config section that is used to configure this ObjectListViewport
*/
- public function __construct($config){
+ public function __construct($config, $multiselect= TRUE){
+
+ $this->multiselect= $multiselect;
+ /* Dummy here */
+ $cr= Registry::getInstance("ConfigManager");
+ $cr->setSection($config);
+ $this->headline= $cr->getValue("headline");
+ $this->footer= $cr->getValue("footer");
+ $this->entryFormat= $cr->getValue("entryFormat");
/* Load and instanciate classes, extract filter, icons, view hooks, etc. */
$this->objects= new ObjectList($config);
/* Load and instanciate classes, extract filter, icons, view hooks, etc. */
$this->objects= new ObjectList($config);
# Dummy implementation. Use pre-defined headline.
$buffer= $this->headline."\n";
# Dummy implementation. Use pre-defined headline.
$buffer= $this->headline."\n";
+ #TODO: Make $buffer a proper HTML table output
return $buffer;
}
return $buffer;
}
*/
private function renderFooter(){
# Dummy implementation. Use pre-defined footer.
*/
private function renderFooter(){
# Dummy implementation. Use pre-defined footer.
- $buffer= $this->footer;
- return "|".$buffer."|\n";
+ $buffer= "|".$this->footer."|";
+
+ #TODO: Make $buffer a proper HTML table output
+ return $buffer."|\n";
}
}
*/
private function renderEntry($entry){
*/
private function renderEntry($entry){
- # Dummy implenetation. It is interested in icon, cn and action
- $buffer= "|".$entry['_icon']."|".$entry['cn']."|".$entry['_actions']."|";
+ /* Copy template */
+ $buffer= $this->entryFormat;
+
+ /* Replace set of attributes */
+ foreach ($this->attributes as $attribute){
+ if (!isset($entry[$attribute])){
+ throw new ObjectListViewportException(sprintf(_("Can't locate attribute '%s' to replace in entry!"), $attribute));
+ } else {
+ $buffer= preg_replace('/\{'.$attribute.'\}/', $entry[$attribute],$buffer);
+ }
+ }
+
+ /* Execute optional filters */
+ preg_match_all ( '/\{_filter\(([^)]+)\)\}/', $buffer, $matches, PREG_SET_ORDER);
+ foreach ($matches as $match){
+ $filterName= preg_replace('/,.+$/', '', $match[1]);
+ $filterParameter= preg_replace('/^[^,]+,/', '', $match[1]);
+ $buffer= preg_replace('/\{_filter\('.$match[1].'\)\}/', $this->applyEntryFilter($filterName, $filterParameter), $buffer);
+ }
+
+ #TODO: Make $buffer a proper HTML table output
return $buffer."\n";
}
return $buffer."\n";
}
+ /*! \brief Applies filter to the given entry format string.
+
+ Instanciates the given ObjectListEntryFilter and calls the method.
+
+ \return rendered output
+ \sa ObjectListEntryFilter
+ */
+ private function applyEntryFilter($filterName, $string){
+ $className= "ObjectListEntryFilter_".$filterName;
+ $cl= new $className;
+ return $cl->filter("$string");
+ }
+
+
/*! \brief Renders complete ObjectList into a string
\return HTML rendered list
/*! \brief Renders complete ObjectList into a string
\return HTML rendered list
$buffer= $this->renderHeadline();
/* Apply current filter */
$buffer= $this->renderHeadline();
/* Apply current filter */
- $filterIterator = new ObjectListFilterIterator($this->objects->getIterator(), 'dummy');
- foreach ($this->objects as $value){
+ $objects= new ObjectListFilterIterator($this->objects->getIterator());
+ foreach ($objects as $value){
$buffer.= $this->renderEntry($value);
}
$buffer.= $this->renderEntry($value);
}