mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-08 17:53:08 +02:00
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
This commit is contained in:
+49
-29
@@ -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'] ),
|
||||
|
||||
Reference in New Issue
Block a user