public function __construct(IContext &$context, CalendarModel &$model) { parent::__construct($model); $this->_context =& $context; $this->_mode = $context->getParam('mode'); if (is_null($this->_mode)) { $this->_mode = self::MODE_READ; } $this->_range = $context->getParam('range'); if (is_null($this->_range)) { $this->_range = self::VIEW_ANNUAL; } $model->setController($this); }
protected $data = array(); public function set(Expression $e, $value) { $this->data[$e->getKey()] = $value; } public function get(Expression $e) { return $this->data[$e->getKey()]; } // Custom functions protected static $sFunctions = array(); protected $functions = array(); public static function regSFunction($name, $foo) { static::$sFunctions[$name] = $foo; } public function regFunction($name, $foo) { $this->functions[$name] = $foo; } public function getFunction($name) { return isset($this->functions[$name]) ? $this->functions[$name] : (isset(static::$sFunctions[$name]) ? static::$sFunctions[$name] : null); } } IContext::regSFunction('trim', function ($str) { return trim($str); }); IContext::regSFunction('concat', function () { return implode('', func_get_args()); });