diff options
-rw-r--r-- | admin/element_set_global.php | 17 | ||||
-rw-r--r-- | admin/element_set_unit.php | 36 | ||||
-rw-r--r-- | admin/include/functions.php | 46 | ||||
-rw-r--r-- | admin/picture_modify.php | 43 | ||||
-rw-r--r-- | admin/themes/default/template/element_set_global.tpl | 26 | ||||
-rw-r--r-- | admin/themes/default/template/element_set_unit.tpl | 29 |
6 files changed, 118 insertions, 79 deletions
diff --git a/admin/element_set_global.php b/admin/element_set_global.php index 1a74e1c42..113b5b1f8 100644 --- a/admin/element_set_global.php +++ b/admin/element_set_global.php @@ -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 diff --git a/admin/element_set_unit.php b/admin/element_set_unit.php index 9abcb3889..d80d65fa8 100644 --- a/admin/element_set_unit.php +++ b/admin/element_set_unit.php @@ -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, ) ); } diff --git a/admin/include/functions.php b/admin/include/functions.php index eb6a4181b..c7b8bf5f1 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -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; +} ?>
\ No newline at end of file diff --git a/admin/picture_modify.php b/admin/picture_modify.php index 42306fc23..e33447f70 100644 --- a/admin/picture_modify.php +++ b/admin/picture_modify.php @@ -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 = ' diff --git a/admin/themes/default/template/element_set_global.tpl b/admin/themes/default/template/element_set_global.tpl index fffea3f09..6291013ad 100644 --- a/admin/themes/default/template/element_set_global.tpl +++ b/admin/themes/default/template/element_set_global.tpl @@ -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)} diff --git a/admin/themes/default/template/element_set_unit.tpl b/admin/themes/default/template/element_set_unit.tpl index 4e188590b..d31b5a95c 100644 --- a/admin/themes/default/template/element_set_unit.tpl +++ b/admin/themes/default/template/element_set_unit.tpl @@ -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> |