function smarty_function_cancel($params, $template) { Clips\require_widget_smarty_plugin('html', 'a'); $bundle_name = Clips\context('current_bundle'); $bundle = Clips\get_default($params, 'bundle', $bundle_name); $cancel = Clips\get_default($params, 'label', 'Cancel'); if ($bundle !== null) { $bundle = Clips\bundle($bundle); $cancel = $bundle->message($cancel); } $request = Clips\context('request'); $bs = $request->breadscrumb(); if (count($bs) > 1) { array_pop($bs); // Pop current $params['href'] = Clips\site_url(array_pop($bs)); $params['title'] = $cancel; $f = true; // Open the link smarty_block_a($params, '', $template, $f); $f = false; return smarty_block_a($params, $cancel, $template, $f); } return ''; }
function smarty_block_field($params, $content = '', $template, &$repeat) { Clips\require_widget_smarty_plugin('Html', 'div'); Clips\require_widget_smarty_plugin('Html', 'label'); // Global variables $labelClass = Clips\get_default($params, 'label-class', 'form-label'); $inputClass = Clips\get_default($params, 'input-class', 'form-input'); $glyphicon = Clips\get_default($params, 'glyphicon', null); if ($repeat) { // The header part // Init the context Clips\context('indent_level', 1, true); Clips\context('indent_level', 1, true); // Indent for the inner div Clips\context_pop('current_field'); // Remove the last current field // Getting the form $form = Clips\context('form'); if ($form) { // Getting the field $field = Clips\get_default($params, 'field', null); if (!isset($field)) { Clips\show_error('No field configured for the field plugin!'); return; } $f = $form->field($field); if (!isset($f)) { Clips\show_error('No field configuration found for field %s!', $field); return; } // Put the field to context Clips\context('current_field', $f); // Processing the form data $data = Clips\get_default(Clips\context('current_form_data'), $field); if ($data) { Clips\context('current_form_field_data', $data, true); // Update the field's value to data $f->value = $data; } // Processing the states $state = Clips\get_default($params, 'state'); if (!$state) { $state = Clips\field_state($f); } if ($state) { Clips\context('current_form_field_state', $state); } } else { Clips\show_error('No form configuration found for this field!'); } } else { if (Clips\clips_context('current_field')) { Clips\context_pop('indent_level'); $f = Clips\clips_context('current_field'); if (\Clips\get_default($f, 'state') == 'none' || $f->state == 'none') { Clips\context_pop('indent_level'); return ''; } if (\Clips\get_default($params, 'state') == 'hidden' || \Clips\get_default($f, 'hidden') || $f->state == 'hidden') { Clips\context_pop('indent_level'); Clips\require_widget_smarty_plugin('Form', 'input'); return smarty_function_input(array('type' => 'hidden'), $template); } // Now for rendering $ret = array(); // Render the icon if ($glyphicon) { // Add the glyphicon $ret[] = Clips\create_tag_with_content('span', '', array('class' => array('glyphicon', 'glyphicon-' . $glyphicon, 'form-control-feedback')), array(), true); } // Render the label $r = true; smarty_block_label(array(), '', $template, $r); // Skip the label head $r = false; $ret[] = smarty_block_label(array('for' => $f->getId(), 'class' => array($labelClass, 'control-label', isset($f->required) ? 'form_field_required' : '')), $f->label, $template, $r); // Render the input row head $r = true; smarty_block_div(array(), '', $template, $r); // Skip the div head // If no input set, using default input if (trim($content) == '') { Clips\require_widget_smarty_plugin('Form', 'input'); $content = smarty_function_input(array(), $template); } // Close the input div $ret[] = smarty_block_div(array('class' => $inputClass), $content, $template, $repeat); // Added the help block $ret[] = Clips\create_tag_with_content('p', '', array('class' => 'help-block'), array(), true); $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } // Altogether Clips\context_pop('indent_level'); CLips\context_pop('current_form_field_data'); CLips\context_pop('current_form_field_state'); return Clips\create_tag_with_content('div', implode("\n{$indent}", $ret), $params, array('class' => array('form-group', 'control-group'))); } } }
<?php in_array(__FILE__, get_included_files()) or exit("No direct script access allowed"); \Clips\require_widget_smarty_plugin('html', 'div'); 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); }
<?php in_array(__FILE__, get_included_files()) or exit("No direct script access allowed"); Clips\require_widget_smarty_plugin('Html', 'li'); Clips\require_widget_smarty_plugin('Html', 'ul'); Clips\require_widget_smarty_plugin('Html', 'action'); function _smarty_block_navigation_tree_node($action, $indent, $template, $repeat, $li_class = array()) { $tool =& Clips\get_clips_tool(); $security = $tool->load_class('securityEngine', true); $result = $security->test($action); if ($result) { // If rejected this action Clips\log('Rejected action [{0}] for reasion [{1}]', array($action->label(), $result[0]->reason, $action)); return ''; } $f = true; // Start the li smarty_block_li(array(), '', $template, $f); // Start the action smarty_block_action(array(), '', $template, $f); // Close the action $a = smarty_block_action(array('action' => $action), '', $template, $repeat); $children = $action->children(); if ($children) { $class[] = 'treeview'; $sub = array(); smarty_block_ul(array('class' => array('treeview', 'sub-navi')), '', $template, $f); foreach ($children as $c) { $sub[] = _smarty_block_navigation_tree_node($c, $indent . "\t\t", $template, $repeat, $li_class); }
<?php in_array(__FILE__, get_included_files()) or exit("No direct script access allowed"); \Clips\require_widget_smarty_plugin('html', 'img'); \Clips\require_widget_smarty_plugin('image', 'resimg'); 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); }
<?php in_array(__FILE__, get_included_files()) or exit("No direct script access allowed"); \Clips\require_widget_smarty_plugin('swiper', 'swiper__slide'); 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); }
public function testRequireWidgetSmartyPlugin() { Clips\require_widget_smarty_plugin('Html', 'h1'); $this->assertTrue(function_exists('smarty_block_h1')); }
<?php in_array(__FILE__, get_included_files()) or exit("No direct script access allowed"); Clips\require_widget_smarty_plugin('Html', 'img'); function smarty_function_resimg($params, $template) { return Clips\create_tag_with_content('div', smarty_function_img($params, $template), array('class' => 'responsive')); }
function smarty_function_password($params, $template) { $params['type'] = 'password'; Clips\require_widget_smarty_plugin('Form', 'input'); return smarty_function_input($params, $template); }