diff options
author | rvelices <rv-github@modusoptimus.com> | 2012-09-05 20:49:12 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2012-09-05 20:49:12 +0000 |
commit | 53a0522894ac474e5e614f2d0d1894b21ab0216f (patch) | |
tree | 7d03c076e0c8f4887b7be61951660f97277d42f0 /admin | |
parent | 5f23fa1473dbbaacd9a6e76db255ac8378301e6f (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')
-rw-r--r-- | admin/batch_manager.php | 7 | ||||
-rw-r--r-- | admin/batch_manager_unit.php | 3 | ||||
-rw-r--r-- | admin/include/functions.php | 67 | ||||
-rw-r--r-- | admin/tags.php | 60 | ||||
-rw-r--r-- | admin/themes/default/template/tags.tpl | 29 |
5 files changed, 117 insertions, 49 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 d67e97d69..3d17e2a0a 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 + ); + } } } @@ -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), + 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 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&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']), diff --git a/admin/themes/default/template/tags.tpl b/admin/themes/default/template/tags.tpl index 51b8c3614..66083029d 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> @@ -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}"> |