1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 10 header("location: index.php"); 11 exit; 12} 13 14/* 15 * smarty_function_fgal_browse: Display the content of a file gallery in browse mode (i.e. with thumbnails) 16 * 17 * params will be used as smarty params for browse_file_gallery.tpl, except special params starting with '_' : 18 * - _id: ID of the gallery 19 * - _offset 20 * - _maxRecords 21 * - _find 22 */ 23function smarty_function_fgal_browse($params, $smarty) 24{ 25 if (! is_array($params) || ! isset($params['_id'])) { 26 return; 27 } 28 global $tiki_p_view_file_gallery, $prefs; 29 $userlib = TikiLib::lib('user'); 30 $tikilib = TikiLib::lib('tiki'); 31 32 if (! isset($params['nbCols'])) { 33 $params['nbCols'] = 0; 34 } 35 if (! isset($params['show_selectall'])) { 36 $params['show_selectall'] = 'y'; 37 } 38 if (! isset($params['show_infos'])) { 39 $params['show_infos'] = 'y'; 40 } 41 if (! isset($params['show_details'])) { 42 $params['show_details'] = 'y'; 43 } 44 if (! isset($params['thumbnail_size'])) { 45 $params['thumbnail_size'] = $prefs['fgal_thumb_max_size']; 46 } 47 if (! isset($params['checkbox_label'])) { 48 $params['checkbox_label'] = ''; 49 } 50 if (! isset($params['file_checkbox_name'])) { 51 $params['file_checkbox_name'] = ''; 52 } 53 if (! isset($params['parentId'])) { 54 $params['parentId'] = 0; 55 } 56 if (! isset($params['view'])) { 57 $params['view'] = ''; 58 } 59 if (! isset($params['show_details'])) { 60 $params['show_details'] = ''; 61 } 62 63 if (! isset($params['_offset'])) { 64 $params['_offset'] = 0; 65 } 66 if (! isset($params['_maxRecords'])) { 67 $params['_maxRecords'] = -1; 68 } 69 if (! isset($params['_sort_mode'])) { 70 $params['_sort_mode'] = ''; 71 } 72 if (! isset($params['_find'])) { 73 $params['_find'] = ''; 74 } 75 76 if ($params['_id'] > 0 && $tiki_p_view_file_gallery == 'y') { 77 $filegallib = TikiLib::lib('filegal'); 78 79 if ($gal_info = $filegallib->get_file_gallery($params['_id'])) { 80 $tikilib->get_perm_object($params['_id'], 'file gallery', $gal_info); 81 if ($userlib->object_has_one_permission($params['_id'], 'file gallery')) { 82 $smarty->assign('individual', 'y'); ///TO CHECK 83 } 84 ///FIXME $podCastGallery = $filegallib->isPodCastGallery($_REQUEST['galleryId'], $gal_info); 85 } 86 87 // Get listing display config 88 include_once('fgal_listing_conf.php'); 89 90 $gal_info['show_action'] = 'n'; 91 $smarty->assignByRef('gal_info', $gal_info); 92 93 // Get list of files in the gallery 94 $files = $filegallib->get_files($params['_offset'], $params['_maxRecords'], $params['_sort_mode'], $params['_find'], $params['_id']); 95 $smarty->assignByRef('files', $files['data']); 96 $smarty->assign('cant', $files['cant']); ///FIXME 97 98 foreach ($params as $k => $v) { 99 if ($k[0] == '_') { 100 continue; 101 } 102 $smarty->assign($k, $v); 103 } 104 } 105 106 return '<div style="padding: 1px; overflow-y: hidden; overflow-x: auto;">' . "\n" . $smarty->fetch('browse_file_gallery.tpl') . "\n</div>"; 107} 108