source: trunk/tags.php @ 2223

Last change on this file since 2223 was 2223, checked in by rvelices, 16 years ago
  • migrate many templates to smarty
  • Property keywords set to Author Date Id Revision
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
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-2008 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: tags.php 2223 2008-02-28 02:41:48Z rvelices $
8// | last update   : $Date: 2008-02-28 02:41:48 +0000 (Thu, 28 Feb 2008) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2223 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27// +-----------------------------------------------------------------------+
28// |                             functions                                 |
29// +-----------------------------------------------------------------------+
30
31function counter_compare($a, $b)
32{
33  if ($a['counter'] == $b['counter'])
34  {
35    return id_compare($a, $b);
36  }
37
38  return ($a['counter'] < $b['counter']) ? +1 : -1;
39}
40
41function id_compare($a, $b)
42{
43  return ($a['id'] < $b['id']) ? -1 : 1;
44}
45
46// +-----------------------------------------------------------------------+
47// |                           initialization                              |
48// +-----------------------------------------------------------------------+
49
50define('PHPWG_ROOT_PATH','./');
51include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
52
53check_status(ACCESS_GUEST);
54
55// +-----------------------------------------------------------------------+
56// |                       page header and options                         |
57// +-----------------------------------------------------------------------+
58
59$title= l10n('Tags');
60$page['body_id'] = 'theTagsPage';
61
62$template->set_filenames(array('tags'=>'tags.tpl'));
63
64// +-----------------------------------------------------------------------+
65// |                        tag cloud construction                         |
66// +-----------------------------------------------------------------------+
67
68// find all tags available for the current user
69$tags = get_available_tags();
70
71// we want only the first most represented tags, so we sort them by counter
72// and take the first tags
73usort($tags, 'counter_compare');
74$tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']);
75
76// depending on its counter and the other tags counter, each tag has a level
77$tags = add_level_to_tags($tags);
78
79// we want tags diplayed in alphabetic order
80usort($tags, 'name_compare');
81
82// display sorted tags
83foreach ($tags as $tag)
84{
85  $template->append(
86    'tags',
87    array(
88      'URL' => make_index_url(
89        array(
90          'tags' => array($tag),
91          )
92        ),
93
94      'NAME' => $tag['name'],
95      'TITLE' => $tag['counter'],
96      'CLASS' => 'tagLevel'.$tag['level'],
97      )
98    );
99}
100
101include(PHPWG_ROOT_PATH.'include/page_header.php');
102$template->pparse('tags');
103include(PHPWG_ROOT_PATH.'include/page_tail.php');
104?>
Note: See TracBrowser for help on using the repository browser.