function smarty_block_form($params, $content = '', $template, &$repeat) { if ($repeat) { // Set the current form to the context Clips\clips_context('indent_level', 1, true); $name = Clips\get_default($params, 'name', Clips\default_form_name()); $data = Clips\context('form_' . $name); if ($data) { Clips\context('current_form_data', $data); } Clips\clips_context('current_form', $name); return; } $content .= "\t" . Clips\create_tag('input', array('type' => 'hidden', 'name' => Clips\Form::FORM_FIELD, 'value' => Clips\get_default($params, 'name', 'form'))); $action = Clips\get_default($params, 'action'); if ($action) { if (strpos($action, 'http') !== 0) { $params['action'] = Clips\site_url($action); } } if (Clips\get_default($params, 'upload')) { unset($params['upload']); $params['enctype'] = 'multipart/form-data'; } Clips\context_pop('current_form'); Clips\context_pop('current_form_data'); Clips\context_pop('indent_level'); return Clips\create_tag_with_content('form', $content, $params, array('action' => '#', 'method' => 'post', 'class' => ['clips-form', 'default-form'])); }
function smarty_function_img($params, $template) { $uri = Clips\get_default($params, 'uri'); if ($uri) { unset($params['uri']); $params['src'] = Clips\static_url($uri); } return Clips\create_tag('img', $params); }
function smarty_block_figure($params, $content = '', $template, &$repeat) { if ($repeat) { Clips\clips_context('indent_level', 1, true); return; } $src = Clips\get_default($params, 'src'); $path = Clips\get_default($params, 'path', 'responsive/size'); $resolutions = Clips\get_default($params, 'resolutions'); $img_path = Clips\find_image($src); if (!$img_path) { Clips\error('figure', array('Can\'t find image ' . $src . '!')); return ''; } $size = Clips\image_size($img_path); $size = $size['width']; if ($resolutions) { // If we are using auto resizing, skip the resolutions foreach ($resolutions as $res) { $attr['data-media' . $res] = Clips\site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src); } } else { $attr = array('path' => Clips\site_url($path)); } foreach ($params as $key => $value) { if ($key == 'path') { continue; } if (strpos($key, 'media') !== false) { $attr['data-' . $key] = Clips\site_url('responsive/size/' . $value . '/' . $src); } else { $attr[$key] = $value; } } $caption = Clips\create_tag_with_content('figcaption', $content); $image_dir = Clips\config('image_dir'); if ($image_dir) { $image_dir = $image_dir[0]; } else { $image_dir = 'application/static/img/'; } $img = Clips\create_tag('img', array('src' => Clips\static_url(Clips\path_join($image_dir, $src)))); $noscript = Clips\create_tag_with_content('noscript', $img); $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } Clips\context_pop('indent_level'); return Clips\create_tag_with_content('figure', $noscript . "\n{$indent}" . $caption, $attr); }
function smarty_function_video($params, $template) { $src = Clips\get_default($params, 'src', null); if (!$src) { Clips\error("No src found for this video tag."); return ''; } $src = Clips\create_tag('source', array('src' => $src, 'type' => "application/x-mpegURL")); return Clips\create_tag_with_content('video', $src, $params, array('class' => array('video-js', 'vjs-default-skin'), 'id' => 'video', 'controls')); }
function smarty_block_swiper__prevbtn($params, $content = '', $template, &$repeat) { if ($repeat) { \Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => 'swiper-button-prev swiper-button-white'); \Clips\context_pop('indent_level'); return \Clips\create_tag('div', $params, $default, $content); }
function smarty_block_slider($params, $content = '', $template, &$repeat) { if ($repeat) { \Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => 'slider'); \Clips\context_pop('indent_level'); return \Clips\create_tag('div', $params, $default, $content); }
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_head($params, $content = '', $template, &$repeat) { if ($repeat) { Clips\clips_context('indent_level', 1, true); // Enstack indent level return; } $encoding = Clips\get_default($params, 'encoding', 'UTF-8'); $version = Clips\context('html_version'); $title = Clips\get_default($params, 'title', null); if (!$title) { // If didn't found title on the parameter, try find it in context $title = Clips\context('html_title'); } // Adding metas if (!$version) { $version = 5; } $meta = Clips\context('html_meta'); if (!$meta) { $meta = array(); } switch ($version) { case '4': case '4t': case '4s': case '4f': case 'xhtml': case 'xhtmlt': case 'xhtmlf': case 'xhtml1.1': array_unshift($meta, array('http-equiv' => 'Content-Type', 'content' => 'text/html;charset=' . $encoding)); break; case '5': array_unshift($meta, array('charset' => $encoding)); break; } $pre = array(); foreach ($meta as $m) { $pre[] = Clips\create_tag('meta', $m); } // Adding the title if ($title) { $pre[] = Clips\create_tag_with_content('title', $title); } $pre = "\t" . implode("\n\t\t", $pre); if (isset($params['title'])) { unset($params['title']); } Clips\context_pop('indent_level'); // Pop the stack before output return Clips\create_tag_with_content('head', $pre . $content, $params); }
function smarty_block_swiper__wrapper($params, $content = '', $template, &$repeat) { if ($repeat) { \Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => 'swiper-wrapper'); $content = "\t" . Clips\process_list_items($params, $content, $template); if (isset($params['items'])) { unset($params['items']); } \Clips\context_pop('indent_level'); return \Clips\create_tag('div', $params, $default, $content); }
function smarty_function_submit($params, $template) { $bundle_name = Clips\context('current_bundle'); $bundle = Clips\get_default($params, 'bundle', $bundle_name); $submit = Clips\get_default($params, 'value', 'Submit'); if ($bundle !== null) { $bundle = Clips\bundle($bundle); $submit = $bundle->message($submit); } if (isset($params['value'])) { $params['value'] = $submit; } return Clips\create_tag('input', $params, array('type' => 'submit', 'value' => $submit, 'class' => array('btn', 'btn-primary'))); }
function smarty_function_input($params, $template) { $default = array('class' => array('form-input', 'form-control')); $f = Clips\clips_context('current_field'); if ($f) { $default = $f->getDefault($default); } $data = Clips\context_pop('current_form_field_data'); if ($data) { $default['value'] = $data; } $state = Clips\context('current_form_field_state'); if ($state && $state == 'readonly') { $value = Clips\get_default($default, 'value'); if ($value) { return "<span>{$value}</span>"; } return "<span>" . Clips\get_default($params, 'value', '') . "</span>"; } return Clips\create_tag('input', $params, $default); }
function smarty_block_breadcrumb($params, $content = '', $template, &$repeat) { if ($repeat) { return; } $items = get_default($params, 'items', null); $tags = array(); if ($items) { $list_tags = array(); foreach ($items as $item) { $a = breadcrumb_process_item($item); if ($a != '') { $list_tags[] = Clips\create_tag('li', array(), array(), breadcrumb_process_item($item)); } else { $list_tags[] = Clips\create_tag('li', array('class' => 'divider'), array(), ''); } } $tags[] = implode("\n", $list_tags); } else { $tags[] = $content; } return Clips\create_tag('div', array('class' => 'breadcrumb'), array(), implode("", $tags)); }
function smarty_block_swiper__slide($params, $content = '', $template, &$repeat) { if ($repeat) { \Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => 'swiper-slide'); $dataImage = \Clips\get_default($params, 'data-image', null); $paginationImage = \Clips\get_default($params, 'data-pagination-image', null); $responsive = \Clips\get_default($params, 'responsive', false); $image = ''; if ($dataImage) { if ($responsive == "true") { $image = smarty_function_resimg(array('data-image' => $dataImage, 'data-pagination-src' => $paginationImage), $template); } else { $image = smarty_function_img(array('src' => $dataImage, 'data-pagination-src' => $dataImage), $template); } unset($params['data-image']); unset($params['data-pagination-image']); unset($params['responsive']); } \Clips\context_pop('indent_level'); return \Clips\create_tag('div', $params, $default, $image . $content); }
function smarty_block_alert($params, $content = '', $template, &$repeat) { if ($repeat) { \Clips\clips_context('indent_level', 1, true); return; } $show = \Clips\get_default($params, 'show', 'info'); unset($params['show']); $default = array('class' => array('alert', $show)); $true = true; // Add message div // Open message div smarty_block_div(array('class' => 'alert-message'), $content, $template, $true); // Close message div $message = smarty_block_div(array('class' => 'alert-message'), $content, $template, $repeat); // Open controls smarty_block_div(array('class' => 'alert-control'), '', $template, $true); // Open close button smarty_block_div(array('class' => 'btn', 'alert-for' => 'close'), \Clips\lang('close'), $template, $true); // Close close button $close_button = smarty_block_div(array('class' => 'btn', 'alert-for' => 'close'), \Clips\lang('close'), $template, $repeat); // Close controls $controls = smarty_block_div(array('class' => 'alert-control'), $close_button, $template, $repeat); $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } \Clips\context_pop('indent_level'); return \Clips\create_tag('div', $params, $default, $message . "\n" . $indent . $controls); }
function smarty_function_picture($params, $template) { $src = Clips\get_default($params, 'src'); if ($src) { if (preg_match('/_\\([A-Za-z0-9_]+\\)/', $src)) { $is_template = true; } } if (!isset($is_template)) { $path = Clips\get_default($params, 'path', 'responsive/size'); $resolutions = Clips\get_default($params, 'resolutions'); $medias = Clips\get_default($params, 'medias'); $img_path = Clips\find_image($src); if (!$img_path) { Clips\error('picture', array('Can\'t find image ' . $src . '!')); return ''; } $size = Clips\image_size($img_path); $size = $size['width']; $content = array(); $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } if ($resolutions || $medias) { if ($resolutions) { // If we are using auto resizing, skip the resolutions unset($params['resolutions']); foreach ($resolutions as $res) { $content[] = "\t" . Clips\create_tag('source', array('src' => Clips\site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src), 'media' => '(min-width:' . $res . 'px)')); } } if ($medias) { unset($params['medias']); foreach ($medias as $media => $res) { $content[] = "\t" . Clips\create_tag('source', array('src' => Clips\site_url('responsive/size/' . $res . '/' . $src), 'media' => '(min-width:' . $media . 'px)')); } } } else { $params['path'] = Clips\site_url($path); } $image_dir = Clips\config('image_dir'); if ($image_dir) { $image_dir = $image_dir[0]; } else { $image_dir = 'application/static/img/'; } Clips\clips_context('indent_level', 1, true); $img = Clips\create_tag('img', array('src' => Clips\static_url(Clips\path_join($image_dir, $src)))); $content[] = "\t" . Clips\create_tag_with_content('noscript', $img); Clips\context_pop('indent_level'); } else { $params['data-role'] = 'item-picture'; $params['path'] = Clips\site_url(Clips\get_default($params, 'path', 'responsive/size')); $indent = ''; $content = array(); } return Clips\create_tag_with_content('picture', implode("\n{$indent}", $content), $params); }
function smarty_function_hr($params, $template) { return Clips\create_tag('hr', $params); }
public function testCreateTag() { $this->assertEquals("<div class=\"a b\">\n\t\n</div>", Clips\create_tag('div', array('class' => array('a', 'b')), array(), '')); }