コード例 #1
0
 /**
  * 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
  * @param  array   $parameters
  * @return mixed
  */
 public static function __callStatic($method, $parameters)
 {
     $method_array = explode('_', strtolower($method));
     $function = 'table';
     $parameters = Helpers::set_multi_class_attributes($function, $method_array, $parameters, 1, 'table-');
     return call_user_func_array('static::' . $function, $parameters);
 }
コード例 #2
0
ファイル: icons.php プロジェクト: manishnakar/critterapp
 /**
  * Allows magic methods such as Icons::home([attributes]) or Icons::close_white()
  *
  * @param  string $method
  * @param  array  $attributes
  * @return string
  */
 public static function __callStatic($method, $parameters)
 {
     // Explode method name
     $method = explode('_', strtolower($method));
     // Get icon name
     $method_array = array(array_get($method, 0));
     // Set facultative white flag
     if (array_get($method, sizeof($method) - 1) == 'white') {
         $method_array[] = 'white';
     }
     // Prepend icon- to classes
     $parameters = Helpers::set_multi_class_attributes(null, $method_array, $parameters, 0, 'icon-');
     return '<i' . HTML::attributes($parameters[0]) . '></i>';
 }
コード例 #3
0
 /**
  * Allows magic methods such as Icons::home([attributes]) or Icons::close_white()
  * 
  * Sample Usage:
  * <code>
  * <?php
  * Icons::plus();
  * // <i class="icon-plus"></i>
  * Icons::folder_open(array('class'=>'widget','data-foo'=>'bar'));
  * // <i class="widget icon-folder-open" data-foo="bar"></i> 
  * Icons::circle_arrow_right_white();
  * // <i class="icon-circle-arrow-right icon-white"></i>
  * ?>
  * </code>
  *
  * @param  string $method
  * @param  array  $attributes
  * @return string
  */
 public static function __callStatic($method, $attributes)
 {
     // Explode method name
     $method_bits = explode('_', strtolower($method));
     //white icon variant? (when using glyphicons sprite version)
     $white = in_array('white', $method_bits);
     //remove the white!
     $method_bits = array_filter($method_bits, function ($val) {
         return $val != 'white';
     });
     // Get icon name
     $icon_classes = array(implode('-', $method_bits));
     if ($white) {
         $icon_classes[] = 'white';
     }
     // Prepend icon- to classes
     $parameters = Helpers::set_multi_class_attributes(null, $icon_classes, $attributes, 0, 'icon-');
     return '<i' . HTML::attributes($parameters[0]) . '></i>';
 }
コード例 #4
0
ファイル: Icon.php プロジェクト: farhan4648gul/developer-side
 /**
  * Allows magic methods such as Icon::home([attributes]) or Icon::close_white()
  *
  * Sample Usage:
  * <code>
  * <?php
  * Icon::plus();
  * // <i class="icon-plus"></i>
  * Icon::folder_open(array('class'=>'widget','data-foo'=>'bar'));
  * // <i class="widget icon-folder-open" data-foo="bar"></i>
  * Icon::circle_arrow_right_white();
  * // <i class="icon-circle-arrow-right icon-white"></i>
  * ?>
  * </code>
  *
  * @param string $method     Name of missing method
  * @param array  $parameters array of parameters passed to missing method
  *
  * @return string
  */
 public static function __callStatic($method, $parameters)
 {
     // Explode method name
     $method_bits = explode('_', strtolower($method));
     // White icon variant? (when using glyphicons sprite version)
     $white = in_array('white', $method_bits);
     // Remove white from array
     $method_bits = array_filter($method_bits, function ($val) {
         return $val != 'white';
     });
     // Get icon name
     $icon_classes = array(implode('-', $method_bits));
     if ($white) {
         $icon_classes[] = 'white';
     }
     // If the parameters weren't put into an array, do it
     if (!isset($parameters[0])) {
         $parameters = array(0 => $parameters);
     }
     // Prepend icon- to classes
     $parameters = Helpers::set_multi_class_attributes(null, $icon_classes, $parameters, 0, Config::get('icons_prefix'));
     return '<i' . HTML::attributes($parameters[0]) . '></i>';
 }
コード例 #5
0
ファイル: form.php プロジェクト: manishnakar/critterapp
 /**
  * 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
  * @param  array   $parameters
  * @return mixed
  */
 protected static function magic_input($method, $parameters)
 {
     //.input-
     //$sizes = array('mini' , 'small', 'medium', 'large', 'xlarge', 'xxlarge');
     $types = array('input', 'text', 'password', 'uneditable', 'select', 'multiselect', 'file', 'textarea', 'date', 'number', 'url', 'telephone', '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;
             case 'textarea':
                 //textarea($name, $value = '', $attributes = array())
                 //Covers all the other methods
                 if (!isset($parameters[1])) {
                     $parameters[1] = '';
                 }
                 $attr_index = 2;
                 break;
             default:
                 //text($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');
         return call_user_func_array('static::' . $function, $parameters);
     }
 }
コード例 #6
0
ファイル: Form.php プロジェクト: Vrian7ipx/cascadadev
    /**
     * 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 functions
                    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;
            }
            if (in_array($function, $types)) {
                $attributes = isset($parameters[$attr_index]) ? $parameters[$attr_index] : array('class' => '');
                $attributes['class'] = isset($attributes['class']) ? $attributes['class'] . ' form-control' : 'form-control';
                $parameters[$attr_index] = $attributes;
            }
            $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);
        } else {

            try {
                //Try solving a macro
                return parent::__callStatic($method, $parameters);
            } catch (\BadMethodCallException $e) {
                //Silences in case there is no macro and continues execution
            }

        }

        array_unshift($parameters, $method);

        return call_user_func_array('parent::input', $parameters);
    }
コード例 #7
0
 /**
  * Checks call to see if we can create a button from a magic call (for you wizards).
  * success_button, mini_primary_button, large_warning_submit, danger_reset, etc...
  *
  * @param string $method     Name of missing method
  * @param array  $parameters array of parameters passed to missing method
  *
  * @return mixed
  */
 public static function __callStatic($method, $parameters)
 {
     $method_array = explode('_', strtolower($method));
     $btn_types = array('normal', 'submit', 'reset', 'link');
     $type_found = array_intersect($method_array, $btn_types);
     if (!$type_found) {
         $type_found = (array) 'normal';
     }
     if (count($type_found) > 0) {
         $function = $type_found[key($type_found)];
         // Set default attributes index
         $attr_index = $function != 'link' ? 1 : 2;
         $parameters = Helpers::set_multi_class_attributes($function, $method_array, $parameters, $attr_index, 'btn-', 'disabled');
         if (in_array('disabled', $method_array)) {
             $parameters[$attr_index]['disabled'] = 'disabled';
         }
         return call_user_func_array('static::' . $function, $parameters);
     }
 }
コード例 #8
-1
ファイル: Table.php プロジェクト: kreezxil/TechnicSolder
 /**
  * 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 = Config::get('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;
     }
 }