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-01 23:31:19 +0000 (Fri, 01 Dec 2006) $ |
---|
10 | // | last modifier : $Author: rub $ |
---|
11 | // | revision : $Revision: 1624 $ |
---|
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 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
101 | |
---|
102 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
103 | //-------------------------------------------------------------- category title |
---|
104 | $template_title = $page['title']; |
---|
105 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) |
---|
106 | { |
---|
107 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
108 | } |
---|
109 | |
---|
110 | if (!isset($page['chronology_field'])) |
---|
111 | { |
---|
112 | $chronology_params = |
---|
113 | array( |
---|
114 | 'chronology_field' => 'created', |
---|
115 | 'chronology_style' => 'monthly', |
---|
116 | 'chronology_view' => 'list', |
---|
117 | ); |
---|
118 | $template->assign_block_vars( |
---|
119 | 'mode_created', |
---|
120 | array( |
---|
121 | 'URL' => duplicate_index_url( $chronology_params, array('start') ) |
---|
122 | ) |
---|
123 | ); |
---|
124 | |
---|
125 | $chronology_params['chronology_field'] = 'posted'; |
---|
126 | $template->assign_block_vars( |
---|
127 | 'mode_posted', |
---|
128 | array( |
---|
129 | 'URL' => duplicate_index_url( $chronology_params, array('start') ) |
---|
130 | ) |
---|
131 | ); |
---|
132 | } |
---|
133 | else |
---|
134 | { |
---|
135 | $template->assign_block_vars( |
---|
136 | 'mode_normal', |
---|
137 | array( |
---|
138 | 'URL' => duplicate_index_url( array(), array('chronology_field','start') ) |
---|
139 | ) |
---|
140 | ); |
---|
141 | |
---|
142 | if ($page['chronology_field'] == 'created') |
---|
143 | { |
---|
144 | $chronology_field = 'posted'; |
---|
145 | } |
---|
146 | else |
---|
147 | { |
---|
148 | $chronology_field = 'created'; |
---|
149 | } |
---|
150 | $url = duplicate_index_url( |
---|
151 | array('chronology_field'=>$chronology_field ), |
---|
152 | array('chronology_date', 'start') |
---|
153 | ); |
---|
154 | $template->assign_block_vars( |
---|
155 | 'mode_'.$chronology_field, |
---|
156 | array('URL' => $url ) |
---|
157 | ); |
---|
158 | } |
---|
159 | // include menubar |
---|
160 | include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
161 | |
---|
162 | $template->assign_vars( |
---|
163 | array( |
---|
164 | 'TITLE' => $template_title |
---|
165 | ) |
---|
166 | ); |
---|
167 | |
---|
168 | if ('search' == $page['section']) |
---|
169 | { |
---|
170 | $template->assign_block_vars( |
---|
171 | 'search_rules', |
---|
172 | array( |
---|
173 | 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], |
---|
174 | ) |
---|
175 | ); |
---|
176 | } |
---|
177 | |
---|
178 | if (isset($page['category']) and is_admin()) |
---|
179 | { |
---|
180 | $template->assign_block_vars( |
---|
181 | 'edit', |
---|
182 | array( |
---|
183 | 'URL' => |
---|
184 | get_root_url().'admin.php?page=cat_modify' |
---|
185 | .'&cat_id='.$page['category'] |
---|
186 | ) |
---|
187 | ); |
---|
188 | } |
---|
189 | |
---|
190 | if (is_admin() and !empty($page['items']) ) |
---|
191 | { |
---|
192 | $template->assign_block_vars( |
---|
193 | 'caddie', |
---|
194 | array( |
---|
195 | 'URL' => |
---|
196 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
197 | ) |
---|
198 | ); |
---|
199 | } |
---|
200 | |
---|
201 | if ( $page['section']=='search' and $page['start']==0 ) |
---|
202 | { |
---|
203 | $tags = get_common_tags($page['items'], |
---|
204 | $conf['content_tag_cloud_items_number'], null); |
---|
205 | if ( count($tags)>1 ) |
---|
206 | { |
---|
207 | $template->assign_block_vars('related_tags', array() ); |
---|
208 | |
---|
209 | $tags = add_level_to_tags($tags); |
---|
210 | foreach ($tags as $tag) |
---|
211 | { |
---|
212 | $template->assign_block_vars( |
---|
213 | 'related_tags.tag', array( |
---|
214 | 'URL' => make_index_url( |
---|
215 | array( |
---|
216 | 'tags' => array( |
---|
217 | array( |
---|
218 | 'id' => $tag['tag_id'], |
---|
219 | 'url_name' => $tag['url_name'], |
---|
220 | ), |
---|
221 | ) |
---|
222 | ) |
---|
223 | ), |
---|
224 | 'NAME' => $tag['name'], |
---|
225 | 'TITLE' => sprintf( |
---|
226 | l10n('%d pictures are also linked to current tags'), |
---|
227 | $tag['counter'] |
---|
228 | ), |
---|
229 | 'CLASS' => 'tagLevel'.$tag['level'] |
---|
230 | ) |
---|
231 | ); |
---|
232 | } |
---|
233 | } |
---|
234 | } |
---|
235 | |
---|
236 | //------------------------------------------------------ main part : thumbnails |
---|
237 | if (isset($page['thumbnails_include'])) |
---|
238 | { |
---|
239 | include(PHPWG_ROOT_PATH.$page['thumbnails_include']); |
---|
240 | } |
---|
241 | //------------------------------------------------------- category informations |
---|
242 | |
---|
243 | // navigation bar |
---|
244 | if ($page['navigation_bar'] != '') |
---|
245 | { |
---|
246 | $template->assign_block_vars( |
---|
247 | 'cat_infos.navigation', |
---|
248 | array( |
---|
249 | 'NAV_BAR' => $page['navigation_bar'], |
---|
250 | ) |
---|
251 | ); |
---|
252 | } |
---|
253 | |
---|
254 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 |
---|
255 | and $page['section'] != 'most_visited' |
---|
256 | and $page['section'] != 'best_rated') |
---|
257 | { |
---|
258 | // image order |
---|
259 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
260 | |
---|
261 | $order_idx = pwg_get_session_var( 'image_order', 0 ); |
---|
262 | |
---|
263 | $orders = get_category_preferred_image_orders(); |
---|
264 | for ($i = 0; $i < count($orders); $i++) |
---|
265 | { |
---|
266 | if ($orders[$i][2]) |
---|
267 | { |
---|
268 | $template->assign_block_vars( |
---|
269 | 'preferred_image_order.order', |
---|
270 | array( |
---|
271 | 'DISPLAY' => $orders[$i][0], |
---|
272 | 'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ), |
---|
273 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
274 | ) |
---|
275 | ); |
---|
276 | } |
---|
277 | } |
---|
278 | } |
---|
279 | |
---|
280 | // category comment |
---|
281 | if (isset($page['comment']) and $page['comment'] != '') |
---|
282 | { |
---|
283 | $template->assign_block_vars( |
---|
284 | 'cat_infos.comment', |
---|
285 | array( |
---|
286 | 'COMMENTS' => $page['comment'] |
---|
287 | ) |
---|
288 | ); |
---|
289 | } |
---|
290 | //------------------------------------------------------------ log informations |
---|
291 | pwg_log('category', $page['title']); |
---|
292 | |
---|
293 | trigger_action('loc_end_index'); |
---|
294 | $template->parse('index'); |
---|
295 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
296 | ?> |
---|