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-06-19 17:53:48 +0000 (Mon, 19 Jun 2006) $ |
---|
10 | // | last modifier : $Author: chrisaga $ |
---|
11 | // | revision : $Revision: 1367 $ |
---|
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 | // +-----------------------------------------------------------------------+ |
---|
34 | // | Check Access and exit when user status is not ok | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | check_status(ACCESS_GUEST); |
---|
37 | |
---|
38 | //---------------------------------------------------------------------- logout |
---|
39 | if ( isset( $_GET['act'] ) |
---|
40 | and $_GET['act'] == 'logout' |
---|
41 | and isset( $_COOKIE[session_name()] ) ) |
---|
42 | { |
---|
43 | // cookie deletion if exists |
---|
44 | $_SESSION = array(); |
---|
45 | session_unset(); |
---|
46 | session_destroy(); |
---|
47 | setcookie(session_name(),'',0, |
---|
48 | ini_get('session.cookie_path'), ini_get('session.cookie_domain') ); |
---|
49 | redirect( make_index_url() ); |
---|
50 | } |
---|
51 | |
---|
52 | //---------------------------------------------- change of image display order |
---|
53 | if (isset($_GET['image_order'])) |
---|
54 | { |
---|
55 | setcookie( |
---|
56 | 'pwg_image_order', |
---|
57 | $_GET['image_order'] > 0 ? $_GET['image_order'] : '', |
---|
58 | 0, cookie_path() |
---|
59 | ); |
---|
60 | |
---|
61 | redirect( |
---|
62 | duplicate_index_URL( |
---|
63 | array(), // nothing to redefine |
---|
64 | array('start') // changing display order goes back to section first page |
---|
65 | ) |
---|
66 | ); |
---|
67 | } |
---|
68 | //-------------------------------------------------------------- initialization |
---|
69 | // detection of the start picture to display |
---|
70 | if (!isset($page['start'])) |
---|
71 | { |
---|
72 | $page['start'] = 0; |
---|
73 | } |
---|
74 | |
---|
75 | // access authorization check |
---|
76 | if (isset($page['category'])) |
---|
77 | { |
---|
78 | check_restrictions($page['category']); |
---|
79 | } |
---|
80 | |
---|
81 | if (isset($page['cat_nb_images']) |
---|
82 | and $page['cat_nb_images'] > $user['nb_image_page']) |
---|
83 | { |
---|
84 | $page['navigation_bar'] = create_navigation_bar( |
---|
85 | duplicate_index_URL(array(), array('start')), |
---|
86 | $page['cat_nb_images'], |
---|
87 | $page['start'], |
---|
88 | $user['nb_image_page'], |
---|
89 | true |
---|
90 | ); |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | $page['navigation_bar'] = ''; |
---|
95 | } |
---|
96 | |
---|
97 | // caddie filling :-) |
---|
98 | if (isset($_GET['caddie'])) |
---|
99 | { |
---|
100 | fill_caddie($page['items']); |
---|
101 | // redirect(); |
---|
102 | } |
---|
103 | |
---|
104 | //----------------------------------------------------- template initialization |
---|
105 | // |
---|
106 | // Start output of page |
---|
107 | // |
---|
108 | $title = $page['title']; |
---|
109 | $page['body_id'] = 'theCategoryPage'; |
---|
110 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
111 | |
---|
112 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
113 | //-------------------------------------------------------------- category title |
---|
114 | $template_title = $page['title']; |
---|
115 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) |
---|
116 | { |
---|
117 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
118 | } |
---|
119 | |
---|
120 | $icon_recent = get_icon(date('Y-m-d')); |
---|
121 | |
---|
122 | if (!isset($page['chronology_field'])) |
---|
123 | { |
---|
124 | $chronology_params = |
---|
125 | array( |
---|
126 | 'chronology_field' => 'created', |
---|
127 | 'chronology_style' => 'monthly', |
---|
128 | 'chronology_view' => 'list', |
---|
129 | ); |
---|
130 | $template->assign_block_vars( |
---|
131 | 'mode_created', |
---|
132 | array( |
---|
133 | 'URL' => duplicate_index_URL( $chronology_params, array('start') ) |
---|
134 | ) |
---|
135 | ); |
---|
136 | |
---|
137 | $chronology_params['chronology_field'] = 'posted'; |
---|
138 | $template->assign_block_vars( |
---|
139 | 'mode_posted', |
---|
140 | array( |
---|
141 | 'URL' => duplicate_index_URL( $chronology_params, array('start') ) |
---|
142 | ) |
---|
143 | ); |
---|
144 | } |
---|
145 | else |
---|
146 | { |
---|
147 | $template->assign_block_vars( |
---|
148 | 'mode_normal', |
---|
149 | array( |
---|
150 | 'URL' => duplicate_index_URL( array(), array('chronology_field','start') ) |
---|
151 | ) |
---|
152 | ); |
---|
153 | |
---|
154 | if ($page['chronology_field'] == 'created') |
---|
155 | { |
---|
156 | $chronology_field = 'posted'; |
---|
157 | } |
---|
158 | else |
---|
159 | { |
---|
160 | $chronology_field = 'created'; |
---|
161 | } |
---|
162 | $url = duplicate_index_URL( |
---|
163 | array('chronology_field'=>$chronology_field ), |
---|
164 | array('chronology_date', 'start') |
---|
165 | ); |
---|
166 | $template->assign_block_vars( |
---|
167 | 'mode_'.$chronology_field, |
---|
168 | array('URL' => $url ) |
---|
169 | ); |
---|
170 | } |
---|
171 | // include menubar |
---|
172 | include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
173 | |
---|
174 | $template->assign_vars( |
---|
175 | array( |
---|
176 | 'TITLE' => $template_title, |
---|
177 | 'TOP_NUMBER' => $conf['top_number'], // still used ? |
---|
178 | 'T_RECENT' => $icon_recent, // still used ? |
---|
179 | ) |
---|
180 | ); |
---|
181 | |
---|
182 | if ('search' == $page['section']) |
---|
183 | { |
---|
184 | $template->assign_block_vars( |
---|
185 | 'search_rules', |
---|
186 | array( |
---|
187 | 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], |
---|
188 | ) |
---|
189 | ); |
---|
190 | } |
---|
191 | |
---|
192 | if (isset($page['category']) and is_admin()) |
---|
193 | { |
---|
194 | $template->assign_block_vars( |
---|
195 | 'edit', |
---|
196 | array( |
---|
197 | 'URL' => |
---|
198 | get_root_url().'admin.php?page=cat_modify' |
---|
199 | .'&cat_id='.$page['category'] |
---|
200 | ) |
---|
201 | ); |
---|
202 | } |
---|
203 | |
---|
204 | if (is_admin() and !empty($page['items']) ) |
---|
205 | { |
---|
206 | $template->assign_block_vars( |
---|
207 | 'caddie', |
---|
208 | array( |
---|
209 | 'URL' => |
---|
210 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
211 | ) |
---|
212 | ); |
---|
213 | } |
---|
214 | |
---|
215 | //------------------------------------------------------ main part : thumbnails |
---|
216 | if (isset($page['thumbnails_include'])) |
---|
217 | { |
---|
218 | include(PHPWG_ROOT_PATH.$page['thumbnails_include']); |
---|
219 | } |
---|
220 | //------------------------------------------------------- category informations |
---|
221 | if ( |
---|
222 | $page['navigation_bar'] != '' |
---|
223 | or (isset($page['comment']) and $page['comment'] != '') |
---|
224 | ) |
---|
225 | { |
---|
226 | $template->assign_block_vars('cat_infos',array()); |
---|
227 | } |
---|
228 | // navigation bar |
---|
229 | if ($page['navigation_bar'] != '') |
---|
230 | { |
---|
231 | $template->assign_block_vars( |
---|
232 | 'cat_infos.navigation', |
---|
233 | array( |
---|
234 | 'NAV_BAR' => $page['navigation_bar'], |
---|
235 | ) |
---|
236 | ); |
---|
237 | } |
---|
238 | |
---|
239 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 |
---|
240 | and $page['section'] != 'most_visited' |
---|
241 | and $page['section'] != 'best_rated') |
---|
242 | { |
---|
243 | // image order |
---|
244 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
245 | |
---|
246 | $order_idx = isset($_COOKIE['pwg_image_order']) |
---|
247 | ? $_COOKIE['pwg_image_order'] |
---|
248 | : 0 |
---|
249 | ; |
---|
250 | |
---|
251 | $orders = get_category_preferred_image_orders(); |
---|
252 | for ($i = 0; $i < count($orders); $i++) |
---|
253 | { |
---|
254 | if ($orders[$i][2]) |
---|
255 | { |
---|
256 | $template->assign_block_vars( |
---|
257 | 'preferred_image_order.order', |
---|
258 | array( |
---|
259 | 'DISPLAY' => $orders[$i][0], |
---|
260 | 'URL' => add_url_params( duplicate_index_URL(), array('image_order'=>$i) ), |
---|
261 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
262 | ) |
---|
263 | ); |
---|
264 | } |
---|
265 | } |
---|
266 | } |
---|
267 | |
---|
268 | if (isset($page['category'])) |
---|
269 | { |
---|
270 | // upload a picture in the category |
---|
271 | if ($page['cat_uploadable']) |
---|
272 | { |
---|
273 | $url = get_root_url().'upload.php?cat='.$page['category']; |
---|
274 | $template->assign_block_vars( |
---|
275 | 'upload', |
---|
276 | array( |
---|
277 | 'U_UPLOAD'=> $url |
---|
278 | ) |
---|
279 | ); |
---|
280 | } |
---|
281 | |
---|
282 | // category comment |
---|
283 | if (isset($page['comment']) and $page['comment'] != '') |
---|
284 | { |
---|
285 | $template->assign_block_vars( |
---|
286 | 'cat_infos.comment', |
---|
287 | array( |
---|
288 | 'COMMENTS' => $page['comment'] |
---|
289 | ) |
---|
290 | ); |
---|
291 | } |
---|
292 | } |
---|
293 | //------------------------------------------------------------ log informations |
---|
294 | pwg_log('category', $page['title']); |
---|
295 | |
---|
296 | $template->parse('index'); |
---|
297 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
298 | ?> |
---|