[3609] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 4 | |
---|
[27125] | 5 | global $conf, $template, $pwg_loaded_plugins, $tags, $page;; |
---|
[3609] | 6 | |
---|
| 7 | function counter_compare($a, $b) |
---|
| 8 | { |
---|
| 9 | if ($a['counter'] == $b['counter']) |
---|
| 10 | { |
---|
| 11 | return id_compare($a, $b); |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | return ($a['counter'] < $b['counter']) ? +1 : -1; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | function id_compare($a, $b) |
---|
| 18 | { |
---|
| 19 | return ($a['id'] < $b['id']) ? -1 : 1; |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | $pwgCumulus_installed = get_db_plugins('active','pwgCumulus'); |
---|
| 23 | |
---|
| 24 | $block['TITLE_URL'] = 'tags.php'; |
---|
| 25 | |
---|
[19067] | 26 | // hack typetags |
---|
| 27 | if (isset($pwg_loaded_plugins['typetags'])) |
---|
| 28 | { |
---|
| 29 | if ($conf['TypeTags']['show_all']) |
---|
| 30 | { |
---|
| 31 | remove_event_handler('render_tag_name', 'typetags_render', 0); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
[3609] | 35 | $tags = get_available_tags(); |
---|
| 36 | |
---|
| 37 | if ((!$pwgCumulus_installed and $datas[0] == 'cumulus') or empty($datas[0])) |
---|
| 38 | { |
---|
| 39 | $datas[0] = 'cloud'; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | if ($datas[0] == 'letters') |
---|
| 43 | { |
---|
| 44 | // we want tags diplayed in alphabetic order |
---|
| 45 | usort($tags, 'tag_alpha_compare'); |
---|
| 46 | |
---|
| 47 | $current_letter = null; |
---|
| 48 | $nb_tags = count($tags); |
---|
| 49 | $current_column = 1; |
---|
| 50 | $current_tag_idx = 0; |
---|
| 51 | |
---|
| 52 | $letter = array( |
---|
| 53 | 'tags' => array() |
---|
| 54 | ); |
---|
| 55 | |
---|
| 56 | foreach ($tags as $tag) |
---|
| 57 | { |
---|
| 58 | $tag_letter = strtoupper(substr($tag['url_name'], 0, 1)); |
---|
| 59 | |
---|
| 60 | if ($current_tag_idx==0) { |
---|
| 61 | $current_letter = $tag_letter; |
---|
| 62 | $letter['TITLE'] = $tag_letter; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | //lettre precedente differente de la lettre suivante |
---|
| 66 | if ($tag_letter !== $current_letter) |
---|
| 67 | { |
---|
| 68 | if ($current_column<$conf['tag_letters_column_number'] |
---|
| 69 | and $current_tag_idx > $current_column*$nb_tags/$conf['tag_letters_column_number'] ) |
---|
| 70 | { |
---|
| 71 | $letter['CHANGE_COLUMN'] = true; |
---|
| 72 | $current_column++; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | $letter['TITLE'] = $current_letter; |
---|
| 76 | |
---|
| 77 | $template->append( |
---|
| 78 | 'letters', |
---|
| 79 | $letter |
---|
| 80 | ); |
---|
| 81 | |
---|
| 82 | $current_letter = $tag_letter; |
---|
| 83 | $letter = array( |
---|
| 84 | 'tags' => array() |
---|
| 85 | ); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | array_push( |
---|
| 89 | $letter['tags'], |
---|
| 90 | array_merge( |
---|
| 91 | $tag, |
---|
| 92 | array( |
---|
| 93 | 'URL' => make_index_url( |
---|
| 94 | array( |
---|
| 95 | 'tags' => array($tag), |
---|
| 96 | ) |
---|
| 97 | ), |
---|
| 98 | ) |
---|
| 99 | ) |
---|
| 100 | ); |
---|
| 101 | |
---|
| 102 | $current_tag_idx++; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // flush last letter |
---|
| 106 | if (count($letter['tags']) > 0) |
---|
| 107 | { |
---|
| 108 | unset($letter['CHANGE_COLUMN']); |
---|
| 109 | $letter['TITLE'] = $current_letter; |
---|
| 110 | $template->append( |
---|
| 111 | 'letters', |
---|
| 112 | $letter |
---|
| 113 | ); |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | usort($tags, 'counter_compare'); |
---|
| 119 | $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']); |
---|
| 120 | |
---|
| 121 | // depending on its counter and the other tags counter, each tag has a level |
---|
| 122 | $tags = add_level_to_tags($tags); |
---|
| 123 | |
---|
| 124 | // we want tags diplayed in alphabetic order |
---|
| 125 | usort($tags, 'tag_alpha_compare'); |
---|
| 126 | |
---|
| 127 | // display sorted tags |
---|
| 128 | foreach ($tags as $tag) |
---|
| 129 | { |
---|
| 130 | $template->append( |
---|
| 131 | 'tags', |
---|
| 132 | array_merge( |
---|
| 133 | $tag, |
---|
| 134 | array( |
---|
| 135 | 'URL' => make_index_url( |
---|
| 136 | array( |
---|
| 137 | 'tags' => array($tag), |
---|
| 138 | ) |
---|
| 139 | ), |
---|
| 140 | ) |
---|
| 141 | ) |
---|
| 142 | ); |
---|
| 143 | } |
---|
[18062] | 144 | if ($datas[0] == 'cumulus' and defined('PWG_CUMULUS_PLUGIN_ROOT')) |
---|
[3609] | 145 | { |
---|
| 146 | include_once PWG_CUMULUS_PLUGIN_ROOT . "/include/pwgCumulusContent.class.php"; |
---|
| 147 | $cumulus = new pwgCumulusContent(get_plugin_data('pwgCumulus')); |
---|
| 148 | $cumulus->loc_begin_page_header(); |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | |
---|
[27125] | 152 | if (isset($pwg_loaded_plugins['typetags'])) |
---|
[19067] | 153 | { |
---|
[27125] | 154 | $page['display_mode'] = $datas[0]; |
---|
[19067] | 155 | typetags_tags(); |
---|
[27125] | 156 | |
---|
[19067] | 157 | if ($conf['TypeTags']['show_all']) |
---|
| 158 | { |
---|
[27125] | 159 | add_event_handler('render_tag_name', 'typetags_render', 0, 2); |
---|
[19067] | 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
[3609] | 163 | $template->assign('display_mode', $datas[0]); |
---|
| 164 | |
---|
[9369] | 165 | $block['TEMPLATE'] = 'stuffs_tags.tpl'; |
---|
| 166 | |
---|
[18062] | 167 | ?> |
---|