function fform_submit($data = '', $value = '', $extra = '')
 {
     $defaults = array('type' => 'submit', 'name' => !is_array($data) ? $data : '', 'value' => $value);
     if (!function_exists('_parse_form_attributes')) {
         return "The Foundation Form Helper requires the Form Helper, please load that first!";
     }
     return "<input " . _parse_form_attributes($data, $defaults) . $extra . " />";
 }
/**
 * Form Element Requirement Indicator
 *
 * Creates the indicator that shows if a form element is required
 *
 * @param  string  the character or characters to show as the indication of requirement
 * @param  array   a key/value pair of attributes
 */
function input_requirement($indicator = '', $data = '')
{
    // ID isn't really a default. It's just here so it is applied before class, which is my preference.
    if (!empty($data['id'])) {
        $defaults['id'] = $data['id'];
    }
    $defaults['class'] = 'input-requirement';
    if (empty($indicator)) {
        $indicator = '&nbsp;';
    }
    return '<div ' . rtrim(_parse_form_attributes($data, $defaults)) . ">" . $indicator . '</div>';
}
function smarty_function_picture($params, $template)
{
    $src = smarty_plugin_get_variable($params, $template, 'src', true);
    $alt = smarty_plugin_get_variable($params, $template, 'alt');
    $path = smarty_plugin_get_variable($params, $template, 'path');
    $CI =& get_instance();
    $CI->load->helper('image');
    $file = find_file($src, 'static/img/');
    // Try to find the image in static/img
    if ($file == null) {
        // We can't read the file
        $file = find_file($src, 'static/uploads/');
        if ($file == null) {
            $src = 'default.png';
        }
    }
    $size = get_image_size($src);
    $size = $size['width'];
    $attr = $params;
    $medias = array();
    $ret = array();
    $attr['src'] = $src;
    if ($path != '') {
        $attr['path'] = site_url($path);
    }
    $ret[] = '<picture ' . _parse_form_attributes($attr, array()) . ' >';
    foreach ($params as $key => $value) {
        // Check if user has set the customized media
        if (strpos($key, 'media') !== false) {
            $media = str_replace('media', '', $key);
            $medias[] = $media;
            $ret[] = "\t" . '<source src="' . site_url('responsive/size/' . $value . '/' . $src) . '" media="(min-width:' . $media . 'px)">';
            continue;
        }
        $attr[$key] = smarty_plugin_get_variable($params, $template, $key, false);
    }
    if ($path == '') {
        $resolutions = get_ci_config('resolutions');
        foreach ($resolutions as $res) {
            if (array_search($res, $medias) !== false) {
                // If the resolution is already covered
                continue;
            }
            $ret[] = "\t" . '<source src="' . site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src) . '" media="(min-width:' . $res . 'px)">';
        }
    }
    $ret[] = "\t" . '<noscript>';
    $ret[] = "\t\t" . '<img src="' . site_url('static/img/' . $src) . '" alt="' . $alt . '">';
    $ret[] = "\t" . '</noscript>';
    $ret[] = '</picture>';
    return implode("\n", $ret);
}
function chainned_dropdown($data = '', $options = array(), $selected = array(), $extra = '', $extra_options = '')
{
    $defaults = array();
    if (is_array($data)) {
        if (isset($data['selected'])) {
            $selected = $data['selected'];
            unset($data['selected']);
            // select tags don't have a selected attribute
        }
        if (isset($data['options'])) {
            $options = $data['options'];
            unset($data['options']);
            // select tags don't use an options attribute
        }
    } else {
        $defaults = array('name' => $data);
    }
    is_array($selected) or $selected = array($selected);
    is_array($options) or $options = array($options);
    // If no selected state was submitted we will attempt to set it automatically
    if (empty($selected)) {
        if (is_array($data)) {
            if (isset($data['name'], $_POST[$data['name']])) {
                $selected = array($_POST[$data['name']]);
            }
        } elseif (isset($_POST[$data])) {
            $selected = array($_POST[$data]);
        }
    }
    $extra = _attributes_to_string($extra);
    $extra_options = _attributes_to_string($extra_options);
    $multiple = count($selected) > 1 && stripos($extra, 'multiple') === FALSE ? ' multiple="multiple"' : '';
    $form = '<select ' . rtrim(_parse_form_attributes($data, $defaults)) . $extra . $multiple . ">\n";
    foreach ($options as $key => $val) {
        $key = (string) $key;
        if (is_array($val)) {
            if (empty($val)) {
                continue;
            }
            $form .= '<optgroup label="' . $key . "\">\n";
            foreach ($val as $optgroup_key => $optgroup_val) {
                $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                $form .= '<option ' . $extra_options . ' value="' . html_escape($optgroup_key) . '"' . $sel . '>' . (string) $optgroup_val . "</option>\n";
            }
            $form .= "</optgroup>\n";
        } else {
            $form .= '<option ' . $extra_options . ' value="' . html_escape($key) . '"' . (in_array($key, $selected) ? ' selected="selected"' : '') . '>' . (string) $val . "</option>\n";
        }
    }
    return $form . "</select>\n";
}
function smarty_block_select($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $attr = get_attr($params, $template);
    $options = get_default($params, 'options', array());
    $selected = get_default($params, 'selected', array());
    $extra = _parse_form_attributes($attr, array());
    if (count($selected) == 0) {
        $selected = $attr['value'];
    }
    return form_dropdown($attr['name'], $options, $selected, $extra);
}
示例#6
0
function smarty_block_figure($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        // Skip the start part
        return;
    }
    $src = smarty_plugin_get_variable($params, $template, 'src', true);
    $path = smarty_plugin_get_variable($params, $template, 'path');
    $size = get_image_size($src);
    $size = $size['width'];
    if ($path == '') {
        // If we are using auto resizing, skip the resolutions
        $resolutions = get_ci_config('resolutions');
        foreach ($resolutions as $res) {
            $attr['data-media' . $res] = site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src);
        }
    }
    foreach ($params as $key => $value) {
        if ($key == 'path') {
            $attr[$key] = site_url(get_smarty_variable($params, $template, 'path', $value));
            continue;
        }
        if (strpos($key, 'media') !== false) {
            $attr['data-' . $key] = site_url('responsive/size/' . $value . '/' . $src);
        } else {
            $attr[$key] = get_smarty_variable($params, $template, $value, $value);
        }
    }
    $ret = array();
    $ret[] = '<figure ' . _parse_form_attributes($attr, array()) . '>';
    if (isset($attr['action'])) {
        $ret[] = '<a href="' . $attr['action'] . '">';
    }
    $ret[] = '<noscript>';
    $ret[] = '<img src="' . site_url('static/img/' . $src) . '">';
    $ret[] = '</noscript>';
    if (isset($attr['action'])) {
        $ret[] = '</a>';
    }
    $ret[] = '<figcaption>';
    $ret[] = $content;
    $ret[] = '</figcaption>';
    $ret[] = '</figure>';
    return implode("\n", $ret);
}
示例#7
0
function arras_form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
{
    $defaults = array('type' => 'checkbox', 'name' => !is_array($data) ? $data : '', 'value' => $value);
    if (is_array($data) and array_key_exists('checked', $data)) {
        $checked = $data['checked'];
        if ($checked == FALSE) {
            unset($data['checked']);
        } else {
            $data['checked'] = 'checked';
        }
    }
    if ($checked == TRUE) {
        $defaults['checked'] = 'checked';
    } else {
        unset($defaults['checked']);
    }
    return "<input " . _parse_form_attributes($data, $defaults) . $extra . " />";
}
示例#8
0
function smarty_block_select($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $attr = get_attr($params, $template);
    $field = get_field($params, $template);
    $CI =& get_instance();
    if (isset($field->model)) {
        $CI->load->model($field->model);
        $parent_vars = $template->parent->tpl_vars;
        $form_data = get_form_data($parent_vars);
        $options = widget_select_get_options(get_default($params, 'options', array()), $form_data, $field, $CI->{$field->model});
    } else {
        $options = get_default($params, 'options', array());
    }
    $attr['url'] = current_url();
    if (isset($field->filters)) {
        $hasfield = false;
        $rel = array();
        foreach ($field->filters as $key => $filter) {
            if (isset($filter->field)) {
                $rel[] = $filter->field;
                $hasfield = true;
            }
        }
        if ($hasfield) {
            $attr['data-rel'] = implode(',', $rel);
        }
    }
    if (isset($params['noselectboxit']) && $params['noselectboxit'] != '') {
        $attr["data-no-selectBoxIt"] = true;
    }
    $parent_vars = $template->parent->tpl_vars;
    $form_data = get_form_data($parent_vars);
    $selected = get_default($params, 'selected', array());
    $extra = _parse_form_attributes($attr, array());
    if (count($selected) == 0) {
        $selected = $attr['value'];
    }
    return form_dropdown($attr['name'], $options, $selected, $extra);
}
示例#9
0
 /**
  * Returns a properly templated dropdown field.
  *
  * @param string $data    The element name or an array of key/value pairs of
  * all attributes.
  * @param array  $options  Array of options for the drop down list.
  * @param string $selected The selected item or an array of selected items.
  * @param string $label   The label of the element.
  * @param string $extra   Any additional items to include, like Javascript.
  * @param string $tooltip A string for inline help or a tooltip icon.
  *
  * @return string The formatted input element, label tag and wrapping divs.
  */
 function ras_form_dropdown($data, $options = array(), $selected = array(), $label = '', $extra = '', $tooltip = '')
 {
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     if (!isset($data['id'])) {
         $data['id'] = $data['name'];
     }
     $output = _parse_form_attributes($data, array());
     if (!is_array($selected)) {
         $selected = array($selected);
     }
     // If no selected option was submitted, attempt to set it automatically
     if (count($selected) === 0) {
         // If the name appears in the $_POST array, grab the value
         if (isset($_POST[$data['name']])) {
             $selected = array($_POST[$data['name']]);
         }
     }
     $options_vals = '';
     foreach ($options as $key => $val) {
         $key = (string) $key;
         if (is_array($val) && !empty($val)) {
             $options_vals .= "<optgroup label='{$key}'>" . PHP_EOL;
             foreach ($val as $optgroup_key => $optgroup_val) {
                 $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                 $options_vals .= "<option value='{$optgroup_key}'{$sel}>{$optgroup_val}</option>" . PHP_EOL;
             }
             $options_vals .= '</optgroup>' . PHP_EOL;
         } else {
             $sel = in_array($key, $selected) ? ' selected="selected"' : '';
             $options_vals .= "<option value='{$key}'{$sel}>{$val}</option>" . PHP_EOL;
         }
     }
     $error = '';
     if (function_exists('form_error') && form_error($data['name'])) {
         $error = ' error';
         $tooltip = '<span class="help-inline">' . form_error($data['name']) . '</span>';
     }
     return "\n<div class='form-group{$error}'>\n    <label class='col-sm-2 control-label' for='{$data['id']}'>{$label}</label>\n    <div class='col-sm-10'>\n         <select {$output} {$extra}>\n            {$options_vals}\n        </select>\n        {$tooltip}\n    </div>\n</div>";
 }
