public static function get_src_settings(FTL_Binding $tag) { $setting_keys = array('method', 'size', 'watermark', 'unsharp', 'start', 'color', 'refresh'); $settings = array_fill_keys($setting_keys, ''); $global_unsharp = Settings::get('media_thumb_unsharp'); // <ion:medias /> parent $parent = $tag->getParent('medias'); if (!is_null($parent)) { $unsharp = $parent->getAttribute('unsharp'); if ($unsharp == NULL) { $settings['unsharp'] = $global_unsharp; } $settings = array_merge($settings, $parent->getAttributes()); } // <ion:media /> parent $parent = $tag->getParent('media'); if (!is_null($parent)) { $unsharp = $parent->getAttribute('unsharp'); if ($unsharp == NULL) { $settings['unsharp'] = $global_unsharp; } $settings = array_merge($settings, $parent->getAttributes()); } $settings = array_merge($settings, $tag->getAttributes()); if (empty($settings['method'])) { $settings['method'] = self::$default_resize_method; } return $settings; }
/** * Pagination tag * * Main class name, id, open tag, close tag, every options from cI in fact ! * * @configuration * /themes/<my_theme>/config/pagination.php * Set the open / close HTML tags for each tag * * /themes/<my_theme>/language/xx/pagination_lang.php * Set the translations items : * - first_link * - last_link * - prev_link * - next_link * */ public static function tag_pagination(FTL_Binding $tag) { if ($tag->getParent()->get('__loop__') === FALSE) { return ''; } // Avoid loop in this tag $tag->getParent()->set('__loop__', FALSE); // Tag cache if (($str = self::get_cache($tag)) !== FALSE) { return $str; } // Current page : 1. Asked page, 2. Down to current $page = $tag->get('page'); if (is_null($page)) { $page = self::registry('page'); } // Number of displayed articles : tag attribute has priority 1. $nb_to_display = $tag->getAttribute('pagination'); if (is_null($nb_to_display)) { $nb_to_display = $page['pagination']; } // Load CI Pagination Lib isset(self::$ci->pagination) or self::$ci->load->library('pagination'); // Current pagination page $args = self::get_special_uri_array('pagination'); $cur_page = isset($args[0]) ? $args[0] : NULL; // Pagination tag config init $pagination_config = array_merge(self::get_pagination_config($tag), array('base_url' => self::get_pagination_base_url($tag), 'per_page' => $nb_to_display, 'total_rows' => $tag->get('nb_total_items'), 'num_links' => 3, 'cur_page' => $cur_page, 'first_link' => lang('first_link'), 'last_link' => lang('last_link'), 'next_link' => lang('next_link'), 'prev_link' => lang('prev_link'))); // Pagination initialization self::$ci->pagination->initialize($pagination_config); // Create the links $page['pagination_links'] = self::$ci->pagination->create_links(); // Tag cache self::set_cache($tag, $page['pagination_links']); return $page['pagination_links']; }
protected static function get_lang_swap(FTL_Binding $tag, $swap) { // $swap = $tag->getAttribute('swap'); if (!is_null($swap)) { $swap = explode(',', $swap); $swap = array_map('trim', $swap); // Try to get internal swap values foreach ($swap as &$str) { if (strpos($str, '::') !== FALSE) { $seg = explode('::', $str); // The asked key must be set if (!empty($seg[1])) { // Get from global value if ($seg[0] == 'global') { $str = self::$context->get_global($seg[1]); } else { $parent = NULL; // Parent not set : current parent if ($seg[0] == '') { $parent = $tag->getDataParent(); } else { $parent = $tag->getParent($seg[0]); } if (!is_null($parent)) { $str = $parent->getValue($seg[1], $parent->name); } else { $str = ''; } } } } } } return $swap; }
/** * Displays the complete error string * (containing all errors) * * @param FTL_Binding * * @return string * * @usage <ion:form:form_name:validation:error /> * * Example with the form called 'profile' : * <ion:form:profile:validation:error /> * */ public static function tag_form_validation_error(FTL_Binding $tag) { $is = $tag->getAttribute('is'); $key = $tag->getAttribute('key'); $delimiter = $tag->getAttribute('delimiter', 'span'); $form_name = $tag->getParent('validation')->getParentName(); // 'additional_error' values $values = NULL; $fd = self::$ci->session->flashdata($form_name); if (!empty($fd['additional_error'])) { $values = $fd['additional_error']; } else { // Adds additional errors to the CI Validation error array self::check_additional_errors($form_name); if (self::$posting_form_name == $form_name) { // We're not in 'redirect mode' : Remove the flash session data self::$ci->session->unset_flashdata($form_name); // Validate the form if it wasn't done self::validate(self::$posting_form_name); // No key : Get the string if (is_null($key)) { self::$ci->form_validation->set_error_delimiters('<' . $delimiter . '>', '</' . $delimiter . '>'); $values = self::$ci->form_validation->error_string(); } else { $values = self::$ci->form_validation->_error_array; } } } if (!is_null($values)) { // Expand mode if (!is_null($is)) { // No key ask : Check against the additional success array if (is_null($key)) { if (!$is == empty($values)) { return self::wrap($tag, $tag->expand()); } } else { if (!$is == empty($values[$key])) { return self::wrap($tag, $tag->expand()); } } } else { if (is_null($key)) { if (!empty($values)) { $str = ''; if (is_string($values)) { $values = array($values); } foreach ($values as $val) { $str .= "<span>" . $val . "</span>"; } return self::wrap($tag, $str); } } else { if (!empty($values[$key])) { return self::wrap($tag, $fd[$key]); } } } } // No posted form : No errors if ($is == FALSE) { return $tag->expand(); } return ''; }
/** * Returns the number of results * * @param FTL_Binding * @return string */ public static function tag_search_results_count(FTL_Binding $tag) { $tag->getParent()->setAttribute('loop', FALSE); return self::tag_simple_value($tag); }
/** * @param FTL_Binding $tag * * @return string * */ public static function tag_element(FTL_Binding $tag) { // Store the parent $parent = $tag->getParent(); $tag->set('__element_parent__', $parent); // Get all the element definition potentially linked to the parent. $elements_definitions = self::get_elements_definition(Settings::get_lang('current')); // Create dynamical tags foreach ($elements_definitions as $definition) { self::$context->define_tag('element:' . $definition['name'], array(__CLASS__, 'tag_element_detail')); } return $tag->expand(); }