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 : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-12-14 00:58:57 +0000 (Thu, 14 Dec 2006) $ |
---|
10 | // | last modifier : $Author: rvelices $ |
---|
11 | // | revision : $Revision: 1655 $ |
---|
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 | //--------------------------------------------------------------------- include |
---|
29 | define('PHPWG_ROOT_PATH','./'); |
---|
30 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
31 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
32 | |
---|
33 | trigger_action('loc_begin_index'); |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | Check Access and exit when user status is not ok | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | check_status(ACCESS_GUEST); |
---|
39 | |
---|
40 | //---------------------------------------------- change of image display order |
---|
41 | if (isset($_GET['image_order'])) |
---|
42 | { |
---|
43 | if ( (int)$_GET['image_order'] > 0) |
---|
44 | { |
---|
45 | pwg_set_session_var('image_order', (int)$_GET['image_order']); |
---|
46 | } |
---|
47 | else |
---|
48 | { |
---|
49 | pwg_unset_session_var('image_order'); |
---|
50 | } |
---|
51 | redirect( |
---|
52 | duplicate_index_url( |
---|
53 | array(), // nothing to redefine |
---|
54 | array('start') // changing display order goes back to section first page |
---|
55 | ) |
---|
56 | ); |
---|
57 | } |
---|
58 | //-------------------------------------------------------------- initialization |
---|
59 | // detection of the start picture to display |
---|
60 | if (!isset($page['start'])) |
---|
61 | { |
---|
62 | $page['start'] = 0; |
---|
63 | } |
---|
64 | |
---|
65 | // access authorization check |
---|
66 | if (isset($page['category'])) |
---|
67 | { |
---|
68 | check_restrictions($page['category']); |
---|
69 | } |
---|
70 | |
---|
71 | if (isset($page['cat_nb_images']) |
---|
72 | and $page['cat_nb_images'] > $user['nb_image_page']) |
---|
73 | { |
---|
74 | $page['navigation_bar'] = create_navigation_bar( |
---|
75 | duplicate_index_url(array(), array('start')), |
---|
76 | $page['cat_nb_images'], |
---|
77 | $page['start'], |
---|
78 | $user['nb_image_page'], |
---|
79 | true |
---|
80 | ); |
---|
81 | } |
---|
82 | else |
---|
83 | { |
---|
84 | $page['navigation_bar'] = ''; |
---|
85 | } |
---|
86 | |
---|
87 | // caddie filling :-) |
---|
88 | if (isset($_GET['caddie'])) |
---|
89 | { |
---|
90 | fill_caddie($page['items']); |
---|
91 | // redirect(); |
---|
92 | } |
---|
93 | |
---|
94 | //----------------------------------------------------- template initialization |
---|
95 | // |
---|
96 | // Start output of page |
---|
97 | // |
---|
98 | $title = $page['title']; |
---|
99 | $page['body_id'] = 'theCategoryPage'; |
---|
100 | |
---|
101 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
102 | //-------------------------------------------------------------- category title |
---|
103 | $template_title = $page['title']; |
---|
104 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) |
---|
105 | { |
---|
106 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
107 | } |
---|
108 | |
---|
109 | if (isset($_GET['filter_local_mode'])) |
---|
110 | { |
---|
111 | $page['filter_local_mode'] = ($_GET['filter_local_mode'] == 'start'); |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | $page['filter_local_mode'] = pwg_get_session_var('filter_local_mode', false); |
---|
116 | } |
---|
117 | |
---|
118 | $page['filter_local_mode'] = (($page['filter_local_mode']) and |
---|
119 | ($page['section'] == 'categories') and |
---|
120 | (!isset($page['chronology_field']))); |
---|
121 | pwg_set_session_var('filter_local_mode', $page['filter_local_mode']); |
---|
122 | |
---|
123 | if ($page['filter_local_mode']) |
---|
124 | { |
---|
125 | $template->assign_block_vars( |
---|
126 | 'stop_filter_local_mode', |
---|
127 | array( |
---|
128 | 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'stop')) |
---|
129 | ) |
---|
130 | ); |
---|
131 | } |
---|
132 | else |
---|
133 | { |
---|
134 | $template->assign_block_vars( |
---|
135 | 'start_filter_local_mode', |
---|
136 | array( |
---|
137 | 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'start')) |
---|
138 | ) |
---|
139 | ); |
---|
140 | } |
---|
141 | |
---|
142 | if (isset($_GET['filter_global_mode'])) |
---|
143 | { |
---|
144 | $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start'); |
---|
145 | pwg_set_session_var('filter_global_mode', $user['filter_global_mode']); |
---|
146 | } |
---|
147 | else |
---|
148 | { |
---|
149 | $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false); |
---|
150 | } |
---|
151 | |
---|
152 | if ($user['filter_global_mode']) |
---|
153 | { |
---|
154 | $template->assign_block_vars( |
---|
155 | 'stop_filter_global_mode', |
---|
156 | array( |
---|
157 | 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'stop')) |
---|
158 | ) |
---|
159 | ); |
---|
160 | } |
---|
161 | else |
---|
162 | { |
---|
163 | $template->assign_block_vars( |
---|
164 | 'start_filter_global_mode', |
---|
165 | array( |
---|
166 | 'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'start')) |
---|
167 | ) |
---|
168 | ); |
---|
169 | } |
---|
170 | |
---|
171 | if (!isset($page['chronology_field'])) |
---|
172 | { |
---|
173 | $chronology_params = |
---|
174 | array( |
---|
175 | 'chronology_field' => 'created', |
---|
176 | 'chronology_style' => 'monthly', |
---|
177 | 'chronology_view' => 'list', |
---|
178 | ); |
---|
179 | $template->assign_block_vars( |
---|
180 | 'mode_created', |
---|
181 | array( |
---|
182 | 'URL' => duplicate_index_url( $chronology_params, array('start') ) |
---|
183 | ) |
---|
184 | ); |
---|
185 | |
---|
186 | $chronology_params['chronology_field'] = 'posted'; |
---|
187 | $template->assign_block_vars( |
---|
188 | 'mode_posted', |
---|
189 | array( |
---|
190 | 'URL' => duplicate_index_url( $chronology_params, array('start') ) |
---|
191 | ) |
---|
192 | ); |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | $template->assign_block_vars( |
---|
197 | 'mode_normal', |
---|
198 | array( |
---|
199 | 'URL' => duplicate_index_url( array(), array('chronology_field','start') ) |
---|
200 | ) |
---|
201 | ); |
---|
202 | |
---|
203 | if ($page['chronology_field'] == 'created') |
---|
204 | { |
---|
205 | $chronology_field = 'posted'; |
---|
206 | } |
---|
207 | else |
---|
208 | { |
---|
209 | $chronology_field = 'created'; |
---|
210 | } |
---|
211 | $url = duplicate_index_url( |
---|
212 | array('chronology_field'=>$chronology_field ), |
---|
213 | array('chronology_date', 'start') |
---|
214 | ); |
---|
215 | $template->assign_block_vars( |
---|
216 | 'mode_'.$chronology_field, |
---|
217 | array('URL' => $url ) |
---|
218 | ); |
---|
219 | } |
---|
220 | // include menubar |
---|
221 | include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
222 | |
---|
223 | $template->assign_vars( |
---|
224 | array( |
---|
225 | 'TITLE' => $template_title |
---|
226 | ) |
---|
227 | ); |
---|
228 | |
---|
229 | if ('search' == $page['section']) |
---|
230 | { |
---|
231 | $template->assign_block_vars( |
---|
232 | 'search_rules', |
---|
233 | array( |
---|
234 | 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], |
---|
235 | ) |
---|
236 | ); |
---|
237 | } |
---|
238 | |
---|
239 | if (isset($page['category']) and is_admin()) |
---|
240 | { |
---|
241 | $template->assign_block_vars( |
---|
242 | 'edit', |
---|
243 | array( |
---|
244 | 'URL' => |
---|
245 | get_root_url().'admin.php?page=cat_modify' |
---|
246 | .'&cat_id='.$page['category'] |
---|
247 | ) |
---|
248 | ); |
---|
249 | } |
---|
250 | |
---|
251 | if (is_admin() and !empty($page['items']) ) |
---|
252 | { |
---|
253 | $template->assign_block_vars( |
---|
254 | 'caddie', |
---|
255 | array( |
---|
256 | 'URL' => |
---|
257 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
258 | ) |
---|
259 | ); |
---|
260 | } |
---|
261 | |
---|
262 | if ( $page['section']=='search' and $page['start']==0 ) |
---|
263 | { |
---|
264 | $tags = get_common_tags($page['items'], |
---|
265 | $conf['content_tag_cloud_items_number'], null); |
---|
266 | if ( count($tags)>1 ) |
---|
267 | { |
---|
268 | $template->assign_block_vars('related_tags', array() ); |
---|
269 | |
---|
270 | $tags = add_level_to_tags($tags); |
---|
271 | foreach ($tags as $tag) |
---|
272 | { |
---|
273 | $template->assign_block_vars( |
---|
274 | 'related_tags.tag', array( |
---|
275 | 'URL' => make_index_url( |
---|
276 | array( |
---|
277 | 'tags' => array( |
---|
278 | array( |
---|
279 | 'id' => $tag['tag_id'], |
---|
280 | 'url_name' => $tag['url_name'], |
---|
281 | ), |
---|
282 | ) |
---|
283 | ) |
---|
284 | ), |
---|
285 | 'NAME' => $tag['name'], |
---|
286 | 'TITLE' => sprintf( |
---|
287 | l10n('%d pictures are also linked to current tags'), |
---|
288 | $tag['counter'] |
---|
289 | ), |
---|
290 | 'CLASS' => 'tagLevel'.$tag['level'] |
---|
291 | ) |
---|
292 | ); |
---|
293 | } |
---|
294 | } |
---|
295 | } |
---|
296 | |
---|
297 | //------------------------------------------------------ main part : thumbnails |
---|
298 | if (isset($page['thumbnails_include'])) |
---|
299 | { |
---|
300 | include(PHPWG_ROOT_PATH.$page['thumbnails_include']); |
---|
301 | } |
---|
302 | //------------------------------------------------------- category informations |
---|
303 | |
---|
304 | // navigation bar |
---|
305 | if ($page['navigation_bar'] != '') |
---|
306 | { |
---|
307 | $template->assign_block_vars( |
---|
308 | 'cat_infos.navigation', |
---|
309 | array( |
---|
310 | 'NAV_BAR' => $page['navigation_bar'], |
---|
311 | ) |
---|
312 | ); |
---|
313 | } |
---|
314 | |
---|
315 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 |
---|
316 | and $page['section'] != 'most_visited' |
---|
317 | and $page['section'] != 'best_rated') |
---|
318 | { |
---|
319 | // image order |
---|
320 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
321 | |
---|
322 | $order_idx = pwg_get_session_var( 'image_order', 0 ); |
---|
323 | |
---|
324 | $orders = get_category_preferred_image_orders(); |
---|
325 | for ($i = 0; $i < count($orders); $i++) |
---|
326 | { |
---|
327 | if ($orders[$i][2]) |
---|
328 | { |
---|
329 | $template->assign_block_vars( |
---|
330 | 'preferred_image_order.order', |
---|
331 | array( |
---|
332 | 'DISPLAY' => $orders[$i][0], |
---|
333 | 'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ), |
---|
334 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
335 | ) |
---|
336 | ); |
---|
337 | } |
---|
338 | } |
---|
339 | } |
---|
340 | |
---|
341 | // category comment |
---|
342 | if (isset($page['comment']) and $page['comment'] != '') |
---|
343 | { |
---|
344 | $template->assign_block_vars( |
---|
345 | 'cat_infos.comment', |
---|
346 | array( |
---|
347 | 'COMMENTS' => $page['comment'] |
---|
348 | ) |
---|
349 | ); |
---|
350 | $header_infos['COMMENT'] = strip_tags($page['comment']); |
---|
351 | } |
---|
352 | //------------------------------------------------------------ log informations |
---|
353 | pwg_log('category', $page['title']); |
---|
354 | |
---|
355 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
356 | trigger_action('loc_end_index'); |
---|
357 | $template->parse('index'); |
---|
358 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
359 | ?> |
---|