示例#10
0
 function form_input_date_restrict($data = '', $value = '', $extra = '')
 {
     $defaults = array('type' => 'text', 'name' => !is_array($data) ? $data : '', 'value' => $value);
     return "<input " . _parse_form_attributes($data, $defaults) . $extra . " class=\"datepicker-restrict\"/>";
 }
示例#11
0
 function form_datelonglabel($name, $label, $required = FALSE, $value = '', $data = '')
 {
     $defaults = array('name' => $name, 'id' => $name, 'value' => set_value($name, $value));
     $output = '<div class="control-group' . (form_error($name) ? ' error' : '') . '">';
     $output .= form_label($label, $name, array('class' => 'control-label'));
     $output .= '<div class="controls">';
     $output .= "<input " . _parse_form_attributes($data, $defaults) . " />";
     if ($required) {
         $output .= '<div class="input-append">';
     }
     if ($required) {
         $output .= '<span class="add-on"><i class="icon-asterisk"></i></span></div>';
     }
     $output .= form_error($name, '<span class="help-inline">', '</span>');
     $output .= '</div>';
     $output .= '</div>' . "\r\n";
     return $output;
 }
示例#12
0
function build_tag($tag, $params, $content)
{
    $attr = array();
    foreach ($params as $key => $value) {
        $attr[$key] = $value;
    }
    $ret = array();
    $ret[] = '<' . $tag . ' ' . _parse_form_attributes($attr, array()) . '>';
    $ret[] = $content;
    $ret[] = '</' . $tag . '>';
    return implode("\n", $ret);
}
function form_textarea_formatted($data = '', $value = '', $extra = '')
{
    $defaults = array('name' => !is_array($data) ? $data : '', 'cols' => '40', 'rows' => '10');
    $prefix = "<p>";
    $suffix = "</p>";
    if (!is_array($data) or !isset($data['value'])) {
        $val = $value;
    } else {
        $val = $data['value'];
        unset($data['value']);
        // textareas don't use the value attribute
    }
    if (isset($data['label']) && isset($data['id'])) {
        $prefix = $prefix . '<label>' . $data['label'] . '</label>';
    }
    $name = is_array($data) ? $data['name'] : $data;
    return $prefix . "<textarea " . _parse_form_attributes($data, $defaults) . $extra . ">" . form_prep($val, $name) . "</textarea>" . $suffix;
}
示例#14
0
    function build_field($field, $label = true, $settings = array())
    {
        //$default = array('name', 'type','settings','class','default','placeholder','id'=>'');
        $fiel = $this->parse_field($field);
        extract($fiel);
        $class = isset($class) && $class ? 'form-control ' . $class : 'form-control';
        if ($label && !$placeholder) {
            do_action('sh_form_before_label', $field);
            echo form_label($placeholder, $name);
            do_action('sh_form_after_label', $field);
        }
        if ($placeholder) {
            $settings['attrs']['placeholder'] = $placeholder;
        }
        $settings['attrs']['class'] = $class;
        $default = sh_set($settings, $name) ? sh_set($settings, $name) : $default;
        switch ($this->type) {
            case "input":
                $html['element'] = form_input(array_merge(array('name' => $name, 'type' => $type, 'value' => '', 'id' => $id), (array) $settings['attrs']));
                break;
            case "dropdown":
                $settings['attrs'] = _parse_form_attributes('', array_merge((array) $settings['attrs'], array('id' => $name)));
                $html['element'] = form_dropdown($name, $options, _WSH()->validation->set_value($name, $default), $settings['attrs']);
                break;
            case "multiselect":
                $size = count($settings['value']) < 10 ? count($settings['value']) * 20 : 220;
                $settings['attrs'] = array_to_string(array_merge((array) $settings['attrs'], array('id' => $field, 'style' => "height:" . $size . "px;")));
                $html['element'] = form_multiselect($field . '[]', $settings['value'], _WSH()->validation->set_value($name, $default_value), $settings['attrs']);
                break;
            case "textarea":
                $settingsvalue = empty($user_settings[$name]) ? sh_set($settings, 'value') : $user_settings[$name];
                $html['element'] = form_textarea(array_merge(array('name' => $name, 'value' => _WSH()->validation->set_value($name, $settingsvalue), 'id' => $name), (array) $settings['attrs']));
                break;
            case "switch":
                $html['element'] = '';
                $checked = sh_set($user_settings, $field) == 'on' ? 'checked="checked"' : '';
                $html['element'] = '<span class="form_style switch"><input type="checkbox" name="' . $field . '" ' . $checked . '></span>';
                break;
            case 'file':
                $html['element'] = '<span class="file_upload">';
                $html['element'] .= form_input(array_merge(array('name' => $field, 'value' => $default_value, 'id' => $field), (array) $settings['attrs'])) . '<input type="file" onchange="this.form.' . $field . '.value = this.value" class="fileUpload" name="' . $field . '_file" id="fileUpload">
									<em>' . __('UPLOAD', THEME_NAME) . '</em>';
                $html['element'] .= '</span>';
                $html['preview'] = '';
                if (sh_set($user_settings, $field)) {
                    $html['preview'] = sh_set($user_settings, $field);
                }
                break;
            case "checkbox":
            case "radio":
                $html['element'] = '<div class="clearfix">';
                foreach ($settings['value'] as $key => $val) {
                    $html['element'] .= form_radio($field, $key, $default_value == $key ? true : '', $settings['attrs']) . '<label class="' . $settings['type'] . ' cont-lable" for="' . $field . '"> ' . $val . '</label>' . '';
                }
                $html['element'] .= '</div>';
                break;
            case "colorbox":
                $html['element'] = form_input(array_merge(array('name' => $field, 'value' => $default_value, 'id' => $field, 'class' => 'nuke-color-field'), (array) $settings['attrs']));
                break;
            case "timepicker":
                $html['element'] = form_input(array_merge(array('name' => $field, 'value' => $default_value, 'id' => $field), (array) $settings['attrs']));
                break;
            case "hidden":
                $html['label'] = '';
                $html['element'] = form_input(array_merge(array('type' => 'hidden', 'name' => $field, 'value' => $default_value, 'id' => $field), sh_set($settings, 'attrs')));
                break;
        }
        do_action('sh_form_before_field', $fiel);
        echo $html['element'];
        do_action('sh_form_after_field', $fiel);
    }
