Esempio n. 1
0
function pinet_smarty_create_button($params, $content = '')
{
    $tag = get_default($params, 'tag', 'button');
    if (isset($params['tag'])) {
        unset($params['tag']);
    }
    $show = get_default($params, 'show', 'default');
    if (isset($params['show'])) {
        unset($params['show']);
    }
    if ($tag == 'input' && !isset($params['type'])) {
        $params['type'] = 'button';
    }
    $params['class'] = make_classes('btn', 'pinet-btn', 'btn-' . $show, get_default($params, 'class', null));
    if ($tag == 'input' && !isset($params['value'])) {
        $params['value'] = $content;
    }
    $params['role'] = 'button';
    if (!isset($params['title'])) {
        $params['title'] = trim(strip_tags($content));
    }
    if (isset($params['icon']) && $params['icon'] != '') {
        $iconName = $params['icon'];
        unset($params['icon']);
        $iconParams = array();
        $iconParams['class'] = make_classes('glyphicon', 'glyphicon-' . $iconName);
        $iconParams['aria-hidden'] = 'true';
        $icon = create_tag('span', $iconParams, array(), '');
        $content = $icon . $content;
    }
    if ($tag == 'input') {
        return create_tag('input', $params, array());
    }
    return create_tag($tag, $params, array(), $content);
}
function smarty_function_alert($params, $template)
{
    $CI =& get_instance();
    $ret = array();
    ci_log('The alerts is ', $CI->getAlerts());
    $origin_class = get_default($params, 'class');
    foreach ($CI->getAlerts() as $alert) {
        $classes = make_classes($origin_class, 'alert');
        $classes[] = 'pinet-alert-' . $alert->type;
        $classes[] = 'alert-map-item';
        $params['class'] = $classes;
        $yes_btn = create_tag('button', array('class' => array('btn', 'pinet-alert-btn-default', 'yes')), array(), 'YES');
        $no_btn = create_tag('button', array('class' => array('btn', 'pinet-alert-btn-default', 'no')), array(), 'NO');
        $content = $yes_btn . $no_btn;
        $menu = create_tag('div', array('class' => array('menu')), array(), $content);
        $info = create_tag('div', array('class' => 'info'), array(), $alert->message);
        $alert_inner = $menu . $info;
        $ret[] = create_tag('div', $params, array('role' => 'alert'), $alert_inner);
    }
    $CI->clearAlerts();
    $alerts = '';
    if ($ret) {
        $alerts = create_tag('div', array('class' => 'pinet-alert-map'), array(), implode("\n", $ret));
    }
    return $alerts;
}
Esempio n. 3
0
function smarty_block_faq($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $tag = get_default($params, 'tag', 'span');
    if (isset($params['tag'])) {
        unset($params['tag']);
    }
    $placement = get_default($params, 'placement', 'bottom');
    $params["data-placement"] = $placement;
    if (isset($params['placement'])) {
        unset($params['placement']);
    }
    $auto = get_default($params, 'auto', true);
    if ($auto) {
        $params['data-toggle'] = 'tooltip';
    }
    if (isset($params['auto'])) {
        unset($params['auto']);
    }
    $show = get_default($params, 'show', 'default');
    $params['class'] = make_classes('faq', 'faq-' . $show, get_default($params, 'class', null));
    if (!isset($params['title'])) {
        $params['title'] = trim(strip_tags($content));
    }
    return create_tag($tag, $params, array(), $content);
}
 public function testMakeClasses()
 {
     print_r(make_classes('a', 'b', array('c', 'd')));
     $this->assertEquals(make_classes('a', 'b', array('c', 'd')), array('a', 'b', 'c', 'd'));
     print_r(make_classes('a', 'b', array('c', '', 'd')));
     $this->assertEquals(make_classes('a', 'b', array('c', 'd')), array('a', 'b', 'c', 'd'));
 }
