Changeset 7550
- Timestamp:
- 02/20/08 07:23:01 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelActAsTaggableBehaviorPlugin/trunk/lib/helper/TagsHelper.php
r4111 r7550 2 2 /* 3 3 * This file is part of the sfPropelActAsTaggableBehavior package. 4 * 4 * 5 5 * (c) 2007 Xavier Lacot <xavier@lacot.org> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. 9 9 */ 10 10 11 /** 12 * Generates a tag cloud from a tags array. 13 * 14 * @param array $tags The tags array. This array must associate the tags 15 * to their weight. The metgod sfPropelActAsTaggableToolkit::normalize() is here 16 * to help generate such an array 17 * 18 * @param mixed $route The route name to be used in the tag. If using the& 19 * link_to_remote function, this parameter acts as the remote options array 20 * 21 * @param array $options Optionnal options array for formating the link. 22 * Supported keys are: 23 * * class: html class to be applied to the tags list 24 * * link_funktion: custom function to be used for generating each tag link 25 * * link_options: html options to be applied to the generated link 26 */ 11 27 function tag_cloud($tags, $route, $options = array()) 12 28 { … … 15 31 if(count($tags) > 0) 16 32 { 17 $emphasizers_begin = array(-2 => '<small><small>', 18 -1 => '<small>', 19 0 => '', 20 1 => '<big>', 33 $emphasizers_begin = array(-2 => '<small><small>', 34 -1 => '<small>', 35 0 => '', 36 1 => '<big>', 21 37 2 => '<big><big>'); 22 $emphasizers_end = array(-2 => '</small></small>', 23 -1 => '</small>', 24 0 => '', 25 1 => '</big>', 38 $emphasizers_end = array(-2 => '</small></small>', 39 -1 => '</small>', 40 0 => '', 41 1 => '</big>', 26 42 2 => '</big></big>'); 27 43 44 $custom_route = is_string($route) && false !== strpos($route, '%s'); 45 46 if (!$custom_route) 47 { 48 $route_link = $route; 49 } 50 28 51 $class = isset($options['class']) ? $options['class'] : 'tag-cloud'; 52 $link_function = isset($options['link_function']) ? $options['link_function'] : 'link_to'; 53 $link_options = isset($options['link_options']) ? $options['link_options'] : array(); 54 $link_options['rel'] = 'tag'; 29 55 $result = '<ul class="'.$class.'">'; 30 56 31 57 foreach ($tags as $name => $count) 32 58 { 33 $link = link_to($name, 34 $route.$name, 35 array('rel' => 'tag')); 59 if ($custom_route) 60 { 61 $route_link = sprintf($route, $name); 62 } 36 63 64 $link = $link_function($name, $route_link, $link_options); 37 65 $result .= ' 38 66 <li>'.$emphasizers_begin[$count].$link.$emphasizers_end[$count].'</li>'; … … 57 85 { 58 86 $link = link_to($tag, 59 $route.$tag, 87 $route.$tag, 60 88 array('rel' => 'tag')); 61 89 … … 81 109 } 82 110 83 $emphasizers_begin = array(-2 => '<small><small>', 84 -1 => '<small>', 85 0 => '', 86 1 => '<big>', 111 $emphasizers_begin = array(-2 => '<small><small>', 112 -1 => '<small>', 113 0 => '', 114 1 => '<big>', 87 115 2 => '<big><big>'); 88 $emphasizers_end = array(-2 => '</small></small>', 89 -1 => '</small>', 90 0 => '', 91 1 => '</big>', 116 $emphasizers_end = array(-2 => '</small></small>', 117 -1 => '</small>', 118 0 => '', 119 1 => '</big>', 92 120 2 => '</big></big>'); 93 121 … … 99 127 { 100 128 $link = link_to($name, 101 $route.$name, 129 $route.$name, 102 130 array('rel' => 'tag')); 103 131 $related_link = link_to($add,