示例#15
0
    /**
     * Returns a properly templated date dropdown field.
     *
     * @param string $data     Either a string with the element name, or an array of key/value pairs of all attributes.
     * @param array  $options  Array of options for the drop down list
     * @param string $selected Either a string of the selected item or an array of selected items
     * @param string $label    A string with the label of the element.
     * @param string $extra    A string with any additional items to include, like Javascript.
     * @param string $tooltip  A string for inline help or a tooltip icon
     *
     * @return string A string with the formatted input element, label tag and wrapping divs.
     */
    function form_dropdown($data, $options = array(), $selected = '', $label = '', $extra = '', $tooltip = '', $extra_html = '')
    {
        $defaults = array('name' => !is_array($data) ? $data : '');
        // If name is empty at this point, try to grab it from the $data array
        if (empty($defaults['name']) && is_array($data) && isset($data['name'])) {
            $defaults['name'] = $data['name'];
            unset($data['name']);
        }
        $output = _parse_form_attributes($data, $defaults);
        if (!is_array($selected)) {
            $selected = array($selected);
        }
        // If no selected state was submitted we will attempt to set it automatically
        if (count($selected) === 0) {
            // If the form name appears in the $_POST array we have a winner!
            if (isset($_POST[$data['name']])) {
                $selected = array($_POST[$data['name']]);
            }
        }
        $options_vals = '';
        foreach ($options as $key => $val) {
            $key = (string) $key;
            if (is_array($val) && !empty($val)) {
                $options_vals .= '<optgroup label="' . $key . '">' . PHP_EOL;
                foreach ($val as $optgroup_key => $optgroup_val) {
                    $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                    $options_vals .= '<option value="' . $optgroup_key . '"' . $sel . '>' . (string) $optgroup_val . "</option>\n";
                }
                $options_vals .= '</optgroup>' . PHP_EOL;
            } else {
                $sel = in_array($key, $selected) ? ' selected="selected"' : '';
                $options_vals .= '<option value="' . $key . '"' . $sel . '>' . (string) $val . "</option>\n";
            }
        }
        $error = '';
        if (function_exists('form_error')) {
            if (form_error($defaults['name'])) {
                $error = ' error';
                $tooltip = '<span class="help-inline">' . form_error($defaults['name']) . '</span>' . PHP_EOL;
            }
        }
        $label = empty($label) ? isset($data['label']) ? $data['label'] : "" : $label;
        $output = <<<EOL


\t\t<div class="form-group form-group-select2">
\t\t\t<label for="{$defaults['name']}">{$label}</label>
\t\t\t<select id="{$defaults['name']}" class="form-control" {$output} {$extra}>
\t\t\t\t{$options_vals}
\t\t\t</select>
\t\t\t{$extra_html}
\t\t\t{$tooltip}
\t\t</div>

EOL;
        return $output;
    }
 function questionnaire_form_checkbox($rules = array(), $value = '', $checked = array(), $attributes = array(), $extra = '')
 {
     $field_name = $rules['field'];
     $data = array('type' => 'checkbox', 'name' => $field_name, 'value' => $value);
     if (in_array($value, $checked)) {
         $data['checked'] = 'checked';
     } else {
         unset($data['checked']);
     }
     return "<input " . _parse_form_attributes($attributes, $data) . $extra . " />";
 }
