Changeset 11039


Ignore:
Timestamp:
May 25, 2011, 11:00:46 AM (10 years ago)
Author:
patdenice
Message:

Load tags for tokeninput directly in html page. Ajax is too slow.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r10849 r11039  
    4444// | Direct actions                                                        |
    4545// +-----------------------------------------------------------------------+
    46 
    47 // tags
    48 if (isset($_GET['fckb_tags']))
    49 {
    50   $query = '
    51 SELECT
    52     id AS tag_id,
    53     name AS tag_name
    54   FROM '.TAGS_TABLE.'
    55 ;';
    56   echo json_encode(get_fckb_taglist($query));
    57   exit();
    58 }
    5946
    6047// theme changer
  • trunk/admin/batch_manager.php

    r10380 r11039  
    362362
    363363// +-----------------------------------------------------------------------+
     364// |                              tags                                     |
     365// +-----------------------------------------------------------------------+
     366
     367$query = '
     368SELECT
     369    id AS tag_id,
     370    name AS tag_name
     371  FROM '.TAGS_TABLE.'
     372;';
     373$template->assign('tags', get_taglist($query));
     374
     375// +-----------------------------------------------------------------------+
    364376// |                         open specific mode                            |
    365377// +-----------------------------------------------------------------------+
  • trunk/admin/batch_manager_global.php

    r10654 r11039  
    138138    else
    139139    {
    140       $tag_ids = get_fckb_tag_ids($_POST['add_tags']);
     140      $tag_ids = get_tag_ids($_POST['add_tags']);
    141141      add_tags($tag_ids, $collection);
    142142
  • trunk/admin/batch_manager_unit.php

    r10648 r11039  
    109109    if (isset($_POST[ 'tags-'.$row['id'] ]))
    110110    {
    111       $tag_ids = get_fckb_tag_ids($_POST[ 'tags-'.$row['id'] ]);
     111      $tag_ids = get_tag_ids($_POST[ 'tags-'.$row['id'] ]);
    112112      set_tags($tag_ids, $row['id']);
    113113    }
     
    257257  WHERE image_id = '.$row['id'].'
    258258;';
    259     $tag_selection = get_fckb_taglist($query);
     259    $tag_selection = get_taglist($query);
    260260
    261261    $template->append(
  • trunk/admin/include/functions.php

    r11008 r11039  
    20982098}
    20992099
    2100 function get_fckb_taglist($query)
     2100function get_taglist($query)
    21012101{
    21022102  $result = pwg_query($query);
     
    21202120}
    21212121
    2122 function get_fckb_tag_ids($raw_tags)
     2122function get_tag_ids($raw_tags)
    21232123{
    21242124  // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New
  • trunk/admin/picture_modify.php

    r9943 r11039  
    167167  if (isset($_POST['tags']))
    168168  {
    169     $tag_ids = get_fckb_tag_ids($_POST['tags']);
     169    $tag_ids = get_tag_ids($_POST['tags']);
    170170  }
    171171  set_tags($tag_ids, $_GET['image_id']);
     
    234234  WHERE image_id = '.$_GET['image_id'].'
    235235;';
    236 $tags = get_fckb_taglist($query);
     236$tag_selection = get_taglist($query);
     237
     238$query = '
     239SELECT
     240    id AS tag_id,
     241    name AS tag_name
     242  FROM '.TAGS_TABLE.'
     243;';
     244$tags = get_taglist($query);
    237245
    238246// retrieving direct information about picture
     
    268276$template->assign(
    269277  array(
     278    'tag_selection' => $tag_selection,
    270279    'tags' => $tags,
    271280    'U_SYNC' => $admin_url_start.'&sync_metadata=1',
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r11008 r11039  
    1010{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
    1111
    12 {footer_script require='jquery.tokeninput'}{literal}
    13 jQuery(document).ready(function() {
    14   jQuery.getJSON('admin.php?fckb_tags=1', function(data) {
    15     jQuery("#tags").tokenInput(
    16       data,
    17       {
    18     {/literal}
    19         hintText: '{'Type in a search term'|@translate}',
    20         noResultsText: '{'No results'|@translate}',
    21         searchingText: '{'Searching...'|@translate}',
    22         newText: ' ({'new'|@translate})',
    23         animateDropdown: false,
    24         preventDuplicates: true,
    25         allowCreation: true
    26     {literal}
    27       }
    28     );
    29   });
     12{footer_script require='jquery.tokeninput'}
     13jQuery(document).ready(function() {ldelim}
     14  jQuery("#tags").tokenInput(
     15    [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
     16    {ldelim}
     17      hintText: '{'Type in a search term'|@translate}',
     18      noResultsText: '{'No results'|@translate}',
     19      searchingText: '{'Searching...'|@translate}',
     20      newText: ' ({'new'|@translate})',
     21      animateDropdown: false,
     22      preventDuplicates: true,
     23      allowCreation: true
     24    }
     25  );
    3026});
    31 {/literal}{/footer_script}
     27{/footer_script}
    3228
    3329{footer_script}
  • trunk/admin/themes/default/template/batch_manager_unit.tpl

    r11008 r11039  
    1414        tag_boxes_selector = tag_boxes_selector + prefix + "#tags-" + {$element.ID};
    1515{/foreach}
    16 {literal}
    17 jQuery(document).ready(function() {
    18   jQuery.getJSON('admin.php?fckb_tags=1', function(data) {
    19     jQuery(tag_boxes_selector).tokenInput(
    20       data,
    21       {
    22     {/literal}
    23         hintText: '{'Type in a search term'|@translate}',
    24         noResultsText: '{'No results'|@translate}',
    25         searchingText: '{'Searching...'|@translate}',
    26         newText: ' ({'new'|@translate})',
    27         animateDropdown: false,
    28         preventDuplicates: true,
    29         allowCreation: true
    30     {literal}
    31       }
    32     );
    33   });
    34  
    35   $("a.preview-box").colorbox();
     16
     17jQuery(document).ready(function() {ldelim}
     18  jQuery(tag_boxes_selector).tokenInput(
     19    [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
     20    {ldelim}
     21      hintText: '{'Type in a search term'|@translate}',
     22      noResultsText: '{'No results'|@translate}',
     23      searchingText: '{'Searching...'|@translate}',
     24      newText: ' ({'new'|@translate})',
     25      animateDropdown: false,
     26      preventDuplicates: true,
     27      allowCreation: true
     28    }
     29  );
     30
     31  jQuery("a.preview-box").colorbox();
    3632});
    37 {/literal}{/footer_script}
     33{/footer_script}
    3834
    3935<h2>{'Batch Manager'|@translate}</h2>
  • trunk/admin/themes/default/template/picture_modify.tpl

    r11008 r11039  
    44
    55{combine_script id='jquery.tokeninput' load='async' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
    6 {footer_script require='jquery.tokeninput'}{literal}
    7 jQuery(document).ready(function() {
    8   jQuery.getJSON('admin.php?fckb_tags=1', function(data) {
    9     jQuery("#tags").tokenInput(
    10       data,
    11       {
    12     {/literal}
    13         hintText: '{'Type in a search term'|@translate}',
    14         noResultsText: '{'No results'|@translate}',
    15         searchingText: '{'Searching...'|@translate}',
    16         newText: ' ({'new'|@translate})',
    17         animateDropdown: false,
    18         preventDuplicates: true,
    19         allowCreation: true
    20     {literal}
    21       }
    22     );
    23   });
     6{footer_script require='jquery.tokeninput'}
     7jQuery(document).ready(function() {ldelim}
     8  jQuery("#tags").tokenInput(
     9    [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
     10    {ldelim}
     11      hintText: '{'Type in a search term'|@translate}',
     12      noResultsText: '{'No results'|@translate}',
     13      searchingText: '{'Searching...'|@translate}',
     14      newText: ' ({'new'|@translate})',
     15      animateDropdown: false,
     16      preventDuplicates: true,
     17      allowCreation: true
     18    }
     19  );
    2420});
    25 {/literal}{/footer_script}
     21{/footer_script}
    2622
    2723{footer_script}
     
    143139        <td>
    144140<select id="tags" name="tags">
    145 {foreach from=$tags item=tag}
     141{foreach from=$tag_selection item=tag}
    146142  <option value="{$tag.id}" class="selected">{$tag.name}</option>
    147143{/foreach}
Note: See TracChangeset for help on using the changeset viewer.