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