feature 724: FCBKcomplete propagated to element_set_global and
element_set_unit to manage tags. Note: multiple instances of FCBKcomplete on the same page does not work as good as a single instance. git-svn-id: http://piwigo.org/svn/trunk@5188 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
b7fee65e8f
commit
3a076f460d
6 changed files with 118 additions and 79 deletions
|
|
@ -148,7 +148,8 @@ if (isset($_POST['submit']))
|
|||
|
||||
if (isset($_POST['add_tags']) and count($collection) > 0)
|
||||
{
|
||||
add_tags($_POST['add_tags'], $collection);
|
||||
$tag_ids = get_fckb_tag_ids($_POST['add_tags']);
|
||||
add_tags($tag_ids, $collection);
|
||||
}
|
||||
|
||||
if (isset($_POST['del_tags']) and count($collection) > 0)
|
||||
|
|
@ -367,20 +368,6 @@ SELECT
|
|||
display_select_cat_wrapper($query, array(), 'dissociate_options', true);
|
||||
}
|
||||
|
||||
$all_tags = get_all_tags();
|
||||
|
||||
if (count($all_tags) > 0)
|
||||
{// add tags
|
||||
$template->assign(
|
||||
array(
|
||||
'ADD_TAG_SELECTION' => get_html_tag_selection(
|
||||
$all_tags,
|
||||
'add_tags'
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (count($page['cat_elements_id']) > 0)
|
||||
{
|
||||
// remove tags
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ SELECT id, date_creation
|
|||
// tags management
|
||||
if (isset($_POST[ 'tags-'.$row['id'] ]))
|
||||
{
|
||||
set_tags($_POST[ 'tags-'.$row['id'] ], $row['id']);
|
||||
$tag_ids = get_fckb_tag_ids($_POST[ 'tags-'.$row['id'] ]);
|
||||
set_tags($tag_ids, $row['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,13 +208,6 @@ SELECT id,path,tn_ext,name,date_creation,comment,author,file
|
|||
|
||||
$src = get_thumbnail_url($row);
|
||||
|
||||
$query = '
|
||||
SELECT tag_id
|
||||
FROM '.IMAGE_TAG_TABLE.'
|
||||
WHERE image_id = '.$row['id'].'
|
||||
;';
|
||||
$selected_tags = array_from_query($query, 'tag_id');
|
||||
|
||||
// creation date
|
||||
if (!empty($row['date_creation']))
|
||||
{
|
||||
|
|
@ -224,21 +218,15 @@ SELECT tag_id
|
|||
list($year,$month,$day) = array('',0,0);
|
||||
}
|
||||
|
||||
if (count($all_tags) > 0)
|
||||
{
|
||||
$tag_selection = get_html_tag_selection(
|
||||
$all_tags,
|
||||
'tags-'.$row['id'],
|
||||
$selected_tags
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tag_selection =
|
||||
'<p>'.
|
||||
l10n('No tag defined. Use Administration>Pictures>Tags').
|
||||
'</p>';
|
||||
}
|
||||
$query = '
|
||||
SELECT
|
||||
tag_id,
|
||||
name AS tag_name
|
||||
FROM '.IMAGE_TAG_TABLE.' AS it
|
||||
JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
|
||||
WHERE image_id = '.$row['id'].'
|
||||
;';
|
||||
$tag_selection = get_fckb_taglist($query);
|
||||
|
||||
$template->append(
|
||||
'elements',
|
||||
|
|
@ -258,7 +246,7 @@ SELECT tag_id
|
|||
'DATE_CREATION_MONTH' => (int)$month,
|
||||
'DATE_CREATION_DAY' => (int)$day,
|
||||
|
||||
'TAG_SELECTION' => $tag_selection,
|
||||
'TAGS' => $tag_selection,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1981,4 +1981,50 @@ function get_active_menu($menu_page)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function get_fckb_taglist($query)
|
||||
{
|
||||
$result = pwg_query($query);
|
||||
$taglist = array();
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push(
|
||||
$taglist,
|
||||
array(
|
||||
'caption' => $row['tag_name'],
|
||||
'value' => '~~'.$row['tag_id'].'~~',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $taglist;
|
||||
}
|
||||
|
||||
function get_fckb_tag_ids($raw_tags)
|
||||
{
|
||||
// In $raw_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();
|
||||
|
||||
foreach ($raw_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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $tag_ids;
|
||||
}
|
||||
?>
|
||||
|
|
@ -106,34 +106,13 @@ 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)
|
||||
// time to deal with tags
|
||||
$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)
|
||||
);
|
||||
}
|
||||
}
|
||||
$tag_ids = get_fckb_tag_ids($_POST['tags']);
|
||||
}
|
||||
|
||||
set_tags(
|
||||
$tag_ids,
|
||||
$_GET['image_id']
|
||||
);
|
||||
set_tags($tag_ids, $_GET['image_id']);
|
||||
|
||||
array_push($page['infos'], l10n('Picture informations updated'));
|
||||
}
|
||||
|
|
@ -194,27 +173,15 @@ if (isset($_POST['dismiss'])
|
|||
}
|
||||
|
||||
// tags
|
||||
$tags = array();
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
tag_id,
|
||||
name
|
||||
name AS tag_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'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$tags = get_fckb_taglist($query);
|
||||
|
||||
// retrieving direct information about picture
|
||||
$query = '
|
||||
|
|
|
|||
|
|
@ -7,6 +7,24 @@
|
|||
</script>
|
||||
{/literal}
|
||||
|
||||
{known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"}
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#tags").fcbkcomplete({
|
||||
json_url: "admin.php?fckb_tags=1",
|
||||
cache: false,
|
||||
filter_case: true,
|
||||
filter_hide: true,
|
||||
firstselected: true,
|
||||
filter_selected: true,
|
||||
maxitems: 10,
|
||||
newel: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
<h2>{'Batch management'|@translate}</h2>
|
||||
|
||||
<h3>{$CATEGORIES_NAV}</h3>
|
||||
|
|
@ -108,7 +126,13 @@
|
|||
|
||||
<tr>
|
||||
<td>{'add tags'|@translate}</td>
|
||||
<td>{if !empty($ADD_TAG_SELECTION)}{$ADD_TAG_SELECTION}{else}<p>{'No tag defined. Use Administration>Pictures>Tags'|@translate}</p>{/if}</td>
|
||||
<td>
|
||||
<select id="tags" name="add_tags">
|
||||
{foreach from=$tags item=tag}
|
||||
<option value="{$tag.value}" class="selected">{$tag.caption}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{if !empty($DEL_TAG_SELECTION)}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,25 @@
|
|||
{include file='include/autosize.inc.tpl'}
|
||||
{include file='include/datepicker.inc.tpl'}
|
||||
|
||||
{known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"}
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$(".tags").fcbkcomplete({
|
||||
json_url: "admin.php?fckb_tags=1",
|
||||
cache: false,
|
||||
filter_case: true,
|
||||
filter_hide: true,
|
||||
firstselected: true,
|
||||
filter_selected: true,
|
||||
maxitems: 10,
|
||||
newel: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
|
||||
<h2>{'Batch management'|@translate}</h2>
|
||||
|
||||
<h3>{$CATEGORIES_NAV}</h3>
|
||||
|
|
@ -75,7 +94,15 @@
|
|||
|
||||
<tr>
|
||||
<td><strong>{'Tags'|@translate}</strong></td>
|
||||
<td>{$element.TAG_SELECTION}</td>
|
||||
<td>
|
||||
|
||||
<select class="tags" name="tags-{$element.ID}">
|
||||
{foreach from=$element.TAGS item=tag}
|
||||
<option value="{$tag.value}" class="selected">{$tag.caption}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue