Index: /trunk/admin/batch_manager_global.php
===================================================================
--- /trunk/admin/batch_manager_global.php (revision 28532)
+++ /trunk/admin/batch_manager_global.php (revision 28533)
@@ -475,4 +475,6 @@
// tags
+$filter_tags = array();
+
if (!empty($_SESSION['bulk_manager_filter']['tags']))
{
@@ -484,18 +486,9 @@
WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')
;';
- $template->assign('filter_tags', get_taglist($query));
-}
-
-// Virtualy associate a picture to a category
-$query = '
-SELECT id,name,uppercats,global_rank
- FROM '.CATEGORIES_TABLE.'
-;';
-$categories = array_from_query($query);
-usort($categories, 'global_rank_compare');
-display_select_categories($categories, array(), 'category_full_name_options', true);
-
-$template->assign('category_parent_options', $template->get_template_vars('category_full_name_options'));
-$template->assign('category_parent_options_selected', array());
+
+ $filter_tags = get_taglist($query);
+}
+
+$template->assign('filter_tags', $filter_tags);
// in the filter box, which category to select by default
@@ -705,5 +698,5 @@
'nb_thumbs_page' => $nb_thumbs_page,
'nb_thumbs_set' => count($page['cat_elements_id']),
- 'CACHE_KEYS' => get_admin_client_cache_keys(array('tags'))
+ 'CACHE_KEYS' => get_admin_client_cache_keys(array('tags', 'categories')),
));
Index: /trunk/admin/cat_modify.php
===================================================================
--- /trunk/admin/cat_modify.php (revision 28532)
+++ /trunk/admin/cat_modify.php (revision 28533)
@@ -289,10 +289,9 @@
$intro.= '
'.l10n('Numeric identifier : %d', $category['id']);
-$template->assign('INTRO', $intro);
-
-$template->assign(
- 'U_MANAGE_RANKS',
- $base_url.'element_set_ranks&cat_id='.$category['id']
- );
+$template->assign(array(
+ 'INTRO' => $intro,
+ 'U_MANAGE_RANKS' => $base_url.'element_set_ranks&cat_id='.$category['id'],
+ 'CACHE_KEYS' => get_admin_client_cache_keys(array('categories')),
+ ));
if ($category['is_virtual'])
@@ -367,19 +366,5 @@
if ($category['is_virtual'])
{
- // the category can be moved in any category but in itself, in any
- // sub-category
- $unmovables = get_subcat_ids(array($category['id']));
-
- $query = '
-SELECT id,name,uppercats,global_rank
- FROM '.CATEGORIES_TABLE.'
- WHERE id NOT IN ('.implode(',', $unmovables).')
-;';
-
- display_select_cat_wrapper(
- $query,
- empty($category['id_uppercat']) ? array() : array($category['id_uppercat']),
- 'move_cat_options'
- );
+ $template->assign('parent_category', empty($category['id_uppercat']) ? array() : array($category['id_uppercat']));
}
Index: /trunk/admin/include/photos_add_direct_prepare.inc.php
===================================================================
--- /trunk/admin/include/photos_add_direct_prepare.inc.php (revision 28532)
+++ /trunk/admin/include/photos_add_direct_prepare.inc.php (revision 28533)
@@ -218,14 +218,5 @@
// existing album
-$query = '
-SELECT id,name,uppercats,global_rank
- FROM '.CATEGORIES_TABLE.'
-;';
-
-display_select_cat_wrapper(
- $query,
- $selected_category,
- 'category_options'
- );
+$template->assign('selected_category', $selected_category);
@@ -257,9 +248,8 @@
}
-$template->assign(
- array(
- 'setup_errors'=> $setup_errors,
- )
- );
+$template->assign(array(
+ 'setup_errors'=> $setup_errors,
+ 'CACHE_KEYS' => get_admin_client_cache_keys(array('categories')),
+ ));
// Warnings
Index: /trunk/admin/themes/default/js/addAlbum.js
===================================================================
--- /trunk/admin/themes/default/js/addAlbum.js (revision 28533)
+++ /trunk/admin/themes/default/js/addAlbum.js (revision 28533)
@@ -0,0 +1,123 @@
+jQuery.fn.pwgAddAlbum = function(options) {
+ if (!options.cache) {
+ jQuery.error('pwgAddAlbum: missing categories cache');
+ }
+
+ var $popup = jQuery('#addAlbumForm');
+ if (!$popup.data('init')) {
+ $popup.find('[name="category_parent"]').selectize({
+ valueField: 'id',
+ labelField: 'fullname',
+ sortField: 'fullname',
+ searchField: ['fullname'],
+ plugins: ['remove_button'],
+ onInitialize: function() {
+ this.on('dropdown_close', function() {
+ if (this.getValue() == '') {
+ this.setValue(0);
+ }
+ });
+ }
+ });
+
+ $popup.find('form').on('submit', function(e) {
+ e.preventDefault();
+
+ jQuery('#categoryNameError').text('');
+
+ var albumParent = $popup.find('[name="category_parent"]'),
+ parent_id = albumParent.val(),
+ name = $popup.find('[name=category_name]').val(),
+ target = $popup.data('target');
+
+ jQuery.ajax({
+ url: 'ws.php?format=json',
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ method: 'pwg.categories.add',
+ parent: parent_id,
+ name: name
+ },
+ beforeSend: function() {
+ jQuery('#albumCreationLoading').show();
+ },
+ success: function(data) {
+ jQuery('#albumCreationLoading').hide();
+ jQuery('[data-add-album="'+ target +'"]').colorbox.close();
+
+ var newAlbum = data.result.id,
+ newAlbum_name = '';
+
+ if (parent_id != 0) {
+ newAlbum_name = albumParent[0].selectize.options[parent_id].fullname +' / ';
+ }
+ newAlbum_name+= name;
+
+ var $albumSelect = jQuery('[name="'+ target +'"]');
+
+ // target is a normal select
+ if (!$albumSelect[0].selectize) {
+ var new_option = jQuery('')
+ .attr('value', newAlbum)
+ .attr('selected', 'selected')
+ .text(newAlbum_name);
+
+ $albumSelect.find('option').removeAttr('selected');
+
+ if (parent_id==0) {
+ $albumSelect.prepend(new_option);
+ }
+ else {
+ $albumSelect.find('option[value='+ parent_id +']').after(new_option);
+ }
+ }
+ // target is selectize
+ else {
+ $albumSelect[0].selectize.addOption({
+ id: newAlbum,
+ fullname: newAlbum_name
+ });
+
+ $albumSelect[0].selectize.setValue(newAlbum);
+ }
+
+ albumParent.val('');
+ jQuery('#albumSelection').show();
+ },
+ error: function(XMLHttpRequest, textStatus, errorThrows) {
+ jQuery('#albumCreationLoading').hide();
+ jQuery('#categoryNameError').text(errorThrows).css('color', 'red');
+ }
+ });
+ });
+ }
+
+ this.colorbox({
+ inline: true,
+ href: '#addAlbumForm',
+ width: 350, height: 300,
+ onComplete: function() {
+ var albumParent = $popup.find('[name="category_parent"]')[0];
+
+ $popup.data('target', jQuery(this).data('addAlbum'));
+
+ albumParent.selectize.clearOptions();
+
+ options.cache.get(function(categories) {
+ categories.push({
+ id: 0,
+ fullname: '------------'
+ });
+
+ albumParent.selectize.load(function(callback) {
+ callback(categories);
+ });
+
+ albumParent.selectize.setValue(0);
+ });
+ }
+ });
+
+ return this;
+};
Index: /trunk/admin/themes/default/template/batch_manager_global.tpl
===================================================================
--- /trunk/admin/themes/default/template/batch_manager_global.tpl (revision 28532)
+++ /trunk/admin/themes/default/template/batch_manager_global.tpl (revision 28533)
@@ -118,4 +118,53 @@
});
});
+
+ {* *}
+ var categoriesCache = new LocalStorageCache({
+ key: 'categoriesAdminList',
+ serverKey: '{$CACHE_KEYS.categories}',
+ serverId: '{$CACHE_KEYS._hash}',
+
+ loader: function(callback) {
+ jQuery.getJSON('{$ROOT_URL}ws.php?format=json&method=pwg.categories.getAdminList', function(data) {
+ callback(data.result.categories);
+ });
+ }
+ });
+
+ jQuery('[data-selectize=categories]').selectize({
+ valueField: 'id',
+ labelField: 'fullname',
+ sortField: 'fullname',
+ searchField: ['fullname'],
+ plugins: ['remove_button']
+ });
+
+ categoriesCache.get(function(categories) {
+ categories.sort(function(a, b) {
+ return a.fullname.localeCompare(b.fullname);
+ });
+
+ jQuery('[data-selectize=categories]').each(function() {
+ this.selectize.load(function(callback) {
+ callback(categories);
+ });
+
+ if (jQuery(this).data('value')) {
+ this.selectize.setValue(jQuery(this).data('value')[0]);
+ }
+
+ // prevent empty value
+ if (this.selectize.getValue() == '') {
+ this.selectize.setValue(categories[0].id);
+ }
+ this.selectize.on('dropdown_close', function() {
+ if (this.getValue() == '') {
+ this.setValue(categories[0].id);
+ }
+ });
+ });
+ });
+
+ jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache });
});
@@ -228,11 +277,4 @@
$("[id^=action_]").hide();
$("#action_"+$(this).prop("value")).show();
-
- /* make sure the #albumSelect is on the right select box so that the */
- /* "add new album" popup fills the right select box */
- if ("associate" == $(this).prop("value") || "move" == $(this).prop("value")) {
- jQuery("#albumSelect").removeAttr("id");
- jQuery("#action_"+$(this).prop("value")+" select").attr("id", "albumSelect");
- }
if ($(this).val() != -1) {
@@ -622,7 +664,6 @@
{'Album'|@translate}
-
+
@@ -632,5 +673,5 @@
{'Tags'|@translate}
-
@@ -834,16 +875,14 @@
{'Parent album'|@translate}
-
+