Changeset 16526
- Timestamp:
- Jul 9, 2012, 12:18:58 PM (12 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/tags.php
r12922 r16526 86 86 'name' => addslashes($tag_name), 87 87 'url_name' => trigger_event('render_tag_url', $tag_name), 88 ) 89 ); 90 } 91 } 92 } 93 mass_updates( 94 TAGS_TABLE, 95 array( 96 'primary' => array('id'), 97 'update' => array('name', 'url_name'), 98 ), 99 $updates 100 ); 101 } 102 // +-----------------------------------------------------------------------+ 103 // | dulicate tags | 104 // +-----------------------------------------------------------------------+ 105 106 if (isset($_POST['duplic_submit'])) 107 { 108 $query = ' 109 SELECT name 110 FROM '.TAGS_TABLE.' 111 ;'; 112 $existing_names = array_from_query($query, 'name'); 113 114 115 $current_name_of = array(); 116 $query = ' 117 SELECT id, name 118 FROM '.TAGS_TABLE.' 119 WHERE id IN ('.$_POST['edit_list'].') 120 ;'; 121 $result = pwg_query($query); 122 while ($row = pwg_db_fetch_assoc($result)) 123 { 124 $current_name_of[ $row['id'] ] = $row['name']; 125 } 126 127 $updates = array(); 128 // we must not rename tag with an already existing name 129 foreach (explode(',', $_POST['edit_list']) as $tag_id) 130 { 131 $tag_name = stripslashes($_POST['tag_name-'.$tag_id]); 132 133 if ($tag_name != $current_name_of[$tag_id]) 134 { 135 if (in_array($tag_name, $existing_names)) 136 { 137 array_push( 138 $page['errors'], 139 sprintf( 140 l10n('Tag "%s" already exists'), 141 $tag_name 142 ) 143 ); 144 } 145 else if (!empty($tag_name)) 146 { 147 mass_inserts( 148 TAGS_TABLE, 149 array('name', 'url_name'), 150 array( 151 array( 152 'name' => $tag_name, 153 'url_name' => trigger_event('render_tag_url', $tag_name), 154 ) 155 ) 156 ); 157 $query = ' 158 SELECT id 159 FROM '.TAGS_TABLE.' 160 WHERE name = \''.$tag_name.'\' 161 ;'; 162 $destination_tag = array_from_query($query, 'id'); 163 $destination_tag_id = $destination_tag[0]; 164 $query = ' 165 SELECT 166 image_id 167 FROM '.IMAGE_TAG_TABLE.' 168 WHERE tag_id = '.$tag_id.' 169 ;'; 170 $destination_tag_image_ids = array_from_query($query, 'image_id'); 171 $inserts = array(); 172 foreach ($destination_tag_image_ids as $image_id) 173 { 174 array_push( 175 $inserts, 176 array( 177 'tag_id' => $destination_tag_id, 178 'image_id' => $image_id 179 ) 180 ); 181 } 182 183 if (count($inserts) > 0) 184 { 185 mass_inserts( 186 IMAGE_TAG_TABLE, 187 array_keys($inserts[0]), 188 $inserts 189 ); 190 } 191 array_push( 192 $page['infos'], 193 sprintf( 194 l10n('Tag "%s" is now a duplicate of "%s"'), 195 stripslashes($tag_name), 196 $current_name_of[$tag_id] 88 197 ) 89 198 ); … … 341 450 ); 342 451 343 if ((isset($_POST['edit']) or isset($_POST[' merge'])) and isset($_POST['tags']))452 if ((isset($_POST['edit']) or isset($_POST['duplicate']) or isset($_POST['merge'])) and isset($_POST['tags'])) 344 453 { 345 454 $list_name = 'EDIT_TAGS_LIST'; 346 if (isset($_POST['merge'])) 455 if (isset($_POST['duplicate'])) 456 { 457 $list_name = 'DUPLIC_TAGS_LIST'; 458 } 459 elseif (isset($_POST['merge'])) 347 460 { 348 461 $list_name = 'MERGE_TAGS_LIST'; -
trunk/admin/themes/default/template/tags.tpl
r12032 r16526 53 53 </fieldset> 54 54 {/if} 55 {if isset($DUPLIC_TAGS_LIST)} 56 <fieldset> 57 <legend>{'Edit tags'|@translate}</legend> 58 <input type="hidden" name="edit_list" value="{$DUPLIC_TAGS_LIST}"> 59 <table class="table2"> 60 <tr class="throw"> 61 <th>{'Source tag'|@translate}</th> 62 <th>{'Name of the duplicate'|@translate}</th> 63 </tr> 64 {foreach from=$tags item=tag} 65 <tr> 66 <td>{$tag.NAME}</td> 67 <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="30"></td> 68 </tr> 69 {/foreach} 70 </table> 71 72 <p> 73 <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}"> 74 <input class="submit" type="submit" name="duplic_submit" value="{'Submit'|@translate}"> 75 <input class="submit" type="reset" value="{'Reset'|@translate}"> 76 </p> 77 </fieldset> 78 {/if} 55 79 56 80 {if isset($MERGE_TAGS_LIST)} … … 86 110 <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}"> 87 111 <input class="submit" type="submit" name="edit" value="{'Edit selected tags'|@translate}"> 112 <input class="submit" type="submit" name="duplicate" value="{'Duplicate selected tags'|@translate}"> 88 113 <input class="submit" type="submit" name="merge" value="{'Merge selected tags'|@translate}"> 89 114 <input class="submit" type="submit" name="delete" value="{'Delete selected tags'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
Note: See TracChangeset
for help on using the changeset viewer.