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 | // | file : $Id: index.php 2138 2007-10-16 01:46:09Z rvelices $ |
---|
8 | // | last update : $Date: 2007-10-16 01:46:09 +0000 (Tue, 16 Oct 2007) $ |
---|
9 | // | last modifier : $Author: rvelices $ |
---|
10 | // | revision : $Revision: 2138 $ |
---|
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 | //--------------------------------------------------------------------- include |
---|
28 | define('PHPWG_ROOT_PATH','./'); |
---|
29 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
30 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
31 | |
---|
32 | trigger_action('loc_begin_index'); |
---|
33 | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | // | Check Access and exit when user status is not ok | |
---|
36 | // +-----------------------------------------------------------------------+ |
---|
37 | check_status(ACCESS_GUEST); |
---|
38 | |
---|
39 | //---------------------------------------------- change of image display order |
---|
40 | if (isset($_GET['image_order'])) |
---|
41 | { |
---|
42 | if ( (int)$_GET['image_order'] > 0) |
---|
43 | { |
---|
44 | pwg_set_session_var('image_order', (int)$_GET['image_order']); |
---|
45 | } |
---|
46 | else |
---|
47 | { |
---|
48 | pwg_unset_session_var('image_order'); |
---|
49 | } |
---|
50 | redirect( |
---|
51 | duplicate_index_url( |
---|
52 | array(), // nothing to redefine |
---|
53 | array('start') // changing display order goes back to section first page |
---|
54 | ) |
---|
55 | ); |
---|
56 | } |
---|
57 | //-------------------------------------------------------------- initialization |
---|
58 | // detection of the start picture to display |
---|
59 | if (!isset($page['start'])) |
---|
60 | { |
---|
61 | $page['start'] = 0; |
---|
62 | } |
---|
63 | |
---|
64 | // access authorization check |
---|
65 | if (isset($page['category'])) |
---|
66 | { |
---|
67 | check_restrictions($page['category']['id']); |
---|
68 | } |
---|
69 | |
---|
70 | if ( count($page['items']) > $user['nb_image_page']) |
---|
71 | { |
---|
72 | $page['navigation_bar'] = create_navigation_bar( |
---|
73 | duplicate_index_url(array(), array('start')), |
---|
74 | count($page['items']), |
---|
75 | $page['start'], |
---|
76 | $user['nb_image_page'], |
---|
77 | true |
---|
78 | ); |
---|
79 | } |
---|
80 | else |
---|
81 | { |
---|
82 | $page['navigation_bar'] = ''; |
---|
83 | } |
---|
84 | |
---|
85 | // caddie filling :-) |
---|
86 | if (isset($_GET['caddie'])) |
---|
87 | { |
---|
88 | fill_caddie($page['items']); |
---|
89 | redirect(duplicate_index_url()); |
---|
90 | } |
---|
91 | |
---|
92 | //----------------------------------------------------- template initialization |
---|
93 | // |
---|
94 | // Start output of page |
---|
95 | // |
---|
96 | $title = $page['title']; |
---|
97 | $page['body_id'] = 'theCategoryPage'; |
---|
98 | |
---|
99 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
100 | //-------------------------------------------------------------- category title |
---|
101 | $template_title = $page['title']; |
---|
102 | if ( count($page['items']) > 0) |
---|
103 | { |
---|
104 | $template_title.= ' ['.count($page['items']).']'; |
---|
105 | } |
---|
106 | $template->assign_var('TITLE', $template_title); |
---|
107 | |
---|
108 | if (isset($page['flat']) or isset($page['chronology_field'])) |
---|
109 | { |
---|
110 | $template->assign_block_vars( |
---|
111 | 'mode_normal', |
---|
112 | array( |
---|
113 | 'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) |
---|
114 | ) |
---|
115 | ); |
---|
116 | } |
---|
117 | |
---|
118 | if (!isset($page['flat']) and 'categories' == $page['section']) |
---|
119 | { |
---|
120 | $template->assign_block_vars( |
---|
121 | 'flat', |
---|
122 | array( |
---|
123 | 'URL' => duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) |
---|
124 | ) |
---|
125 | ); |
---|
126 | } |
---|
127 | |
---|
128 | if (!isset($page['chronology_field'])) |
---|
129 | { |
---|
130 | $chronology_params = |
---|
131 | array( |
---|
132 | 'chronology_field' => 'created', |
---|
133 | 'chronology_style' => 'monthly', |
---|
134 | 'chronology_view' => 'list', |
---|
135 | ); |
---|
136 | $template->assign_block_vars( |
---|
137 | 'mode_created', |
---|
138 | array( |
---|
139 | 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
140 | ) |
---|
141 | ); |
---|
142 | |
---|
143 | $chronology_params['chronology_field'] = 'posted'; |
---|
144 | $template->assign_block_vars( |
---|
145 | 'mode_posted', |
---|
146 | array( |
---|
147 | 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
148 | ) |
---|
149 | ); |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | if ($page['chronology_field'] == 'created') |
---|
154 | { |
---|
155 | $chronology_field = 'posted'; |
---|
156 | } |
---|
157 | else |
---|
158 | { |
---|
159 | $chronology_field = 'created'; |
---|
160 | } |
---|
161 | $url = duplicate_index_url( |
---|
162 | array('chronology_field'=>$chronology_field ), |
---|
163 | array('chronology_date', 'start', 'flat') |
---|
164 | ); |
---|
165 | $template->assign_block_vars( |
---|
166 | 'mode_'.$chronology_field, |
---|
167 | array('URL' => $url ) |
---|
168 | ); |
---|
169 | } |
---|
170 | // include menubar |
---|
171 | include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
172 | |
---|
173 | if ('search' == $page['section']) |
---|
174 | { |
---|
175 | $template->assign_block_vars( |
---|
176 | 'search_rules', |
---|
177 | array( |
---|
178 | 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], |
---|
179 | ) |
---|
180 | ); |
---|
181 | } |
---|
182 | |
---|
183 | if (isset($page['category']) and is_admin()) |
---|
184 | { |
---|
185 | $template->assign_block_vars( |
---|
186 | 'edit', |
---|
187 | array( |
---|
188 | 'URL' => |
---|
189 | get_root_url().'admin.php?page=cat_modify' |
---|
190 | .'&cat_id='.$page['category']['id'] |
---|
191 | ) |
---|
192 | ); |
---|
193 | } |
---|
194 | |
---|
195 | if (is_admin() and !empty($page['items']) ) |
---|
196 | { |
---|
197 | $template->assign_block_vars( |
---|
198 | 'caddie', |
---|
199 | array( |
---|
200 | 'URL' => |
---|
201 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
202 | ) |
---|
203 | ); |
---|
204 | } |
---|
205 | |
---|
206 | if ( $page['section']=='search' and $page['start']==0 and |
---|
207 | !isset($page['chronology_field']) and isset($page['qsearch_details']) ) |
---|
208 | { |
---|
209 | $template->assign_var('QUERY_SEARCH', |
---|
210 | htmlspecialchars($page['qsearch_details']['q']) ); |
---|
211 | |
---|
212 | $cats = array_merge( |
---|
213 | (array)@$page['qsearch_details']['matching_cats_no_images'], |
---|
214 | (array)@$page['qsearch_details']['matching_cats'] ); |
---|
215 | if (count($cats)) |
---|
216 | { |
---|
217 | usort($cats, 'name_compare'); |
---|
218 | $hints = array(); |
---|
219 | foreach ( $cats as $cat ) |
---|
220 | { |
---|
221 | $hints[] = get_cat_display_name( array($cat) ); |
---|
222 | } |
---|
223 | $template->assign_block_vars( 'category_search_results', |
---|
224 | array( |
---|
225 | 'CONTENT' => implode(' — ', $hints) |
---|
226 | ) |
---|
227 | ); |
---|
228 | } |
---|
229 | |
---|
230 | $tags = (array)@$page['qsearch_details']['matching_tags']; |
---|
231 | if (count($tags)) |
---|
232 | { |
---|
233 | usort($tags, 'name_compare'); |
---|
234 | $hints = array(); |
---|
235 | foreach ( $tags as $tag ) |
---|
236 | { |
---|
237 | $hints[] = |
---|
238 | '<a href="' . make_index_url(array('tags'=>array($tag))) . '">' |
---|
239 | .$tag['name'] |
---|
240 | .'</a>'; |
---|
241 | } |
---|
242 | $template->assign_block_vars( 'tag_search_results', |
---|
243 | array( |
---|
244 | 'CONTENT' => implode(' — ', $hints) |
---|
245 | ) |
---|
246 | ); |
---|
247 | } |
---|
248 | } |
---|
249 | |
---|
250 | //------------------------------------------------------ main part : thumbnails |
---|
251 | if ( 0==$page['start'] |
---|
252 | and !isset($page['flat']) |
---|
253 | and !isset($page['chronology_field']) |
---|
254 | and ('recent_cats'==$page['section'] or 'categories'==$page['section']) |
---|
255 | ) |
---|
256 | { |
---|
257 | include(PHPWG_ROOT_PATH.'include/category_cats.inc.php'); |
---|
258 | } |
---|
259 | if ( !empty($page['items']) ) |
---|
260 | { |
---|
261 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
262 | } |
---|
263 | //------------------------------------------------------- category informations |
---|
264 | |
---|
265 | // navigation bar |
---|
266 | if ($page['navigation_bar'] != '') |
---|
267 | { |
---|
268 | $template->assign_block_vars( |
---|
269 | 'cat_infos.navigation', |
---|
270 | array( |
---|
271 | 'NAV_BAR' => $page['navigation_bar'], |
---|
272 | ) |
---|
273 | ); |
---|
274 | } |
---|
275 | |
---|
276 | if ( count($page['items']) > 0 |
---|
277 | and $page['section'] != 'most_visited' |
---|
278 | and $page['section'] != 'best_rated') |
---|
279 | { |
---|
280 | // image order |
---|
281 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
282 | |
---|
283 | $order_idx = pwg_get_session_var( 'image_order', 0 ); |
---|
284 | |
---|
285 | $orders = get_category_preferred_image_orders(); |
---|
286 | for ($i = 0; $i < count($orders); $i++) |
---|
287 | { |
---|
288 | if ($orders[$i][2]) |
---|
289 | { |
---|
290 | $template->assign_block_vars( |
---|
291 | 'preferred_image_order.order', |
---|
292 | array( |
---|
293 | 'DISPLAY' => $orders[$i][0], |
---|
294 | 'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ), |
---|
295 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
296 | ) |
---|
297 | ); |
---|
298 | } |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | // category comment |
---|
303 | if (isset($page['comment']) and $page['comment'] != '') |
---|
304 | { |
---|
305 | $template->assign_block_vars( |
---|
306 | 'cat_infos.comment', |
---|
307 | array( |
---|
308 | 'COMMENTS' => $page['comment'] |
---|
309 | ) |
---|
310 | ); |
---|
311 | } |
---|
312 | //------------------------------------------------------------ log informations |
---|
313 | pwg_log(); |
---|
314 | |
---|
315 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
316 | trigger_action('loc_end_index'); |
---|
317 | $template->parse('index'); |
---|
318 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
319 | ?> |
---|