示例#17
0
 /**
 * Form Button
 *
 * @param	mixed
 * @param    string
 * @param	mixed
 *
 *@return	string
 */
 function form_button($data = '', $content = '', $extra = '')
 {
     $defaults = array('name' => is_array($data) ? '' : $data, 'type' => 'button');
     if (is_array($data) && isset($data['content'])) {
         $content = $data['content'];
         unset($data['content']);
         // content is not an attribute
     }
     return '<button ' . _parse_form_attributes($data, $defaults) . _attributes_to_string($extra) . '>' . $content . "</button>\n";
 }
示例#18
0
 function form_button($data = '', $content = '', $extra = '')
 {
     $defaults = ['name' => !is_array($data) ? $data : '', 'type' => 'button'];
     if (is_array($data) and isset($data['content'])) {
         $content = $data['content'];
         unset($data['content']);
         // content is not an attribute
     }
     return '<button ' . _parse_form_attributes($data, $defaults) . $extra . '>' . $content . '</button>';
 }
示例#19
0
    /**
     * Returns a properly templated dropdown field.
     *
     * @param string $data     Either a string with the element name, or an array of key/value pairs of all attributes, which must include a name or id.
     * @param array  $options  Array of options for the drop down list
     * @param string $selected Either a string of the selected item or an array of selected items
     * @param string $label    A string with the label of the element.
     * @param string $extra    A string with any additional items to include, like Javascript.
     * @param string $tooltip  A string for inline help or a tooltip icon
     *
     * @return string A string with the formatted input element, label tag and wrapping divs.
     */
    function form_dropdown($data, $options = array(), $selected = array(), $label = '', $extra = '', $tooltip = '')
    {
        if (empty($extra)) {
            $extra = 'class="form-control"';
        }
        if (!is_array($data)) {
            $data = array('name' => $data);
        }
        if (!isset($data['id'])) {
            $data['id'] = $data['name'];
        }
        $output = _parse_form_attributes($data, array());
        if (!is_array($selected)) {
            $selected = array($selected);
        }
        // If no selected state was submitted we will attempt to set it automatically
        if (count($selected) === 0) {
            // If the form name appears in the $_POST array we have a winner!
            if (isset($_POST[$data['name']])) {
                $selected = array($_POST[$data['name']]);
            }
        }
        $options_vals = '';
        foreach ($options as $key => $val) {
            $key = (string) $key;
            if (is_array($val) && !empty($val)) {
                $options_vals .= '<optgroup label="' . $key . '">' . PHP_EOL;
                foreach ($val as $optgroup_key => $optgroup_val) {
                    $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                    $options_vals .= '<option value="' . $optgroup_key . '"' . $sel . '>' . (string) $optgroup_val . "</option>\n";
                }
                $options_vals .= '</optgroup>' . PHP_EOL;
            } else {
                $sel = in_array($key, $selected) ? ' selected="selected"' : '';
                $options_vals .= '<option value="' . $key . '"' . $sel . '>' . (string) $val . "</option>\n";
            }
        }
        $error = '';
        if (function_exists('form_error')) {
            if (form_error($data['name'])) {
                $error = ' has-error';
                $tooltip = '<span class="help-block">' . form_error($data['name']) . '</span>' . PHP_EOL;
            }
        } else {
            if (!empty($tooltip)) {
                $tooltip = '<span class="help-block">' . $tooltip . '</span>' . PHP_EOL;
            }
        }
        $output = <<<EOL

<div class="form-group {$error}">
\t<label class="col-lg-3 col-md-3 col-sm-4 control-label" for="{$data['id']}">{$label}</label>
\t<div class="col-lg-6 col-sm-8 col-md-6">
\t\t <select {$output} {$extra}>
\t\t\t{$options_vals}
\t\t</select>
\t\t{$tooltip}
\t</div>
</div>

EOL;
        return $output;
    }
 function bs_form_dropdown($name = '', $options = array(), $selected = array(), $extra = array())
 {
     $extra['class'] = !empty($extra['class']) ? 'form-control ' . $extra['class'] : 'form-control';
     $extra = _parse_form_attributes($extra, array());
     return form_dropdown($name, $options, $selected, $extra);
 }