function smarty_block_input_group($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $params['class'] = make_classes('input-group', get_default($params, 'class', null));
    return create_tag('div', $params, array(), $content);
}
function smarty_block_pinet_statebar($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $params['class'] = make_classes(array('pinet-statebar'), get_default($params, 'class', array()));
    return create_tag('div', $params, array(), $content);
}
function smarty_block_listview($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $attr = array('id' => 'listview', 'class' => make_classes(array('listview', 'display'), get_default($params, 'class', array())));
    return create_tag('ul', $attr, array(), $content);
}
function smarty_block_table_row($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $params['class'] = make_classes('table-row', get_default($params, 'class', null));
    return create_tag('div', $params, array(), $content);
}
function smarty_block_button_group($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $params['data-toggle'] = 'buttons';
    $params['class'] = make_classes('btn-group', get_default($params, 'class', ''));
    return create_tag('div', $params, array(), $content);
}
Esempio n. 10
0
function smarty_block_col($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $col = create_tag('div', array('class' => 'scroll'), array(), $content);
    $params['class'] = make_classes('col', get_default($params, 'class', null));
    return create_tag('div', $params, array(), $col);
}
Esempio n. 11
0
function smarty_function_icon($params, $template)
{
    $type = get_default($params, 'type');
    $tag = get_default($params, 'tag', 'i');
    if (isset($params['tag'])) {
        unset($params['tag']);
    }
    $params['class'] = make_classes('glyphicon', 'glyphicon-' . $type, get_default($params, 'class', null));
    $params['aria-hidden'] = 'true';
    return create_tag($tag, $params, array(), '');
}
Esempio n. 12
0
function smarty_function_label($params, $template)
{
    if (isset($template->block_data)) {
        $f = $template->block_data;
        $field = $f->name;
        $params['for'] = $f->getId();
        $params['class'] = make_classes(get_default($params, 'class'), 'control-label');
        return create_tag('label', $params, array(), $f->label);
    }
    return create_tag('label', $params);
}
function smarty_block_radio_group($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $params['data-toggle'] = 'buttons';
    $show = get_default($params, 'show', 'default');
    if (isset($params['show'])) {
        unset($params['show']);
    }
    $params['class'] = make_classes('btn-group pinet-radio-group btn-group-' . $show, get_default($params, 'class', ''));
    return create_tag('div', $params, array(), $content);
}
Esempio n. 14
0
function smarty_function_banner($params, $template)
{
    $src = get_default($params, 'src', null);
    if ($src == null) {
        ci_error(lang_f('The banner\'s attribute src must be set!'));
        return '';
    }
    $params['class'] = make_classes('pinet_banner', get_default($params, 'class', null));
    $height = get_default($params, 'height', null);
    if ($height != null) {
        $params['style'] .= 'height:' . $height . ';';
    }
    return create_tag('div', $params, array(), '');
}
Esempio n. 15
0
function smarty_block_tag($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $tag = get_default($params, 'tag', 'span');
    if (isset($params['tag'])) {
        unset($params['tag']);
    }
    $show = get_default($params, 'show', 'default');
    $params['class'] = make_classes('label', 'label-' . $show, get_default($params, 'class', null));
    if (!isset($params['title'])) {
        $params['title'] = trim(strip_tags($content));
    }
    return create_tag($tag, $params, array(), $content);
}
function smarty_block_bs_container($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $containerClass = 'container';
    if (isset($params['display']) && $params['display'] != '') {
        $display = $params['display'];
        unset($params['display']);
        $containerClass .= ' container-' . $display;
    }
    $params['class'] = make_classes($containerClass, get_default($params, 'class', null));
    $template->block_data = array('sdsds');
    return create_tag('div', $params, array(), $content);
}
function smarty_block_dropbutton($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $ret = array();
    $show = get_default($params, 'show', 'default');
    $params['class'] = make_classes('btn', 'btn-' . $show, 'dropdown-toggle', get_default($params, 'class', null));
    $label = get_default($params, 'label', '') . ' ';
    if (!isset($params['title'])) {
        $params['title'] = strip_tags($label);
    }
    $params['data-toggle'] = 'dropdown';
    $params['aria-expanded'] = 'false';
    $items = get_default($params, 'items', null);
    if (isset($params['items'])) {
        unset($params['items']);
    }
    $split = get_default($params, 'split', null);
    if (isset($split) && $split == true) {
        unset($params['split']);
        $tags[] = create_tag('button', array('class' => array('btn', 'btn-' . $show)), array(), $label);
        $label = '';
    }
    $tags[] = create_tag('button', $params, array(), $label . create_tag('span', array('class' => 'caret'), array(), ''));
    if ($items) {
        $list_tags = array();
        foreach ($items as $item) {
            $a = dropdown_button_process_item($item);
            if ($a != '') {
                $list_tags[] = create_tag('li', array(), array(), dropdown_button_process_item($item));
            } else {
                $list_tags[] = create_tag('li', array('class' => 'divider'), array(), '');
            }
        }
        $tags[] = create_tag('ul', array('class' => 'dropdown-menu', 'role' => 'menu'), array(), implode("\n", $list_tags));
    } else {
        $tags[] = $content;
    }
    $direction = get_default($params, 'direction', '');
    $dropbuttonClass = array('btn-group');
    if ($direction == 'up') {
        $dropbuttonClass[] = "dropup";
    }
    return create_tag('div', array('class' => $dropbuttonClass), array(), implode("", $tags));
}
Esempio n. 18
0
function smarty_function_iframe($params, $template)
{
    $src = get_default($params, 'src', null);
    if (!$src) {
        ci_error('The src attribute must be set for iframe.');
        return '';
    }
    $src = site_url($src);
    $lazy = get_default($params, 'lazy', false);
    $class = $lazy ? 'iframe-lazy' : 'iframe';
    $params['class'] = make_classes($class, get_default($params, 'class'));
    if ($lazy) {
        $params['data-src'] = $src;
        unset($params['src']);
    }
    return create_tag('iframe', $params, array(), '');
}
Esempio n. 19
0
function smarty_block_container($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        add_container($params, $template);
        return;
    }
    $layout = get_default($params, 'layout', false);
    if (isset($template->block_data->parent) && is_object($template->block_data->parent) && get_class($template->block_data->parent) == 'Pinet_Container') {
        $template->block_data = $template->block_data->parent;
    } else {
        $template->block_data = null;
    }
    if ($layout) {
        return create_tag('div', array('class' => make_classes(get_default($params, 'class'))), array(), $content);
    }
    return $content;
}
function smarty_block_checkbox_button($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $show = get_default($params, 'show', 'default');
    if (isset($params['show'])) {
        unset($params['show']);
    }
    $classes = make_classes('btn', 'pinet-btn', 'btn-' . $show, get_default($params, 'class', null));
    $params['type'] = 'checkbox';
    $params['autocomplete'] = 'off';
    $input = create_tag('input', $params, array());
    if (isset($params["checked"]) && $params["checked"] != '') {
        $classes[] = "active";
    }
    return create_tag('label', array('class' => $classes), array(), $input . $content);
}
function smarty_function_datatable($params, $template)
{
    $attr = array('id' => 'datatable', 'class' => make_classes(array('datatable', 'display'), get_default($params, 'class', array())));
    return create_tag('table', $attr, array(), ' ');
}
function smarty_function_helpblock($params, $template)
{
    $classes = make_classes(get_default($params, 'class'), array('help-block'));
    return create_tag('p', array('class' => $classes));
}
/**
 * The field group has many states, list as below:
 *
 * None: The field group won't show in the form
 * Hidden: The field group is hidden from user
 * Disabled: The field group is disabled
 * Readonly: The field group is readonly
 *
 * The field state can be set in 4 ways:
 *
 * 1. By the tag itself
 * 2. By the security engine
 * 3. By the controller
 * 4. By the form configuration
 *
 * The priority of the value is like the list too. So, the tag itself
 * will have the highest priority than others.
 */
