1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | //--------------------------------------------------------------------- include |
---|
25 | define('PHPWG_ROOT_PATH','./'); |
---|
26 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
27 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
28 | |
---|
29 | trigger_action('loc_begin_index'); |
---|
30 | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // | Check Access and exit when user status is not ok | |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | check_status(ACCESS_GUEST); |
---|
35 | |
---|
36 | //---------------------------------------------- change of image display order |
---|
37 | if (isset($_GET['image_order'])) |
---|
38 | { |
---|
39 | if ( (int)$_GET['image_order'] > 0) |
---|
40 | { |
---|
41 | pwg_set_session_var('image_order', (int)$_GET['image_order']); |
---|
42 | } |
---|
43 | else |
---|
44 | { |
---|
45 | pwg_unset_session_var('image_order'); |
---|
46 | } |
---|
47 | redirect( |
---|
48 | duplicate_index_url( |
---|
49 | array(), // nothing to redefine |
---|
50 | array('start') // changing display order goes back to section first page |
---|
51 | ) |
---|
52 | ); |
---|
53 | } |
---|
54 | //-------------------------------------------------------------- initialization |
---|
55 | // detection of the start picture to display |
---|
56 | if (!isset($page['start'])) |
---|
57 | { |
---|
58 | $page['start'] = 0; |
---|
59 | } |
---|
60 | |
---|
61 | // access authorization check |
---|
62 | if (isset($page['category'])) |
---|
63 | { |
---|
64 | check_restrictions($page['category']['id']); |
---|
65 | } |
---|
66 | |
---|
67 | if (count($page['items']) > $user['nb_image_page']) |
---|
68 | { |
---|
69 | $page['navigation_bar'] = create_navigation_bar( |
---|
70 | duplicate_index_url(array(), array('start')), |
---|
71 | count($page['items']), |
---|
72 | $page['start'], |
---|
73 | $user['nb_image_page'], |
---|
74 | true |
---|
75 | ); |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | $page['navigation_bar'] = ''; |
---|
80 | } |
---|
81 | |
---|
82 | // caddie filling :-) |
---|
83 | if (isset($_GET['caddie'])) |
---|
84 | { |
---|
85 | fill_caddie($page['items']); |
---|
86 | redirect(duplicate_index_url()); |
---|
87 | } |
---|
88 | |
---|
89 | //----------------------------------------------------- template initialization |
---|
90 | // |
---|
91 | // Start output of page |
---|
92 | // |
---|
93 | $title = $page['title']; |
---|
94 | $page['body_id'] = 'theCategoryPage'; |
---|
95 | |
---|
96 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
97 | //-------------------------------------------------------------- category title |
---|
98 | $template_title = $page['title']; |
---|
99 | if (count($page['items']) > 0) |
---|
100 | { |
---|
101 | $template_title.= ' ['.count($page['items']).']'; |
---|
102 | } |
---|
103 | $template->assign('TITLE', $template_title); |
---|
104 | |
---|
105 | if (isset($page['flat']) or isset($page['chronology_field'])) |
---|
106 | { |
---|
107 | $template->assign( |
---|
108 | 'U_MODE_NORMAL', |
---|
109 | duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) |
---|
110 | ); |
---|
111 | } |
---|
112 | |
---|
113 | if (!isset($page['flat']) and 'categories' == $page['section']) |
---|
114 | { |
---|
115 | $template->assign( |
---|
116 | 'U_MODE_FLAT', |
---|
117 | duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) |
---|
118 | ); |
---|
119 | } |
---|
120 | |
---|
121 | if (!isset($page['chronology_field'])) |
---|
122 | { |
---|
123 | $chronology_params = |
---|
124 | array( |
---|
125 | 'chronology_field' => 'created', |
---|
126 | 'chronology_style' => 'monthly', |
---|
127 | 'chronology_view' => 'list', |
---|
128 | ); |
---|
129 | $template->assign( |
---|
130 | 'U_MODE_CREATED', |
---|
131 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
132 | ); |
---|
133 | |
---|
134 | $chronology_params['chronology_field'] = 'posted'; |
---|
135 | $template->assign( |
---|
136 | 'U_MODE_POSTED', |
---|
137 | duplicate_index_url( $chronology_params, array('start', 'flat') ) |
---|
138 | ); |
---|
139 | } |
---|
140 | else |
---|
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', 'flat') |
---|
153 | ); |
---|
154 | $template->assign( |
---|
155 | 'U_MODE_'.strtoupper($chronology_field), |
---|
156 | $url |
---|
157 | ); |
---|
158 | } |
---|
159 | // include menubar |
---|
160 | include(trigger_event('menubar_file', |
---|
161 | PHPWG_ROOT_PATH.'include/menubar.inc.php')); |
---|
162 | |
---|
163 | if ('search' == $page['section']) |
---|
164 | { |
---|
165 | $template->assign( |
---|
166 | 'U_SEARCH_RULES', |
---|
167 | get_root_url().'search_rules.php?search_id='.$page['search'] |
---|
168 | ); |
---|
169 | } |
---|
170 | |
---|
171 | if (isset($page['category']) and is_admin()) |
---|
172 | { |
---|
173 | $template->assign( |
---|
174 | 'U_EDIT', |
---|
175 | get_root_url().'admin.php?page=cat_modify' |
---|
176 | .'&cat_id='.$page['category']['id'] |
---|
177 | ); |
---|
178 | } |
---|
179 | |
---|
180 | if (is_admin() and !empty($page['items'])) |
---|
181 | { |
---|
182 | $template->assign( |
---|
183 | 'U_CADDIE', |
---|
184 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
185 | ); |
---|
186 | } |
---|
187 | |
---|
188 | if ( $page['section']=='search' and $page['start']==0 and |
---|
189 | !isset($page['chronology_field']) and isset($page['qsearch_details']) ) |
---|
190 | { |
---|
191 | $template->assign('QUERY_SEARCH', |
---|
192 | htmlspecialchars($page['qsearch_details']['q']) ); |
---|
193 | |
---|
194 | $cats = array_merge( |
---|
195 | (array)@$page['qsearch_details']['matching_cats_no_images'], |
---|
196 | (array)@$page['qsearch_details']['matching_cats'] ); |
---|
197 | if (count($cats)) |
---|
198 | { |
---|
199 | usort($cats, 'name_compare'); |
---|
200 | $hints = array(); |
---|
201 | foreach ( $cats as $cat ) |
---|
202 | { |
---|
203 | $hints[] = get_cat_display_name( array($cat) ); |
---|
204 | } |
---|
205 | $template->assign( 'category_search_results', $hints); |
---|
206 | } |
---|
207 | |
---|
208 | $tags = (array)@$page['qsearch_details']['matching_tags']; |
---|
209 | if (count($tags)) |
---|
210 | { |
---|
211 | usort($tags, 'name_compare'); |
---|
212 | $hints = array(); |
---|
213 | foreach ( $tags as $tag ) |
---|
214 | { |
---|
215 | $hints[] = |
---|
216 | '<a href="' . make_index_url(array('tags'=>array($tag))) . '">' |
---|
217 | .$tag['name'] |
---|
218 | .'</a>'; |
---|
219 | } |
---|
220 | $template->assign( 'tag_search_results', $hints); |
---|
221 | } |
---|
222 | } |
---|
223 | |
---|
224 | //------------------------------------------------------ main part : thumbnails |
---|
225 | if ( 0==$page['start'] |
---|
226 | and !isset($page['flat']) |
---|
227 | and !isset($page['chronology_field']) |
---|
228 | and ('recent_cats'==$page['section'] or 'categories'==$page['section']) |
---|
229 | ) |
---|
230 | { |
---|
231 | include(PHPWG_ROOT_PATH.'include/category_cats.inc.php'); |
---|
232 | } |
---|
233 | if ( !empty($page['items']) ) |
---|
234 | { |
---|
235 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
236 | } |
---|
237 | //------------------------------------------------------- category informations |
---|
238 | |
---|
239 | // slideshow |
---|
240 | // execute after init thumbs in order to have all picture informations |
---|
241 | if (!empty($page['cat_slideshow_url'])) |
---|
242 | { |
---|
243 | if (isset($_GET['slideshow'])) |
---|
244 | { |
---|
245 | redirect($page['cat_slideshow_url']); |
---|
246 | } |
---|
247 | else |
---|
248 | { |
---|
249 | $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']); |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | // navigation bar |
---|
254 | $template->assign( 'NAV_BAR', $page['navigation_bar'] ); |
---|
255 | |
---|
256 | if ( count($page['items']) > 0 |
---|
257 | and $page['section'] != 'most_visited' |
---|
258 | and $page['section'] != 'best_rated') |
---|
259 | { |
---|
260 | // image order |
---|
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->append( |
---|
269 | 'image_orders', |
---|
270 | array( |
---|
271 | 'DISPLAY' => $orders[$i][0], |
---|
272 | 'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ), |
---|
273 | 'SELECTED' => ($order_idx==$i ? true:false), |
---|
274 | ) |
---|
275 | ); |
---|
276 | } |
---|
277 | } |
---|
278 | } |
---|
279 | |
---|
280 | // category comment |
---|
281 | if (isset($page['comment']) and $page['comment'] != '') |
---|
282 | { |
---|
283 | $template->assign('CONTENT_DESCRIPTION', $page['comment'] ); |
---|
284 | } |
---|
285 | //------------------------------------------------------------ log informations |
---|
286 | pwg_log(); |
---|
287 | |
---|
288 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
289 | trigger_action('loc_end_index'); |
---|
290 | $template->pparse('index'); |
---|
291 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
292 | ?> |
---|