Changeset 11333 for extensions/SmartAlbums/init_cat_modify.php
- Timestamp:
- Jun 12, 2011, 5:56:09 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/init_cat_modify.php
r10980 r11333 11 11 12 12 $cat_id = $_GET['cat_id']; 13 list($cat_dir) = pwg_db_fetch_row(pwg_query( "SELECT dir FROM ".CATEGORIES_TABLE." WHERE id = ".$cat_id.";"));13 list($cat_dir) = pwg_db_fetch_row(pwg_query('SELECT dir FROM '.CATEGORIES_TABLE.' WHERE id = '.$cat_id.';')); 14 14 15 15 // category must be virtual … … 23 23 { 24 24 // test if it was a Smart Album 25 $result = pwg_query( "SELECT DISTINCT category_id FROM ".CATEGORY_FILTERS_TABLE." WHERE category_id = ".$cat_id.";");25 $result = pwg_query('SELECT DISTINCT category_id FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';'); 26 26 $was_smart = pwg_db_num_rows($result); 27 27 … … 29 29 if ($was_smart AND !isset($_POST['is_smart'])) 30 30 { 31 pwg_query( "DELETE FROM ".IMAGE_CATEGORY_TABLE." WHERE category_id = ".$cat_id." AND smart = true;");32 pwg_query( "DELETE FROM ".CATEGORY_FILTERS_TABLE." WHERE category_id = ".$cat_id.";");31 pwg_query('DELETE FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;'); 32 pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';'); 33 33 } 34 34 /* no filter selected */ … … 40 40 else if (isset($_POST['is_smart']) AND count($_POST['filters']) > 0) 41 41 { 42 pwg_query( "DELETE FROM ".CATEGORY_FILTERS_TABLE." WHERE category_id = ".$cat_id.";");42 pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';'); 43 43 44 44 $limit_is_set = false; … … 47 47 if (($filter = smart_check_filter($filter)) != false) 48 48 { 49 pwg_query("INSERT INTO ".CATEGORY_FILTERS_TABLE." 50 VALUES(".$cat_id.", '".$filter['type']."', '".$filter['cond']."', '".$filter['value']."');"); 49 $query = ' 50 INSERT INTO '.CATEGORY_FILTERS_TABLE.' 51 VALUES( 52 '.$cat_id.', 53 "'.$filter['type'].'", 54 "'.$filter['cond'].'", 55 "'.$filter['value'].'" 56 ) 57 ;'; 58 pwg_query($query); 51 59 } 52 60 } … … 59 67 60 68 /* select options, for html_options */ 61 $template->assign('options', array( 62 'tags' => array( 63 'all' => l10n('All these tags'), 64 'one' => l10n('One of these tags'), 65 'none' => l10n('None of these tags'), 66 'only' => l10n('Only these tags'), 67 ), 68 'date' => array( 69 'the' => l10n('Added the'), 70 'before' => l10n('Added before the'), 71 'after' => l10n('Added after the'), 72 ), 73 'limit' => array('limit' => 'limit'), // second filter not used 74 )); 69 $template->assign( 70 'options', 71 array( 72 'tags' => array( 73 'all' => l10n('All these tags'), 74 'one' => l10n('One of these tags'), 75 'none' => l10n('None of these tags'), 76 'only' => l10n('Only these tags'), 77 ), 78 'date' => array( 79 'the' => l10n('Added the'), 80 'before' => l10n('Added before the'), 81 'after' => l10n('Added after the'), 82 ), 83 'limit' => array('limit' => 'limit'), // second filter not used 84 ) 85 ); 75 86 76 87 /* get filters for this album */ 77 $filters = pwg_query( "SELECT * FROM ".CATEGORY_FILTERS_TABLE." WHERE category_id = ".$cat_id." ORDER BY type ASC, cond ASC;");88 $filters = pwg_query('SELECT * FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.' ORDER BY type ASC, cond ASC;'); 78 89 while ($filter = pwg_db_fetch_assoc($filters)) 79 90 { … … 81 92 if ($filter['type'] == 'tags') 82 93 { 83 $query = "84 85 86 87 FROM ".TAGS_TABLE."88 WHERE id IN(".$filter['value'].")89 ";90 $filter['value'] = get_ fckb_taglist($query);94 $query = ' 95 SELECT 96 id AS tag_id, 97 name AS tag_name 98 FROM '.TAGS_TABLE.' 99 WHERE id IN('.$filter['value'].') 100 '; 101 $filter['value'] = get_taglist($query); 91 102 } 92 103 … … 98 109 } 99 110 111 /* all tags */ 112 $query = ' 113 SELECT 114 id AS tag_id, 115 name AS tag_name 116 FROM '.TAGS_TABLE.' 117 ;'; 118 $tags = get_taglist($query); 119 100 120 /* get image number */ 101 121 if ($template->get_template_vars('IMAGE_COUNT') == null) 102 122 { 103 list($image_num) = pwg_db_fetch_row(pwg_query( "SELECT count(*) FROM ".IMAGE_CATEGORY_TABLE." WHERE category_id = ".$cat_id." AND smart = true;"));123 list($image_num) = pwg_db_fetch_row(pwg_query('SELECT count(*) FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;')); 104 124 $template->assign('IMAGE_COUNT', l10n_dec('%d photo', '%d photos', $image_num)); 105 125 } … … 108 128 'SMART_PATH' => SMART_PATH, 109 129 'COUNT_SCRIPT_URL' => SMART_PATH.'include/count_images.php', 130 'tags' => $tags, 110 131 )); 111 132 $template->set_prefilter('categories', 'smart_cat_modify_prefilter');
Note: See TracChangeset
for help on using the changeset viewer.