source: branches/1.7/tags.php @ 27569

Last change on this file since 27569 was 2410, checked in by rvelices, 16 years ago
  • tags improvement : pass to templates all fields in table #tags (handy for plugins such as type tags)
  • 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: 4.3 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: tags.php 2410 2008-07-01 02:10:13Z rvelices $
9// | last update   : $Date: 2008-07-01 02:10:13 +0000 (Tue, 01 Jul 2008) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 2410 $
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_merge(
95      $tag,
96      array(
97        'URL' => make_index_url(
98          array(
99            'tags' => array($tag),
100            )
101          ),
102
103        'NAME' => $tag['name'],
104        'TITLE' => $tag['counter'],
105        'CLASS' => 'tagLevel'.$tag['level'],
106        )
107      )
108    );
109}
110
111// +-----------------------------------------------------------------------+
112// |                           html code display                           |
113// +-----------------------------------------------------------------------+
114
115$template->assign_block_vars('title',array());
116$template->parse('tags');
117include(PHPWG_ROOT_PATH.'include/page_tail.php');
118?>
Note: See TracBrowser for help on using the repository browser.