Index: /trunk/admin/element_set_global.php =================================================================== --- /trunk/admin/element_set_global.php (revision 5187) +++ /trunk/admin/element_set_global.php (revision 5188) @@ -149,5 +149,6 @@ 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); } @@ -368,18 +369,4 @@ } -$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) { Index: /trunk/admin/element_set_unit.php =================================================================== --- /trunk/admin/element_set_unit.php (revision 5187) +++ /trunk/admin/element_set_unit.php (revision 5188) @@ -106,5 +106,6 @@ 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']); } } @@ -208,36 +209,23 @@ $src = get_thumbnail_url($row); + // creation date + if (!empty($row['date_creation'])) + { + list($year,$month,$day) = explode('-', $row['date_creation']); + } + else + { + list($year,$month,$day) = array('',0,0); + } + $query = ' -SELECT tag_id - FROM '.IMAGE_TAG_TABLE.' +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'].' ;'; - $selected_tags = array_from_query($query, 'tag_id'); - - // creation date - if (!empty($row['date_creation'])) - { - list($year,$month,$day) = explode('-', $row['date_creation']); - } - else - { - 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 = - '
'. - l10n('No tag defined. Use Administration>Pictures>Tags'). - '
'; - } + $tag_selection = get_fckb_taglist($query); $template->append( @@ -259,5 +247,5 @@ 'DATE_CREATION_DAY' => (int)$day, - 'TAG_SELECTION' => $tag_selection, + 'TAGS' => $tag_selection, ) ); Index: /trunk/admin/include/functions.php =================================================================== --- /trunk/admin/include/functions.php (revision 5187) +++ /trunk/admin/include/functions.php (revision 5188) @@ -1982,3 +1982,49 @@ 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; +} ?> Index: /trunk/admin/picture_modify.php =================================================================== --- /trunk/admin/picture_modify.php (revision 5187) +++ /trunk/admin/picture_modify.php (revision 5188) @@ -107,32 +107,11 @@ ); - // 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) - ); - } - } - } - - set_tags( - $tag_ids, - $_GET['image_id'] - ); + $tag_ids = get_fckb_tag_ids($_POST['tags']); + } + set_tags($tag_ids, $_GET['image_id']); array_push($page['infos'], l10n('Picture informations updated')); @@ -195,25 +174,13 @@ // 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 Index: /trunk/admin/themes/default/template/element_set_global.tpl =================================================================== --- /trunk/admin/themes/default/template/element_set_global.tpl (revision 5187) +++ /trunk/admin/themes/default/template/element_set_global.tpl (revision 5188) @@ -5,4 +5,22 @@ +{/literal} + +{known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"} +{literal} + {/literal} @@ -109,5 +127,11 @@{'No tag defined. Use Administration>Pictures>Tags'|@translate}
{/if}