Changeset 26442 for extensions/SmartAlbums/admin/album.php
- Timestamp:
- Jan 4, 2014, 4:13:08 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/admin/album.php
r21358 r26442 1 1 <?php 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based photo gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2012 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 if(!defined("PHPWG_ROOT_PATH")) die ("Hacking attempt!"); 2 defined('SMART_PATH') or die('Hacking attempt!'); 25 3 26 4 // +-----------------------------------------------------------------------+ … … 33 11 34 12 check_input_parameter('cat_id', $_GET, false, PATTERN_ID); 35 36 $admin_album_base_url = get_root_url().'admin.php?page=album-'.$_GET['cat_id']; 37 $self_url = SMART_ADMIN.'-album&cat_id='.$_GET['cat_id']; 13 $cat_id = $_GET['cat_id']; 14 15 $admin_album_base_url = get_root_url().'admin.php?page=album-'.$cat_id; 16 $self_url = SMART_ADMIN.'-album&cat_id='.$cat_id; 38 17 39 18 $query = ' 40 19 SELECT * 41 20 FROM '.CATEGORIES_TABLE.' 42 WHERE id = '.$ _GET['cat_id'].'21 WHERE id = '.$cat_id.' 43 22 ;'; 44 23 $category = pwg_db_fetch_assoc(pwg_query($query)); … … 48 27 die("unknown album"); 49 28 } 29 30 // category must be virtual 31 if ($category['dir'] != NULL) 32 { 33 die("physical album"); 34 } 35 50 36 51 37 // +-----------------------------------------------------------------------+ … … 60 46 61 47 62 $cat_id = $_GET['cat_id'];63 64 // category must be virtual65 if ($category['dir'] != NULL)66 {67 die("physical album");68 }69 70 48 // +-----------------------------------------------------------------------+ 71 49 // | Save Filters | … … 78 56 var_dump($_POST['filters']); 79 57 } 80 58 81 59 // test if it was a Smart Album 82 60 $query = ' 83 SELECT DISTINCT category_id 84 FROM '.CATEGORY_FILTERS_TABLE.' 61 SELECT DISTINCT category_id 62 FROM '.CATEGORY_FILTERS_TABLE.' 85 63 WHERE category_id = '.$cat_id.' 86 64 ;'; 87 65 $was_smart = pwg_db_num_rows(pwg_query($query)); 88 66 89 67 /* this album is no longer a SmartAlbum */ 90 if ( $was_smart AND !isset($_POST['is_smart']))68 if ($was_smart and !isset($_POST['is_smart'])) 91 69 { 92 70 pwg_query('DELETE FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;'); 93 71 pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';'); 72 94 73 set_random_representant(array($cat_id)); 74 75 define('SMART_NOT_UPDATE', 1); 95 76 invalidate_user_cache(); 96 77 } 97 78 /* no filter selected */ 98 else if ( isset($_POST['is_smart']) AND empty($_POST['filters']))99 { 100 array_push($page['errors'], l10n('No filter selected'));79 else if (isset($_POST['is_smart']) and empty($_POST['filters'])) 80 { 81 $page['errors'][] = l10n('No filter selected'); 101 82 } 102 83 /* everything is fine */ 103 else if ( isset($_POST['is_smart']))84 else if (isset($_POST['is_smart'])) 104 85 { 105 86 pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';'); 106 87 107 88 $inserts = array(); 108 89 foreach ($_POST['filters'] as $filter) … … 114 95 } 115 96 } 116 97 117 98 mass_inserts( 118 CATEGORY_FILTERS_TABLE, 119 array('category_id', 'type', 'cond', 'value'), 99 CATEGORY_FILTERS_TABLE, 100 array('category_id', 'type', 'cond', 'value'), 120 101 $inserts, 121 102 array('ignore'=>true) 122 103 ); 123 104 124 105 $associated_images = smart_make_associations($cat_id); 125 106 $template->assign('IMAGE_COUNT', l10n_dec('%d photo', '%d photos', count($associated_images))); 126 127 array_push($page['infos'], sprintf(l10n('%d photos associated to album %s'), count($associated_images), ''));128 107 108 $page['infos'][] = l10n('%d photos associated to album %s', count($associated_images), ''); 109 129 110 define('SMART_NOT_UPDATE', 1); 130 111 invalidate_user_cache(); … … 225 206 /* get filters for this album */ 226 207 $query = ' 227 SELECT * 228 FROM '.CATEGORY_FILTERS_TABLE.' 208 SELECT * 209 FROM '.CATEGORY_FILTERS_TABLE.' 229 210 WHERE category_id = '.$cat_id.' 230 ORDER BY 231 type ASC, 211 ORDER BY 212 type ASC, 232 213 cond ASC 233 214 ;'; … … 250 231 WHERE id IN('.$filter['value'].') 251 232 ;'; 252 $filter['value'] = get_taglist($query); 253 } 254 233 $filter['value'] = get_taglist($query); 234 } 235 255 236 $template->append('filters', $filter); 256 237 } … … 260 241 $template->assign('format_options', array( 261 242 'portrait' => l10n('Portrait'), 262 'square' => l10n(' Square'),243 'square' => l10n('square'), 263 244 'lanscape' => l10n('Landscape'), 264 245 'panorama' => l10n('Panorama'), … … 274 255 /* all albums */ 275 256 $query = ' 276 SELECT 277 id, 278 name, 279 uppercats, 257 SELECT 258 id, 259 name, 260 uppercats, 280 261 global_rank 281 262 FROM '.CATEGORIES_TABLE.' … … 303 284 while ($row = pwg_db_fetch_assoc($result)) 304 285 { 305 $widths[] = $row['width']; 306 $heights[] = $row['height']; 307 $ratios[] = floor($row['width'] * 100 / $row['height']) / 100; 286 if ($row['width']>0 && $row['height']>0) 287 { 288 $widths[] = $row['width']; 289 $heights[] = $row['height']; 290 $ratios[] = floor($row['width'] / $row['height'] * 100) / 100; 291 } 308 292 } 309 293 … … 354 338 } 355 339 356 foreach ( array_keys($ratio_categories) as $ratio_category)357 { 358 if (count($ratio_ categories[$ratio_category]) > 0)359 { 360 $dimensions['ratio_'.$ratio_ category] = array(361 'min' => $ratio_ categories[$ratio_category][0],362 'max' => $ratio_categories[$ratio_category][count($ratio_categories[$ratio_category]) - 1]340 foreach ($ratio_categories as $ratio_name => $ratio_values) 341 { 342 if (count($ratio_values) > 0) 343 { 344 $dimensions['ratio_'.$ratio_name] = array( 345 'min' => $ratio_values[0], 346 'max' => array_pop($ratio_values), 363 347 ); 364 348 } … … 371 355 { 372 356 $query = ' 373 SELECT count(1) 374 FROM '.IMAGE_CATEGORY_TABLE.' 375 WHERE 376 category_id = '.$cat_id.' 357 SELECT count(1) 358 FROM '.IMAGE_CATEGORY_TABLE.' 359 WHERE 360 category_id = '.$cat_id.' 377 361 AND smart = true 378 362 '; … … 396 380 )); 397 381 398 $template->set_filename('SmartAlbums_content', dirname(__FILE__).'/template/album.tpl'); 399 400 ?> 382 $template->set_filename('SmartAlbums_content', realpath(SMART_PATH . 'admin/template/album.tpl'));
Note: See TracChangeset
for help on using the changeset viewer.