示例#21
0
/**
 * Text Input Field
 * Extended: Will automatically add an id that has the same value as the name
 *
 * @access	public
 * @param	mixed
 * @param	string
 * @param	string
 * @return	string
 */
function form_input($data = '', $value = '', $extra = '')
{
    $defaults = array('type' => 'text', 'name' => !is_array($data) ? $data : '', 'value' => $value, 'id' => $data);
    return "<input " . _parse_form_attributes($data, $defaults) . $extra . " />";
}
 function form_output($data = '')
 {
     $defaults = array('name' => !is_array($data) ? $data : '');
     return "<output " . _parse_form_attributes($data, $defaults) . "></output>";
 }
示例#23
0
function form_button($n = '', $y = '', $o = '')
{
    $p = array('name' => !is_array($n) ? $n : '', 'type' => 'button');
    if (is_array($n) and isset($n['content'])) {
        $y = $n['content'];
        unset($n['content']);
    }
    return "<button " . _parse_form_attributes($n, $p) . $o . ">" . $y . "</button>";
}
示例#24
0
    function form_checkbox($data = '', $value = '', $label = '', $extra = '', $tooltip = '')
    {
        $defaults = array('type' => 'checkbox', 'name' => !is_array($data) ? $data : '', 'value' => $value, 'class' => 'btn btn-default');
        if (empty($defaults['name']) && is_array($data) && isset($data['name'])) {
            $defaults['name'] = $data['name'];
            unset($data['name']);
        }
        $output = _parse_form_attributes($data, $defaults);
        $output = <<<EOL

        <div class="checkbox">
            <label for="{$defaults['name']}">
              <input type="checkbox"> {$label}
            </label>
        </div>

EOL;
        return $output;
    }
