From 1b7781c8669ac98d656b57f4b540ef0fa818a94a Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 19 Jan 2011 13:19:16 +0000 Subject: feature 1289 added: easy "delete orphan tags" function. On the "tags" administration page, a warning message is displayed if you have at least one orphan tag + direct action to delete them. git-svn-id: http://piwigo.org/svn/trunk@8762 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/tags.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'admin/tags.php') diff --git a/admin/tags.php b/admin/tags.php index 412a57b14..16dea3661 100644 --- a/admin/tags.php +++ b/admin/tags.php @@ -137,6 +137,19 @@ DELETE ); } +// +-----------------------------------------------------------------------+ +// | delete orphan tags | +// +-----------------------------------------------------------------------+ + +if (isset($_GET['action']) and 'delete_orphans' == $_GET['action']) +{ + check_pwg_token(); + + delete_orphan_tags(); + $_SESSION['page_infos'] = array(l10n('Orphan tags deleted')); + redirect(get_root_url().'admin.php?page=tags'); +} + // +-----------------------------------------------------------------------+ // | add a tag | // +-----------------------------------------------------------------------+ @@ -199,6 +212,31 @@ $template->assign( ) ); +// +-----------------------------------------------------------------------+ +// | orphan tags | +// +-----------------------------------------------------------------------+ + +$orphan_tags = get_orphan_tags(); + +$orphan_tag_names = array(); +foreach ($orphan_tags as $tag) +{ + array_push($orphan_tag_names, $tag['name']); +} + +if (count($orphan_tag_names) > 0) +{ + array_push( + $page['warnings'], + sprintf( + l10n('You have %d orphan tags: %s.').' '.l10n('Delete orphan tags').'', + count($orphan_tag_names), + implode(', ', $orphan_tag_names), + get_root_url().'admin.php?page=tags&action=delete_orphans&pwg_token='.get_pwg_token() + ) + ); +} + // +-----------------------------------------------------------------------+ // | form creation | // +-----------------------------------------------------------------------+ -- cgit v1.2.3