source: trunk/include/menubar.inc.php @ 1377

Last change on this file since 1377 was 1377, checked in by nikrou, 18 years ago

svn merge -r1366:1371 from branch 1.6 into trunk

  • Property svn:executable set to *
File size: 8.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-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $Id:$
9// | last update   : $Date:$
10// | last modifier : $Author:$
11// | revision      : $Revision:$
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 * This file is included by the main page to show the menu bar
30 *
31 */ 
32$template->set_filenames(
33  array(
34    'menubar' => 'menubar.tpl',
35    )
36  );
37
38$template->assign_vars(
39  array(
40    'NB_PICTURE' => $user['nb_total_images'],
41    'USERNAME' => $user['username'],
42    'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
43    'F_IDENTIFY' => get_root_url().'identification.php',
44    'U_HOME' => make_index_URL(),
45    'U_REGISTER' => get_root_url().'register.php',
46    'U_LOST_PASSWORD' => get_root_url().'password.php',
47    'U_LOGOUT' => add_url_params(make_index_URL(), array('act'=>'logout') ),
48    'U_ADMIN'=> get_root_url().'admin.php',
49    'U_PROFILE'=> get_root_url().'profile.php',
50    )
51  );
52
53//-------------------------------------------------------------- external links
54if (count($conf['links']) > 0)
55{
56  $template->assign_block_vars('links', array());
57
58  foreach ($conf['links'] as $url => $label)
59  {
60    $template->assign_block_vars(
61      'links.link',
62      array(
63        'URL' => $url,
64        'LABEL' => $label
65        )
66      );
67  }
68}
69//------------------------------------------------------------------------ tags
70if ('tags' == $page['section'])
71{
72  $template->assign_block_vars('tags', array());
73
74  // display tags associated to currently tagged items, less current tags
75  $tags = array();
76
77  if ( !empty($page['items']) )
78  {
79    $query = '
80SELECT tag_id, name, url_name, count(*) counter
81  FROM '.IMAGE_TAG_TABLE.'
82    INNER JOIN '.TAGS_TABLE.' ON tag_id = id
83  WHERE image_id IN ('.implode(',', $items).')
84    AND tag_id NOT IN ('.implode(',', $page['tag_ids']).')
85  GROUP BY tag_id
86  ORDER BY name ASC
87;';
88    $result = pwg_query($query);
89    while($row = mysql_fetch_array($result))
90    {
91      array_push($tags, $row);
92    }
93  }
94
95  $tags = add_level_to_tags($tags);
96
97  foreach ($tags as $tag)
98  {
99    $template->assign_block_vars(
100      'tags.tag',
101      array(
102        'URL_ADD' => make_index_URL(
103          array(
104            'tags' => array_merge(
105              $page['tags'],
106              array(
107                array(
108                  'id' => $tag['tag_id'],
109                  'url_name' => $tag['url_name'],
110                  ),
111                )
112              )
113            )
114          ),
115
116        'URL' => make_index_URL(
117          array(
118            'tags' => array(
119              array(
120                'id' => $tag['tag_id'],
121                'url_name' => $tag['url_name'],
122                ),
123              )
124            )
125          ),
126
127        'NAME' => $tag['name'],
128
129        'TITLE' => l10n('See pictures linked to this tag only'),
130
131        'TITLE_ADD' => sprintf(
132          l10n('%d pictures are also linked to current tags'),
133          $tag['counter']
134          ),
135
136        'CLASS' => 'tagLevel'.$tag['level']
137        )
138      );
139  }
140}
141//---------------------------------------------------------- special categories
142// favorites categories
143if ( !$user['is_the_guest'] )
144{
145  $template->assign_block_vars('username', array());
146
147  $template->assign_block_vars(
148    'special_cat',
149    array(
150      'URL' => make_index_URL(array('section' => 'favorites')),
151      'TITLE' => $lang['favorite_cat_hint'],
152      'NAME' => $lang['favorite_cat']
153      ));
154}
155// most visited
156$template->assign_block_vars(
157  'special_cat',
158  array(
159    'URL' => make_index_URL(array('section' => 'most_visited')),
160    'TITLE' => $lang['most_visited_cat_hint'],
161    'NAME' => $lang['most_visited_cat']
162    ));
163// best rated
164if ($conf['rate'])
165{
166  $template->assign_block_vars(
167    'special_cat',
168    array(
169      'URL' => make_index_URL(array('section' => 'best_rated')),
170      'TITLE' => $lang['best_rated_cat_hint'],
171      'NAME' => $lang['best_rated_cat']
172      )
173    );
174}
175// random
176$template->assign_block_vars(
177  'special_cat',
178  array(
179    'URL' => get_root_url().'random.php',
180    'TITLE' => $lang['random_cat_hint'],
181    'NAME' => $lang['random_cat']
182    ));
183// recent pics
184$template->assign_block_vars(
185  'special_cat',
186  array(
187    'URL' => make_index_URL(array('section' => 'recent_pics')),
188    'TITLE' => $lang['recent_pics_cat_hint'],
189    'NAME' => $lang['recent_pics_cat']
190    ));
191// recent cats
192$template->assign_block_vars(
193  'special_cat',
194  array(
195    'URL' => make_index_URL(array('section' => 'recent_cats')),
196    'TITLE' => $lang['recent_cats_cat_hint'],
197    'NAME' => $lang['recent_cats_cat']
198    ));
199
200// calendar
201$template->assign_block_vars(
202  'special_cat',
203  array(
204    'URL' =>
205      make_index_URL(
206        array(
207          'chronology_field' => ($conf['calendar_datefield']=='date_available'
208                                  ? 'posted' : 'created'),
209           'chronology_style'=> 'monthly',
210           'chronology_view' => 'calendar'
211        )
212      ),
213    'TITLE' => $lang['calendar_hint'],
214    'NAME' => $lang['calendar']
215    )
216  );
217//--------------------------------------------------------------------- summary
218
219if ($user['is_the_guest'])
220{
221  $template->assign_block_vars('register', array());
222  $template->assign_block_vars('login', array());
223
224  $template->assign_block_vars('quickconnect', array());
225  if ($conf['authorize_remembering'])
226  {
227    $template->assign_block_vars('quickconnect.remember_me', array());
228  }
229}
230else
231{
232  $template->assign_block_vars('hello', array());
233
234  if (is_autorize_status(ACCESS_CLASSIC))
235  {
236    $template->assign_block_vars('profile', array());
237  }
238
239  // the logout link has no meaning with Apache authentication : it is not
240  // possible to logout with this kind of authentication.
241  if (!$conf['apache_authentication'])
242  {
243    $template->assign_block_vars('logout', array());
244  }
245
246  if (is_admin())
247  {
248    $template->assign_block_vars('admin', array());
249  }
250}
251
252// tags link
253$template->assign_block_vars(
254  'summary',
255  array(
256    'TITLE' => l10n('See available tags'),
257    'NAME' => l10n('Tags'),
258    'U_SUMMARY'=> get_root_url().'tags.php',
259    )
260  );
261
262// search link
263$template->assign_block_vars(
264  'summary',
265  array(
266    'TITLE'=>$lang['hint_search'],
267    'NAME'=>$lang['search'],
268    'U_SUMMARY'=> get_root_url().'search.php',
269    'REL'=> 'rel="search"'
270    )
271  );
272
273// comments link
274$template->assign_block_vars(
275  'summary',
276  array(
277    'TITLE'=>$lang['hint_comments'],
278    'NAME'=>$lang['comments'],
279    'U_SUMMARY'=> get_root_url().'comments.php',
280    )
281  );
282
283// about link
284$template->assign_block_vars(
285  'summary',
286  array(
287    'TITLE'     => $lang['about_page_title'],
288    'NAME'      => $lang['About'],
289    'U_SUMMARY' => get_root_url().'about.php',
290    )
291  );
292
293// notification
294$template->assign_block_vars(
295  'summary',
296  array(
297    'TITLE'=>l10n('notification'),
298    'NAME'=>l10n('Notification'),
299    'U_SUMMARY'=> get_root_url().'notification.php',
300    'REL'=> 'rel="nofollow"'
301    )
302  );
303$template->assign_var_from_handle('MENUBAR', 'menubar');
304?>
Note: See TracBrowser for help on using the repository browser.