function smarty_block_field_group($params, $content = '', $template, &$repeat)
{
    $CI =& get_instance();
    $CI->load->helper('form');
    $labelClass = get_default($params, 'labelClass');
    $inputClass = get_default($params, 'inputClass');
    $glyphicon = get_default($params, 'glyphicon');
    if ($labelClass == "") {
        $labelClass = "pinet-form-label";
    }
    if ($inputClass == "") {
        $inputClass = "pinet-form-input";
    }
    $f = get_field($params, $template);
    if ($f == null) {
        return '';
    }
    if ($repeat) {
        // This is the start part
        // Set the field to parent's template variables to let the form fields to access it
        $parent_vars['current_form_field'] = new Smarty_Variable($f);
        $template->block_data = $f;
        return;
    }
    if ($f->state == 'none') {
        ci_log('The field is not allowed for this security configuration', $f);
        return '';
    }
    $layout = get_default($params, 'layout', array());
    $classes = make_classes(get_default($params, 'class'), array('form-group', 'control-group'));
    $label_layout_class = 'col-1280-2';
    $element_layout_class = 'col-1280-10';
    if (is_array($layout)) {
        if (isset($layout['label'])) {
            $label_layout_class = 'col-1280-' . $layout['label'];
        }
        if (isset($layout['element'])) {
            $element_layout_class = 'col-1280-' . $layout['element'];
        }
        if (isset($layout['mobile-label'])) {
            $label_layout_class .= ' col-320-' . $layout['mobile-label'];
        }
        if (isset($layout['mobile-element'])) {
            $element_layout_class .= ' col-320-' . $layout['mobile-element'];
        }
    } else {
        if (isset($f->container)) {
            $template->block_data = $f->container;
        } else {
            $template->block_data = null;
        }
        return create_tag('div', array('class' => $classes), array(), $content);
    }
    // Creating the label div
    if (!isset($f->label)) {
        $f->label = '';
    }
    $label = create_tag('label', array('for' => $f->getId(), 'class' => array($label_layout_class, $labelClass, 'control-label', isset($f->required) ? 'form_field_required' : '')), array(), $f->label);
    if (trim($content) == '') {
        // If we don't have any sub element, just add an input
        $inputData = array();
        // Check field type
        if (isset($f->type) && $f->type != '') {
            $inputData['type'] = $f->type;
        }
        $content = smarty_function_input($inputData, $template);
    }
    if (is_string($glyphicon) && $glyphicon != '') {
        $classes = make_classes($classes, array('has-feedback'));
        $content .= create_tag('span', array('class' => array('glyphicon', 'glyphicon-' . $glyphicon, 'form-control-feedback')), array(), '');
    }
    // Adding the error notification area
    $content .= create_tag('p', array('class' => array('help-block')), array(), '');
    // Creating the element div
    $element = create_tag('div', array('class' => array($element_layout_class, $inputClass)), array(), $content);
    if (isset($f->container)) {
        $template->block_data = $f->container;
    } else {
        $template->block_data = null;
    }
    if ($f->state == 'hidden') {
        $classes[] = 'hidden';
    }
    // Jam them together
    return create_tag('div', array('class' => $classes), array(), $label . "\n" . $element);
}