Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezimagecatalogue/user/imagelist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: imagelist.php 9826 2003-06-02 10:21:27Z jhe $
5 //
6 // Created on: <10-Dec-2000 16:16:20 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU 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, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlog.php" );
30 // include_once( "classes/ezfile.php" );
31 // include_once( "classes/ezlist.php" );
32
33 // include_once( "ezuser/classes/ezuser.php" );
34 // include_once( "ezuser/classes/ezpermission.php" );
35 // include_once( "ezuser/classes/ezobjectpermission.php" );
36
37 // include_once( "ezimagecatalogue/classes/ezimage.php" );
38 // include_once( "ezimagecatalogue/classes/ezimagecategory.php" );
39 // include_once( "classes/ezhttptool.php" );
40
41 $ini =& eZINI::instance( 'site.ini' );
42
43 $Language = $ini->variable( "eZImageCatalogueMain", "Language" );
44 $ImageDir = $ini->variable( "eZImageCatalogueMain", "ImageDir" );
45
46 $t = new eZTemplate( "kernel/ezimagecatalogue/user/" . $ini->variable( "eZImageCatalogueMain", "TemplateDir" ),
47 "kernel/ezimagecatalogue/user/intl/", $Language, "imagelist.php" );
48
49 $t->set_file( "image_list_page_tpl", "imagelist.tpl" );
50
51 $t->setAllStrings();
52
53 $user =& eZUser::currentUser();
54 // Set detail or normal mode
55 if ( isset( $DetailView ) )
56 {
57 $session =& eZSession::globalSession();
58 $session->setVariable( "ImageViewMode", "Detail" );
59 }
60 if ( isset( $NormalView ) )
61 {
62 $session =& eZSession::globalSession();
63 $session->setVariable( "ImageViewMode", "Normal" );
64 }
65
66 $checkMode =& eZSession::globalSession();
67
68 if ( $checkMode->variable( "ImageViewMode" ) == "Detail" )
69 {
70 $DetailView = true;
71 }
72 else if ( $checkMode->variable( "ImageViewMode" ) == "Normal" )
73 {
74 $NormalView = true;
75 }
76
77 $t->set_block( "image_list_page_tpl", "current_category_tpl", "current_category" );
78
79 // path
80 $t->set_block( "image_list_page_tpl", "path_item_tpl", "path_item" );
81 $t->set_block( "image_list_page_tpl", "image_list_tpl", "image_list" );
82 $t->set_block( "image_list_page_tpl", "normal_view_button", "normal_button" );
83 $t->set_block( "image_list_page_tpl", "detail_view_button", "detail_button" );
84 $t->set_block( "image_list_page_tpl", "write_menu_tpl", "write_menu" );
85
86 $t->set_block( "write_menu_tpl", "next_tpl", "next" );
87 $t->set_block( "write_menu_tpl", "previous_tpl", "prev" );
88 $t->set_block( "write_menu_tpl", "default_new_tpl", "default_new" );
89 $t->set_block( "write_menu_tpl", "default_delete_tpl", "default_delete" );
90
91 $t->set_block( "default_delete_tpl", "delete_categories_button_tpl", "delete_categories_button" );
92 $t->set_block( "default_delete_tpl", "delete_images_button_tpl", "delete_images_button" );
93
94 $t->set_block( "image_list_tpl", "image_tpl", "image" );
95 $t->set_block( "image_list_tpl", "detail_view_tpl", "detail_view" );
96
97 $t->set_block( "image_tpl", "read_tpl", "read" );
98 $t->set_block( "image_tpl", "read_span_tpl", "read_span" );
99 $t->set_block( "image_tpl", "write_tpl", "write" );
100
101 $t->set_block( "detail_view_tpl", "detail_read_tpl", "detail_read" );
102 $t->set_block( "detail_view_tpl", "detail_write_tpl", "detail_write" );
103 $t->set_block( "detail_read_tpl", "image_variation_tpl", "variation" );
104
105 $t->set_block( "image_list_page_tpl", "category_list_tpl", "category_list" );
106 $t->set_block( "category_list_tpl", "category_tpl", "category" );
107
108 $t->set_block( "category_tpl", "category_write_tpl", "category_write" );
109 $t->set_block( "category_tpl", "category_read_tpl", "category_read" );
110
111 $t->set_var( "read", "" );
112 $t->set_var( "variation", "" );
113 $t->set_var( "write_menu", "" );
114
115 $t->set_var( "next", "" );
116 $t->set_var( "prev", "" );
117
118 $t->set_var( "delete_images_button" , "" );
119 $t->set_var( "delete_categories_button" , "" );
120 $t->set_var( "default_new" , "" );
121 $t->set_var( "default_delete" , "" );
122 $t->set_var( "main_category_id", isset( $CategoryID ) ? $CategoryID : false );
123 $t->set_var( "category", "" );
124
125 $category = new eZImageCategory( $CategoryID );
126
127 // sections
128 // include_once( "ezsitemanager/classes/ezsection.php" );
129
130 // tempo fix for admin users - maybe in the future must be changed
131 if ( $CategoryID != 0 )
132 {
133 $GlobalSectionID = eZImageCategory::sectionIDstatic( $CategoryID );
134 }
135
136 if ( !$GlobalSectionID )
137 $GlobalSectionID = $ini->variable( "eZImageCatalogueMain", "DefaultSection" );
138
139 // init the section
140 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
141 $sectionObject->setOverrideVariables();
142
143 // Check if user have permission to the current category
144
145 $error = true;
146
147 if ( eZObjectPermission::hasPermission( $category->id(), "imagecatalogue_category", "r", $user ) ||
148 eZImageCategory::isOwner( $user, $CategoryID ) )
149 {
150 $error = false;
151 }
152
153 if ( $CategoryID == 0 )
154 {
155 $t->set_var( "current_category_description", "" );
156 $error = false;
157 }
158
159 $t->set_var( "current_category", "" );
160
161 if ( $category->id() != 0 )
162 {
163 $t->set_var( "current_category_description", $category->description() );
164 $t->set_var( "category_id", $category->id() );
165 $t->set_var( "category_name", $category->name() );
166
167 $t->parse( "current_category", "current_category_tpl" );
168 }
169
170 // path
171 $pathArray = $category->path();
172
173 $t->set_var( "path_item", "" );
174 foreach ( $pathArray as $path )
175 {
176 $t->set_var( "category_id", $path[0] );
177 $t->set_var( "category_name", $path[1] );
178
179 $t->parse( "path_item", "path_item_tpl", true );
180 }
181
182
183 // Print out all the categories
184 $categoryList =& $category->getByParent( $category );
185
186 $i = 0;
187 foreach ( $categoryList as $categoryItem )
188 {
189 $t->set_var( "category_name", $categoryItem->name() );
190 $t->set_var( "category_id", $categoryItem->id() );
191 $t->set_var( "category_description", $categoryItem->description() );
192
193 $t->set_var( "category_read", "" );
194 $t->set_var( "category_write", "" );
195 ( $i % 2 ) ? $t->set_var( "td_class", "bgdark" ) : $t->set_var( "td_class", "bglight" );
196
197 // Check if user have write permission
198 if ( ( $user ) &&
199 ( eZObjectPermission::hasPermission( $categoryItem->id(), "imagecatalogue_category", "w", $user ) ) ||
200 ( eZImageCategory::isOwner( $user, $categoryItem->id() ) ) )
201 {
202 $t->parse( "category_write", "category_write_tpl" );
203 $t->parse( "delete_categories_button", "delete_categories_button_tpl" );
204 $t->parse( "default_delete", "default_delete_tpl" );
205 $t->parse( "write_menu", "write_menu_tpl" );
206 }
207
208 // Check if user have read permission
209 if ( eZObjectPermission::hasPermission( $categoryItem->id(), "imagecatalogue_category", "r", $user ) ||
210 eZImageCategory::isOwner( $user, $categoryItem->id()) )
211 {
212 $t->parse( "category_read", "category_read_tpl" );
213 $t->parse( "category", "category_tpl", true );
214 $i++;
215 }
216 }
217
218 if ( count( $categoryList ) > 0 && !isset( $SearchText ) )
219 {
220 $t->parse( "category_list", "category_list_tpl" );
221 }
222 else
223 {
224 $t->set_var( "category_list", "" );
225 }
226
227 $limit = $ini->variable( "eZImageCatalogueMain", "ListImagesPerPage" );
228
229 // Print out all the images
230 if ( isset( $SearchText ) )
231 {
232 $imageList =& eZImage::search( $SearchText );
233 $count =& eZImage::searchCount( $SearchText );
234
235 $URL = "search/?SearchText=$SearchText";
236
237 $page_link = "search/?SearchText=$SearchText&Offset={item_index}";
238 $page_link_next = "search/?SearchText=$SearchText&Offset={item_next_index}";
239 $page_link_prev = "search/?SearchText=$SearchText&Offset={item_previous_index}";
240 }
241 else
242 {
243 $imageList =& $category->images( "time", $Offset, $limit );
244 $count =& $category->imageCount();
245
246 $URL = "image/list/$CategoryID/$Offset";
247
248 $page_link = "image/list/$CategoryID/parent/{item_index}";
249 $page_link_next = "image/list/$CategoryID/parent/{item_next_index}";
250 $page_link_prev = "image/list/$CategoryID/parent/{item_previous_index}";
251 }
252
253 $i = 0;
254 $j = 0;
255 $counter = 0;
256
257 foreach ( $imageList as $image )
258 {
259 ( $i % 2 ) ? $t->set_var( "td_class", "bgdark" ) : $t->set_var( "td_class", "bglight" );
260
261 $t->set_var( "main_category_id", $CategoryID . "/" . $Offset );
262
263 $t->set_var( "end_tr", "" );
264 $t->set_var( "begin_tr", "" );
265
266 $t->set_var( "image_id", $image->id() );
267 $t->set_var( "original_image_name", $image->originalFileName() );
268 $t->set_var( "image_name", $image->name() );
269 $t->set_var( "image_caption", $image->name() );
270 $t->set_var( "image_url", $image->name() );
271
272 $width =& $ini->variable( "eZImageCatalogueMain", "ThumbnailViewWidth" );
273 $height =& $ini->variable( "eZImageCatalogueMain", "ThumbnailViewHight" );
274
275 $variation =& $image->requestImageVariation( $width, $height );
276
277 $t->set_var( "image_description",$image->description() );
278 $t->set_var( "image_alt", $image->name() );
279 $t->set_var( "image_src", "/" . $variation->imagePath() );
280 $t->set_var( "image_width", $variation->width() );
281 $t->set_var( "image_height", $variation->height() );
282 $t->set_var( "image_file_name", $image->originalFileName() );
283
284 if ( $image->fileExists( true ) )
285 {
286 $imagePath =& $image->filePath( true );
287 $size = eZPBFile::filesize( $imagePath );
288 }
289 else
290 {
291 $size = 0;
292 }
293
294 $size = eZPBFile::siFileSize( $size );
295
296 $t->set_var( "image_size", $size["size-string"] );
297 $t->set_var( "image_unit", $size["unit"] );
298 $t->set_var( "image_caption", $image->caption() );
299
300 $t->set_var( "read", "" );
301 $t->set_var( "write", "" );
302
303 $t->set_var( "read_span", "" );
304 $imagesPerRow = $ini->variable( "eZImageCatalogueMain", "ListImagesPerRow" );
305 if ( count( $imageList ) == $counter + 1 )
306 {
307 $colspan = ( $imagesPerRow - 1 ) - ( $imagesPerRow % 4 );
308 if ( $colspan > 0 )
309 {
310 $t->set_var( "col_span", $colspan );
311 $t->parse( "read_span", "read_span_tpl" );
312 }
313 }
314
315 // Check if user have read permission
316 $t->set_var( "detail_read", "" );
317 $can_read = false;
318 $can_write = false;
319
320 $variationList = $image->variations();
321
322 for ( $i = 0; $i < count( $variationList ); $i++ )
323 {
324 if ( $variationList[$i]->height() == $image->height() &&
325 $variationList[$i]->width() == $image->width() )
326 {
327 $value = array_slice( $variationList, $i, 1 );
328 $variationList = array_merge( $value, array_slice( $variationList, 0, $i - 1 ), array_slice( $variationList, $i + 1 ) );
329 break;
330 }
331 }
332
333 $t->set_var( "variation", "" );
334
335
336 $can_read = true;
337 if ( ( $j % $imagesPerRow ) == 0 )
338 {
339 $t->set_var( "begin_tr", "<tr>" );
340 }
341 else if ( ( $j % $imagesPerRow ) == ( $imagesPerRow - 1 ) )
342 {
343 $t->set_var( "end_tr", "</tr>" );
344 }
345
346 if ( isset( $DetailView ) )
347 {
348 $t->parse( "detail_read", "detail_read_tpl" );
349 }
350 else
351 {
352 $t->parse( "read", "read_tpl" );
353 }
354 $j++;
355
356 // Check if user have write permission
357 if ( ( $user ) &&
358 ( eZObjectPermission::hasPermission( $CategoryID, "imagecatalogue_category", "w", $user ) &&
359 ( eZObjectPermission::hasPermission( $image->id(), "imagecatalogue_image", "w", $user ) ) ) ||
360 ( eZImage::isOwner( $user, $image->id() ) ) )
361 {
362 $can_write = true;
363 if ( isset( $DetailView ) )
364 {
365 $deleteImage = true;
366 $t->parse( "detail_write", "detail_write_tpl" );
367
368 $t->parse( "delete_images_button", "delete_images_button_tpl" );
369 $t->parse( "default_delete", "default_delete_tpl" );
370 $t->parse( "write_menu", "write_menu_tpl" );
371 }
372 else
373 {
374 $t->parse( "write", "write_tpl" );
375 }
376 }
377 else
378 {
379 $t->set_var( "detail_write", "" );
380 }
381
382 // Set the detail or normail view
383 if ( isset( $DetailView ) )
384 {
385 $t->set_var( "image", "" );
386
387 if ( $can_read )
388 $t->parse( "detail_view", "detail_view_tpl", true );
389 }
390 else
391 {
392 $t->set_var( "detail_view", "" );
393
394 if ( $can_read )
395 $t->parse( "image", "image_tpl", true );
396 }
397
398 $counter++;
399 }
400 $t->set_var( "URL", $URL );
401 $t->set_var( "page_link", $page_link );
402 $t->set_var( "page_link_next", $page_link_next );
403 $t->set_var( "page_link_prev", $page_link_prev );
404
405
406 $t->set_var( "main_category_id", $CategoryID );
407 eZList::drawNavigator( $t, $count, $limit, $Offset, "image_list_page_tpl" );
408
409 $t->set_var( "detail_button", "" );
410 $t->set_var( "normal_button", "" );
411 $t->set_var( "pos", $Offset );
412
413 if ( isset( $DetailView ) )
414 {
415 $t->set_var( "is_detail_view", "true" );
416 $t->parse( "normal_button", "normal_view_button" );
417 }
418 else
419 {
420 $t->set_var( "is_detail_view", "" );
421 $t->parse( "detail_button", "detail_view_button" );
422 }
423
424 // Print out the category/image menu
425 if ( $category->id() != 0 )
426 {
427 if ( ( $user ) &&
428 ( eZObjectPermission::hasPermission( $category->id(), "imagecatalogue_category", "w", $user ) ) )
429 {
430 $t->parse( "default_new", "default_new_tpl" );
431 $t->parse( "write_menu", "write_menu_tpl" );
432 }
433 }
434 else
435 {
436 if ( eZPermission::checkPermission( $user, "eZImageCatalogue", "WriteToRoot" ) )
437 {
438 $t->parse( "default_new", "default_new_tpl" );
439 $t->parse( "write_menu", "write_menu_tpl" );
440 }
441 }
442
443 if ( count( $imageList ) > 0 )
444 {
445 $t->parse( "image_list", "image_list_tpl" );
446 }
447 else
448 {
449 $t->set_var( "normal_button", "" );
450 $t->set_var( "detail_button", "" );
451 $t->set_var( "image_list", "" );
452 }
453
454 $t->set_var( "image_dir", $ImageDir );
455
456 if ( $error == false )
457 {
458 $t->pparse( "output", "image_list_page_tpl" );
459 }
460 else
461 {
462 eZHTTPTool::header( "Location: /error/403/" );
463 exit();
464 }
465
466 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$session
$session
Definition: admin/articlelist.php:44
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImageCategory
Definition: ezimagecategory.php:43
eZImageCategory\isOwner
static isOwner( $user, $imageCategory=false)
Definition: ezimagecategory.php:480
eZImage\isOwner
static isOwner( $user, $image)
Definition: ezimage.php:1274
eZImage\searchCount
static searchCount( $name, $literal=false)
Definition: ezimage.php:269
eZImage\search
static search(&$queryText, $offset=0, $limit=30, $userID=-1)
Definition: ezimage.php:221
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZPBFile\siFileSize
static & siFileSize( $size)
Definition: ezpbfile.php:220
eZPBFile\filesize
static filesize( $filename)
Definition: ezpbfile.php:339
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$SearchText
$SearchText
Definition: ezaddress/admin/typelist.php:143
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$imageList
$imageList
Definition: ezimagecatalogue/admin/unassigned.php:96
$category
$category
Definition: ezimagecatalogue/user/imagelist.php:125
$ImageDir
$ImageDir
Definition: ezimagecatalogue/user/imagelist.php:44
$t
$t
Definition: ezimagecatalogue/user/imagelist.php:46
$pathArray
if( $category->id() !=0) $pathArray
Definition: ezimagecatalogue/user/imagelist.php:171
$page_link_next
$page_link_next
Definition: ezimagecatalogue/user/imagelist.php:249
$user
$user
Definition: ezimagecatalogue/user/imagelist.php:53
$page_link
$page_link
Definition: ezimagecatalogue/user/imagelist.php:248
$sectionObject
$sectionObject
Definition: ezimagecatalogue/user/imagelist.php:140
$URL
$URL
Definition: ezimagecatalogue/user/imagelist.php:246
$j
$j
Definition: ezimagecatalogue/user/imagelist.php:254
$page_link_prev
$page_link_prev
Definition: ezimagecatalogue/user/imagelist.php:250
$i
$i
Definition: ezimagecatalogue/user/imagelist.php:186
$Language
$Language
Definition: ezimagecatalogue/user/imagelist.php:43
$ini
$ini
Definition: ezimagecatalogue/user/imagelist.php:41
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: ezimagecatalogue/user/imagelist.php:184
$checkMode
if(isset( $DetailView)) if(isset( $NormalView)) $checkMode
Definition: ezimagecatalogue/user/imagelist.php:66
$counter
$counter
Definition: ezimagecatalogue/user/imagelist.php:255
$limit
$limit
Definition: ezimagecatalogue/user/imagelist.php:227
$error
$error
Definition: ezimagecatalogue/user/imagelist.php:145
$count
$count
Definition: ezimagecatalogue/user/imagelist.php:244
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
exit
exit
Definition: folder.php:81
$image
$image
Definition: user/articlelist.php:242
$height
$height
Definition: user/imageview.php:171
$width
$width
Definition: user/imageview.php:170
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.