Changeset 5188
- Timestamp:
- Mar 19, 2010, 1:50:19 PM (14 years ago)
- Location:
- trunk/admin
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/element_set_global.php
r4731 r5188 149 149 if (isset($_POST['add_tags']) and count($collection) > 0) 150 150 { 151 add_tags($_POST['add_tags'], $collection); 151 $tag_ids = get_fckb_tag_ids($_POST['add_tags']); 152 add_tags($tag_ids, $collection); 152 153 } 153 154 … … 368 369 } 369 370 370 $all_tags = get_all_tags();371 372 if (count($all_tags) > 0)373 {// add tags374 $template->assign(375 array(376 'ADD_TAG_SELECTION' => get_html_tag_selection(377 $all_tags,378 'add_tags'379 ),380 )381 );382 }383 384 371 if (count($page['cat_elements_id']) > 0) 385 372 { -
trunk/admin/element_set_unit.php
r4334 r5188 106 106 if (isset($_POST[ 'tags-'.$row['id'] ])) 107 107 { 108 set_tags($_POST[ 'tags-'.$row['id'] ], $row['id']); 108 $tag_ids = get_fckb_tag_ids($_POST[ 'tags-'.$row['id'] ]); 109 set_tags($tag_ids, $row['id']); 109 110 } 110 111 } … … 208 209 $src = get_thumbnail_url($row); 209 210 211 // creation date 212 if (!empty($row['date_creation'])) 213 { 214 list($year,$month,$day) = explode('-', $row['date_creation']); 215 } 216 else 217 { 218 list($year,$month,$day) = array('',0,0); 219 } 220 210 221 $query = ' 211 SELECT tag_id 212 FROM '.IMAGE_TAG_TABLE.' 222 SELECT 223 tag_id, 224 name AS tag_name 225 FROM '.IMAGE_TAG_TABLE.' AS it 226 JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id 213 227 WHERE image_id = '.$row['id'].' 214 228 ;'; 215 $selected_tags = array_from_query($query, 'tag_id'); 216 217 // creation date 218 if (!empty($row['date_creation'])) 219 { 220 list($year,$month,$day) = explode('-', $row['date_creation']); 221 } 222 else 223 { 224 list($year,$month,$day) = array('',0,0); 225 } 226 227 if (count($all_tags) > 0) 228 { 229 $tag_selection = get_html_tag_selection( 230 $all_tags, 231 'tags-'.$row['id'], 232 $selected_tags 233 ); 234 } 235 else 236 { 237 $tag_selection = 238 '<p>'. 239 l10n('No tag defined. Use Administration>Pictures>Tags'). 240 '</p>'; 241 } 229 $tag_selection = get_fckb_taglist($query); 242 230 243 231 $template->append( … … 259 247 'DATE_CREATION_DAY' => (int)$day, 260 248 261 'TAG _SELECTION' => $tag_selection,249 'TAGS' => $tag_selection, 262 250 ) 263 251 ); -
trunk/admin/include/functions.php
r5173 r5188 1982 1982 return 0; 1983 1983 } 1984 1985 function get_fckb_taglist($query) 1986 { 1987 $result = pwg_query($query); 1988 $taglist = array(); 1989 while ($row = pwg_db_fetch_assoc($result)) 1990 { 1991 array_push( 1992 $taglist, 1993 array( 1994 'caption' => $row['tag_name'], 1995 'value' => '~~'.$row['tag_id'].'~~', 1996 ) 1997 ); 1998 } 1999 2000 return $taglist; 2001 } 2002 2003 function get_fckb_tag_ids($raw_tags) 2004 { 2005 // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New 2006 // tag', 'Another new tag') The ~~34~~ means that it is an existing 2007 // tag. I've added the surrounding ~~ to permit creation of tags like "10" 2008 // or "1234" (numeric characters only) 2009 2010 $tag_ids = array(); 2011 2012 foreach ($raw_tags as $raw_tag) 2013 { 2014 if (preg_match('/^~~(\d+)~~$/', $raw_tag, $matches)) 2015 { 2016 array_push($tag_ids, $matches[1]); 2017 } 2018 else 2019 { 2020 // we have to create a new tag 2021 array_push( 2022 $tag_ids, 2023 tag_id_from_tag_name($raw_tag) 2024 ); 2025 } 2026 } 2027 2028 return $tag_ids; 2029 } 1984 2030 ?> -
trunk/admin/picture_modify.php
r5067 r5188 107 107 ); 108 108 109 // In $_POST[tags] we receive something like array('~~6~~', '~~59~~', 'New 110 // tag', 'Another new tag') The ~~34~~ means that it is an existing 111 // tag. I've added the surrounding ~~ to permit creation of tags like "10" 112 // or "1234" (numeric characters only) 109 // time to deal with tags 113 110 $tag_ids = array(); 114 111 if (isset($_POST['tags'])) 115 112 { 116 foreach ($_POST['tags'] as $raw_tag) 117 { 118 if (preg_match('/^~~(\d+)~~$/', $raw_tag, $matches)) 119 { 120 array_push($tag_ids, $matches[1]); 121 } 122 else 123 { 124 // we have to create a new tag 125 array_push( 126 $tag_ids, 127 tag_id_from_tag_name($raw_tag) 128 ); 129 } 130 } 131 } 132 133 set_tags( 134 $tag_ids, 135 $_GET['image_id'] 136 ); 113 $tag_ids = get_fckb_tag_ids($_POST['tags']); 114 } 115 set_tags($tag_ids, $_GET['image_id']); 137 116 138 117 array_push($page['infos'], l10n('Picture informations updated')); … … 195 174 196 175 // tags 197 $tags = array();198 199 176 $query = ' 200 177 SELECT 201 178 tag_id, 202 name 179 name AS tag_name 203 180 FROM '.IMAGE_TAG_TABLE.' AS it 204 181 JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id 205 182 WHERE image_id = '.$_GET['image_id'].' 206 183 ;'; 207 $result = pwg_query($query); 208 while ($row = pwg_db_fetch_assoc($result)) 209 { 210 array_push( 211 $tags, 212 array( 213 'value' => '~~'.$row['tag_id'].'~~', 214 'caption' => $row['name'], 215 ) 216 ); 217 } 184 $tags = get_fckb_taglist($query); 218 185 219 186 // retrieving direct information about picture -
trunk/admin/themes/default/template/element_set_global.tpl
r5123 r5188 5 5 <script type="text/javascript"> 6 6 pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#date_creation_year", "#date_creation_linked_date", "#date_creation_action_set"); 7 </script> 8 {/literal} 9 10 {known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"} 11 {literal} 12 <script type="text/javascript"> 13 $(document).ready(function() { 14 $("#tags").fcbkcomplete({ 15 json_url: "admin.php?fckb_tags=1", 16 cache: false, 17 filter_case: true, 18 filter_hide: true, 19 firstselected: true, 20 filter_selected: true, 21 maxitems: 10, 22 newel: true 23 }); 24 }); 7 25 </script> 8 26 {/literal} … … 109 127 <tr> 110 128 <td>{'add tags'|@translate}</td> 111 <td>{if !empty($ADD_TAG_SELECTION)}{$ADD_TAG_SELECTION}{else}<p>{'No tag defined. Use Administration>Pictures>Tags'|@translate}</p>{/if}</td> 129 <td> 130 <select id="tags" name="add_tags"> 131 {foreach from=$tags item=tag} 132 <option value="{$tag.value}" class="selected">{$tag.caption}</option> 133 {/foreach} 134 </select> 135 </td> 112 136 </tr> 113 137 -
trunk/admin/themes/default/template/element_set_unit.tpl
r5123 r5188 2 2 {include file='include/autosize.inc.tpl'} 3 3 {include file='include/datepicker.inc.tpl'} 4 5 {known_script id="jquery.fcbkcomplete" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.fcbkcomplete.js"} 6 {literal} 7 <script type="text/javascript"> 8 $(document).ready(function() { 9 $(".tags").fcbkcomplete({ 10 json_url: "admin.php?fckb_tags=1", 11 cache: false, 12 filter_case: true, 13 filter_hide: true, 14 firstselected: true, 15 filter_selected: true, 16 maxitems: 10, 17 newel: true 18 }); 19 }); 20 </script> 21 {/literal} 22 4 23 5 24 <h2>{'Batch management'|@translate}</h2> … … 76 95 <tr> 77 96 <td><strong>{'Tags'|@translate}</strong></td> 78 <td>{$element.TAG_SELECTION}</td> 97 <td> 98 99 <select class="tags" name="tags-{$element.ID}"> 100 {foreach from=$element.TAGS item=tag} 101 <option value="{$tag.value}" class="selected">{$tag.caption}</option> 102 {/foreach} 103 </select> 104 105 </td> 79 106 </tr> 80 107
Note: See TracChangeset
for help on using the changeset viewer.