aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-05-25 09:00:46 +0000
committerpatdenice <patdenice@piwigo.org>2011-05-25 09:00:46 +0000
commitc9b7beb12f38890631ab12c8086b1bff28eed4a4 (patch)
tree7c90d91c8c4d5949abd9d6d378dc9c84680d3163
parent4c13229cd9c7ce6a8b2e93b922b1e2dbc9b9799c (diff)
Load tags for tokeninput directly in html page. Ajax is too slow.
git-svn-id: http://piwigo.org/svn/trunk@11039 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin.php13
-rw-r--r--admin/batch_manager.php12
-rw-r--r--admin/batch_manager_global.php2
-rw-r--r--admin/batch_manager_unit.php4
-rw-r--r--admin/include/functions.php4
-rw-r--r--admin/picture_modify.php13
-rw-r--r--admin/themes/default/template/batch_manager_global.tpl34
-rw-r--r--admin/themes/default/template/batch_manager_unit.tpl38
-rw-r--r--admin/themes/default/template/picture_modify.tpl36
9 files changed, 76 insertions, 80 deletions
diff --git a/admin.php b/admin.php
index 16cb74e59..3ac3a3b68 100644
--- a/admin.php
+++ b/admin.php
@@ -44,19 +44,6 @@ check_status(ACCESS_ADMINISTRATOR);
// | Direct actions |
// +-----------------------------------------------------------------------+
-// tags
-if (isset($_GET['fckb_tags']))
-{
- $query = '
-SELECT
- id AS tag_id,
- name AS tag_name
- FROM '.TAGS_TABLE.'
-;';
- echo json_encode(get_fckb_taglist($query));
- exit();
-}
-
// theme changer
if (isset($_GET['change_theme']))
{
diff --git a/admin/batch_manager.php b/admin/batch_manager.php
index b333ca9ac..c1d3687d4 100644
--- a/admin/batch_manager.php
+++ b/admin/batch_manager.php
@@ -361,6 +361,18 @@ if (in_array($page['tab'], $tab_codes))
$tabsheet->assign();
// +-----------------------------------------------------------------------+
+// | tags |
+// +-----------------------------------------------------------------------+
+
+$query = '
+SELECT
+ id AS tag_id,
+ name AS tag_name
+ FROM '.TAGS_TABLE.'
+;';
+$template->assign('tags', get_taglist($query));
+
+// +-----------------------------------------------------------------------+
// | open specific mode |
// +-----------------------------------------------------------------------+
diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php
index a2c1ec4fd..8535f98c1 100644
--- a/admin/batch_manager_global.php
+++ b/admin/batch_manager_global.php
@@ -137,7 +137,7 @@ DELETE
}
else
{
- $tag_ids = get_fckb_tag_ids($_POST['add_tags']);
+ $tag_ids = get_tag_ids($_POST['add_tags']);
add_tags($tag_ids, $collection);
if ('with no tag' == $page['prefilter'])
diff --git a/admin/batch_manager_unit.php b/admin/batch_manager_unit.php
index aa28b856e..b7ca074d7 100644
--- a/admin/batch_manager_unit.php
+++ b/admin/batch_manager_unit.php
@@ -108,7 +108,7 @@ SELECT id, date_creation
// tags management
if (isset($_POST[ 'tags-'.$row['id'] ]))
{
- $tag_ids = get_fckb_tag_ids($_POST[ 'tags-'.$row['id'] ]);
+ $tag_ids = get_tag_ids($_POST[ 'tags-'.$row['id'] ]);
set_tags($tag_ids, $row['id']);
}
}
@@ -256,7 +256,7 @@ SELECT
JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
WHERE image_id = '.$row['id'].'
;';
- $tag_selection = get_fckb_taglist($query);
+ $tag_selection = get_taglist($query);
$template->append(
'elements',
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 20bfbfb51..510ef767a 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -2097,7 +2097,7 @@ function get_active_menu($menu_page)
return 0;
}
-function get_fckb_taglist($query)
+function get_taglist($query)
{
$result = pwg_query($query);
@@ -2119,7 +2119,7 @@ function get_fckb_taglist($query)
return $taglist;
}
-function get_fckb_tag_ids($raw_tags)
+function get_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
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index 333bf3e88..97bff6e5e 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -166,7 +166,7 @@ if (isset($_POST['submit']) and count($page['errors']) == 0)
$tag_ids = array();
if (isset($_POST['tags']))
{
- $tag_ids = get_fckb_tag_ids($_POST['tags']);
+ $tag_ids = get_tag_ids($_POST['tags']);
}
set_tags($tag_ids, $_GET['image_id']);
@@ -233,7 +233,15 @@ SELECT
JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
WHERE image_id = '.$_GET['image_id'].'
;';
-$tags = get_fckb_taglist($query);
+$tag_selection = get_taglist($query);
+
+$query = '
+SELECT
+ id AS tag_id,
+ name AS tag_name
+ FROM '.TAGS_TABLE.'
+;';
+$tags = get_taglist($query);
// retrieving direct information about picture
$query = '
@@ -267,6 +275,7 @@ $admin_url_start.= isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '';
$template->assign(
array(
+ 'tag_selection' => $tag_selection,
'tags' => $tags,
'U_SYNC' => $admin_url_start.'&amp;sync_metadata=1',
'U_DELETE' => $admin_url_start.'&amp;delete=1&amp;pwg_token='.get_pwg_token(),
diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl
index 641fd61f8..f645b3f53 100644
--- a/admin/themes/default/template/batch_manager_global.tpl
+++ b/admin/themes/default/template/batch_manager_global.tpl
@@ -9,26 +9,22 @@
{combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'}
{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
-{footer_script require='jquery.tokeninput'}{literal}
-jQuery(document).ready(function() {
- jQuery.getJSON('admin.php?fckb_tags=1', function(data) {
- jQuery("#tags").tokenInput(
- data,
- {
- {/literal}
- hintText: '{'Type in a search term'|@translate}',
- noResultsText: '{'No results'|@translate}',
- searchingText: '{'Searching...'|@translate}',
- newText: ' ({'new'|@translate})',
- animateDropdown: false,
- preventDuplicates: true,
- allowCreation: true
- {literal}
- }
- );
- });
+{footer_script require='jquery.tokeninput'}
+jQuery(document).ready(function() {ldelim}
+ jQuery("#tags").tokenInput(
+ [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
+ {ldelim}
+ hintText: '{'Type in a search term'|@translate}',
+ noResultsText: '{'No results'|@translate}',
+ searchingText: '{'Searching...'|@translate}',
+ newText: ' ({'new'|@translate})',
+ animateDropdown: false,
+ preventDuplicates: true,
+ allowCreation: true
+ }
+ );
});
-{/literal}{/footer_script}
+{/footer_script}
{footer_script}
var nb_thumbs_page = {$nb_thumbs_page};
diff --git a/admin/themes/default/template/batch_manager_unit.tpl b/admin/themes/default/template/batch_manager_unit.tpl
index dec11a998..66b8b6b17 100644
--- a/admin/themes/default/template/batch_manager_unit.tpl
+++ b/admin/themes/default/template/batch_manager_unit.tpl
@@ -13,28 +13,24 @@ prefix = ", ";
{/if}
tag_boxes_selector = tag_boxes_selector + prefix + "#tags-" + {$element.ID};
{/foreach}
-{literal}
-jQuery(document).ready(function() {
- jQuery.getJSON('admin.php?fckb_tags=1', function(data) {
- jQuery(tag_boxes_selector).tokenInput(
- data,
- {
- {/literal}
- hintText: '{'Type in a search term'|@translate}',
- noResultsText: '{'No results'|@translate}',
- searchingText: '{'Searching...'|@translate}',
- newText: ' ({'new'|@translate})',
- animateDropdown: false,
- preventDuplicates: true,
- allowCreation: true
- {literal}
- }
- );
- });
-
- $("a.preview-box").colorbox();
+
+jQuery(document).ready(function() {ldelim}
+ jQuery(tag_boxes_selector).tokenInput(
+ [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
+ {ldelim}
+ hintText: '{'Type in a search term'|@translate}',
+ noResultsText: '{'No results'|@translate}',
+ searchingText: '{'Searching...'|@translate}',
+ newText: ' ({'new'|@translate})',
+ animateDropdown: false,
+ preventDuplicates: true,
+ allowCreation: true
+ }
+ );
+
+ jQuery("a.preview-box").colorbox();
});
-{/literal}{/footer_script}
+{/footer_script}
<h2>{'Batch Manager'|@translate}</h2>
diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl
index 5c6b2bf08..8cc01c43a 100644
--- a/admin/themes/default/template/picture_modify.tpl
+++ b/admin/themes/default/template/picture_modify.tpl
@@ -3,26 +3,22 @@
{include file='include/datepicker.inc.tpl'}
{combine_script id='jquery.tokeninput' load='async' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
-{footer_script require='jquery.tokeninput'}{literal}
-jQuery(document).ready(function() {
- jQuery.getJSON('admin.php?fckb_tags=1', function(data) {
- jQuery("#tags").tokenInput(
- data,
- {
- {/literal}
- hintText: '{'Type in a search term'|@translate}',
- noResultsText: '{'No results'|@translate}',
- searchingText: '{'Searching...'|@translate}',
- newText: ' ({'new'|@translate})',
- animateDropdown: false,
- preventDuplicates: true,
- allowCreation: true
- {literal}
- }
- );
- });
+{footer_script require='jquery.tokeninput'}
+jQuery(document).ready(function() {ldelim}
+ jQuery("#tags").tokenInput(
+ [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
+ {ldelim}
+ hintText: '{'Type in a search term'|@translate}',
+ noResultsText: '{'No results'|@translate}',
+ searchingText: '{'Searching...'|@translate}',
+ newText: ' ({'new'|@translate})',
+ animateDropdown: false,
+ preventDuplicates: true,
+ allowCreation: true
+ }
+ );
});
-{/literal}{/footer_script}
+{/footer_script}
{footer_script}
pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#date_creation_year", "#date_creation_linked_date", "#date_creation_action_set");
@@ -142,7 +138,7 @@ pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#da
<td><strong>{'Tags'|@translate}</strong></td>
<td>
<select id="tags" name="tags">
-{foreach from=$tags item=tag}
+{foreach from=$tag_selection item=tag}
<option value="{$tag.id}" class="selected">{$tag.name}</option>
{/foreach}
</select>