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