/** * Checks call to see if we can create a table from a magic call (for you wizards). * hover_striped, bordered_condensed, etc. * * @param string $method Method name * @param array $parameters Method parameters * * @return mixed */ public static function __callStatic($method, $parameters) { // Opening a table if (str_contains($method, 'open') or $method == 'open') { $method = strtolower($method); $classes = explode('_', $method); $method = array_pop($classes); // Fallback to default type if defined if (sizeof($classes) == 0) { $classes = Helpers::getContainer('config')->get('bootstrapper::table.classes'); } // Filter table classes $classes = array_intersect($classes, static::$classes); $attributes = Helpers::set_multi_class_attributes($method, $classes, $parameters, 0, 'table-'); $attributes = array_get($attributes, 0); static::$table = new static($attributes); return static::$table->open(); } // Set default function if (!$method) { $method = 'table'; } // Use cases switch ($method) { case 'close': $close = static::table()->close(); static::$table = null; return $close; break; default: return call_user_func_array(array(static::table(), $method), $parameters); break; } }
/** * Checks call to see if we can create an input from a magic call (for you wizards). * large_text, xlarge_textarea, small_number, etc... * * @param string $method Name of missing method * @param array $parameters array of parameters passed to missing method * * @return mixed */ protected static function magic_input($method, $parameters) { //$sizes = array('mini' , 'small', 'medium', 'large', 'xlarge', 'xxlarge', 'span1', 'span2', 'span3', 'span4', 'span5', 'span6', 'span7', 'span8', 'span9', 'span10', 'span11', 'span12'); $types = array('input', 'text', 'password', 'uneditable', 'select', 'multiselect', 'file', 'textarea', 'date', 'number', 'url', 'tel', 'email', 'search'); $method_array = explode('_', strtolower($method)); $type_found = array_intersect($method_array, $types); if (count($type_found) > 0) { $function = $type_found[key($type_found)]; $attr_index = 0; switch ($function) { case 'password': case 'file': case 'uneditable': // password($name, $attributes = array()) // Set attributes array and call function $attr_index = 1; break; case 'input': // input($type, $name, $value = null, $attributes = array()) // Set defaults and attributes array and call function if (!isset($parameters[2])) { $parameters[2] = null; } $attr_index = 3; break; case 'select': case 'multiselect': // select($name, $options = array(), $selected = null, $attributes = array()) // Set defaults and attributes array and call function if (!isset($parameters[1])) { $parameters[1] = array(); } if (!isset($parameters[2])) { $parameters[2] = null; } $attr_index = 3; break; default: // text($name, $value = null, $attributes = array()) // textarea($name, $value = null, $attributes = array()) // Covers all the other methods if (!isset($parameters[1])) { $parameters[1] = null; } $attr_index = 2; break; } $parameters = Helpers::set_multi_class_attributes($function, $method_array, $parameters, $attr_index, 'input-', 'span'); $method = $function; } if (method_exists('Bootstrapper\\Form', $method)) { return call_user_func_array('static::' . $method, $parameters); } elseif (method_exists(static::getFacadeAccessor(), $method)) { return parent::__callStatic($method, $parameters); } array_unshift($parameters, $method); return call_user_func_array('parent::input', $parameters); }