diff options
author | plegall <plg@piwigo.org> | 2010-03-06 22:10:23 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2010-03-06 22:10:23 +0000 |
commit | 1c545c601beeeaafacd367d7af2077742c0fcce6 (patch) | |
tree | 95ac1513741ea80c6bed3afd6869a1fdd3ec0bed /admin/picture_modify.php | |
parent | 97a8ddcfe7c8d3f50b3e577c0915c551e7af12fa (diff) |
feature 724: improved "add tags" form. Instead of a big list of checkboxes,
displays a dynamic list of tags with jQuery, with suggestions based on
existing tags and the ability to create new tags on the fly.
The change was applied only on admin/picture_modify.php for test purpose.
Note : FCBKcomplete 2.7 had a bug on "remote tag" click, and the bug was fixed
on 2.7.1. But the suggestions were not working with 2.7.1. So I took the 2.7
and applied the tiny change to make the "remove tag" click work.
git-svn-id: http://piwigo.org/svn/trunk@5067 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/picture_modify.php')
-rw-r--r-- | admin/picture_modify.php | 78 |
1 files changed, 49 insertions, 29 deletions
diff --git a/admin/picture_modify.php b/admin/picture_modify.php index c7914f3a0..42306fc23 100644 --- a/admin/picture_modify.php +++ b/admin/picture_modify.php @@ -106,8 +106,32 @@ if (isset($_POST['submit']) and count($page['errors']) == 0 and !is_adviser()) array($data) ); + // In $_POST[tags] we receive something like array('~~6~~', '~~59~~', 'New + // tag', 'Another new tag') The ~~34~~ means that it is an existing + // tag. I've added the surrounding ~~ to permit creation of tags like "10" + // or "1234" (numeric characters only) + $tag_ids = array(); + if (isset($_POST['tags'])) + { + foreach ($_POST['tags'] as $raw_tag) + { + if (preg_match('/^~~(\d+)~~$/', $raw_tag, $matches)) + { + array_push($tag_ids, $matches[1]); + } + else + { + // we have to create a new tag + array_push( + $tag_ids, + tag_id_from_tag_name($raw_tag) + ); + } + } + } + set_tags( - isset($_POST['tags']) ? $_POST['tags'] : array(), + $tag_ids, $_GET['image_id'] ); @@ -169,6 +193,29 @@ if (isset($_POST['dismiss']) set_random_representant($_POST['cat_elected']); } +// tags +$tags = array(); + +$query = ' +SELECT + tag_id, + name + FROM '.IMAGE_TAG_TABLE.' AS it + JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id + WHERE image_id = '.$_GET['image_id'].' +;'; +$result = pwg_query($query); +while ($row = pwg_db_fetch_assoc($result)) +{ + array_push( + $tags, + array( + 'value' => '~~'.$row['tag_id'].'~~', + 'caption' => $row['name'], + ) + ); +} + // retrieving direct information about picture $query = ' SELECT * @@ -185,14 +232,6 @@ if (!empty($row['storage_category_id'])) $image_file = $row['file']; -// tags -$query = ' -SELECT tag_id - FROM '.IMAGE_TAG_TABLE.' - WHERE image_id = '.$_GET['image_id'].' -;'; -$selected_tags = array_from_query($query, 'tag_id'); - // +-----------------------------------------------------------------------+ // | template init | // +-----------------------------------------------------------------------+ @@ -203,26 +242,9 @@ $template->set_filenames( ) ); -$all_tags = get_all_tags(); - -if (count($all_tags) > 0) -{ - $tag_selection = get_html_tag_selection( - $all_tags, - 'tags', - $selected_tags - ); -} -else -{ - $tag_selection = - '<p>'. - l10n('No tag defined. Use Administration>Pictures>Tags'). - '</p>'; -} - $template->assign( array( + 'tags' => $tags, 'U_SYNC' => get_root_url().'admin.php?page=picture_modify'. '&image_id='.$_GET['image_id']. @@ -245,8 +267,6 @@ $template->assign( 'AUTHOR' => isset($_POST['author']) ? $_POST['author'] : @$row['author'], - 'TAG_SELECTION' => $tag_selection, - 'DESCRIPTION' => htmlspecialchars( isset($_POST['description']) ? stripslashes($_POST['description']) : @$row['comment'] ), |