示例#25
0
 /**
  * Text Input Field
  *
  * @param	mixed
  * @param	string
  * @param	string
  * @return	string
  */
 function form_number($data = '', $value = '', $extra = '')
 {
     $defaults = array('type' => 'number', 'name' => is_array($data) ? '' : $data, 'value' => $value);
     return '<input ' . _parse_form_attributes($data, $defaults) . $extra . " />\n";
 }
示例#26
0
 function _mis_form_common($type = 'text', $data = '', $value = '', $label = '', $extra = '', $ui_type = '')
 {
     $form = '<div class="form-group ';
     if ($ui_type != '') {
         $form .= 'has-' . strtolower($ui_type);
     }
     $form .= '">';
     $id = is_array($data) && isset($data['id']) ? $data['id'] : '';
     if ($label != '') {
         $form .= mis_form_label($label, $id, '', $ui_type);
     }
     $defaults = array('type' => $type, 'name' => !is_array($data) ? $data : '', 'value' => $value, 'class' => 'form-control');
     $form .= "<input " . _parse_form_attributes($data, $defaults) . $extra . " />";
     $form .= "</div>";
     return $form;
 }
示例#27
0
 function form_button($data = '', $content = '', $extra = '')
 {
     $defaults = array('name' => !is_array($data) ? $data : '', 'type' => 'button');
     if (is_array($data) and isset($data['content'])) {
         $content = $data['content'];
         unset($data['content']);
         // content is not an attribute
     }
     return "<button " . _parse_form_attributes($data, $defaults) . $extra . ">" . $content . "</button>";
 }
示例#28
0
 function form_button($data = '', $content = '', $extra = '')
 {
     $defaults = array('name' => !is_array($data) ? $data : '', 'type' => 'button');
     if (is_array($data) and isset($data['content'])) {
         $content = $data['content'];
         unset($data['content']);
         // content is not an attribute
     }
     if ($extra != '') {
         $extra = " {$extra}";
     }
     return '<button ' . _parse_form_attributes($data, $defaults) . "{$extra}>{$content}</button>";
 }