aboutsummaryrefslogtreecommitdiffstats
path: root/admin/tags.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-09-05 20:49:12 +0000
committerrvelices <rv-github@modusoptimus.com>2012-09-05 20:49:12 +0000
commit53a0522894ac474e5e614f2d0d1894b21ab0216f (patch)
tree7d03c076e0c8f4887b7be61951660f97277d42f0 /admin/tags.php
parent5f23fa1473dbbaacd9a6e76db255ac8378301e6f (diff)
merge-r17765 from trunk to branch 2.4 feature 2737: improve tag administration screen
show for every tag - the number of photos - link to public index page - link to batch manager edit add an event for extended description multi language strings (used for autocompletion and shown in the tag admin screen) instead of hard coded in the core [lang=.. git-svn-id: http://piwigo.org/svn/branches/2.4@17766 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/tags.php')
-rw-r--r--admin/tags.php60
1 files changed, 46 insertions, 14 deletions
diff --git a/admin/tags.php b/admin/tags.php
index 077b3cd67..87fbf440c 100644
--- a/admin/tags.php
+++ b/admin/tags.php
@@ -45,7 +45,7 @@ SELECT name
FROM '.TAGS_TABLE.'
;';
$existing_names = array_from_query($query, 'name');
-
+
$current_name_of = array();
$query = '
@@ -58,7 +58,7 @@ SELECT id, name
{
$current_name_of[ $row['id'] ] = $row['name'];
}
-
+
$updates = array();
// we must not rename tag with an already existing name
foreach (explode(',', $_POST['edit_list']) as $tag_id)
@@ -117,7 +117,7 @@ if (isset($_POST['confirm_merge']))
{
$destination_tag_id = $_POST['destination_tag'];
$tag_ids = explode(',', $_POST['merge_list']);
-
+
if (is_array($tag_ids) and count($tag_ids) > 1)
{
$name_of_tag = array();
@@ -133,7 +133,7 @@ SELECT
{
$name_of_tag[ $row['id'] ] = trigger_event('render_tag_name', $row['name']);
}
-
+
$tag_ids_to_delete = array_diff(
$tag_ids,
array($destination_tag_id)
@@ -188,7 +188,7 @@ SELECT
{
$tags_deleted[] = $name_of_tag[$tag_id];
}
-
+
array_push(
$page['infos'],
sprintf(
@@ -216,11 +216,11 @@ SELECT name
$tag_names = array_from_query($query, 'name');
delete_tags($_POST['tags']);
-
+
array_push(
$page['infos'],
l10n_dec(
- 'The following tag was deleted',
+ 'The following tag was deleted',
'The %d following tags were deleted',
count($tag_names)).' : '.
implode(', ', $tag_names)
@@ -234,7 +234,7 @@ SELECT name
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');
@@ -268,7 +268,7 @@ SELECT id
)
)
);
-
+
array_push(
$page['infos'],
sprintf(
@@ -331,12 +331,44 @@ if (count($orphan_tag_names) > 0)
// | form creation |
// +-----------------------------------------------------------------------+
+
+// tag counters
+$query = '
+SELECT tag_id, COUNT(image_id) AS counter
+ FROM '.IMAGE_TAG_TABLE.'
+ GROUP BY tag_id';
+$tag_counters = simple_hash_from_query($query, 'tag_id', 'counter');
+
+// all tags
+$query = '
+SELECT *
+ FROM '.TAGS_TABLE.'
+;';
+$result = pwg_query($query);
+$all_tags = array();
+while ($tag = pwg_db_fetch_assoc($result))
+{
+ $raw_name = $tag['name'];
+ $tag['name'] = trigger_event('render_tag_name', $raw_name);
+ $tag['counter'] = intval(@$tag_counters[ $tag['id'] ]);
+ $tag['U_VIEW'] = make_index_url(array('tags'=>array($tag)));
+ $tag['U_EDIT'] = 'admin.php?page=batch_manager&amp;cat=tag-'.$tag['id'];
+
+ $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
+ $alt_names = array_diff( array_unique($alt_names), array($tag['name']) );
+ if (count($alt_names))
+ {
+ $tag['alt_names'] = implode(', ', $alt_names);
+ }
+ $all_tags[] = $tag;
+}
+usort($all_tags, 'tag_alpha_compare');
+
+
+
$template->assign(
array(
- 'TAG_SELECTION' => get_html_tag_selection(
- get_all_tags(),
- 'tags'
- ),
+ 'all_tags' => $all_tags,
)
);
@@ -347,7 +379,7 @@ if ((isset($_POST['edit']) or isset($_POST['merge'])) and isset($_POST['tags']))
{
$list_name = 'MERGE_TAGS_LIST';
}
-
+
$template->assign(
array(
$list_name => implode(',', $_POST['tags']),