Beispiel #1
1
function show_page($page)
{
    $template = "view/templates/default_template.php";
    if (file_exists($template) && is_file($template)) {
        require_once $template;
    } else {
        require_once "view/templates/default_template.php";
    }
    echo get_document_head();
    echo get_header_start();
    if (is_logged_in()) {
        echo get_logout();
    } else {
    }
    echo get_header_end();
    if (is_logged_in()) {
        echo get_menu();
    } else {
        echo get_guest_menu();
    }
    if (is_logged_in()) {
        if ($page == "startpage") {
            echo "startpage";
        } else {
            if ($page == "fileupload") {
                echo get_fileupload();
            } else {
                if ($page == "nyheter") {
                    echo get_news();
                } else {
                    if ($page == "flowing") {
                        echo get_flowing();
                    } else {
                        if ($page == "event") {
                            echo get_event();
                        } else {
                            if ($page == "profile") {
                                $user_id = 1;
                                echo get_profile($user_id);
                            } else {
                                echo get_default("");
                            }
                        }
                    }
                }
            }
        }
    } else {
        echo get_login();
    }
    echo get_footer();
    echo get_document_end();
}
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);
}
Beispiel #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);
}
function smarty_block_slink($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $href = get_default($params, 'href', null);
    if (isset($params['uri']) && $params['uri'] != '') {
        $uri = $params['uri'];
        $params['href'] = site_url($uri);
    } else {
        if (isset($params['uri']) && $params['uri'] == '') {
            $uri = $params['uri'];
            $params['href'] = '';
        } else {
            if ($href == '') {
                trigger_error('must need href attribute');
            } else {
                $params['href'] = $href;
            }
        }
    }
    unset($params['uri']);
    $params['href'] = lang($href);
    return create_tag('a', $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;
}
function smarty_function_a($params, $template)
{
    $uri = get_default($params, 'uri', '');
    $title = lang(get_default($params, 'title', ''));
    unset($params['uri']);
    return anchor($uri, $title, $params);
}
function smarty_function_img($params, $template)
{
    $CI =& get_instance();
    $CI->load->helper('html');
    $attr = array();
    $src = get_default($params, 'src');
    $class = get_default($params, 'class');
    $alt = get_default($params, 'alt');
    $title = get_default($params, 'title');
    $width = get_default($params, 'width');
    $height = get_default($params, 'height');
    if ($src != '') {
        $attr['src'] = $src;
    }
    if ($class != '') {
        $attr['class'] = $class;
    }
    if ($alt != '') {
        $attr['alt'] = $alt;
    }
    if ($title != '') {
        $attr['title'] = $title;
    }
    if ($width != '') {
        $attr['width'] = $width;
    }
    if ($height != '') {
        $attr['height'] = $height;
    }
    return img($attr);
}
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);
}
Beispiel #9
0
function get_default_array($defaults)
{
    $f_get = array();
    foreach ($defaults as $n => $d) {
        $f_get[strtolower($n)] = get_default($n, $d);
    }
    return $f_get;
}
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);
}
function smarty_block_link($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $uri = get_default($params, 'uri', '');
    unset($params['uri']);
    return anchor($uri, $content, $params);
}
function smarty_function_js($params, $template)
{
    $position = get_default($params, 'position', 'foot');
    $CI =& get_instance();
    foreach ($CI->jsFiles as $js) {
        if ($position == $js->position) {
            echo $js->render();
        }
    }
}
Beispiel #16
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);
}
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_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(), '');
}
function smarty_function_banner($params, $template)
{
    $src = get_default($params, 'src', null);
    if ($src == null) {
        return '';
    }
    $height = get_default($params, 'height', null);
    if ($height != null) {
        $params['style'] .= 'height:' . $height . ';';
    }
    return Clips\create_tag('div', $params, array('class' => 'pinet_banner'), '');
}
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);
}
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(), '');
}
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);
}
function smarty_block_report($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    $CI =& get_instance();
    $CI->load->library(array('report'));
    $name = get_default($params, 'name');
    $begin = get_default($params, 'begin');
    $end = get_default($params, 'end');
    $args = get_default($params, 'args');
    $args = count($args) ? $args : array();
    $mode = get_default($params, 'mode');
    $mode = $mode ? $mode : 'day';
    return "var {$name} = new Highcharts.Chart(" . $CI->report->show($name, $begin, $end, $args, $mode) . ");";
}
Beispiel #24
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);
}
Beispiel #25
0
 public function __construct($hash, $name, $value, array &$args, array $targs)
 {
     $global = get_default($args, 'global', false);
     if ($global) {
         $nameParts = LibraryManager::SplitNamespace($value);
         $value = $nameParts[\count($nameParts) - 1];
     }
     parent::__construct(InfoKind::T_FUNC, $hash, $name, $value, $args, $targs);
     grokit_assert(array_key_exists('input', $args), 'Malformed return value from function generator ' . $name . ': No input defined.');
     $this->args = $args['input'];
     grokit_assert(array_key_exists('result', $args), 'Malformed return value from function generator ' . $name . ': No result type defined.');
     $this->resultType = $args['result'];
     if (array_key_exists('deterministic', $args)) {
         $this->deterministic = $args['deterministic'];
     }
 }
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);
}
Beispiel #27
0
 protected function initDepends()
 {
     $depends = get_default($this->config, 'depends');
     if ($depends) {
         if (!is_array($depends)) {
             $depends = array($depends);
         }
         foreach ($depends as $d) {
             $w = $this->tool->widget($d);
             if (valid_obj($w, 'Clips\\WidgetV2')) {
                 // Call the init function to force init the widget
                 $w->init_v2();
             }
         }
     }
 }
function smarty_block_toolbar($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        // This is the start part
        add_container($params, $template, 'toolbar');
        return;
    }
    $params['id'] = get_default($params, 'id', 'toolbar');
    $classes = get_default($params, 'class', array());
    if (is_string($classes)) {
        $classes = explode(' ', $classes);
    }
    $classes[] = 'toolbar';
    $classes[] = 'pinet-toolbar';
    $params['class'] = implode(' ', $classes);
    return build_tag('div', $params, $content);
}
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_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(), '');
}