[1119] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
| 5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | branch : BSF (Best So Far) |
---|
| 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2006-03-22 02:01:47 +0100 (mer, 22 mar 2006) $ |
---|
| 10 | // | last modifier : $Author: rvelices $ |
---|
| 11 | // | revision : $Revision: 1092 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
| 27 | |
---|
| 28 | // +-----------------------------------------------------------------------+ |
---|
| 29 | // | functions | |
---|
| 30 | // +-----------------------------------------------------------------------+ |
---|
| 31 | |
---|
| 32 | function counter_compare($a, $b) |
---|
| 33 | { |
---|
| 34 | if ($a['counter'] == $b['counter']) |
---|
| 35 | { |
---|
| 36 | return tag_id_compare($a, $b); |
---|
| 37 | } |
---|
| 38 | |
---|
[1120] | 39 | return ($a['counter'] < $b['counter']) ? +1 : -1; |
---|
[1119] | 40 | } |
---|
| 41 | |
---|
| 42 | function tag_id_compare($a, $b) |
---|
| 43 | { |
---|
| 44 | return ($a['tag_id'] < $b['tag_id']) ? -1 : 1; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | // +-----------------------------------------------------------------------+ |
---|
| 48 | // | initialization | |
---|
| 49 | // +-----------------------------------------------------------------------+ |
---|
| 50 | |
---|
| 51 | define('PHPWG_ROOT_PATH','./'); |
---|
| 52 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
| 53 | |
---|
| 54 | check_status(ACCESS_GUEST); |
---|
| 55 | |
---|
| 56 | // +-----------------------------------------------------------------------+ |
---|
| 57 | // | page header and options | |
---|
| 58 | // +-----------------------------------------------------------------------+ |
---|
| 59 | |
---|
| 60 | $title= l10n('Tags'); |
---|
| 61 | $page['body_id'] = 'theTagsPage'; |
---|
| 62 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
| 63 | |
---|
| 64 | $template->set_filenames(array('tags'=>'tags.tpl')); |
---|
| 65 | $template->assign_vars( |
---|
| 66 | array( |
---|
| 67 | 'U_HOME' => make_index_url(), |
---|
| 68 | ) |
---|
| 69 | ); |
---|
| 70 | |
---|
| 71 | // +-----------------------------------------------------------------------+ |
---|
| 72 | // | tag cloud construction | |
---|
| 73 | // +-----------------------------------------------------------------------+ |
---|
| 74 | |
---|
| 75 | // find all tags available for the current user |
---|
| 76 | $tags = get_available_tags(explode(',', $user['forbidden_categories'])); |
---|
| 77 | |
---|
| 78 | // we want only the first most represented tags, so we sort them by counter |
---|
| 79 | // and take the first tags |
---|
| 80 | usort($tags, 'counter_compare'); |
---|
| 81 | $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']); |
---|
| 82 | |
---|
| 83 | // depending on its counter and the other tags counter, each tag has a level |
---|
| 84 | $tags = add_level_to_tags($tags); |
---|
| 85 | |
---|
| 86 | // we want tags diplayed in alphabetic order |
---|
| 87 | usort($tags, 'name_compare'); |
---|
| 88 | |
---|
| 89 | // display sorted tags |
---|
| 90 | foreach ($tags as $tag) |
---|
| 91 | { |
---|
| 92 | $template->assign_block_vars( |
---|
| 93 | 'tag', |
---|
| 94 | array( |
---|
| 95 | 'URL' => make_index_url( |
---|
| 96 | array( |
---|
| 97 | 'tags' => array( |
---|
| 98 | array( |
---|
| 99 | 'id' => $tag['tag_id'], |
---|
| 100 | 'url_name' => $tag['url_name'], |
---|
| 101 | ), |
---|
| 102 | ), |
---|
| 103 | ) |
---|
| 104 | ), |
---|
[1120] | 105 | |
---|
[1119] | 106 | 'NAME' => $tag['name'], |
---|
| 107 | 'TITLE' => $tag['counter'], |
---|
| 108 | 'CLASS' => 'tagLevel'.$tag['level'], |
---|
| 109 | ) |
---|
| 110 | ); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | // +-----------------------------------------------------------------------+ |
---|
| 114 | // | html code display | |
---|
| 115 | // +-----------------------------------------------------------------------+ |
---|
| 116 | |
---|
| 117 | $template->assign_block_vars('title',array()); |
---|
| 118 | $template->parse('tags'); |
---|
| 119 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
| 120 | ?> |
---|