.

WidgetList Class Reference
[View]

A generic list. More...

Inheritance diagram for WidgetList:
IWidget IRenderer

List of all members.

Public Member Functions

  __construct (PageData $page_data, IView $parent_view, $items, $empty_message= '')
  render ($policy=self::NONE)
  Renders what should be rendered.

Static Public Member Functions

static  output (PageData $page_data, IView $parent_view, $items, $empty_message= '', $policy=self::NONE)

Protected Member Functions

  render_items ($page_data, $items, $policy)

Protected Attributes

  $empty_message
  $items
  $page_data
  $parent_view

Detailed Description

A generic list.

Author:
Gerd Riesselmann

Definition at line 8 of file list.widget.php.


Constructor & Destructor Documentation

WidgetList::__construct ( PageData page_data,
IView parent_view,
items,
empty_message = ''  
)

Definition at line 19 of file list.widget.php.

00019                                                                                                           {
00020                 $this->page_data = $page_data;
00021                 $this->parent_view = $parent_view;
00022                 $this->items = $items;
00023                 $this->empty_message = $empty_message;  
00024         } 

Member Function Documentation

static WidgetList::output ( PageData page_data,
IView parent_view,
items,
empty_message = '',
policy = self::NONE  
) [static]

Definition at line 14 of file list.widget.php.

00014                                                                                                                                 {
00015                 $widget = new WidgetList($page_data, $parent_view, $items, $empty_message);
00016                 return $widget->render($policy);                        
00017         } 
WidgetList::render ( policy = self::NONE  ) 

Renders what should be rendered.

Parameters:
int  $policy Defines how to render, meaning depends on implementation
Returns:
string The rendered content

Implements IRenderer.

Definition at line 26 of file list.widget.php.

00026                                                    {
00027                 $ret = '';
00028                 $items = Arr::force($this->items, false);
00029                 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/list');
00030                 $view->assign('page_data', $this->page_data);
00031                 $view->assign('parent_view', $this->parent_view);
00032                 $view->assign('items', $this->render_items($this->page_data, $items, $policy));
00033                 $view->assign('policy', $policy);
00034                 $view->assign('empty_message', $this->empty_message);
00035                 $ret = $view->render();
00036                 return $ret;
00037         }
WidgetList::render_items ( page_data,
items,
policy  
) [protected]

Definition at line 39 of file list.widget.php.

00039                                                                      {
00040                 $ret = array();
00041                 $i = 1;
00042                 $c = count($items);
00043                 foreach($items as $item) {
00044                         $cls = array('listitem');
00045                         if ($item instanceof IDataObject) {
00046                                 $cls[] = 'listitem-' . $item->get_table_name();
00047                         }
00048                         if ($i == 1) { $cls[] = 'first'; }
00049                         if ($i == $c) { $cls[] = 'last'; }
00050                         $ret[] = html::div(WidgetListItem::output($item, $policy), implode(' ', $cls));
00051                         $i++;
00052                 }               
00053                 return $ret;
00054         }

Member Data Documentation

WidgetList::$empty_message [protected]

Definition at line 12 of file list.widget.php.

WidgetList::$items [protected]

Definition at line 11 of file list.widget.php.

WidgetList::$page_data [protected]

Definition at line 9 of file list.widget.php.

WidgetList::$parent_view [protected]

Definition at line 10 of file list.widget.php.


The documentation for this class was generated from the following file: