00001 <?php
00002
00003
00004
00005
00006
00007
00008 class WidgetActionLink implements IWidget {
00009 public $action;
00010 public $params;
00011 public $attrs;
00012 public $text;
00013
00014 public static function output($text, $action, $params = null, $html_attrs = array()) {
00015 $w = new WidgetActionLink($text, $action, $params, $html_attrs);
00016 return $w->render();
00017 }
00018
00019 public function __construct($text, $action, $params = null, $html_attrs = array()) {
00020 $this->text = $text;
00021 $this->action = $action;
00022 $this->attrs = $html_attrs;
00023 $this->params = $params;
00024 }
00025
00026 public function render($policy = self::NONE) {
00027 $text = ($this->text instanceof ISelfDescribing) ? String::escape($this->text->get_title()) : $this->text;
00028 return html::a(
00029 $text,
00030 ActionMapper::get_path($this->action, $this->params),
00031 '',
00032 $this->attrs
00033 );
00034 }
00035 }