00001 <?php
00002
00003
00004
00005 class WidgetAlphaPager implements IWidget {
00006 const LINK_TO_SUBPAGES = 256;
00007 const INCLUDE_NUMERIC = 4096;
00008
00009 public $selected = '';
00010 public $base_url = '';
00011
00012 public static function output($policy = self::LINK_TO_SUBPAGES, $base_url = '', $selected = '') {
00013 $w = new WidgetAlphaPager($base_url, $selected);
00014 return $w->render($policy);
00015 }
00016
00017 public function __construct($base_url, $selected) {
00018 $this->selected = $selected;
00019 $this->base_url = $base_url ? $base_url : Url::current()->build(Url::RELATIVE);
00020 $this->base_url = rtrim($this->base_url, '/') . '/';
00021 }
00022
00023 public function render($policy = self::NONE) {
00024 $letters = range('a', 'z');
00025 if (Common::flag_is_set($policy, self::INCLUDE_NUMERIC)) {
00026 array_unshift($letters, '0-9');
00027 }
00028 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/alphapager');
00029 $view->assign('letters', $letters);
00030 $view->assign('base_url', $this->base_url);
00031 $view->assign('selected', $this->selected);
00032 $view->assign('policy', $policy);
00033 return $view->render();
00034 }
00035 }