1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * triggered by 'render_tag_name' |
---|
5 | */ |
---|
6 | function typetags_render($tag) |
---|
7 | { |
---|
8 | global $pwg_loaded_plugins; |
---|
9 | |
---|
10 | $query = ' |
---|
11 | SELECT color |
---|
12 | FROM '.typetags_TABLE.' AS tt |
---|
13 | INNER JOIN '.TAGS_TABLE.' AS t |
---|
14 | ON t.id_typetags = tt.id |
---|
15 | WHERE t.name = "'.mysql_real_escape_string($tag).'" |
---|
16 | ;';; |
---|
17 | list($color) = pwg_db_fetch_row(pwg_query($query)); |
---|
18 | |
---|
19 | if ($color === null) |
---|
20 | { |
---|
21 | return $tag; |
---|
22 | } |
---|
23 | elseif (isset($pwg_loaded_plugins['ExtendedDescription'])) |
---|
24 | { |
---|
25 | return "[lang=all]<span style='color:".$color.";'>[/lang]".$tag."[lang=all]</span>[/lang]"; |
---|
26 | } |
---|
27 | else |
---|
28 | { |
---|
29 | return "<span style='color:".$color.";'>".$tag."</span>"; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * colors tags on picture page |
---|
35 | */ |
---|
36 | /*function typetags_picture() |
---|
37 | { |
---|
38 | global $template; |
---|
39 | |
---|
40 | $tags = $template->get_template_vars('related_tags'); |
---|
41 | if (empty($tags)) return; |
---|
42 | |
---|
43 | $query = ' |
---|
44 | SELECT |
---|
45 | t.id , |
---|
46 | tt.color |
---|
47 | FROM '.typetags_TABLE.' AS tt |
---|
48 | INNER JOIN '.TAGS_TABLE.' AS t |
---|
49 | ON t.id_typetags = tt.id |
---|
50 | WHERE t.id_typetags IS NOT NULL |
---|
51 | ;'; |
---|
52 | $tagsColor = simple_hash_from_query($query, 'id', 'color'); |
---|
53 | if (empty($tagsColor)) return; |
---|
54 | |
---|
55 | foreach ($tags as $key => $tag) |
---|
56 | { |
---|
57 | if (isset($tagsColor[ $tag['id'] ])) |
---|
58 | { |
---|
59 | $tags[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';'; |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | $template->clear_assign('related_tags'); |
---|
64 | $template->assign('related_tags', $tags); |
---|
65 | }*/ |
---|
66 | |
---|
67 | /** |
---|
68 | * colors tags on tags page |
---|
69 | */ |
---|
70 | function typetags_tags() |
---|
71 | { |
---|
72 | global $template; |
---|
73 | |
---|
74 | $query = ' |
---|
75 | SELECT |
---|
76 | t.id , |
---|
77 | tt.color |
---|
78 | FROM '.typetags_TABLE.' AS tt |
---|
79 | INNER JOIN '.TAGS_TABLE.' AS t |
---|
80 | ON t.id_typetags = tt.id |
---|
81 | WHERE t.id_typetags IS NOT NULL |
---|
82 | ;'; |
---|
83 | $tagsColor = simple_hash_from_query($query, 'id', 'color'); |
---|
84 | if (empty($tagsColor)) return; |
---|
85 | |
---|
86 | $display = $template->get_template_vars('display_mode'); |
---|
87 | if ($display == 'letters') |
---|
88 | { |
---|
89 | $letters = $template->get_template_vars('letters'); |
---|
90 | if (empty($letters)) return; |
---|
91 | |
---|
92 | foreach ($letters as $k1 => $letter) |
---|
93 | { |
---|
94 | foreach ($letter['tags'] as $k2 => $tag) |
---|
95 | { |
---|
96 | if (isset($tagsColor[ $tag['id'] ])) |
---|
97 | { |
---|
98 | $letters[$k1]['tags'][$k2]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';'; |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | $template->clear_assign('letters'); |
---|
104 | $template->assign('letters', $letters); |
---|
105 | } |
---|
106 | elseif ($display == 'cloud') |
---|
107 | { |
---|
108 | $tags = $template->get_template_vars('tags'); |
---|
109 | if (empty($tags)) return; |
---|
110 | |
---|
111 | foreach ($tags as $key => $tag) |
---|
112 | { |
---|
113 | if (isset($tagsColor[ $tag['id'] ])) |
---|
114 | { |
---|
115 | $tags[$key]['URL'].= '" style="color:'.$tagsColor[ $tag['id'] ].';'; |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | $template->clear_assign('tags'); |
---|
120 | $template->assign('tags', $tags); |
---|
121 | } |
---|
122 | elseif ($display == 'cumulus') |
---|
123 | { |
---|
124 | $tags = $template->get_template_vars('tags'); |
---|
125 | if (empty($tags)) return; |
---|
126 | |
---|
127 | foreach ($tags as $key => $tag) |
---|
128 | { |
---|
129 | if (isset($tagsColor[ $tag['id'] ])) |
---|
130 | { |
---|
131 | $tagsColor[ $tag['id'] ] = str_replace('#', '0x', $tagsColor[ $tag['id'] ]); |
---|
132 | $tags[$key]['URL'].= '\' color=\''.$tagsColor[ $tag['id'] ].'\' hicolor=\''.$tagsColor[ $tag['id'] ]; |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | $template->clear_assign('tags'); |
---|
137 | $template->assign('tags', $tags); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | ?> |
---|