.

WidgetAlphaList Class Reference

Prints list, and ALPHA pager. More...

Inheritance diagram for WidgetAlphaList:
IWidget IRenderer

List of all members.

Public Member Functions

  __construct ($items, $params)
  render ($policy=self::NONE)

Static Public Member Functions

static  output ($items, $params=array(), $policy=self::LINK_TO_SUBPAGES)
  Constructor.

Public Attributes

  $items
  $params
const  INCLUDE_NUMERIC = 4096
const  LINK_TO_FRAGMENT = 0
  Link to fragment (Letter) from pager.
const  LINK_TO_SUBPAGE_BELOW_SECTION = 1024
  Put a lin kto subpages below each section.
const  LINK_TO_SUBPAGES = 256
  Link to subpages Url::current() + letter from pager.
const  NO_PAGER = 512
  Do not print a pager.

Detailed Description

Prints list, and ALPHA pager.

Definition at line 5 of file alphalist.widget.php.


Constructor & Destructor Documentation

WidgetAlphaList::__construct ( items,
params  
)

Definition at line 41 of file alphalist.widget.php.

00041                                                      {
00042                 $this->items = $items;
00043                 $this->params = $params;
00044         }

Member Function Documentation

static WidgetAlphaList::output ( items,
params = array(),
policy = self::LINK_TO_SUBPAGES  
) [static]

Constructor.

Parameters:
array  $params associative array with members 'css_class' and 'more_title'

Definition at line 33 of file alphalist.widget.php.

00033                                                                                                  {
00034                 if (is_string($params)) {
00035                         $params = array('css_class' => $params);
00036                 }
00037                 $w = new WidgetAlphaList($items, $params);
00038                 return $w->render($policy);
00039         }
WidgetAlphaList::render ( policy = self::NONE  ) 

Implements IRenderer.

Definition at line 46 of file alphalist.widget.php.

00046                                                    {
00047                 $ret = '';
00048                 if (count($this->items) > 10) {
00049                         if (!Common::flag_is_set($policy, self::NO_PAGER)) {
00050                                 $ret .= WidgetAlphaPager::output($policy);
00051                         }
00052 
00053                         $data = array_fill_keys(range('a', 'z'), array());
00054                         if (Common::flag_is_set($policy, self::INCLUDE_NUMERIC)) {
00055                                 $data = array_merge(array('0-9' => array()), $data);
00056                         }
00057                         // TODO Does not handle numbers
00058                         foreach($this->items as $key => $value) {
00059                                 $clean = String::plain_ascii($key);
00060                                 $data[substr($clean, 0, 1)][] = $value;
00061                         }
00062 
00063                         $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/alphalist', false);
00064                         $view->assign('data', $data);
00065                         $view->assign('items', $this->items);
00066                         $view->assign('params', $this->params);
00067                         $view->assign('policy', $policy);
00068                 }
00069                 else {
00070                         ksort($this->items);
00071                         $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/alphalist/empty', false);
00072                 }
00073                 $view->assign('items', $this->items);
00074                 $view->assign('params', $this->params);
00075                 $view->assign('policy', $policy);
00076                 $ret .= $view->render();
00077                 return $ret;
00078         }       

Member Data Documentation

WidgetAlphaList::$items

Definition at line 25 of file alphalist.widget.php.

WidgetAlphaList::$params

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

Definition at line 23 of file alphalist.widget.php.

Link to fragment (Letter) from pager.

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

Put a lin kto subpages below each section.

Definition at line 21 of file alphalist.widget.php.

Link to subpages Url::current() + letter from pager.

Definition at line 13 of file alphalist.widget.php.

Do not print a pager.

Definition at line 17 of file alphalist.widget.php.


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