aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-09-05 20:38:30 +0000
committerrvelices <rv-github@modusoptimus.com>2012-09-05 20:38:30 +0000
commitdadd8f6307843311c9025be00915c95ff52407a7 (patch)
tree425b8ec1b77809abe6f540bb5727b30f2dd1b871 /admin
parent528c75ab35b915b574b4977b8d19412b69845d26 (diff)
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/trunk@17765 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/batch_manager.php7
-rw-r--r--admin/batch_manager_unit.php3
-rw-r--r--admin/include/functions.php71
-rw-r--r--admin/tags.php66
-rw-r--r--admin/themes/default/template/tags.tpl31
5 files changed, 123 insertions, 55 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php
index 7869e4cc2..71f3c72f6 100644
--- a/admin/batch_manager.php
+++ b/admin/batch_manager.php
@@ -114,6 +114,13 @@ if (isset($_GET['cat']))
'category' => $_GET['cat']
);
}
+
+ if (substr_compare($_GET['cat'],'tag-',0,4)==0)
+ {
+ $_SESSION['bulk_manager_filter']=array();
+ $_SESSION['bulk_manager_filter']['tags'] = array(intval(substr($_GET['cat'],4)));
+ $_SESSION['bulk_manager_filter']['tag_mode'] = 'AND';
+ }
}
if (!isset($_SESSION['bulk_manager_filter']))
diff --git a/admin/batch_manager_unit.php b/admin/batch_manager_unit.php
index caeb437d2..d6702db21 100644
--- a/admin/batch_manager_unit.php
+++ b/admin/batch_manager_unit.php
@@ -181,9 +181,6 @@ if (count($page['cat_elements_id']) > 0)
);
$template->assign(array('navbar' => $nav_bar));
- // tags
- $all_tags = get_all_tags();
-
$element_ids = array();
$is_category = false;
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 2be457816..30f1517e9 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1205,7 +1205,7 @@ function create_virtual_category($category_name, $parent_id=null, $options=array
{
return array('error' => l10n('The name of an album must not be empty'));
}
-
+
$insert = array(
'name' => $category_name,
'rank' => 0,
@@ -1474,11 +1474,14 @@ DELETE
}
}
- mass_inserts(
- IMAGE_TAG_TABLE,
- array_keys($inserts[0]),
- $inserts
- );
+ if (count($inserts))
+ {
+ mass_inserts(
+ IMAGE_TAG_TABLE,
+ array_keys($inserts[0]),
+ $inserts
+ );
+ }
}
}
@@ -1498,7 +1501,7 @@ function associate_images_to_categories($images, $categories)
{
return false;
}
-
+
// get existing associations
$query = '
SELECT
@@ -1509,7 +1512,7 @@ SELECT
AND category_id IN ('.implode(',', $categories).')
;';
$result = pwg_query($query);
-
+
$existing = array();
while ($row = pwg_db_fetch_assoc($result))
{
@@ -2119,38 +2122,46 @@ function get_taglist($query, $only_user_language=true)
$result = pwg_query($query);
$taglist = array();
+ $altlist = array();
while ($row = pwg_db_fetch_assoc($result))
{
- if (!$only_user_language and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
+ $raw_name = $row['name'];
+ $name = trigger_event('render_tag_name', $raw_name);
+
+ $taglist[] = array(
+ 'name' => $name,
+ 'id' => '~~'.$row['id'].'~~',
+ );
+
+ if (!$only_user_language)
{
- foreach ($matches[2] as $tag_name)
+ $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
+
+ // TEMP 2.4
+ if (count($alt_names)==0 and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
{
- array_push(
- $taglist,
- array(
- 'name' => trigger_event('render_tag_name', $tag_name),
+ foreach ($matches[2] as $alt)
+ {
+ $alt_names[] = $alt;
+ }
+ }
+
+ foreach( array_diff( array_unique($alt_names), array($name) ) as $alt)
+ {
+ $altlist[] = array(
+ 'name' => $alt,
'id' => '~~'.$row['id'].'~~',
- )
);
}
-
- $row['name'] = preg_replace('#\[lang=(.*?)\](.*?)\[/lang\]#is', null, $row['name']);
- }
-
- if (strlen($row['name']) > 0)
- {
- array_push(
- $taglist,
- array(
- 'name' => trigger_event('render_tag_name', $row['name']),
- 'id' => '~~'.$row['id'].'~~',
- )
- );
}
}
- $cmp = create_function('$a,$b', 'return strcasecmp($a["name"], $b["name"]);');
- usort($taglist, $cmp);
+ usort($taglist, 'tag_alpha_compare');
+ if (count($altlist))
+ {
+ usort($altlist, 'tag_alpha_compare');
+ $taglist = array_merge($taglist, $altlist);
+ }
return $taglist;
}
diff --git a/admin/tags.php b/admin/tags.php
index cf5b36fb6..cfb855aa7 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)
@@ -110,7 +110,7 @@ SELECT name
FROM '.TAGS_TABLE.'
;';
$existing_names = array_from_query($query, 'name');
-
+
$current_name_of = array();
$query = '
@@ -123,7 +123,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)
@@ -179,7 +179,7 @@ SELECT id, name
)
);
}
-
+
if (count($inserts) > 0)
{
mass_inserts(
@@ -226,7 +226,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();
@@ -242,7 +242,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)
@@ -297,7 +297,7 @@ SELECT
{
$tags_deleted[] = $name_of_tag[$tag_id];
}
-
+
array_push(
$page['infos'],
sprintf(
@@ -325,11 +325,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)
@@ -343,7 +343,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');
@@ -377,7 +377,7 @@ SELECT id
)
)
);
-
+
array_push(
$page['infos'],
sprintf(
@@ -440,12 +440,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,
)
);
@@ -460,7 +492,7 @@ if ((isset($_POST['edit']) or isset($_POST['duplicate']) or isset($_POST['merge'
{
$list_name = 'MERGE_TAGS_LIST';
}
-
+
$template->assign(
array(
$list_name => implode(',', $_POST['tags']),
diff --git a/admin/themes/default/template/tags.tpl b/admin/themes/default/template/tags.tpl
index a51b7d376..b34b88285 100644
--- a/admin/themes/default/template/tags.tpl
+++ b/admin/themes/default/template/tags.tpl
@@ -40,7 +40,7 @@ jQuery(document).ready(function(){
{foreach from=$tags item=tag}
<tr>
<td>{$tag.NAME}</td>
- <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="30"></td>
+ <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="50"></td>
</tr>
{/foreach}
</table>
@@ -64,7 +64,7 @@ jQuery(document).ready(function(){
{foreach from=$tags item=tag}
<tr>
<td>{$tag.NAME}</td>
- <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="30"></td>
+ <td><input type="text" name="tag_name-{$tag.ID}" value="{$tag.NAME}" size="50"></td>
</tr>
{/foreach}
</table>
@@ -95,7 +95,7 @@ jQuery(document).ready(function(){
<label>
{'New tag'|@translate}
- <input type="text" name="add_tag" size="30">
+ <input type="text" name="add_tag" size="50">
</label>
<p><input class="submit" type="submit" name="add" value="{'Submit'|@translate}"></p>
@@ -103,8 +103,29 @@ jQuery(document).ready(function(){
<fieldset>
<legend>{'Tag selection'|@translate}</legend>
-
- {$TAG_SELECTION}
+{html_style}
+.showInfo{ldelim}position:static; display:inline-block; text-indent:6px}
+{/html_style}
+{footer_script}{literal}
+jQuery('.showInfo').tipTip({
+ 'delay' : 0,
+ 'fadeIn' : 200,
+ 'fadeOut' : 200,
+ 'maxWidth':'300px',
+ 'keepAlive':true,
+ 'activation':'click'
+ });
+{/literal}{/footer_script}
+<ul class="tagSelection">
+{foreach from=$all_tags item=tag}
+ <li>{capture name='showInfo'}<b>{$tag.name}</b><br>{$pwg->l10n_dec('%d photo', '%d photos', $tag.counter)} <a href="{$tag.U_VIEW}">{'View'|@translate}</a> <a href="{$tag.U_EDIT}">{'Edit'|@translate}</a>{if !empty($tag.alt_names)}<br>{$tag.alt_names}{/if}{/capture}
+ <a class="showInfo" title="{$smarty.capture.showInfo|@htmlspecialchars}">i</a>
+ <label>
+ <input type="checkbox" name="tags[]" value="{$tag.id}"> {$tag.name}
+ </label>
+ </li>
+{/foreach}
+</ul>
<p>
<input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">