Changeset 8762
- Timestamp:
- Jan 19, 2011, 2:19:16 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin.php
r8756 r8762 92 92 $page['errors'] = array(); 93 93 $page['infos'] = array(); 94 $page['warnings'] = array(); 94 95 95 96 if (isset($_SESSION['page_infos'])) … … 177 178 } 178 179 180 if (count($page['warnings']) != 0) 181 { 182 $template->assign('warnings', $page['warnings']); 183 } 184 179 185 // Add the Piwigo Official menu 180 186 $template->assign( 'pwgmenu', pwg_URL() ); -
trunk/admin/include/functions.php
r8734 r8762 362 362 363 363 trigger_action('delete_user', $user_id); 364 } 365 366 /** 367 * Deletes all tags linked to no photo 368 */ 369 function delete_orphan_tags() 370 { 371 $orphan_tags = get_orphan_tags(); 372 373 if (count($orphan_tags) > 0) 374 { 375 $orphan_tag_ids = array(); 376 foreach ($orphan_tags as $tag) 377 { 378 array_push($orphan_tag_ids, $tag['id']); 379 } 380 381 $query = ' 382 DELETE 383 FROM '.TAGS_TABLE.' 384 WHERE id IN ('.implode(',', $orphan_tag_ids).') 385 ;'; 386 pwg_query($query); 387 } 388 } 389 390 /** 391 * Get all tags (id + name) linked to no photo 392 */ 393 function get_orphan_tags() 394 { 395 $orphan_tags = array(); 396 397 $query = ' 398 SELECT 399 id, 400 name 401 FROM '.TAGS_TABLE.' 402 LEFT JOIN '.IMAGE_TAG_TABLE.' ON id = tag_id 403 WHERE tag_id IS NULL 404 ;'; 405 $result = pwg_query($query); 406 while ($row = pwg_db_fetch_assoc($result)) 407 { 408 array_push($orphan_tags, $row); 409 } 410 411 return $orphan_tags; 364 412 } 365 413 -
trunk/admin/maintenance.php
r8728 r8762 54 54 update_path(); 55 55 update_average_rate(); 56 break; 57 } 58 case 'delete_orphan_tags' : 59 { 60 delete_orphan_tags(); 56 61 break; 57 62 } … … 134 139 'U_MAINT_CATEGORIES' => $start_url.'categories', 135 140 'U_MAINT_IMAGES' => $start_url.'images', 141 'U_MAINT_ORPHAN_TAGS' => $start_url.'delete_orphan_tags', 136 142 'U_MAINT_HISTORY_DETAIL' => $start_url.'history_detail', 137 143 'U_MAINT_HISTORY_SUMMARY' => $start_url.'history_summary', … … 140 146 'U_MAINT_DATABASE' => $start_url.'database', 141 147 'U_MAINT_C13Y' => $start_url.'c13y', 142 148 'U_MAINT_SEARCH' => $start_url.'search', 143 149 'U_MAINT_COMPILED_TEMPLATES' => $start_url.'compiled-templates', 144 150 'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance', -
trunk/admin/tags.php
r8728 r8762 139 139 140 140 // +-----------------------------------------------------------------------+ 141 // | delete orphan tags | 142 // +-----------------------------------------------------------------------+ 143 144 if (isset($_GET['action']) and 'delete_orphans' == $_GET['action']) 145 { 146 check_pwg_token(); 147 148 delete_orphan_tags(); 149 $_SESSION['page_infos'] = array(l10n('Orphan tags deleted')); 150 redirect(get_root_url().'admin.php?page=tags'); 151 } 152 153 // +-----------------------------------------------------------------------+ 141 154 // | add a tag | 142 155 // +-----------------------------------------------------------------------+ … … 201 214 202 215 // +-----------------------------------------------------------------------+ 216 // | orphan tags | 217 // +-----------------------------------------------------------------------+ 218 219 $orphan_tags = get_orphan_tags(); 220 221 $orphan_tag_names = array(); 222 foreach ($orphan_tags as $tag) 223 { 224 array_push($orphan_tag_names, $tag['name']); 225 } 226 227 if (count($orphan_tag_names) > 0) 228 { 229 array_push( 230 $page['warnings'], 231 sprintf( 232 l10n('You have %d orphan tags: %s.').' <a href="%s">'.l10n('Delete orphan tags').'</a>', 233 count($orphan_tag_names), 234 implode(', ', $orphan_tag_names), 235 get_root_url().'admin.php?page=tags&action=delete_orphans&pwg_token='.get_pwg_token() 236 ) 237 ); 238 } 239 240 // +-----------------------------------------------------------------------+ 203 241 // | form creation | 204 242 // +-----------------------------------------------------------------------+ -
trunk/admin/themes/default/template/admin.tpl
r8665 r8762 127 127 {/if} 128 128 129 {if isset($warnings)} 130 <div class="warnings"> 131 <ul> 132 {foreach from=$warnings item=warning} 133 <li>{$warning}</li> 134 {/foreach} 135 </ul> 136 </div> 137 {/if} 138 129 139 {$ADMIN_CONTENT} 130 140 </div> -
trunk/admin/themes/default/template/maintenance.tpl
r8723 r8762 12 12 <li><a href="{$U_MAINT_CATEGORIES}">{'Update albums informations'|@translate}</a></li> 13 13 <li><a href="{$U_MAINT_IMAGES}">{'Update photos information'|@translate}</a></li> 14 <li><a href="{$U_MAINT_ORPHAN_TAGS}">{'Delete orphan tags'|@translate}</a></li> 14 15 <li><a href="{$U_MAINT_DATABASE}">{'Repair and optimize database'|@translate}</a></li> 15 </ul>16 17 <ul>18 16 <li><a href="{$U_MAINT_HISTORY_DETAIL}" onclick="return confirm('{'Purge history detail'|@translate}');">{'Purge history detail'|@translate}</a></li> 19 17 <li><a href="{$U_MAINT_HISTORY_SUMMARY}" onclick="return confirm('{'Purge history summary'|@translate}');">{'Purge history summary'|@translate}</a></li> … … 22 20 <li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate}');">{'Purge search history'|@translate}</a></li> 23 21 <li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li> 24 </ul>25 26 <ul>27 22 <li><a href="{$U_MAINT_C13Y}">{'Reinitialize check integrity'|@translate}</a></li> 28 23 </ul> -
trunk/language/en_UK/admin.lang.php
r8728 r8762 215 215 $lang['default'] = "default"; 216 216 $lang['delete album'] = "delete album"; 217 $lang['Delete orphan tags'] = 'Delete orphan tags'; 217 218 $lang['Delete Representant'] = "Delete Representant"; 218 219 $lang['Delete selected photos'] = "Delete selected photos"; … … 471 472 $lang['Order of menubar items has been updated successfully.'] = 'Order of menubar items has been updated successfully.'; 472 473 $lang['Original templates'] = "Original templates"; 474 $lang['Orphan tags deleted'] = 'Orphan tags deleted'; 473 475 $lang['Other plugins'] = "Other plugins available"; 474 476 $lang['Other private albums'] = "Other private albums"; … … 762 764 $lang['You cannot delete your account'] = "You cannot delete your account"; 763 765 $lang['You cannot move an album in its own sub album'] = "You cannot move an album in its own sub album"; 766 $lang['You have %d orphan tags: %s.'] = 'You have %d orphan tags: %s.'; 764 767 $lang['You have subscribed to receiving notifications by mail.'] = "You have subscribed to receive notifications by mail."; 765 768 $lang['You have unsubscribed from receiving notifications by mail.'] = "You have unsubscribed from being notified by mail."; -
trunk/language/fr_FR/admin.lang.php
r8728 r8762 560 560 $lang['Replacers (customized templates)'] = "Remplaçants (templates modifiés)"; 561 561 $lang['Original templates'] = "Templates d'origine"; 562 $lang['Orphan tags deleted'] = 'Tags orphelins supprimés'; 562 563 $lang['Optional URL keyword'] = "Paramètre facultatif de l'URL"; 563 564 $lang['Templates configuration has been recorded.'] = "La configuration des templates a été enregistrée."; … … 782 783 $lang['with no tag'] = 'sans tag'; 783 784 $lang['Week starts on'] = 'La semaine commence le'; 785 $lang['You have %d orphan tags: %s.'] = 'Vous avez %d tags orphelins: %s.'; 786 $lang['Delete orphan tags'] = 'Supprimer les tags orphelins'; 784 787 ?>
Note: See TracChangeset
for help on using the changeset viewer.