/** * Displays an error concerning one tag use * * @param FTL_Binding * @param String Message * @param String Error template * * @return String Error message * */ protected static function show_tag_error(FTL_Binding $tag, $message, $template = 'error_tag') { // Build the tag string as written in the view $attributes = $tag->getAttributes(); $attr_str = ''; foreach ($attributes as $key => $value) { $attr_str .= ' ' . $key . '="' . $value . '"'; } // Used by APPPATH.'errors/'.$template.EXT $tag_name = '<' . self::$tag_prefix . ':' . $tag->nesting() . ' ' . $attr_str . '>'; ob_start(); include APPPATH . 'errors/' . $template . EXT; $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
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; }
/** * Filters the articles regarding range. * */ public static function filter_articles(FTL_Binding $tag, $articles) { // Range : Start and stop index, coma separated $range = $tag->getAttribute('range'); if (!is_null($range)) { $range = explode(',', $range); } // Number of wished displayed medias $limit = $tag->getAttribute('limit'); $from = $to = FALSE; if (is_array($range)) { $from = $range[0]; $to = isset($range[1]) && $range[1] >= $range[0] ? $range[1] : FALSE; } // Return list ? // If set to "list", will return the list, coma separated. // Usefull for javascript // Not yet implemented $return = $tag->getAttribute('return', FALSE); if (!empty($articles)) { // Range / Limit ? if (!is_null($range)) { $length = $to !== FALSE ? $to + 1 - $from : count($articles) + 1 - $from; if ($limit > 0 && $limit < $length) { $length = $limit; } $from = $from - 1; $articles = array_slice($articles, $from, $length); } else { if ($limit > 0) { $articles = array_slice($articles, 0, $limit); } } // Other filters if (!empty($articles)) { // $keys = array_keys($filtered_medias[0]); $attributes = $tag->getAttributes(); $attributes = array_diff(array_keys($attributes), array('tag', 'class', 'type', 'order_by', 'range', 'limit', 'filter', 'return')); if (!empty($attributes)) { $tmp_articles = $articles; $filtered_articles = array(); foreach ($attributes as $attribute) { $attribute_value = $tag->getAttribute($attribute); foreach ($tmp_articles as $article) { if (isset($article[$attribute])) { if ($article[$attribute] == $attribute_value) { $filtered_articles[] = $article; } } else { $filtered_articles[] = $article; } } } $articles = $filtered_articles; } } } return $articles; }