public static function one(&$options, $name, $alt = null, $convert = true) { if (!$convert && is_array($options)) { return isset($options[$name]) ? $options[$name] : $alt; } $options = Options::make($options); return $options->get($name, $alt); }
public function __construct($connection, $connect = true) { $this->connectionArgs = Options::make($connection, Options::make(array('host' => 'localhost'))); if ($connect) { $this->connect(); $this->connectionArgs = null; } $this->_fire('init'); }
protected function _init() { // overridable _POST and _GET $this->post = Options::make($_POST); $this->get = Options::make($_GET); $this->user = SessionUser::user(); // overridable Output / View / Template engine $O = Output::$class; $this->tpl = new $O($this); }
public function resolveRoute($route, $uri) { // routes have a leading / $path = '/' . $uri; // make a nice little regex $from = $route->from; $from = trim($from, '^ /'); if (!$this->dispatcher->options->case_sensitive_paths) { $from = strtolower($from); $path = strtolower($path); } $from = $this->routeToRegex($from, $route); $from = '^/' . $from; $from = '#' . $from . '#'; // regex the path if (0 < preg_match($from, $path, $match)) { // NULL, Array, String or Closure $to = $route->to; if (null === $to) { // Array $to = $match; } else { if (is_callable($to)) { // String or Array $to = $to($match, $uri); } } if (is_string($to)) { $options = Options::make($route->options); $match[0] = preg_replace('/%(\\d+)/', '%\\1$s', $to); $goto = call_user_func_array('sprintf', $match); if ($options->redirect) { return $this->redirect($goto, $options->redirect); } return $goto; } else { if (is_array($to)) { // any implicit arguments? if (!isset($to['arguments'])) { // arguments from regex if (1 < count($match)) { $to['arguments'] = array_slice($match, 1); } } // return Location Array return $to; } } } }
public function getOptions() { return Options::make(array('default_action' => 'index', 'not_found_exception' => 'row\\http\\NotFoundException', 'module_class_prefix' => '', 'module_class_postfix' => 'Controller', 'action_name_prefix' => '', 'action_name_postfix' => 'Action', 'action_path_wildcards' => array('#' => '(\\d+)', '%' => '([^/]+)', '*' => '(.+)', 'DATE' => '(\\d{4}-\\d\\d?\\-\\d\\d?)'), 'case_sensitive_paths' => false)); }
public function __construct($rules, $options = array()) { $this->rules = $rules; $this->options = Options::make($options, Options::make(array('errors' => Options::make(array('notEmpty' => 'Must submit value', 'regex' => 'Invalid value format'))))); }
public final function __construct(\row\Controller $application, $options = array()) { $this->application = $application; $this->options = Options::make($options); $this->_fire('init'); }
function options($options) { return Options::make($options); }
public function &useElements() { if (!$this->_elements) { if (!is_a($this->defaults, 'row\\database\\Model') && !is_a($this->defaults, 'row\\core\\Options')) { $this->defaults = Options::make((array) $this->defaults); } $elements = array(); $index = 0; foreach ($this->elements($this->defaults) as $name => $element) { $element['_name'] = $name; $element['_index'] = $index++; $this->elementTitle($element); $elements[$name] = $element; } $this->_elements = $elements; } return $this->_elements; }
public static function translate($text, $replace = array(), $options = array()) { $options = Options::make($options); if ($replace) { $text = static::replace($text, $replace); } if ($options->get('ucfirst', true)) { $text = ucfirst($text); } return $text; }