Beispiel #1
0
 /**
  * checkbox
  * create input type checkbox.
  *
  * @param	string value
  * @param	bool checked or not
  * @param	array attributes
  *
  * @return string tag input type checkbox
  */
 public function checkbox($name, $value = '', $checked = false, $params = array())
 {
     $id = $class = $this->generateId();
     $type = 'checkbox';
     $defaults = compact('name', 'value', 'id', 'class', 'type');
     if (Request::isMethod('post')) {
         $checked = $value === $this->catchValue($name);
     }
     if (true === $checked) {
         $defaults['checked'] = 'checked';
     }
     if (!is_bool($checked)) {
         $params = $checked;
     }
     return '<input ' . $this->addAttributes($params, $defaults) . ($this->html5 ? ' >' : ' />') . "\n";
 }
Beispiel #2
0
 /**
  * handle
  * add handler for request.
  *
  * @param   [mixed]
  */
 public function handle($param)
 {
     if (func_num_args() > 3) {
         // throw new Exception('Parameter is only accepted maximal 3 arguments');
     }
     $params = func_get_args();
     $handler = array_pop($params);
     $callback = is_object($handler) && method_exists($handler, 'bindTo') ? $handler->bindTo($this, $this) : $handler;
     if (count($params) > 1) {
         $methods = array_shift($params);
         foreach ((array) $methods as $method) {
             if (Http\Request::isMethod($method)) {
                 foreach ((array) $params[0] as $key) {
                     if (!$this->routeCollection->has($key)) {
                         $this->routeCollection->add($key, $callback);
                     }
                 }
             }
         }
     } else {
         foreach ((array) $params[0] as $key) {
             if ($this->routeCollection->has($key)) {
                 continue;
             }
             $this->routeCollection->add($key, $callback);
         }
     }
     return $this;
 }