source: trunk/tags.php @ 1874

Last change on this file since 1874 was 1815, checked in by rvelices, 18 years ago

tags returned by get_all_tags, get_available_tags contain id key instead of tag_id
(as expected by make_index_url, as $pagetags was and as the database model is)

  • Property eol-style set to native
  • Property keywords set to Author Date Id Revision
File size: 4.4 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-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $Id$
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
32function counter_compare($a, $b)
33{
34  if ($a['counter'] == $b['counter'])
35  {
36    return id_compare($a, $b);
37  }
38
39  return ($a['counter'] < $b['counter']) ? +1 : -1;
40}
41
42function id_compare($a, $b)
43{
44  return ($a['id'] < $b['id']) ? -1 : 1;
45}
46
47// +-----------------------------------------------------------------------+
48// |                           initialization                              |
49// +-----------------------------------------------------------------------+
50
51define('PHPWG_ROOT_PATH','./');
52include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
53
54check_status(ACCESS_GUEST);
55
56// +-----------------------------------------------------------------------+
57// |                       page header and options                         |
58// +-----------------------------------------------------------------------+
59
60$title= l10n('Tags');
61$page['body_id'] = 'theTagsPage';
62include(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();
77
78// we want only the first most represented tags, so we sort them by counter
79// and take the first tags
80usort($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
87usort($tags, 'name_compare');
88
89// display sorted tags
90foreach ($tags as $tag)
91{
92  $template->assign_block_vars(
93    'tag',
94    array(
95      'URL' => make_index_url(
96        array(
97          'tags' => array($tag),
98          )
99        ),
100
101      'NAME' => $tag['name'],
102      'TITLE' => $tag['counter'],
103      'CLASS' => 'tagLevel'.$tag['level'],
104      )
105    );
106}
107
108// +-----------------------------------------------------------------------+
109// |                           html code display                           |
110// +-----------------------------------------------------------------------+
111
112$template->assign_block_vars('title',array());
113$template->parse('tags');
114include(PHPWG_ROOT_PATH.'include/page_tail.php');
115?>
Note: See TracBrowser for help on using the repository browser.