Changeset 12032 for trunk/admin
- Timestamp:
- Sep 2, 2011, 10:37:21 AM (13 years ago)
- Location:
- trunk/admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r12030 r12032 1395 1395 } 1396 1396 1397 /** 1398 * 1399 */ 1400 function delete_tags($tag_ids) 1401 { 1402 if (is_numeric($tag_ids)) 1403 { 1404 $tag_ids = array($tag_ids); 1405 } 1406 1407 if (!is_array($tag_ids)) 1408 { 1409 return false; 1410 } 1411 1412 $query = ' 1413 DELETE 1414 FROM '.IMAGE_TAG_TABLE.' 1415 WHERE tag_id IN ('.implode(',', $tag_ids).') 1416 ;'; 1417 pwg_query($query); 1418 1419 $query = ' 1420 DELETE 1421 FROM '.TAGS_TABLE.' 1422 WHERE id IN ('.implode(',', $tag_ids).') 1423 ;'; 1424 pwg_query($query); 1425 } 1426 1397 1427 function tag_id_from_tag_name($tag_name) 1398 1428 { -
trunk/admin/tags.php
r11487 r12032 102 102 103 103 // +-----------------------------------------------------------------------+ 104 // | merge tags | 105 // +-----------------------------------------------------------------------+ 106 107 if (isset($_POST['confirm_merge'])) 108 { 109 if (!isset($_POST['destination_tag'])) 110 { 111 array_push( 112 $page['errors'], 113 l10n('No destination tag selected') 114 ); 115 } 116 else 117 { 118 $destination_tag_id = $_POST['destination_tag']; 119 $tag_ids = explode(',', $_POST['merge_list']); 120 121 if (is_array($tag_ids) and count($tag_ids) > 1) 122 { 123 $name_of_tag = array(); 124 $query = ' 125 SELECT 126 id, 127 name 128 FROM '.TAGS_TABLE.' 129 WHERE id IN ('.implode(',', $tag_ids).') 130 ;'; 131 $result = pwg_query($query); 132 while ($row = pwg_db_fetch_assoc($result)) 133 { 134 $name_of_tag[ $row['id'] ] = trigger_event('render_tag_name', $row['name']); 135 } 136 137 $tag_ids_to_delete = array_diff( 138 $tag_ids, 139 array($destination_tag_id) 140 ); 141 142 $query = ' 143 SELECT 144 DISTINCT(image_id) 145 FROM '.IMAGE_TAG_TABLE.' 146 WHERE tag_id IN ('.implode(',', $tag_ids_to_delete).') 147 ;'; 148 $image_ids = array_from_query($query, 'image_id'); 149 150 delete_tags($tag_ids_to_delete); 151 152 $query = ' 153 SELECT 154 image_id 155 FROM '.IMAGE_TAG_TABLE.' 156 WHERE tag_id = '.$destination_tag_id.' 157 ;'; 158 $destination_tag_image_ids = array_from_query($query, 'image_id'); 159 160 $image_ids_to_link = array_diff( 161 $image_ids, 162 $destination_tag_image_ids 163 ); 164 165 $inserts = array(); 166 foreach ($image_ids_to_link as $image_id) 167 { 168 array_push( 169 $inserts, 170 array( 171 'tag_id' => $destination_tag_id, 172 'image_id' => $image_id 173 ) 174 ); 175 } 176 177 if (count($inserts) > 0) 178 { 179 mass_inserts( 180 IMAGE_TAG_TABLE, 181 array_keys($inserts[0]), 182 $inserts 183 ); 184 } 185 186 $tags_deleted = array(); 187 foreach ($tag_ids_to_delete as $tag_id) 188 { 189 $tags_deleted[] = $name_of_tag[$tag_id]; 190 } 191 192 array_push( 193 $page['infos'], 194 sprintf( 195 l10n('Tags <em>%s</em> merged into tag <em>%s</em>'), 196 implode(', ', $tags_deleted), 197 $name_of_tag[$destination_tag_id] 198 ) 199 ); 200 } 201 } 202 } 203 204 205 // +-----------------------------------------------------------------------+ 104 206 // | delete tags | 105 207 // +-----------------------------------------------------------------------+ … … 113 215 ;'; 114 216 $tag_names = array_from_query($query, 'name'); 115 116 $query = ' 117 DELETE 118 FROM '.IMAGE_TAG_TABLE.' 119 WHERE tag_id IN ('.implode(',', $_POST['tags']).') 120 ;'; 121 pwg_query($query); 122 123 $query = ' 124 DELETE 125 FROM '.TAGS_TABLE.' 126 WHERE id IN ('.implode(',', $_POST['tags']).') 127 ;'; 128 pwg_query($query); 217 218 delete_tags($_POST['tags']); 129 219 130 220 array_push( … … 251 341 ); 252 342 253 if (isset($_POST['edit']) and isset($_POST['tags'])) 254 { 343 if ((isset($_POST['edit']) or isset($_POST['merge'])) and isset($_POST['tags'])) 344 { 345 $list_name = 'EDIT_TAGS_LIST'; 346 if (isset($_POST['merge'])) 347 { 348 $list_name = 'MERGE_TAGS_LIST'; 349 } 350 255 351 $template->assign( 256 352 array( 257 'EDIT_TAGS_LIST'=> implode(',', $_POST['tags']),353 $list_name => implode(',', $_POST['tags']), 258 354 ) 259 355 ); -
trunk/admin/themes/default/template/tags.tpl
r11317 r12032 1 1 {include file='include/tag_selection.inc.tpl'} 2 3 {footer_script}{literal} 4 jQuery(document).ready(function(){ 5 function displayDeletionWarnings() { 6 jQuery(".warningDeletion").show(); 7 jQuery("input[name=destination_tag]:checked").parent("label").children(".warningDeletion").hide(); 8 } 9 10 displayDeletionWarnings(); 11 12 jQuery("#mergeTags label").click(function() { 13 displayDeletionWarnings(); 14 }); 15 16 jQuery("input[name=merge]").click(function() { 17 if (jQuery("ul.tagSelection input[type=checkbox]:checked").length < 2) { 18 alert("{/literal}{'Select at least two tags for merging'|@translate}{literal}"); 19 return false; 20 } 21 }); 22 }); 23 {/literal}{/footer_script} 24 2 25 3 26 <div class="titrePage"> … … 31 54 {/if} 32 55 56 {if isset($MERGE_TAGS_LIST)} 57 <input type="hidden" name="merge_list" value="{$MERGE_TAGS_LIST}"> 58 59 <fieldset id="mergeTags"> 60 <legend>{'Merge tags'|@translate}</legend> 61 {'Select the destination tag'|@translate}<br><br> 62 {foreach from=$tags item=tag name=tagloop} 63 <label><input type="radio" name="destination_tag" value="{$tag.ID}"{if $smarty.foreach.tagloop.index == 0} checked="checked"{/if}> {$tag.NAME}<span class="warningDeletion"> {'(this tag will be deleted)'|@translate}</span></label><br> 64 {/foreach} 65 <br><input type="submit" name="confirm_merge" value="{'Confirm merge'|@translate}"> 66 </fieldset> 67 {/if} 68 33 69 <fieldset> 34 70 <legend>{'Add a tag'|@translate}</legend> … … 50 86 <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}"> 51 87 <input class="submit" type="submit" name="edit" value="{'Edit selected tags'|@translate}"> 88 <input class="submit" type="submit" name="merge" value="{'Merge selected tags'|@translate}"> 52 89 <input class="submit" type="submit" name="delete" value="{'Delete selected tags'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"> 53 90 </p> -
trunk/admin/themes/default/theme.css
r12029 r12032 1079 1079 .ui-progressbar-value { background-image: url(images/pbar-ani.gif); height:10px;margin:-1px;border:1px solid #E78F08;} 1080 1080 1081 /* Tag Manager */ 1082 .warningDeletion {display:none;font-style:italic;}
Note: See TracChangeset
for help on using the changeset viewer.