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
This commit is contained in:
parent
5f23fa1473
commit
53a0522894
5 changed files with 118 additions and 50 deletions
|
@ -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']))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2095,38 +2098,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),
|
||||
'id' => '~~'.$row['id'].'~~',
|
||||
)
|
||||
);
|
||||
foreach ($matches[2] as $alt)
|
||||
{
|
||||
$alt_names[] = $alt;
|
||||
}
|
||||
}
|
||||
|
||||
$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'].'~~',
|
||||
)
|
||||
);
|
||||
foreach( array_diff( array_unique($alt_names), array($name) ) as $alt)
|
||||
{
|
||||
$altlist[] = array(
|
||||
'name' => $alt,
|
||||
'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;
|
||||
}
|
||||
|
|
|
@ -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&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']),
|
||||
|
|
|
@ -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>
|
||||
|
@ -71,7 +71,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>
|
||||
|
@ -79,8 +79,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}">
|
||||
|
|
Loading…
Reference in a new issue