示例#1
0
 public static function link_to()
 {
     $args = func_get_args();
     $options = array_pop($args);
     if (isset($options['fn'])) {
         array_push($args, PHP_EOL . $options['fn']());
     }
     return \Hook\Framework\Helper::link_to($args, $options['hash']);
 }
示例#2
0
 public static function input($args, $attributes)
 {
     if (!isset($attributes['name']) && isset($args[0])) {
         // TODO: analyse context recursively
         if (Router::getInstance()->view->context->count() > 0) {
             $attributes['name'] = Router::getInstance()->view->context->top() . '[' . $args[0] . ']';
         } else {
             $attributes['name'] = $args[0];
         }
     }
     if (isset($attributes['options'])) {
         return \Hook\Framework\Helper::select($args, $attributes);
     }
     // use 'text' as default input type
     if (!isset($attributes['type'])) {
         $is_type_as_name = in_array($attributes['name'], array('email', 'password', 'date'));
         $attributes['type'] = $is_type_as_name ? $attributes['name'] : 'text';
     }
     return array('<input' . html_attributes($attributes) . ' />', 'raw');
 }