Changeset 26665 for extensions/typetags/include/events_public.inc.php
- Timestamp:
- Jan 12, 2014, 7:13:40 PM (10 years ago)
- Location:
- extensions/typetags/include
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/typetags/include/events_public.inc.php
r24342 r26665 1 1 <?php 2 defined('TYPETAGS_PATH') or die('Hacking attempt!'); 2 3 3 4 /** 4 5 * triggered by 'render_tag_name' 5 6 */ 6 function typetags_render($tag )7 function typetags_render($tag_name, $tag=array()) 7 8 { 8 global $pwg_loaded_plugins, $page ;9 10 if ( defined('IN_ADMIN') and in_array($page['page'], array('photo', 'batch_manager')))9 global $pwg_loaded_plugins, $page, $typetags_cache; 10 11 if (defined('IN_ADMIN') and in_array($page['page'], array('photo', 'batch_manager', 'tags'))) 11 12 { 12 return $tag ;13 return $tag_name; 13 14 } 14 15 $query = ' 15 16 if (isset($typetags_cache['tags'][$tag_name])) 17 { 18 return $typetags_cache['tags'][$tag_name]; 19 } 20 21 if (!isset($typetags_cache['colors'])) 22 { 23 $query = ' 24 SELECT id, color 25 FROM ' . TYPETAGS_TABLE . ' 26 ;'; 27 $typetags_cache['colors'] = query2array($query, 'id', 'color'); 28 } 29 30 if (!empty($tag['id_typetags'])) 31 { 32 $color = $typetags_cache['colors'][ $tag['id_typetags'] ]; 33 } 34 else 35 { 36 if (isset($tag['id'])) 37 { 38 $where = 't.id = ' . $tag['id']; 39 } 40 else 41 { 42 $where = 't.name = "' . pwg_db_real_escape_string($tag_name) . '"'; 43 } 44 45 $query = ' 16 46 SELECT color 17 FROM '.typetags_TABLE.' AS tt 18 INNER JOIN '.TAGS_TABLE.' AS t 19 ON t.id_typetags = tt.id 20 WHERE t.name = "'.pwg_db_real_escape_string($tag).'" 21 ;';; 22 list($color) = pwg_db_fetch_row(pwg_query($query)); 23 24 if ($color === null) 47 FROM ' . TYPETAGS_TABLE . ' AS tt 48 INNER JOIN ' . TAGS_TABLE . ' AS t 49 ON t.id_typetags = tt.id 50 WHERE ' . $where . ' 51 ;'; 52 list($color) = pwg_db_fetch_row(pwg_query($query)); 53 } 54 55 if ($color === null) 25 56 { 26 return $tag;57 $ret = $tag_name; 27 58 } 28 59 elseif (isset($pwg_loaded_plugins['ExtendedDescription'])) 29 60 { 30 return "[lang=all]<span style='color:".$color.";'>[/lang]".$tag."[lang=all]</span>[/lang]";61 $ret = '[lang=all]<span style="color:' . $color . ';">[/lang]' . $tag_name . '[lang=all]</span>[/lang]'; 31 62 } 32 63 else 33 64 { 34 return "<span style='color:".$color.";'>".$tag."</span>";65 $ret = '<span style="color:' . $color . ';">' . $tag_name . '</span>'; 35 66 } 67 68 $typetags_cache['tags'][$tag_name] = $ret; 69 return $ret; 36 70 } 37 71 … … 42 76 { 43 77 global $template; 44 78 45 79 $tags = $template->get_template_vars('related_tags'); 46 80 if (empty($tags)) return; 47 81 48 82 $query = ' 49 83 SELECT 50 84 t.id , 51 85 tt.color 52 FROM '. typetags_TABLE.' AS tt86 FROM '.TYPETAGS_TABLE.' AS tt 53 87 INNER JOIN '.TAGS_TABLE.' AS t 54 88 ON t.id_typetags = tt.id … … 65 99 } 66 100 } 67 101 68 102 $template->clear_assign('related_tags'); 69 103 $template->assign('related_tags', $tags); … … 75 109 function typetags_tags() 76 110 { 77 global $template; 111 global $template, $page, $tags; 112 113 if (empty($tags)) 114 { 115 return; 116 } 78 117 79 118 $query = ' 80 119 SELECT 81 t.id 120 t.id, 82 121 tt.color 83 FROM ' .typetags_TABLE.' AS tt84 INNER JOIN ' .TAGS_TABLE.' AS t85 122 FROM ' . TYPETAGS_TABLE . ' AS tt 123 INNER JOIN ' . TAGS_TABLE . ' AS t 124 ON t.id_typetags = tt.id 86 125 WHERE t.id_typetags IS NOT NULL 87 126 ;'; 88 $tagsColor = simple_hash_from_query($query, 'id', 'color'); 89 if (empty($tagsColor)) return; 127 $tagsColor = query2array($query, 'id', 'color'); 90 128 91 $display = $template->get_template_vars('display_mode'); 92 if ($display == 'letters') 129 if (empty($tagsColor)) 130 { 131 return; 132 } 133 134 // LETTERS 135 if ($page['display_mode'] == 'letters') 93 136 { 94 137 $letters = $template->get_template_vars('letters'); 95 if (empty($letters)) return;96 138 97 foreach ($letters as $k1 =>$letter)139 foreach ($letters as &$letter) 98 140 { 99 foreach ($letter['tags'] as $k2 =>$tag)141 foreach ($letter['tags'] as &$tag) 100 142 { 101 143 if (isset($tagsColor[ $tag['id'] ])) 102 144 { 103 $ letters[$k1]['tags'][$k2]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';145 $tag['URL'].= '" style="color:' . $tagsColor[ $tag['id'] ] . ';'; 104 146 } 105 147 } 148 unset($tag); 106 149 } 107 108 $template->clear_assign('letters'); 150 unset($letter); 151 109 152 $template->assign('letters', $letters); 110 153 } 111 elseif ($display == 'cloud') 154 // CLOUD 155 else if ($page['display_mode'] == 'cloud') 112 156 { 113 157 $tags = $template->get_template_vars('tags'); 114 if (empty($tags)) return;115 158 116 foreach ($tags as $key =>$tag)159 foreach ($tags as &$tag) 117 160 { 118 161 if (isset($tagsColor[ $tag['id'] ])) 119 162 { 120 $tag s[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';';163 $tag['URL'].= '" style="color:' . $tagsColor[ $tag['id'] ] . ';'; 121 164 } 122 165 } 123 124 $template->clear_assign('tags'); 166 unset($tag); 167 125 168 $template->assign('tags', $tags); 126 169 } 127 elseif ($display == 'cumulus') 170 // CUMULUS 171 else if ($page['display_mode'] == 'cumulus') 128 172 { 129 173 $tags = $template->get_template_vars('tags'); 130 if (empty($tags)) return;131 174 132 foreach ($tags as $key =>$tag)175 foreach ($tags as &$tag) 133 176 { 134 177 if (isset($tagsColor[ $tag['id'] ])) 135 178 { 136 179 $tagsColor[ $tag['id'] ] = str_replace('#', '0x', $tagsColor[ $tag['id'] ]); 137 $tag s[$key]['URL'].= '\' color=\''.$tagsColor[ $tag['id'] ].'\' hicolor=\''.$tagsColor[ $tag['id'] ];180 $tag['URL'].= '\' color=\'' . $tagsColor[ $tag['id'] ] . '\' hicolor=\'' . $tagsColor[ $tag['id'] ]; 138 181 } 139 182 } 140 141 $template->clear_assign('tags'); 183 unset($tag); 184 142 185 $template->assign('tags', $tags); 143 186 } 144 187 } 145 146 ?>
Note: See TracChangeset
for help on using the changeset viewer.