Changeset 26442
- Timestamp:
- Jan 4, 2014, 4:13:08 PM (11 years ago)
- Location:
- extensions/SmartAlbums
- Files:
-
- 1 added
- 3 deleted
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/admin.php
r16938 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('SMART_PATH') or die('Hacking attempt!'); 3 3 4 4 global $conf, $template, $page; … … 25 25 26 26 $template->assign_var_from_handle('ADMIN_CONTENT', 'SmartAlbums_content'); 27 28 ?> -
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')); -
extensions/SmartAlbums/admin/cat_list.php
r21658 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('SMART_PATH') or die('Hacking attempt!'); 3 3 4 4 if (isset($_GET['hide_messages'])) … … 16 16 $categories = array(); 17 17 $query = ' 18 SELECT 18 SELECT 19 19 id, 20 20 name, … … 51 51 if (isset($output_create['error'])) 52 52 { 53 array_push($page['errors'], $output_create['error']);53 $page['errors'][] = $output_create['error']; 54 54 } 55 55 else … … 69 69 { 70 70 $associated_images = smart_make_associations($category['id']); 71 array_push($page['infos'], 72 sprintf(l10n('%d photos associated to album %s'),73 count($associated_images),74 '«'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'»'75 )71 72 $page['infos'][] = l10n( 73 '%d photos associated to album %s', 74 count($associated_images), 75 '«'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'»' 76 76 ); 77 77 } … … 80 80 else 81 81 { 82 $associated_images = smart_make_associations($_GET['smart_generate']); 83 array_push($page['infos'], 84 sprintf(l10n('%d photos associated to album %s'),85 count($associated_images),86 '«'.trigger_event('render_category_name', $categories[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'»'87 )82 $associated_images = smart_make_associations($_GET['smart_generate']); 83 84 $page['infos'][] = l10n( 85 '%d photos associated to album %s', 86 count($associated_images), 87 '«'.trigger_event('render_category_name', $categories[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'»' 88 88 ); 89 89 } 90 90 91 91 define('SMART_NOT_UPDATE', 1); 92 92 invalidate_user_cache(); … … 100 100 'PWG_TOKEN' => get_pwg_token(), 101 101 )); 102 102 103 103 // retrieve all existing categories for album creation 104 104 $query = ' … … 108 108 109 109 display_select_cat_wrapper( 110 $query, 111 null, 110 $query, null, 112 111 'category_options' 113 112 ); 114 113 115 114 if ($conf['SmartAlbums']['show_list_messages']) 116 115 { 117 array_push($page['warnings'], l10n('Only SmartAlbums are displayed on this page'));118 array_push($page['warnings'], sprintf(l10n('To order albums please go the main albums <a href="%s">management page</a>'), $base_url.'cat_list'));119 array_push($page['warnings'], '<a href="'.$self_url.'&hide_messages">['.l10n('Don\'t show this message again').']</a>');116 $page['warnings'][] = l10n('Only SmartAlbums are displayed on this page'); 117 $page['warnings'][] = sprintf(l10n('To order albums please go the main albums <a href="%s">management page</a>'), $base_url.'cat_list'); 118 $page['warnings'][] = '<a href="'.$self_url.'&hide_messages">['.l10n('Don\'t show this message again').']</a>'; 120 119 } 121 120 … … 125 124 126 125 $categories_count_images = array(); 127 if ( count($categories))126 if (count($categories)) 128 127 { 129 128 $query = ' 130 SELECT 131 category_id, 129 SELECT 130 category_id, 132 131 COUNT(image_id) AS total_images 133 132 FROM '.IMAGE_CATEGORY_TABLE.' … … 154 153 'U_SMART' => $self_url.'&smart_generate='.$category['id'], 155 154 ); 156 155 157 156 $template->append('categories', $tpl_cat); 158 157 } 159 158 160 $template->set_filename('SmartAlbums_content', dirname(__FILE__).'/template/cat_list.tpl'); 161 162 ?> 159 $template->set_filename('SmartAlbums_content', realpath(SMART_PATH . 'admin/template/cat_list.tpl')); -
extensions/SmartAlbums/admin/config.php
r19446 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('SMART_PATH') or die('Hacking attempt!'); 3 3 4 // Enregistrement de la configuration5 4 if (isset($_POST['submit'])) 6 5 { 7 if ( $_POST['update_timeout'] == 0 or !preg_match('#^[0-9.]+$#', $_POST['update_timeout']))6 if ($_POST['update_timeout'] == 0 or !preg_match('#^[0-9.]+$#', $_POST['update_timeout'])) 8 7 { 9 array_push($page['errors'], l10n('Invalid number of days'));8 $page['errors'][] = l10n('Invalid number of days'); 10 9 $_POST['update_timeout'] = $conf['SmartAlbums']['update_timeout']; 11 10 } 12 11 13 12 $conf['SmartAlbums'] = array( 14 13 'show_list_messages' => $conf['SmartAlbums']['show_list_messages'], … … 19 18 'smart_is_forbidden' => isset($_POST['smart_is_forbidden']), 20 19 ); 21 20 22 21 conf_update_param('SmartAlbums', serialize($conf['SmartAlbums'])); 23 array_push($page['infos'], l10n('Information data registered in database'));22 $page['infos'][] = l10n('Information data registered in database'); 24 23 } 25 24 26 25 $template->assign($conf['SmartAlbums']); 27 26 28 $template->set_filename('SmartAlbums_content', dirname(__FILE__).'/template/config.tpl'); 29 30 ?> 27 $template->set_filename('SmartAlbums_content', realpath(SMART_PATH . 'admin/template/config.tpl')); -
extensions/SmartAlbums/admin/template/album.tpl
r19722 r26442 1 {combine_css path=$SMART_PATH|@cat:"admin/template/style.css"} 2 {combine_script id='sprintf' load='footer' path=$SMART_PATH|@cat:"admin/template/sprintf.js"} 1 {combine_css path=$SMART_PATH|cat:'admin/template/style.css'} 3 2 {include file='include/datepicker.inc.tpl'} 3 {combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} 4 5 {combine_css path='themes/default/js/plugins/jquery.tokeninput.css'} 4 6 {combine_script id='jquery.tokeninput' load='footer' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'} 5 {combine_css path="themes/default/js/plugins/chosen.css"} 7 8 {combine_css path='themes/default/js/plugins/chosen.css'} 6 9 {combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} 7 {combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} 10 11 {combine_css path='themes/default/js/ui/theme/jquery.ui.slider.css'} 8 12 {combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'} 9 13 10 {footer_script}{literal} 11 var count=0; 12 var limit_count=0; 13 var level_count=0; 14 15 // MAIN EVENT HANDLERS 16 $('#addFilter').change(function() { 17 add_filter($(this).attr('value')); 18 $(this).attr('value', '-1'); 19 }); 20 21 $('#removeFilters').click(function() { 22 $('#filtersList li').each(function() { 23 $(this).remove(); 14 {*combine_script id='smartalbums.filters' require='common,datepicker.js,jquery.tokeninput,jquery.chosen,jquery.ui.slider' 15 path=$SMART_PATH|cat:'admin/template/filters.js' load='footer' template=true*} 16 17 {footer_script require='jquery'} 18 var addFilter = (function($){ 19 var count=0, 20 limit_count=0, 21 level_count=0; 22 23 // MAIN EVENT HANDLERS 24 $('#addFilter').change(function() { 25 if ($(this).val() != -1) { 26 add_filter($(this).val()); 27 $(this).val(-1); 28 } 24 29 }); 25 26 limit_level=0; 27 level_count=0; 28 return false; 29 }); 30 31 $('input[name="is_smart"]').change(function() { 32 $('#SmartAlbum_options').toggle(); 33 $('input[name="countImages"]').toggle(); 34 $('.count_images_wrapper').toggle(); 35 }); 36 37 $('input[name="countImages"]').click(function() { 38 countImages($("#smart")); 39 return false; 40 }); 41 42 43 // ADD FILTER FUNCTIONS 44 function add_filter(type, cond, value) { 45 count++; 46 47 content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count); 48 $block = $(content); 49 $("#filtersList").append($block); 50 51 if (cond) { 52 select_cond($block, type, cond); 53 } 54 55 if (value) { 56 if (type == "tags") { 57 $block.find(".filter-value .tagSelect").html(value); 58 } 59 else if (type == "album") { 60 select_options($block, value); 61 } 62 else if (type == "level") { 63 select_options($block, value); 64 } 65 else if (type != "dimensions") { 66 $block.find(".filter-value input").val(value); 67 } 68 } 69 70 init_jquery_handlers($block); 71 72 if (type == "dimensions") { 73 select_dimensions($block, cond, value); 74 } 75 76 if (type == 'limit') { 77 limit_count=1; 78 $("#addFilter option[value='limit']").attr('disabled','disabled'); 79 } 80 else if (type == 'level') { 81 level_count=1; 82 $("#addFilter option[value='level']").attr('disabled','disabled'); 83 } 84 } 85 86 function select_cond($block, type, cond) { 87 $block.find(".filter-cond option").removeAttr('selected'); 88 $block.find(".filter-cond option[value='"+cond+"']").attr('selected', 'selected'); 89 } 90 91 function select_dimensions($block, cond, value) { 92 if (!cond) cond = 'width'; 93 94 $block.find(".filter-value span:not(.filter_dimension_info)").hide(); 95 $block.find(".filter-value .dimension_"+cond).show(); 96 97 if (value) { 98 values = value.split(','); 99 } 100 else { 101 values = $block.find(".filter_dimension_"+cond+"_slider").slider("values"); 102 } 103 $block.find(".filter_dimension_"+cond+"_slider").slider("values", values); 104 } 105 106 function select_options($block, value) { 107 values = value.split(','); 108 for (j in values) { 109 $block.find(".filter-value option[value='"+ values[j] +"']").attr('selected', 'selected'); 110 } 111 } 112 113 114 // DECLARE JQUERY PLUGINS AND VERSATILE HANDLERS 115 function init_jquery_handlers($block) { 116 // remove filter 117 $block.find(".removeFilter").click(function() { 118 type = $(this).next("input").val(); 30 31 $('#removeFilters').click(function() { 32 $('#filtersList li').each(function() { 33 $(this).remove(); 34 }); 35 36 limit_level=0; 37 level_count=0; 38 return false; 39 }); 40 41 $('input[name="is_smart"]').change(function() { 42 $('#SmartAlbum_options').toggle(); 43 $('input[name="countImages"]').toggle(); 44 $('.count_images_wrapper').toggle(); 45 }); 46 47 $('input[name="countImages"]').click(function() { 48 countImages($("#smart")); 49 return false; 50 }); 51 52 53 // ADD FILTER FUNCTIONS 54 function add_filter(type, cond, value) { 55 count++; 56 57 var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count); 58 $block = $($.parseHTML(content)).appendTo("#filtersList"); 59 60 if (cond) { 61 select_cond($block, type, cond); 62 } 63 64 if (value) { 65 if (type == "tags") { 66 $block.find(".filter-value .tagSelect").html(value); 67 } 68 else if (type == "album") { 69 select_options($block, value); 70 } 71 else if (type == "level") { 72 select_options($block, value); 73 } 74 else if (type != "dimensions") { 75 $block.find(".filter-value input").val(value); 76 } 77 } 78 79 init_jquery_handlers($block); 80 81 if (type == "dimensions") { 82 select_dimensions($block, cond, value); 83 } 84 119 85 if (type == 'limit') { 120 86 limit_count=1; 121 $("#addFilter option[value='limit']"). removeAttr('disabled');87 $("#addFilter option[value='limit']").attr('disabled','disabled'); 122 88 } 123 89 else if (type == 'level') { 124 90 level_count=1; 125 $("#addFilter option[value='level']").removeAttr('disabled'); 126 } 127 128 $(this).parents('li').remove(); 129 return false; 130 }); 131 132 // date filter 133 if ($block.hasClass('filter_date')) { 134 $block.find("input[type='text']").each(function() { 135 $(this).datepicker({dateFormat:'yy-mm-dd', firstDay:1}); 91 $("#addFilter option[value='level']").attr('disabled','disabled'); 92 } 93 } 94 95 function select_cond($block, type, cond) { 96 $block.find(".filter-cond option").removeAttr('selected'); 97 $block.find(".filter-cond option[value='"+cond+"']").attr('selected', 'selected'); 98 } 99 100 function select_dimensions($block, cond, value) { 101 console.log($block, cond, value); 102 cond = cond || 'width'; 103 104 $block.find(">.filter-value>span").hide(); 105 $block.find(".dimension_"+cond).show(); 106 107 if (value) { 108 values = value.split(','); 109 } 110 else { 111 values = $block.find(".filter_dimension_"+cond+"_slider").slider("values"); 112 } 113 $block.find(".filter_dimension_"+cond+"_slider").slider("values", values); 114 } 115 116 function select_options($block, value) { 117 values = value.split(','); 118 for (j in values) { 119 $block.find(".filter-value option[value='"+ values[j] +"']").attr('selected', 'selected'); 120 } 121 } 122 123 124 // DECLARE JQUERY PLUGINS AND VERSATILE HANDLERS 125 function init_jquery_handlers($block) { 126 // remove filter 127 $block.find(".removeFilter").click(function() { 128 type = $(this).next("input").val(); 129 if (type == 'limit') { 130 limit_count=1; 131 $("#addFilter option[value='limit']").removeAttr('disabled'); 132 } 133 else if (type == 'level') { 134 level_count=1; 135 $("#addFilter option[value='level']").removeAttr('disabled'); 136 } 137 138 $(this).parents('li').remove(); 139 return false; 136 140 }); 137 } 138 139 // tags filter 140 if ($block.hasClass('filter_tags')) { 141 $block.find(".tagSelect").tokenInput( 142 {/literal} 143 [{foreach from=$all_tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}], 144 {ldelim} 145 hintText: '{'Type in a search term'|@translate}', 146 noResultsText: '{'No results'|@translate}', 147 searchingText: '{'Searching...'|@translate}', 148 animateDropdown: false, 149 preventDuplicates: true, 150 allowCreation: false 151 {literal} 152 }); 153 } 154 155 // album filter 156 if ($block.hasClass('filter_album')) { 157 $block.find(".albumSelect").chosen(); 158 } 159 160 // dimension filter 161 if ($block.hasClass('filter_dimensions')) { 162 $block.find(".filter-cond select").change(function() { 163 select_dimensions($block, $(this).attr("value")); 164 }); 165 {/literal} 166 167 $block.find(".filter_dimension_width_slider").slider({ldelim} 168 range: true, 169 min: {$dimensions.bounds.min_width}, 170 max: {$dimensions.bounds.max_width}, 171 values: [{$dimensions.bounds.min_width}, {$dimensions.bounds.max_width}], 172 slide: function(event, ui) {ldelim} 173 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|@translate}"); 174 }, 175 change: function(event, ui) {ldelim} 176 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|@translate}"); 177 } 178 }); 179 180 $block.find(".filter_dimension_height_slider").slider({ldelim} 181 range: true, 182 min: {$dimensions.bounds.min_height}, 183 max: {$dimensions.bounds.max_height}, 184 values: [{$dimensions.bounds.min_height}, {$dimensions.bounds.max_height}], 185 slide: function(event, ui) {ldelim} 186 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|@translate}"); 187 }, 188 change: function(event, ui) {ldelim} 189 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|@translate}"); 190 } 191 }); 192 193 $block.find(".filter_dimension_ratio_slider").slider({ldelim} 194 range: true, 195 step: 0.01, 196 min: {$dimensions.bounds.min_ratio}, 197 max: {$dimensions.bounds.max_ratio}, 198 values: [{$dimensions.bounds.min_ratio}, {$dimensions.bounds.max_ratio}], 199 slide: function(event, ui) {ldelim} 200 change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|@translate}"); 201 }, 202 change: function(event, ui) {ldelim} 203 change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|@translate}"); 204 } 205 }); 206 {literal} 207 208 $block.find("a.dimensions-choice").click(function() { 209 $block.find(".filter_dimension_"+ $(this).data("type") +"_slider").slider("values", 210 [$(this).data("min"), $(this).data("max")] 141 142 // date filter 143 if ($block.hasClass('filter_date')) { 144 $block.find("input[type='text']").each(function() { 145 $(this).datepicker({ 146 dateFormat:'yy-mm-dd', 147 firstDay:1 148 }); 149 }); 150 } 151 152 // tags filter 153 if ($block.hasClass('filter_tags')) { 154 $block.find(".tagSelect").tokenInput( 155 [{foreach from=$all_tags item=tag name=tags}{ name:"{$tag.name|escape:javascript}", id:"{$tag.id}" }{if !$smarty.foreach.tags.last},{/if}{/foreach}], 156 { 157 hintText: '{'Type in a search term'|translate}', 158 noResultsText: '{'No results'|translate}', 159 searchingText: '{'Searching...'|translate}', 160 animateDropdown: false, 161 preventDuplicates: true, 162 allowFreeTagging: false 163 } 211 164 ); 212 }); 213 } 214 } 215 216 217 // GENERAL FUNCTIONS 218 function change_dimension_info($block, values, text) { 219 $block.find("input[name$='[value][min]']").val(values[0]); 220 $block.find("input[name$='[value][max]']").val(values[1]); 221 $block.find(".filter_dimension_info").html(sprintf(text, values[0], values[1])); 222 } 223 224 function countImages(form) { 225 {/literal} 226 jQuery.post("{$COUNT_SCRIPT_URL}", 'cat_id={$CAT_ID}&'+form.serialize(), 227 {literal} 228 function success(data) { 229 jQuery('.count_images_wrapper').html(data); 230 } 231 ); 232 } 233 234 function doBlink(obj,start,finish) { 235 jQuery(obj).fadeOut(400).fadeIn(400); 236 if(start!=finish) { 237 doBlink(obj,start+1,finish); 238 } else { 239 jQuery(obj).fadeOut(400); 240 } 241 } 242 {/literal} 243 244 {if isset($new_smart)}doBlink('.new_smart', 0, 3);{/if} 165 } 166 167 // album filter 168 if ($block.hasClass('filter_album')) { 169 $block.find(".albumSelect").chosen(); 170 } 171 172 // dimension filter 173 if ($block.hasClass('filter_dimensions')) { 174 $block.find(".filter-cond select").change(function() { 175 select_dimensions($block, $(this).val()); 176 }); 177 178 $block.find(".filter_dimension_width_slider").slider({ 179 range: true, 180 min: {$dimensions.bounds.min_width}, 181 max: {$dimensions.bounds.max_width}, 182 values: [{$dimensions.bounds.min_width}, {$dimensions.bounds.max_width}], 183 slide: function(event, ui) { 184 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}"); 185 }, 186 change: function(event, ui) { 187 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}"); 188 } 189 }); 190 191 $block.find(".filter_dimension_height_slider").slider({ 192 range: true, 193 min: {$dimensions.bounds.min_height}, 194 max: {$dimensions.bounds.max_height}, 195 values: [{$dimensions.bounds.min_height}, {$dimensions.bounds.max_height}], 196 slide: function(event, ui) { 197 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}"); 198 }, 199 change: function(event, ui) { 200 change_dimension_info($block, ui.values, "{'between %d and %d pixels'|translate}"); 201 } 202 }); 203 204 $block.find(".filter_dimension_ratio_slider").slider({ 205 range: true, 206 step: 0.01, 207 min: {$dimensions.bounds.min_ratio}, 208 max: {$dimensions.bounds.max_ratio}, 209 values: [{$dimensions.bounds.min_ratio}, {$dimensions.bounds.max_ratio}], 210 slide: function(event, ui) { 211 change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|translate}"); 212 }, 213 change: function(event, ui) { 214 change_dimension_info($block, ui.values, "{'between %.2f and %.2f'|translate}"); 215 } 216 }); 217 218 $block.find("a.dimensions-choice").click(function() { 219 $block.find(".filter_dimension_"+ $(this).data("type") +"_slider").slider("values", 220 [$(this).data("min"), $(this).data("max")] 221 ); 222 }); 223 } 224 } 225 226 227 // GENERAL FUNCTIONS 228 function change_dimension_info($block, values, text) { 229 $block.find("input[name$='[value][min]']").val(values[0]); 230 $block.find("input[name$='[value][max]']").val(values[1]); 231 $block.find(".filter_dimension_info").html(sprintf(text, values[0], values[1])); 232 } 233 234 function countImages(form) { 235 jQuery.post("{$COUNT_SCRIPT_URL}", 'cat_id={$CAT_ID}&'+form.serialize(), 236 function success(data) { 237 jQuery('.count_images_wrapper').html(data); 238 } 239 ); 240 } 241 242 243 {if isset($new_smart)} 244 function doBlink(obj,start,finish) { 245 jQuery(obj).fadeOut(400).fadeIn(400); 246 if(start!=finish) { 247 doBlink(obj,start+1,finish); 248 } 249 else { 250 jQuery(obj).fadeOut(400); 251 } 252 } 253 254 doBlink('.new_smart', 0, 3); 255 {/if} 256 257 return add_filter; // expose add_filter method 258 }(jQuery)); 245 259 {/footer_script} 246 260 247 261 248 262 <div class="titrePage"> 249 <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'| @translate} [SmartAlbum]</h2>263 <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'|translate} [SmartAlbum]</h2> 250 264 </div> 251 265 252 266 <noscript> 253 <div class="errors"><ul><li>JavaScript required!</li></ul></div>267 <div class="errors"><ul><li>JavaScript required!</li></ul></div> 254 268 </noscript> 255 269 256 270 <div id="batchManagerGlobal"> 257 271 <form action="{$F_ACTION}" method="POST" id="smart"> 258 <p style="text-align:left;"><label><input type="checkbox" name="is_smart" {if isset($filters) OR isset($new_smart)}checked="checked"{/if}/> {'This album is a SmartAlbum'| @translate}</label></p>272 <p style="text-align:left;"><label><input type="checkbox" name="is_smart" {if isset($filters) OR isset($new_smart)}checked="checked"{/if}/> {'This album is a SmartAlbum'|translate}</label></p> 259 273 260 274 <fieldset id="SmartAlbum_options" style="margin-top:1em;{if !isset($filters) AND !isset($new_smart)}display:none;{/if}"> 261 <legend>{'Filters'| @translate}</legend>262 275 <legend>{'Filters'|translate}</legend> 276 263 277 <ul id="filtersList"> 264 278 {foreach from=$filters item=filter}{strip} … … 268 282 {assign var='value' value=$filter.value} 269 283 {/if} 270 284 271 285 {if $filter.type == 'limit'} 272 286 {footer_script} … … 280 294 {/footer_script} 281 295 {/if} 282 283 {footer_script}add _filter('{$filter.type}', '{$filter.cond}', '{$value|escape:javascript}');{/footer_script}296 297 {footer_script}addFilter('{$filter.type}', '{$filter.cond}', '{$value|escape:javascript}');{/footer_script} 284 298 {/strip}{/foreach} 285 299 </ul> 286 300 287 301 <div> 288 <b>{'Mode'| @translate} :</b>302 <b>{'Mode'|translate} :</b> 289 303 <label><input type="radio" name="filters[0][value]" value="and" {if $filter_mode=='and'}checked="checked"{/if}> AND</label> 290 304 <label><input type="radio" name="filters[0][value]" value="or" {if $filter_mode=='or'}checked="checked"{/if}> OR</label> … … 292 306 <input type="hidden" name="filters[0][cond]" value="mode"> 293 307 </div> 294 308 295 309 <p class="actionButtons"> 296 310 <select id="addFilter"> 297 <option value="-1">{'Add a filter'| @translate}</option>311 <option value="-1">{'Add a filter'|translate}</option> 298 312 <option disabled="disabled">------------------</option> 299 <option value="tags">{'Tags'| @translate}</option>300 <option value="date">{'Date'| @translate}</option>301 <option value="name">{'Photo name'| @translate}</option>302 <option value="album">{'Album'| @translate}</option>303 <option value="dimensions">{'Dimensions'| @translate}</option>304 <option value="author">{'Author'| @translate}</option>305 <option value="hit">{'Hits'| @translate}</option>306 <option value="rating_score">{'Rating score'| @translate}</option>307 <option value="level">{'Privacy level'| @translate}</option>308 <option value="limit">{'Max. number of photos'| @translate}</option>309 </select> 310 <a id="removeFilters">{'Remove all filters'| @translate}</a>311 {if isset($new_smart)}<span class="new_smart">{'Add filters here'| @translate}</span>{/if}313 <option value="tags">{'Tags'|translate}</option> 314 <option value="date">{'Date'|translate}</option> 315 <option value="name">{'Photo name'|translate}</option> 316 <option value="album">{'Album'|translate}</option> 317 <option value="dimensions">{'Dimensions'|translate}</option> 318 <option value="author">{'Author'|translate}</option> 319 <option value="hit">{'Hits'|translate}</option> 320 <option value="rating_score">{'Rating score'|translate}</option> 321 <option value="level">{'Privacy level'|translate}</option> 322 <option value="limit">{'Max. number of photos'|translate}</option> 323 </select> 324 <a id="removeFilters">{'Remove all filters'|translate}</a> 325 {if isset($new_smart)}<span class="new_smart">{'Add filters here'|translate}</span>{/if} 312 326 </p> 313 327 </fieldset> 314 328 315 329 <p class="actionButtons" id="applyFilterBlock"> 316 <input class="submit" type="submit" value="{'Submit'| @translate}" name="submitFilters"/>317 <input class="submit" type="submit" value="{'Count'| @translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/>330 <input class="submit" type="submit" value="{'Submit'|translate}" name="submitFilters"/> 331 <input class="submit" type="submit" value="{'Count'|translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/> 318 332 <span class="count_images_wrapper" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}><span class="count_image">{$IMAGE_COUNT}</span></span> 319 333 </p> … … 327 341 <li id="filter_iiii" class="filter_tags"> 328 342 <span class="filter-title"> 329 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>343 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 330 344 <input type="hidden" name="filters[iiii][type]" value="tags"/> 331 345 {$options.tags.name} 332 346 </span> 333 347 334 348 <span class="filter-cond"> 335 349 <select name="filters[iiii][cond]"> … … 337 351 </select> 338 352 </span> 339 353 340 354 <span class="filter-value"> 341 355 <select name="filters[iiii][value]" class="tagSelect"> … … 344 358 </li> 345 359 </div> 346 360 347 361 <!-- date --> 348 362 <div id="filter_date"> 349 363 <li id="filter_iiii" class="filter_date"> 350 364 <span class="filter-title"> 351 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>365 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 352 366 <input type="hidden" name="filters[iiii][type]" value="date"/> 353 367 {$options.date.name} 354 368 </span> 355 369 356 370 <span class="filter-cond"> 357 371 <select name="filters[iiii][cond]"> … … 359 373 </select> 360 374 </span> 361 375 362 376 <span class="filter-value"> 363 377 <input type="text" name="filters[iiii][value]" size="30"/> … … 365 379 </li> 366 380 </div> 367 381 368 382 <!-- name --> 369 383 <div id="filter_name"> 370 384 <li id="filter_iiii" class="filter_name"> 371 385 <span class="filter-title"> 372 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>386 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 373 387 <input type="hidden" name="filters[iiii][type]" value="name"/> 374 388 {$options.name.name} 375 389 </span> 376 390 377 391 <span class="filter-cond"> 378 392 <select name="filters[iiii][cond]"> … … 380 394 </select> 381 395 </span> 382 396 383 397 <span class="filter-value"> 384 398 <input type="text" name="filters[iiii][value]" size="30"/> … … 386 400 </li> 387 401 </div> 388 402 389 403 <!-- album --> 390 404 <div id="filter_album"> 391 405 <li id="filter_iiii" class="filter_album"> 392 406 <span class="filter-title"> 393 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>407 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 394 408 <input type="hidden" name="filters[iiii][type]" value="album"/> 395 409 {$options.album.name} 396 410 </span> 397 411 398 412 <span class="filter-cond"> 399 413 <select name="filters[iiii][cond]"> … … 401 415 </select> 402 416 </span> 403 404 <span class="filter-value"> 405 <select name="filters[iiii][value][]" class="albumSelect" multiple="multiple" data-placeholder="{'Select albums...'| @translate}">417 418 <span class="filter-value"> 419 <select name="filters[iiii][value][]" class="albumSelect" multiple="multiple" data-placeholder="{'Select albums...'|translate}"> 406 420 {html_options options=$all_albums} 407 421 </select> … … 409 423 </li> 410 424 </div> 411 425 412 426 <!-- dimensions --> 413 427 <div id="filter_dimensions"> 414 428 <li id="filter_iiii" class="filter_dimensions"> 415 429 <span class="filter-title"> 416 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>430 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 417 431 <input type="hidden" name="filters[iiii][type]" value="dimensions"/> 418 432 {$options.dimensions.name} … … 427 441 <span class="filter-value"> 428 442 <span class="dimension_width"> 429 <span class="filter_dimension_info"></span>430 | <a class="dimensions-choice" data-type="width" data-min="{$dimensions.bounds.min_width}" data-max="{$dimensions.bounds.max_width}">{'Reset'|@translate}</a>431 <div class="filter_dimension_width_slider"></div>443 <span class="filter_dimension_info"></span> 444 | <a class="dimensions-choice" data-type="width" data-min="{$dimensions.bounds.min_width}" data-max="{$dimensions.bounds.max_width}">{'Reset'|translate}</a> 445 <div class="filter_dimension_width_slider"></div> 432 446 </span> 433 447 434 <span class=" filter-valuedimension_height">435 <span class="filter_dimension_info"></span>436 | <a class="dimensions-choice" data-type="height" data-min="{$dimensions.bounds.min_height}" data-max="{$dimensions.bounds.max_height}">{'Reset'|@translate}</a>437 <div class="filter_dimension_height_slider"></div>448 <span class="dimension_height"> 449 <span class="filter_dimension_info"></span> 450 | <a class="dimensions-choice" data-type="height" data-min="{$dimensions.bounds.min_height}" data-max="{$dimensions.bounds.max_height}">{'Reset'|translate}</a> 451 <div class="filter_dimension_height_slider"></div> 438 452 </span> 439 453 440 <span class=" filter-valuedimension_ratio">441 <span class="filter_dimension_info"></span>442 {if isset($dimensions.ratio_portrait)}443 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_portrait.min}" data-max="{$dimensions.ratio_portrait.max}">{'Portrait'|@translate}</a>444 {/if}445 {if isset($dimensions.ratio_square)}446 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_square.min}" data-max="{$dimensions.ratio_square.max}">{'square'|@translate}</a>447 {/if}448 {if isset($dimensions.ratio_landscape)}449 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_landscape.min}" data-max="{$dimensions.ratio_landscape.max}">{'Landscape'|@translate}</a>450 {/if}451 {if isset($dimensions.ratio_panorama)}452 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_panorama.min}" data-max="{$dimensions.ratio_panorama.max}">{'Panorama'|@translate}</a>453 {/if}454 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.bounds.min_ratio}" data-max="{$dimensions.bounds.max_ratio}">{'Reset'|@translate}</a>455 <div class="filter_dimension_ratio_slider"></div>454 <span class="dimension_ratio"> 455 <span class="filter_dimension_info"></span> 456 {if isset($dimensions.ratio_portrait)} 457 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_portrait.min}" data-max="{$dimensions.ratio_portrait.max}">{'Portrait'|translate}</a> 458 {/if} 459 {if isset($dimensions.ratio_square)} 460 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_square.min}" data-max="{$dimensions.ratio_square.max}">{'square'|translate}</a> 461 {/if} 462 {if isset($dimensions.ratio_landscape)} 463 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_landscape.min}" data-max="{$dimensions.ratio_landscape.max}">{'Landscape'|translate}</a> 464 {/if} 465 {if isset($dimensions.ratio_panorama)} 466 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.ratio_panorama.min}" data-max="{$dimensions.ratio_panorama.max}">{'Panorama'|translate}</a> 467 {/if} 468 | <a class="dimensions-choice" data-type="ratio" data-min="{$dimensions.bounds.min_ratio}" data-max="{$dimensions.bounds.max_ratio}">{'Reset'|translate}</a> 469 <div class="filter_dimension_ratio_slider"></div> 456 470 </span> 457 471 </span> … … 461 475 </li> 462 476 </div> 463 477 464 478 <!-- author --> 465 479 <div id="filter_author"> 466 480 <li id="filter_iiii" class="filter_author"> 467 481 <span class="filter-title"> 468 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>482 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 469 483 <input type="hidden" name="filters[iiii][type]" value="author"/> 470 484 {$options.author.name} 471 485 </span> 472 486 473 487 <span class="filter-cond"> 474 488 <select name="filters[iiii][cond]"> … … 476 490 </select> 477 491 </span> 478 492 479 493 <span class="filter-value"> 480 494 <input type="text" name="filters[iiii][value]" size="30"/> 481 <i>{'For "Is (not) in", separate each author by a comma'| @translate}</i>482 </span> 483 </li> 484 </div> 485 495 <i>{'For "Is (not) in", separate each author by a comma'|translate}</i> 496 </span> 497 </li> 498 </div> 499 486 500 <!-- hit --> 487 501 <div id="filter_hit"> 488 502 <li id="filter_iiii" class="filter_hit"> 489 503 <span class="filter-title"> 490 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>504 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 491 505 <input type="hidden" name="filters[iiii][type]" value="hit"/> 492 506 {$options.hit.name} 493 507 </span> 494 508 495 509 <span class="filter-cond"> 496 510 <select name="filters[iiii][cond]"> … … 498 512 </select> 499 513 </span> 500 514 501 515 <span class="filter-value"> 502 516 <input type="text" name="filters[iiii][value]" size="5"/> … … 504 518 </li> 505 519 </div> 506 520 507 521 <!-- rating_score --> 508 522 <div id="filter_rating_score"> 509 523 <li id="filter_iiii" class="filter_rating_score"> 510 524 <span class="filter-title"> 511 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>525 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 512 526 <input type="hidden" name="filters[iiii][type]" value="rating_score"/> 513 527 {$options.rating_score.name} 514 528 </span> 515 529 516 530 <span class="filter-cond"> 517 531 <select name="filters[iiii][cond]"> … … 519 533 </select> 520 534 </span> 521 535 522 536 <span class="filter-value"> 523 537 <input type="text" name="filters[iiii][value]" size="5"/> … … 525 539 </li> 526 540 </div> 527 541 528 542 <!-- level --> 529 543 <div id="filter_level"> 530 544 <li id="filter_iiii" class="filter_level"> 531 545 <span class="filter-title"> 532 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>546 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 533 547 <input type="hidden" name="filters[iiii][type]" value="level"/> 534 548 {$options.level.name} 535 549 </span> 536 550 537 551 <input type="hidden" name="filters[iiii][cond]" value="level"/> 538 552 539 553 <span class="filter-value"> 540 554 <select name="filters[iiii][value]"> … … 544 558 </li> 545 559 </div> 546 560 547 561 <!-- limit --> 548 562 <div id="filter_limit"> 549 563 <li id="filter_iiii" class="filter_limit"> 550 564 <span class="filter-title"> 551 <a href="#" class="removeFilter" title="{'remove this filter'| @translate}"><span>[x]</span></a>565 <a href="#" class="removeFilter" title="{'remove this filter'|translate}"><span>[x]</span></a> 552 566 <input type="hidden" name="filters[iiii][type]" value="limit"/> 553 567 {$options.limit.name} 554 568 </span> 555 569 556 570 <input type="hidden" name="filters[iiii][cond]" value="limit"/> 557 571 558 572 <span class="filter-value"> 559 573 <input type="text" name="filters[iiii][value]" size="5"/> -
extensions/SmartAlbums/admin/template/cat_list.tpl
r19446 r26442 1 {footer_script require='jquery.ui.sortable'}{literal} 2 jQuery(document).ready(function(){ 3 jQuery("#addAlbumOpen").click(function(){ 4 jQuery("#createAlbum").toggle(); 5 jQuery("input[name=virtual_name]").focus(); 6 jQuery("#autoOrder").hide(); 7 }); 1 {footer_script require='jquery'} 2 jQuery("#addAlbumOpen").click(function(){ 3 jQuery("#createAlbum").toggle(); 4 jQuery("input[name=virtual_name]").focus(); 5 jQuery("#autoOrder").hide(); 6 }); 8 7 9 jQuery("#addAlbumClose").click(function(){ 10 jQuery("#createAlbum").hide(); 11 }); 8 jQuery("#addAlbumClose").click(function(){ 9 jQuery("#createAlbum").hide(); 12 10 }); 13 {/ literal}{/footer_script}11 {/footer_script} 14 12 15 {* è *}16 13 17 14 <div class="titrePage"> … … 24 21 <p class="showCreateAlbum"> 25 22 <span id="notManualOrder"> 26 <a href="#" id="addAlbumOpen">{'create a new SmartAlbum'| @translate}</a>27 | <a href="{$F_ACTION}&smart_generate=all">{'Regenerate photos list of all SmartAlbums'| @translate}</a>23 <a href="#" id="addAlbumOpen">{'create a new SmartAlbum'|translate}</a> 24 | <a href="{$F_ACTION}&smart_generate=all">{'Regenerate photos list of all SmartAlbums'|translate}</a> 28 25 </span> 29 26 </p> 30 27 31 28 <fieldset id="createAlbum" style="display:none;"> 32 <legend>{'create a new SmartAlbum'| @translate}</legend>29 <legend>{'create a new SmartAlbum'|translate}</legend> 33 30 <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}"> 34 31 35 32 <p> 36 <strong>{'Album name'| @translate}</strong> :33 <strong>{'Album name'|translate}</strong> : 37 34 <input type="text" name="virtual_name"> 38 35 </p> 39 36 <p> 40 <strong>{'Parent album'| @translate}</strong> :37 <strong>{'Parent album'|translate}</strong> : 41 38 <select class="categoryDropDown" name="parent_id"> 42 39 <option value="0">------------</option> … … 45 42 </p> 46 43 <p class="actionButtons"> 47 <input class="submit" type="submit" value="{'Create'| @translate}" name="submitAdd">48 <a href="#" id="addAlbumClose">{'Cancel'| @translate}</a>44 <input class="submit" type="submit" value="{'Create'|translate}" name="submitAdd"> 45 <a href="#" id="addAlbumClose">{'Cancel'|translate}</a> 49 46 </p> 50 47 </fieldset> … … 58 55 <!-- category {$category.ID} --> 59 56 <p class="albumTitle"> 60 <strong><a href="{$category.U_CHILDREN}" title="{'manage sub-albums'| @translate}">{$category.NAME}</a></strong>57 <strong><a href="{$category.U_CHILDREN}" title="{'manage sub-albums'|translate}">{$category.NAME}</a></strong> 61 58 <img src="{$SMART_PATH}admin/template/lightning.png"> 62 {'%d photos'| @translate|sprintf:$category.IMG_COUNT}59 {'%d photos'|translate:$category.IMG_COUNT} 63 60 </p> 64 61 65 62 <p class="albumActions"> 66 <a href="{$category.U_EDIT}">{'Edit'| @translate}</a>67 | <a href="{$category.U_SMART}" title="{$category.LAST_UPDATE}">{'Regenerate photos list of this SmartAlbum'| @translate}</a>63 <a href="{$category.U_EDIT}">{'Edit'|translate}</a> 64 | <a href="{$category.U_SMART}" title="{$category.LAST_UPDATE}">{'Regenerate photos list of this SmartAlbum'|translate}</a> 68 65 {if isset($category.U_DELETE) } 69 | <a href="{$category.U_DELETE}" onclick="return confirm('{'Are you sure?'| @translate|@escape:javascript}');">{'delete album'|@translate}</a>66 | <a href="{$category.U_DELETE}" onclick="return confirm('{'Are you sure?'|translate|escape:javascript}');">{'delete album'|translate}</a> 70 67 {/if} 71 68 {if cat_admin_access($category.ID)} 72 | <a href="{$category.U_JUMPTO}">{'jump to album'| @translate} ?</a>69 | <a href="{$category.U_JUMPTO}">{'jump to album'|translate} ?</a> 73 70 {/if} 74 71 </p> -
extensions/SmartAlbums/admin/template/config.tpl
r19446 r26442 1 {html_head}{literal} 2 <style type="text/css"> 3 .showInfo { 4 position:static; 5 display:inline-block; 6 padding:1px 6px !important; 7 width:auto; 8 font-size:0.8em; 9 line-height:1.2em; 10 } 11 </style> 12 {/literal}{/html_head} 1 {footer_script require="jquery"} 2 jQuery(".showInfo").tipTip({ 3 delay: 0, 4 fadeIn: 200, 5 fadeOut: 200, 6 maxWidth: '300px', 7 defaultPosition:"right" 8 }); 9 {/footer_script} 13 10 14 {footer_script require="jquery"}15 jQuery(".showInfo").tipTip({ldelim}16 delay: 0,17 fadeIn: 200,18 fadeOut: 200,19 maxWidth: '300px',20 defaultPosition:"right"21 });22 {/footer_script}23 11 24 12 <div class="titrePage"> … … 26 14 </div> 27 15 28 <form method="post" action="" class="properties"> 16 <form method="post" action="" class="properties"> 29 17 <fieldset id="commentsConf"> 30 18 <ul> 31 19 <li> 32 20 <label> 33 <input type="checkbox" name="update_on_ upload" value="true" {if $update_on_upload}checked="checked"{/if}/>34 <b>{'Update albums on file upload'|@translate}</b>35 < a class="showInfo" title="{'can cause slowdowns'|@translate}">i</a>36 < /label>21 <input type="checkbox" name="update_on_date" value="true" {if $update_on_date}checked="checked"{/if}/> 22 {assign var=input value='</label><input type="text" name="update_timeout" size="2" value="'|cat:$update_timeout|cat:'"/>'} 23 <b>{'Update albums every %s days'|translate:$input}</b> 24 <!-- label --> 37 25 </li> 38 26 <li> 39 27 <label> 40 <input type="checkbox" name="update_on_ date" value="true" {if $update_on_date}checked="checked"{/if}/>41 {assign var=input value='<input type="text" name="update_timeout" size="2" value="'|cat:$update_timeout|cat:'"/>'}42 < b>{'Update albums every %s days'|@translate|sprintf:$input}</b>28 <input type="checkbox" name="update_on_upload" value="true" {if $update_on_upload}checked="checked"{/if}/> 29 <b>{'Update albums on file upload'|translate}</b> 30 <a class="icon-info-circled-1 showInfo" title="{'can cause slowdowns'|translate}"></a> 43 31 </label> 44 32 </li> … … 46 34 <label> 47 35 <input type="checkbox" name="smart_is_forbidden" value="true" {if $smart_is_forbidden}checked="checked"{/if}/> 48 <b>{'Exclude SmartAlbums from permissions management'| @translate}</b>49 <a class=" showInfo" title="{'SmartAlbums are considered private for everyone, and a user can see it\'s content only if available in another album he has access to.'|@translate}">i</a>36 <b>{'Exclude SmartAlbums from permissions management'|translate}</b> 37 <a class="icon-info-circled-1 showInfo" title="{'SmartAlbums are considered private for everyone, and a user can see it\'s content only if available in another album he has access to.'|translate}"></a> 50 38 </label> 51 39 </li> 52 40 </ul> 53 41 </fieldset> 54 55 <p class="formButtons"><input class="submit" type="submit" value="{'Submit'| @translate}" name="submit" /></p>42 43 <p class="formButtons"><input class="submit" type="submit" value="{'Submit'|translate}" name="submit" /></p> 56 44 </form> -
extensions/SmartAlbums/admin/template/style.css
r19722 r26442 8 8 } 9 9 #batchManagerGlobal #filtersList li.token-input-input-token { 10 margin-bottom:-3px !important; 10 margin-bottom:-3px !important; 11 11 } 12 12 13 13 #batchManagerGlobal .filter_dimensions .ui-slider-horizontal { 14 margin:5px 0 3px 0;15 width: 500px;14 margin:5px 0 3px 0; 15 width:400px; 16 16 } 17 17 -
extensions/SmartAlbums/include/count_images.php
r17821 r26442 10 10 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 11 11 12 i f (!is_admin())die('Hacking attempt!');12 is_admin() or die('Hacking attempt!'); 13 13 14 14 … … 18 18 $page['errors'] = array(); 19 19 $limit_is_set = false; 20 20 21 21 foreach ($_POST['filters'] as $filter) 22 22 { 23 23 if (($filter = smart_check_filter($filter)) != false) 24 24 { 25 array_push($filters, $filter);25 $filters[] = $filter; 26 26 } 27 27 else 28 28 { 29 echo '<span class="filter_error">'. $page['errors'][ count($page['errors'])-1 ].'</span>';29 echo '<span class="filter_error">'. array_pop($page['errors']) .'</span>'; 30 30 exit; 31 31 } -
extensions/SmartAlbums/include/events_admin.inc.php
r24342 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 2 defined('SMART_PATH') or die('Hacking attempt!'); 3 4 /** 5 * new tab on album properties page 6 */ 7 function smart_tab($sheets, $id) 8 { 9 if ($id == 'album') 10 { 11 global $category; 12 13 if ($category['dir'] == null) 14 { 15 $sheets['smartalbum'] = array( 16 'caption' => 'SmartAlbum', 17 'url' => SMART_ADMIN.'-album&cat_id='.$_GET['cat_id'], 18 ); 19 } 20 } 21 22 return $sheets; 23 } 24 25 /** 26 * admin plugins menu link 27 */ 28 function smart_admin_menu($menu) 29 { 30 $menu[] = array( 31 'NAME' => 'SmartAlbums', 32 'URL' => SMART_ADMIN, 33 ); 34 return $menu; 35 } 36 3 37 /** 4 38 * Add a link into categories list to regenerate associations 5 39 */ 6 $smart_count = 0;7 8 40 function smart_cat_list() 9 41 { 10 global $template, $page, $smart_count; 42 global $template, $page; 43 44 if (!isset($smart_count)) 45 { 46 $smart_count = 0; 47 } 11 48 12 49 $self_url = get_root_url().'admin.php?page=cat_list'.(isset($_GET['parent_id']) ? '&parent_id='.$_GET['parent_id'] : null); 13 50 14 51 /* get categories with smart filters */ 15 52 $query = ' 16 SELECT DISTINCT id, name 53 SELECT DISTINCT id, name 17 54 FROM '.CATEGORIES_TABLE.' AS c 18 55 INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf 19 56 ON c.id = cf.category_id'; 20 57 if (!isset($_GET['parent_id'])) 21 58 { … … 30 67 $query .= ' 31 68 ;'; 32 33 $smart_cats = hash_from_query($query, 'id'); 34 $smart_count = count($smart_cats); 35 69 70 $smart_cats = query2array($query, 'id'); 71 36 72 if (isset($_GET['smart_generate'])) 37 73 { … … 42 78 { 43 79 $associated_images = smart_make_associations($category['id']); 44 array_push($page['infos'], 45 sprintf(l10n('%d photos associated to album %s'),46 count($associated_images),47 '«'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'»'48 )80 81 $page['infos'][] = l10n( 82 '%d photos associated to album %s', 83 count($associated_images), 84 '«'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'»' 49 85 ); 50 86 } … … 53 89 else 54 90 { 55 $associated_images = smart_make_associations($_GET['smart_generate']); 56 array_push($page['infos'], 57 sprintf(l10n('%d photos associated to album %s'),58 count($associated_images),59 '«'.trigger_event('render_category_name', $smart_cats[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'»'60 )91 $associated_images = smart_make_associations($_GET['smart_generate']); 92 93 $page['infos'][] = l10n( 94 '%d photos associated to album %s', 95 count($associated_images), 96 '«'.trigger_event('render_category_name', $smart_cats[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'»' 61 97 ); 62 98 } 63 99 64 100 define('SMART_NOT_UPDATE', 1); 65 101 invalidate_user_cache(); 66 102 } 67 103 68 104 // create regenerate link 69 105 $tpl_cat = array(); … … 72 108 $tpl_cat[$cat] = $self_url.'&smart_generate='.$cat; 73 109 } 74 $tpl_cat['all'] = $self_url.'&smart_generate=all'; 75 110 if (count($smart_cats)) 111 { 112 $tpl_cat['all'] = $self_url.'&smart_generate=all'; 113 } 114 76 115 $template->assign(array( 77 116 'SMART_URL' => $tpl_cat, 78 117 'SMART_PATH' => SMART_PATH, 79 118 )); 80 119 81 120 $template->set_prefilter('categories', 'smart_cat_list_prefilter'); 82 121 } 83 122 84 123 85 function smart_cat_list_prefilter($content , &$smarty)124 function smart_cat_list_prefilter($content) 86 125 { 87 global $smart_count;88 89 126 $search[0] = '{if isset($category.U_MANAGE_ELEMENTS) }'; 90 127 $replacement[0] = $search[0].' … … 93 130 {/if}'; 94 131 95 if ($smart_count > 0) 96 { 97 $search[1] = '<a href="#" id="autoOrderOpen">{\'apply automatic sort order\'|@translate}</a>'; 98 $replacement[1] = $search[1].' 99 | <a href="{$SMART_URL.all}">{\'Regenerate photos list of all SmartAlbums\'|@translate}</a>'; 100 } 101 132 $search[1] = '<a href="#" id="autoOrderOpen">{\'apply automatic sort order\'|@translate}</a>'; 133 $replacement[1] = $search[1].' 134 {if isset($SMART_URL.all)}| <a href="{$SMART_URL.all}">{\'Regenerate photos list of all SmartAlbums\'|@translate}</a>{/if}'; 135 102 136 $search[2] = '{$category.NAME}</a></strong>'; 103 137 $replacement[2] = $search[2].' … … 108 142 return str_replace($search, $replacement, $content); 109 143 } 110 111 ?> -
extensions/SmartAlbums/include/functions.inc.php
r21658 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('SMART_PATH') or die('Hacking attempt!'); 3 3 4 4 /* … … 10 10 { 11 11 $query = ' 12 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 13 WHERE 14 category_id = '.$cat_id.' 12 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 13 WHERE 14 category_id = '.$cat_id.' 15 15 AND smart = true 16 16 ;'; 17 17 pwg_query($query); 18 18 19 19 $images = smart_get_pictures($cat_id); 20 20 21 21 if (count($images) != 0) 22 22 { … … 30 30 } 31 31 mass_inserts( 32 IMAGE_CATEGORY_TABLE, 33 array_keys($datas[0]), 32 IMAGE_CATEGORY_TABLE, 33 array_keys($datas[0]), 34 34 $datas, 35 35 array('ignore'=>true) 36 36 ); 37 37 } 38 38 39 39 // representant, try to not overwrite if still in images list 40 40 $query = ' … … 44 44 ;'; 45 45 list($rep_id) = pwg_db_fetch_row(pwg_query($query)); 46 47 if ( !in_array($rep_id, $images))46 47 if (!in_array($rep_id, $images)) 48 48 { 49 49 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 50 50 set_random_representant(array($cat_id)); 51 51 } 52 52 53 53 $query = ' 54 54 UPDATE '.CATEGORY_FILTERS_TABLE.' … … 57 57 ;'; 58 58 pwg_query($query); 59 59 60 60 return $images; 61 61 } … … 69 69 { 70 70 global $conf; 71 72 if ( defined('SMART_NOT_UPDATE') OR !$conf['SmartAlbums']['update_on_upload'] ) return; 73 71 72 if (defined('SMART_NOT_UPDATE')) 73 { 74 return; 75 } 76 74 77 // get categories with smart filters 75 78 $query = ' 76 SELECT DISTINCT id 77 FROM '.CATEGORIES_TABLE.' AS c 78 INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf 79 ON c.id = cf.category_id 79 SELECT DISTINCT category_id 80 FROM '.CATEGORY_FILTERS_TABLE.' 80 81 ;'; 81 82 82 83 // regenerate photo list 83 $smart_cats = array_from_query($query, 'id');84 $smart_cats = query2array($query, null, 'category_id'); 84 85 array_map('smart_make_associations', $smart_cats); 85 86 } … … 97 98 98 99 /* get filters */ 99 if ( $filters === null)100 if (!isset($filters)) 100 101 { 101 102 $query = ' 102 SELECT * 103 FROM '.CATEGORY_FILTERS_TABLE.' 104 WHERE category_id = '.$cat_id.' 103 SELECT * 104 FROM '.CATEGORY_FILTERS_TABLE.' 105 WHERE category_id = '.$cat_id.' 105 106 ORDER BY type ASC, cond ASC 106 107 ;'; 107 108 $result = pwg_query($query); 108 109 if (!pwg_db_num_rows($result)) return array(); 110 109 110 if (!pwg_db_num_rows($result)) 111 { 112 return array(); 113 } 114 111 115 $filters = array(); 112 116 while ($row = pwg_db_fetch_assoc($result)) … … 123 127 return array(); 124 128 } 125 129 126 130 $mode = 'and'; 127 131 128 132 /* build constrains */ 129 133 ## generate 'join', 'where' arrays and 'limit' string to create the SQL query 130 134 ## inspired by PicsEngine 3 by Michael Villar 131 135 $i_tags = 1; 136 $join = array(); 137 $where = array(); 138 132 139 foreach ($filters as $filter) 133 140 { … … 142 149 case 'all': 143 150 { 151 $tags_arr = explode(',', $filter['value']); 152 foreach ($tags_arr as $value) 153 { 154 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 155 $where[] = 'it'.$i_tags.'.tag_id = '.$value; 156 $i_tags++; 157 } 158 159 break; 160 } 161 // search images which tags are in the list 162 case 'one': 163 { 164 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 165 $where[] = 'it'.$i_tags.'.tag_id IN ('.$filter['value'].')'; 166 $i_tags++; 167 168 break; 169 } 170 // exclude images which tags are in the list 171 case 'none': 172 { 173 $sub_query = ' 174 SELECT it'.$i_tags.'.image_id 175 FROM '.IMAGE_TAG_TABLE.' AS it'.$i_tags.' 176 WHERE 177 it'.$i_tags.'.image_id = i.id AND 178 it'.$i_tags.'.tag_id IN ('.$filter['value'].') 179 GROUP BY it'.$i_tags.'.image_id 180 '; 181 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 182 $where[] = 'NOT EXISTS ('.$sub_query.')'; 183 $i_tags++; 184 185 break; 186 } 187 // exclude images which tags are not in the list and search images which have all tags 188 case 'only': 189 { 190 $sub_query = ' 191 SELECT it'.$i_tags.'.image_id 192 FROM '.IMAGE_TAG_TABLE.' AS it'.$i_tags.' 193 WHERE 194 it'.$i_tags.'.image_id = i.id AND 195 it'.$i_tags.'.tag_id NOT IN ('.$filter['value'].') 196 GROUP BY it'.$i_tags.'.image_id 197 '; 198 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 199 $where[] = 'NOT EXISTS ('.$sub_query.')'; 200 $i_tags++; 201 144 202 $tags_arr = explode(',', $filter['value']); 145 203 foreach($tags_arr as $value) … … 149 207 $i_tags++; 150 208 } 151 152 break; 153 } 154 // search images which tags are in the list 155 case 'one': 156 { 157 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 158 $where[] = 'it'.$i_tags.'.tag_id IN ('.$filter['value'].')'; 159 $i_tags++; 160 161 break; 162 } 163 // exclude images which tags are in the list 164 case 'none': 165 { 166 $sub_query = ' 167 SELECT it'.$i_tags.'.image_id 168 FROM '.IMAGE_TAG_TABLE.' AS it'.$i_tags.' 169 WHERE 170 it'.$i_tags.'.image_id = i.id AND 171 it'.$i_tags.'.tag_id IN ('.$filter['value'].') 172 GROUP BY it'.$i_tags.'.image_id 173 '; 174 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 175 $where[] = 'NOT EXISTS ('.$sub_query.')'; 176 $i_tags++; 177 178 break; 179 } 180 // exclude images which tags are not in the list and search images which have all tags 181 case 'only': 182 { 183 $sub_query = ' 184 SELECT it'.$i_tags.'.image_id 185 FROM '.IMAGE_TAG_TABLE.' AS it'.$i_tags.' 186 WHERE 187 it'.$i_tags.'.image_id = i.id AND 188 it'.$i_tags.'.tag_id NOT IN ('.$filter['value'].') 189 GROUP BY it'.$i_tags.'.image_id 190 '; 191 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 192 $where[] = 'NOT EXISTS ('.$sub_query.')'; 193 $i_tags++; 194 195 $tags_arr = explode(',', $filter['value']); 196 foreach($tags_arr as $value) 197 { 198 $join[] = IMAGE_TAG_TABLE.' AS it'.$i_tags.' ON i.id = it'.$i_tags.'.image_id'; 199 $where[] = 'it'.$i_tags.'.tag_id = '.$value; 200 $i_tags++; 201 } 202 203 break; 204 } 205 } 206 207 break; 208 } 209 209 210 break; 211 } 212 } 213 214 break; 215 } 216 210 217 // date 211 218 case 'date': … … 232 239 break; 233 240 } 234 235 break; 236 } 237 241 242 break; 243 } 244 238 245 // name 239 246 case 'name': … … 263 270 break; 264 271 } 265 266 break; 267 } 268 272 273 break; 274 } 275 269 276 // album 270 277 case 'album': … … 279 286 { 280 287 $sub_query = ' 281 SELECT image_id 288 SELECT image_id 282 289 FROM '.IMAGE_CATEGORY_TABLE.' 283 290 WHERE category_id = '.$value.' … … 285 292 $where[] = 'i.id IN ('.$sub_query.')'; 286 293 } 287 294 288 295 break; 289 296 } … … 297 304 '; 298 305 $where[] = 'i.id IN ('.$sub_query.')'; 299 306 300 307 break; 301 308 } … … 309 316 '; 310 317 $where[] = 'i.id NOT IN ('.$sub_query.')'; 311 318 312 319 break; 313 320 } … … 321 328 '; 322 329 $where[] = 'i.id NOT IN ('.$sub_query.')'; 323 330 324 331 $albums_arr = explode(',', $filter['value']); 325 332 foreach($albums_arr as $value) 326 333 { 327 334 $sub_query = ' 328 SELECT image_id 335 SELECT image_id 329 336 FROM '.IMAGE_CATEGORY_TABLE.' 330 337 WHERE category_id = '.$value.' … … 332 339 $where[] = 'i.id IN ('.$sub_query.')'; 333 340 } 334 335 break; 336 } 337 } 338 339 break; 340 } 341 341 342 break; 343 } 344 } 345 346 break; 347 } 348 342 349 // dimensions 343 350 case 'dimensions': 344 351 { 345 352 $filter['value'] = explode(',', $filter['value']); 346 353 347 354 switch ($filter['cond']) 348 355 { … … 358 365 } 359 366 } 360 367 361 368 // author 362 369 case 'author': … … 384 391 break; 385 392 } 386 387 break; 388 } 389 393 394 break; 395 } 396 390 397 // hit 391 398 case 'hit': … … 400 407 break; 401 408 } 402 403 break; 404 } 405 409 410 break; 411 } 412 406 413 // rating_score 407 414 case 'rating_score': … … 416 423 break; 417 424 } 418 419 break; 420 } 421 425 426 break; 427 } 428 422 429 // level 423 430 case 'level': … … 426 433 break; 427 434 } 428 435 429 436 // limit 430 437 case 'limit': … … 433 440 break; 434 441 } 435 442 436 443 // mode 437 444 case 'mode': … … 442 449 } 443 450 } 444 451 445 452 /* bluid query */ 446 453 $MainQuery = ' 447 454 SELECT i.id 448 455 FROM '.IMAGES_TABLE.' AS i'; 449 450 if ( isset($join))456 457 if (count($join)) 451 458 { 452 459 $MainQuery.= ' 453 460 LEFT JOIN '.implode("\n LEFT JOIN ", $join); 454 461 } 455 if ( isset($where))462 if (count($where)) 456 463 { 457 464 $MainQuery.= ' … … 471 478 file_put_contents(SMART_PATH.'dump_query.sql', $MainQuery); 472 479 } 473 474 return array_from_query($MainQuery, 'id');480 481 return query2array($MainQuery, null, 'id'); 475 482 } 476 483 … … 484 491 { 485 492 global $page, $limit_is_set, $level_is_set; 493 486 494 $error = false; 487 488 495 if (!isset($limit_is_set)) $limit_is_set = false; 489 496 if (!isset($level_is_set)) $level_is_set = false; 490 497 491 498 switch ($filter['type']) 492 499 { … … 496 503 if ($filter['value'] == null) 497 504 { 498 $error = true; 499 array_push($page['errors'], l10n('No tag selected')); 505 $page['errors'][] = l10n('No tag selected'); 500 506 } 501 507 else … … 511 517 if (!preg_match('#([0-9]{4})-([0-9]{2})-([0-9]{2})#', $filter['value'])) 512 518 { 513 $error = true; 514 array_push($page['errors'], l10n('Date string is malformed')); 519 $page['errors'][] = l10n('Date string is malformed'); 515 520 } 516 521 break; … … 521 526 if (empty($filter['value'])) 522 527 { 523 $error = true; 524 array_push($page['errors'], l10n('Name is empty')); 525 } 526 else if ( $filter['cond']=='regex' and @preg_match('/'.$filter['value'].'/', null)===false ) 527 { 528 $error = true; 529 array_push($page['errors'], l10n('Regex is malformed')); 528 $page['errors'][] = l10n('Name is empty'); 529 } 530 else if ($filter['cond']=='regex' and @preg_match('/'.$filter['value'].'/', null)===false) 531 { 532 $page['errors'][] = l10n('Regex is malformed'); 530 533 } 531 534 break; … … 536 539 if (@$filter['value'] == null) 537 540 { 538 $error = true; 539 array_push($page['errors'], l10n('No album selected')); 541 $page['errors'][] = l10n('No album selected'); 540 542 } 541 543 else … … 548 550 case 'dimensions': 549 551 { 550 if ( empty($filter['value']['min']) or empty($filter['value']['max']))552 if (empty($filter['value']['min']) or empty($filter['value']['max'])) 551 553 { 552 554 $error = true; … … 563 565 if (empty($filter['value'])) 564 566 { 565 $error = true; 566 array_push($page['errors'], l10n('Author is empty')); 567 } 568 else if ( $filter['cond']=='regex' and @preg_match('/'.$filter['value'].'/', null)===false ) 569 { 570 $error = true; 571 array_push($page['errors'], l10n('Regex is malformed')); 567 $page['errors'][] = l10n('Author is empty'); 568 } 569 else if ($filter['cond']=='regex' and @preg_match('/'.$filter['value'].'/', null)===false) 570 { 571 $page['errors'][] = l10n('Regex is malformed'); 572 572 } 573 573 else … … 580 580 case 'hit': 581 581 { 582 if (!preg_match('#([0-9]{1,})#', $filter['value'])) 583 { 584 $error = true; 585 array_push($page['errors'], l10n('Hits must be an integer')); 582 if (!preg_match('#([0-9]+)#', $filter['value'])) 583 { 584 $page['errors'][] = l10n('Hits must be an integer'); 586 585 } 587 586 break; … … 590 589 case 'rating_score': 591 590 { 592 if (!preg_match('#([0-9]{1,})#', $filter['value'])) 593 { 594 $error = true; 595 array_push($page['errors'], l10n('Rating score must be an integer')); 591 if (!preg_match('#([0-9]+)#', $filter['value'])) 592 { 593 $page['errors'][] = l10n('Rating score must be an integer'); 596 594 } 597 595 break; … … 602 600 if ($level_is_set == true) // only one level is allowed, first is saved 603 601 { 604 $error = true; 605 array_push($page['errors'], l10n('You can\'t use more than one level filter')); 602 $page['errors'][] = l10n('You can\'t use more than one level filter'); 606 603 } 607 604 else … … 617 614 if ($limit_is_set == true) // only one limit is allowed, first is saved 618 615 { 619 $error = true; 620 array_push($page['errors'], l10n('You can\'t use more than one limit filter')); 621 } 622 else if (!preg_match('#([0-9]{1,})#', $filter['value'])) 623 { 624 $error = true; 625 array_push($page['errors'], l10n('Limit must be an integer')); 626 } 627 else 628 { 629 $filter['cond'] = 'level'; 616 $page['errors'][] = l10n('You can\'t use more than one limit filter'); 617 } 618 else if (!preg_match('#([0-9]+)#', $filter['value'])) 619 { 620 $page['errors'][] = l10n('Limit must be an integer'); 621 } 622 else 623 { 624 $filter['cond'] = 'limit'; 630 625 $limit_is_set = true; 631 626 } … … 638 633 break; 639 634 } 640 635 641 636 default: 642 637 { … … 645 640 } 646 641 } 647 648 649 if ( $error == false)642 643 644 if (!$error && empty($page['errors'])) 650 645 { 651 646 return $filter; … … 656 651 } 657 652 } 658 659 660 /**661 * clean table when categories are deleted662 */663 function smart_delete_categories($ids)664 {665 $query = '666 DELETE FROM '.CATEGORY_FILTERS_TABLE.'667 WHERE category_id IN('.implode(',', $ids).')668 ;';669 pwg_query($query);670 }671 672 /**673 * update images list periodically674 */675 function smart_periodic_update()676 {677 global $conf;678 679 // we only search for old albums every hour, nevermind which user is connected680 if ($conf['SmartAlbums']['last_update'] > time() - 3600) return;681 682 $conf['SmartAlbums']['last_update'] = time();683 conf_update_param('SmartAlbums', serialize($conf['SmartAlbums']));684 685 // get categories with smart filters686 $query = '687 SELECT DISTINCT id688 FROM '.CATEGORIES_TABLE.' AS c689 INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf690 ON c.id = cf.category_id691 WHERE updated < DATE_SUB(NOW(), INTERVAL '.$conf['SmartAlbums']['update_timeout'].' DAY)692 ;';693 694 // regenerate photo list695 $smart_cats = array_from_query($query, 'id');696 array_map('smart_make_associations', $smart_cats);697 }698 699 ?> -
extensions/SmartAlbums/language/en_UK/plugin.lang.php
r19446 r26442 2 2 3 3 $lang['No filter selected'] = 'No filter selected'; 4 $lang['%d photo'] = '%d photo';5 $lang['%d photos'] = '%d photos';6 4 $lang['All these tags'] = 'All these tags'; 7 5 $lang['One of these tags'] = 'One of these tags'; … … 63 61 $lang['SmartAlbums are considered private for everyone, and a user can see it\'s content only if available in another album he has access to.'] = 'SmartAlbums are considered private for everyone, and a user can see it\'s content only if available in another album he has access to.'; 64 62 $lang['Update albums every %s days'] = 'Update albums every %s days'; 63 $lang['Invalid number of days'] = 'Invalid number of days'; 64 $lang['Mode'] = 'Mode'; 65 $lang['Select albums...'] = 'Select albums...'; 65 66 66 67 ?> -
extensions/SmartAlbums/language/fr_FR/plugin.lang.php
r19446 r26442 2 2 3 3 $lang['No filter selected'] = 'Aucun filtre sélectionné'; 4 $lang['%d photo'] = '%d photo';5 $lang['%d photos'] = '%d photos';6 4 $lang['All these tags'] = 'Tous les tags'; 7 5 $lang['One of these tags'] = 'Un des tags'; … … 63 61 $lang['SmartAlbums are considered private for everyone, and a user can see it\'s content only if available in another album he has access to.'] = 'Les SmartAlbums sont considérés comme privés pour tout le monde, et un utilisateur ne peut voir leur contenu que si disponible dans un autre album auquel il a accès.'; 64 62 $lang['Update albums every %s days'] = 'Mettre à jour les albums tous les %s jours'; 63 $lang['Invalid number of days'] = 'Nombre de jour invalide'; 64 $lang['Mode'] = 'Mode'; 65 $lang['Select albums...'] = 'Albums...'; 65 66 66 67 ?> -
extensions/SmartAlbums/main.inc.php
r19446 r26442 4 4 Version: auto 5 5 Description: Easily create dynamic albums with tags, date and other criteria 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=5446 Plugin URI: auto 7 7 Author: Mistic 8 8 Author URI: http://www.strangeplanet.fr 9 9 */ 10 10 11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 11 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 12 12 13 global $prefixeTable; 13 14 14 define('SMART_PATH', PHPWG_PLUGINS_PATH . 'SmartAlbums/'); 15 define('SMART_ID', 'SmartAlbums'); 16 define('SMART_PATH', PHPWG_PLUGINS_PATH . SMART_ID . '/'); 15 17 define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters'); 16 define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-SmartAlbums');17 define('SMART_VERSION', 18 // define('SMART_DEBUG',true);18 define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-' . SMART_ID); 19 define('SMART_VERSION', 'auto'); 20 // define('SMART_DEBUG', true); 19 21 20 22 21 23 add_event_handler('init', 'smart_init'); 22 24 add_event_handler('init', 'smart_periodic_update'); 23 add_event_handler(' invalidate_user_cache', 'smart_make_all_associations');25 add_event_handler('delete_categories', 'smart_delete_categories'); 24 26 25 27 if (defined('IN_ADMIN')) 26 28 { 27 include_once(SMART_PATH.'include/ cat_list.php');29 include_once(SMART_PATH.'include/events_admin.inc.php'); 28 30 add_event_handler('loc_begin_cat_list', 'smart_cat_list'); 29 add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 31 add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 30 32 add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu'); 31 add_event_handler('delete_categories', 'smart_delete_categories');32 33 } 33 34 35 include_once(SMART_PATH.'include/events.inc.php'); 34 36 include_once(SMART_PATH.'include/functions.inc.php'); 35 37 … … 40 42 function smart_init() 41 43 { 42 global $conf, $pwg_loaded_plugins; 43 44 if ( 45 SMART_VERSION == 'auto' or 46 $pwg_loaded_plugins['SmartAlbums']['version'] == 'auto' or 47 version_compare($pwg_loaded_plugins['SmartAlbums']['version'], SMART_VERSION, '<') 48 ) 49 { 50 include_once(SMART_PATH . 'include/install.inc.php'); 51 smart_albums_install(); 52 53 if ( $pwg_loaded_plugins['SmartAlbums']['version'] != 'auto' and SMART_VERSION != 'auto' ) 54 { 55 $query = ' 56 UPDATE '. PLUGINS_TABLE .' 57 SET version = "'. SMART_VERSION .'" 58 WHERE id = "SmartAlbums"'; 59 pwg_query($query); 60 61 $pwg_loaded_plugins['SmartAlbums']['version'] = SMART_VERSION; 62 63 if (defined('IN_ADMIN')) 64 { 65 $_SESSION['page_infos'][] = 'Smart Albums updated to version '. SMART_VERSION; 66 } 67 } 68 } 69 44 global $conf; 45 46 include_once(SMART_PATH . 'maintain.inc.php'); 47 $maintain = new SmartAlbums_maintain(SMART_ID); 48 $maintain->autoUpdate(SMART_VERSION, 'install'); 49 70 50 if (defined('IN_ADMIN')) 71 51 { … … 73 53 } 74 54 $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']); 75 76 if ( script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden'])55 56 if (script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden']) 77 57 { 78 58 add_event_handler('loc_end_section_init', 'smart_init_page_items'); 79 include_once(SMART_PATH.'include/page_items.php'); 59 } 60 61 if ($conf['SmartAlbums']['update_on_upload']) 62 { 63 add_event_handler('invalidate_user_cache', 'smart_make_all_associations'); 80 64 } 81 65 } 82 83 /**84 * new tab on album properties page85 */86 function smart_tab($sheets, $id)87 {88 if ($id != 'album') return $sheets;89 90 global $category;91 92 if ($category['dir'] == null)93 {94 $sheets['smartalbum'] = array(95 'caption' => 'SmartAlbum',96 'url' => SMART_ADMIN.'-album&cat_id='.$_GET['cat_id'],97 );98 }99 100 return $sheets;101 }102 103 104 /**105 * admin plugins menu link106 */107 function smart_admin_menu($menu)108 {109 array_push($menu, array(110 'NAME' => 'SmartAlbums',111 'URL' => SMART_ADMIN,112 ));113 return $menu;114 }115 116 ?> -
extensions/SmartAlbums/maintain.inc.php
r21658 r26442 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 include_once(PHPWG_PLUGINS_PATH . 'SmartAlbums/include/install.inc.php'); 4 class SmartAlbums_maintain extends PluginMaintain 5 { 6 private $installed = false; 5 7 6 function plugin_install() 7 { 8 smart_albums_install(); 9 define('smart_albums_installed', true); 10 } 8 private $default_conf = array( 9 'update_on_upload' => false, 10 'update_on_date' => true, 11 'update_timeout' => 3, 12 'show_list_messages' => true, 13 'smart_is_forbidden' => false, 14 'last_update' => 0, 15 ); 11 16 12 function plugin_activate() 13 { 14 if (!defined('smart_albums_installed'))17 private $table; 18 19 function __construct($plugin_id) 15 20 { 16 smart_albums_install(); 21 global $prefixeTable; 22 23 parent::__construct($plugin_id); 24 25 $this->table = $prefixeTable . 'category_filters'; 26 } 27 28 function install($plugin_version, &$errors=array()) 29 { 30 global $conf, $prefixeTable; 31 32 if (empty($conf['SmartAlbums'])) 33 { 34 $conf['SmartAlbums'] = serialize($this->default_conf); 35 conf_update_param('SmartAlbums', $conf['SmartAlbums']); 36 } 37 else 38 { 39 $new_conf = is_string($conf['SmartAlbums']) ? unserialize($conf['SmartAlbums']) : $conf['SmartAlbums']; 40 41 // new param in 2.0.2 42 if (!isset($new_conf['smart_is_forbidden'])) 43 { 44 $new_conf['smart_is_forbidden'] = true; 45 } 46 47 // new params in 2.1.0 48 if (!isset($new_conf['update_on_date'])) 49 { 50 $new_conf['update_on_date'] = true; 51 $new_conf['update_timeout'] = 3; 52 $new_conf['last_update'] = 0; 53 } 54 55 $conf['SmartAlbums'] = serialize($new_conf); 56 conf_update_param('SmartAlbums', $conf['SmartAlbums']); 57 } 58 59 // new table 60 pwg_query( 61 'CREATE TABLE IF NOT EXISTS `' . $this->table . '` ( 62 `category_id` smallint(5) unsigned NOT NULL, 63 `type` varchar(16) NOT NULL, 64 `cond` varchar(16) NULL, 65 `value` text NULL, 66 `updated` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00" 67 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 68 ;'); 69 70 // new column on image category table 71 $result = pwg_query('SHOW COLUMNS FROM `' . IMAGE_CATEGORY_TABLE . '` LIKE "smart";'); 72 if (!pwg_db_num_rows($result)) 73 { 74 pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` ADD `smart` ENUM(\'true\', \'false\') NOT NULL DEFAULT \'false\';'); 75 } 76 77 // new column on category filters table (2.1.1) 78 $result = pwg_query('SHOW COLUMNS FROM `' . $this->table . '` LIKE "updated";'); 79 if (!pwg_db_num_rows($result)) 80 { 81 pwg_query('ALTER TABLE `' . $this->table . '` ADD `updated` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00"'); 82 } 83 84 // remove column on category table, moved to category filters table (2.1.1) 85 $result = pwg_query('SHOW COLUMNS FROM `' . CATEGORIES_TABLE . '` LIKE "smart_update";'); 86 if (pwg_db_num_rows($result)) 87 { 88 pwg_query('UPDATE `' . $this->table . '` AS f SET updated = ( SELECT smart_update FROM `' . CATEGORIES_TABLE . '` AS c WHERE c.id = f.category_id );'); 89 pwg_query('ALTER TABLE `' . CATEGORIES_TABLE . '` DROP `smart_update`;'); 90 } 91 92 // date filters renamed in 2.0 93 $query = ' 94 SELECT category_id 95 FROM `' . $this->table . '` 96 WHERE 97 type = "date" AND 98 cond IN ("the","before","after","the_crea","before_crea","after_crea") 99 ;'; 100 101 if (pwg_db_num_rows(pwg_query($query))) 102 { 103 $name_changes = array( 104 'the' => 'the_post', 105 'before' => 'before_post', 106 'after' => 'after_post', 107 'the_crea' => 'the_taken', 108 'before_crea' => 'before_taken', 109 'after_crea' => 'after_taken', 110 ); 111 foreach ($name_changes as $old => $new) 112 { 113 pwg_query('UPDATE `' . $this->table . '` SET cond = "' . $new . '" WHERE type = "date" AND cond = "' . $old . '";'); 114 } 115 } 116 117 $this->installed = true; 118 } 119 120 function activate($plugin_version, &$errors=array()) 121 { 122 if (!$this->installed) 123 { 124 $this->install($plugin_version, $errors); 125 } 126 } 127 128 function deactivate() 129 { 130 } 131 132 function uninstall() 133 { 134 conf_delete_param('SmartAlbums'); 135 136 pwg_query('DROP TABLE `' . $this->table . '`;'); 137 138 pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` DROP `smart`;'); 17 139 } 18 140 } 19 20 function plugin_uninstall()21 {22 global $prefixeTable;23 24 pwg_query('DROP TABLE `' . $prefixeTable . 'category_filters`;');25 pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` DROP `smart`;');26 pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = \'SmartAlbums\' LIMIT 1;');27 }28 29 ?>
Note: See TracChangeset
for help on using the changeset viewer.