Changeset 28063
- Timestamp:
- Apr 3, 2014, 8:03:58 PM (10 years ago)
- Location:
- extensions/SmartAlbums
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/admin/template/album.tpl
r27266 r28063 70 70 } 71 71 else if (type == "album") { 72 var values = value.split(','), 73 recursive = values.splice(0, 1)[0]; 74 value = values.join(','); 75 72 76 select_options($block, value); 77 $block.find('.filter-value input[type="checkbox"]').prop('checked', recursive=="true"); 73 78 } 74 79 else if (type == "level") { -
extensions/SmartAlbums/admin/template/filters.inc.tpl
r27266 r28063 82 82 {html_options options=$all_albums} 83 83 </select> 84 85 <label><input type="checkbox" name="filters[iiii][recursive]"> {'include child albums'|translate}</label> 84 86 </span> 85 87 </li> -
extensions/SmartAlbums/admin/template/style.css
r26442 r28063 27 27 padding-left:0px; 28 28 } 29 #filtersList 29 #filtersList>li { 30 30 padding:3px 0; 31 31 border-bottom:1px dotted rgba(100, 100, 100, 0.5); 32 32 display:block; 33 33 } 34 #filtersList 34 #filtersList>li>span { 35 35 display:inline-block; 36 36 vertical-align:middle; -
extensions/SmartAlbums/include/functions.inc.php
r27266 r28063 277 277 case 'album': 278 278 { 279 $filter['values'] = explode(',', $filter['value']); 280 $filter['recursive'] = array_shift($filter['values']) == "true"; 281 $filter['value'] = implode(',', $filter['values']); 282 279 283 switch ($filter['cond']) 280 284 { … … 282 286 case 'all': 283 287 { 284 $albums_arr = explode(',', $filter['value']); 285 foreach($albums_arr as $value) 286 { 288 foreach ($filter['values'] as $value) 289 { 290 if ($filter['recursive']) 291 { 292 $value = get_subcat_ids_query(array($value)); 293 } 287 294 $sub_query = ' 288 295 SELECT image_id 289 296 FROM '.IMAGE_CATEGORY_TABLE.' 290 WHERE category_id = '.$value.'297 WHERE category_id IN('.$value.') 291 298 '; 292 299 $where[] = 'i.id IN ('.$sub_query.')'; … … 298 305 case 'one': 299 306 { 307 if ($filter['recursive']) 308 { 309 $value = get_subcat_ids_query($filter['values']); 310 } 311 else 312 { 313 $value = $filter['value']; 314 } 300 315 $sub_query = ' 301 316 SELECT image_id 302 317 FROM '.IMAGE_CATEGORY_TABLE.' 303 WHERE category_id IN('.$ filter['value'].')318 WHERE category_id IN('.$value.') 304 319 '; 305 320 $where[] = 'i.id IN ('.$sub_query.')'; … … 310 325 case 'none': 311 326 { 327 if ($filter['recursive']) 328 { 329 $value = get_subcat_ids_query($filter['values']); 330 } 331 else 332 { 333 $value = $filter['value']; 334 } 312 335 $sub_query = ' 313 336 SELECT image_id 314 337 FROM '.IMAGE_CATEGORY_TABLE.' 315 WHERE category_id IN('.$ filter['value'].')338 WHERE category_id IN('.$value.') 316 339 '; 317 340 $where[] = 'i.id NOT IN ('.$sub_query.')'; … … 322 345 case 'only': 323 346 { 347 if ($filter['recursive']) 348 { 349 $value = get_subcat_ids_query($filter['values']); 350 } 351 else 352 { 353 $value = $filter['value']; 354 } 324 355 $sub_query = ' 325 356 SELECT image_id 326 357 FROM '.IMAGE_CATEGORY_TABLE.' 327 WHERE category_id NOT IN('.$ filter['value'].')358 WHERE category_id NOT IN('.$value.') 328 359 '; 329 360 $where[] = 'i.id NOT IN ('.$sub_query.')'; 330 361 331 $albums_arr = explode(',', $filter['value']); 332 foreach($albums_arr as $value) 333 { 362 foreach ($filter['values'] as $value) 363 { 364 if ($filter['recursive']) 365 { 366 $value = get_subcat_ids_query(array($value)); 367 } 334 368 $sub_query = ' 335 369 SELECT image_id … … 544 578 else 545 579 { 580 array_unshift($filter['value'], boolean_to_string(isset($filter['recursive']))); 546 581 $filter['value'] = implode(',', $filter['value']); 547 582 } … … 651 686 } 652 687 } 688 689 /** 690 * Returns SQL query returning all subcategory identifiers of given category ids 691 * 692 * @param int[] $ids 693 * @return int[] 694 */ 695 function get_subcat_ids_query($ids) 696 { 697 $query = ' 698 SELECT DISTINCT(id) 699 FROM '.CATEGORIES_TABLE.' 700 WHERE '; 701 foreach ($ids as $num => $category_id) 702 { 703 if ($num > 0) 704 { 705 $query.= ' 706 OR '; 707 } 708 $query.= 'uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$category_id.'(,|$)\''; 709 } 710 return $query; 711 } -
extensions/SmartAlbums/maintain.inc.php
r27300 r28063 119 119 pwg_query('UPDATE `' . $this->table . '` SET cond = "" WHERE type = "limit" AND cond = "limit";'); 120 120 pwg_query('ALTER TABLE `' . $this->table . '` CHANGE `cond` `cond` VARCHAR(32) NULL ;'); 121 122 $result = pwg_query('SELECT COUNT(*) FROM `' . $this->table . '` WHERE type="album" AND (value NOT LIKE "true,%" OR value NOT LIKE "false,%");'); 123 if (pwg_db_num_rows(pwg_query($query))) 124 { 125 pwg_query('UPDATE `' . $this->table . '` SET value = CONCAT("false,", value) WHERE type="album";'); 126 } 121 127 122 128 $this->installed = true;
Note: See TracChangeset
for help on using the changeset viewer.