summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c7ca20)
raw | patch | inline | side by side (parent: 3c7ca20)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 2 Nov 2007 16:53:33 +0000 (16:53 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 2 Nov 2007 16:53:33 +0000 (16:53 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-playground@7722 594d385d-05f5-0310-b6e9-bd551577e9d8
include/autoload-data.inc | patch | blob | history | |
include/class_ObjectList.inc | patch | blob | history | |
include/class_ObjectListFilterIterator.inc | patch | blob | history | |
include/class_ObjectListViewport.inc | patch | blob | history | |
include/class_objectListEntryFilter.inc | [new file with mode: 0644] | patch | blob |
include/class_objectListEntryFilter_uppercase.inc | [new file with mode: 0644] | patch | blob |
index 38a3268358d9cc013ab7837c58baa72badc506a7..b08c3f543b3266e57b7e00aa1caff30694f6a46f 100644 (file)
"AutoloadException" => "include/autoload.inc",
"ObjectListException" => "include/class_ObjectList.inc",
"ObjectList" => "include/class_ObjectList.inc",
+ "ObjectListEntryFilter" => "include/class_objectListEntryFilter.inc",
+ "ObjectListEntryFilter_uppercase" => "include/class_objectListEntryFilter_uppercase.inc",
"ObjectListFilterIterator" => "include/class_ObjectListFilterIterator.inc",
"ObjectListViewportException" => "include/class_ObjectListViewport.inc",
"ObjectListViewport" => "include/class_ObjectListViewport.inc",
"ObjectListIterator" => "include/class_ObjectListIterator.inc",
);
-?>
\ No newline at end of file
+?>
index a0ca9e4c9ecbf9da8cb350f1dca2ee2ce247c4c2..9185c7b42713f98af0b0c5ce2456180c3318fdc3 100644 (file)
private function load(){
# Crap filling
$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"),
+ array("dn" => "cn=Demo client,ou=systems,dc=gonicus,dc=de", "cn" => "Demo client", "_icon" => "s_terminal.png", "_actions" => "ED", "objectClass" => array('gotoWorkstation')),
+ array("dn" => "cn=Demo client2,ou=systems,dc=gonicus,dc=de", "cn" => "Demo client2", "_icon" => "s_terminal.png", "_actions" => "ED", "objectClass" => array('gotoWorkstation')),
+ array("dn" => "cn=Printer,ou=systems,dc=gonicus,dc=de", "cn" => "Printer", "_icon" => "s_printer.png", "_actions" => "ED", "objectClass" => array('gotoPrinter')),
+ array("dn" => "cn=Server,ou=systems,dc=gonicus,dc=de", "cn" => "Server", "_icon" => "s_server.png", "_actions" => "ED", "objectClass" => array("goServer")),
);
}
diff --git a/include/class_ObjectListFilterIterator.inc b/include/class_ObjectListFilterIterator.inc
index c71bcda9142e6555185a31e99db72bbde9047f1c..91cf5b19d5e8afde619b202c5861cc5829cf5a70 100644 (file)
This class handles filtering of ObjectList iterators.
*/
class ObjectListFilterIterator extends FilterIterator {
- private $filter;
- public function __construct(ObjectListIterator $objectListIterator, $filter) {
+ public function __construct(ObjectListIterator $objectListIterator) {
parent::__construct($objectListIterator);
- $this->filter = $filter;
}
public function accept() {
$current = $this->getInnerIterator()->current();
-
+
+ /* This is a dummy, currently. Accept everything. */
return TRUE;
}
}
index 568ea0477b707e157780f4b9eb6e5d48f96fcf96..330dbfc6c6cc416a7e8285531476e60809a5fd1c 100644 (file)
class ObjectListViewport {
# DUMMY values ---->
- private $headline= "|{16px}|{90%}Name|{64px}Actions|";
+ private $headline= "|{16px}|{90%}Name|{64px:R}Actions|";
private $footer= "Statistics with no information currently";
+ private $entryFormat= "|{_icon}|{cn} ({_filter(uppercase,{cn})})|{_actions}|";
+ private $attributes= array('cn', '_icon', '_actions', 'dn');
# <--- DUMMY values.
/*!
# Dummy implementation. Use pre-defined headline.
$buffer= $this->headline."\n";
+ #TODO: Make $buffer a proper HTML table output
return $buffer;
}
*/
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){
- # 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";
}
+ /*! \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
$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);
}
diff --git a/include/class_objectListEntryFilter.inc b/include/class_objectListEntryFilter.inc
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+/*! \brief Interface for ObjectListEntryFilter objects.
+ \author Cajus Pollmeier <pollmeier@gonicus.de>
+ \version 1.00
+ \date 2007/11/02
+
+ This interface describes what we need to filter a string
+ for use with list objects.
+ */
+interface ObjectListEntryFilter {
+ static public function filter($string);
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/class_objectListEntryFilter_uppercase.inc b/include/class_objectListEntryFilter_uppercase.inc
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+/*! \brief Implements a sample ObjectListEntryFilter interface.
+ \author Cajus Pollmeier <pollmeier@gonicus.de>
+ \version 1.00
+ \date 2007/11/02
+
+ This class converts entries in lists to upper case.
+ */
+class ObjectListEntryFilter_uppercase implements ObjectListEntryFilter {
+ static public function filter($string) {
+ return strtoupper($string);
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>