Differences

This shows you the differences between two versions of the page.

Link to this comparison view

dev:changes_in_2.7 [2014/09/03 11:10]
plg $themeconf['colorscheme']
dev:changes_in_2.7 [2014/09/22 15:25] (current)
plg info about batch manager and filters + search.tpl
Line 63: Line 63:
  
 Two utility functions was added: **safe_unserialize** and **safe_json_decode** which can be used if you are not sure if the value has already been unserialized or not. Two utility functions was added: **safe_unserialize** and **safe_json_decode** which can be used if you are not sure if the value has already been unserialized or not.
- 
-==== Date(-time) inputs ==== 
-TODO 
  
 ==== Selectize ==== ==== Selectize ====
-TODO+ 
 +The plugins TokenInput and Chosen have been removed in favor to [[http://brianreavis.github.io/selectize.js/|Selectize]]. 
 + 
 +Use this to load the script: 
 +<code> 
 +{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'} 
 +</code> 
 + 
 +The old plugins sources will be removed in further version, your are advised to migrate now. 
 + 
 +== Theming == 
 + 
 +Selectize comes with two colorschemes, dark and clear loaded conditionally with help of [[#themeconf_colorscheme|$themeconf['colorscheme']]]. 
 + 
 +Use this to load the CSS: 
 +<code> 
 +{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.{$themeconf.colorscheme}.css"} 
 +</code> 
 + 
 +== Cache == 
 + 
 +We added a LocalStorage cache for the lists of tags/albums/users/groups. It is used on every core Selectize box and considerably speeds-up loading time of admin pages. Here is how to use it. 
 + 
 +**Include the script (before or after Selectize):** 
 +<code> 
 +{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'} 
 +</code> 
 + 
 +**Add the HTML element:** 
 +<code html> 
 +<select data-selectize="categories" data-value="{$associated_albums|@json_encode|escape:html}" 
 +        data-default="{$STORAGE_ALBUM}" name="associate[]" multiple> 
 +</select> 
 +</code> 
 +''$associated_albums'' must be an array of identifiers for the preselect items.   
 +''data-default'' represents a item which can't be removed. 
 + 
 +**Init the cache:** 
 +<code javascript> 
 +var categoriesCache = new CategoriesCache({ 
 +  serverKey: '{$CACHE_KEYS.categories}', 
 +  serverId: '{$CACHE_KEYS._hash}', 
 +  rootUrl: '{$ROOT_URL}' 
 +}); 
 +</code> 
 +''$CACHE_KEYS'' array is used to sync the cache with the server, it contains state keys for ''categories'', ''tags'', ''users'' and ''groups''. 
 + 
 +**Init Selectize with the cache:** 
 +<code javascript> 
 +categoriesCache.selectize(jQuery('[data-selectize=categories]')); 
 +</code> 
 + 
 +== Add album popin == 
 + 
 +The reusable "add new album" popin (using Colorbox) has obviously been rewritten to use (exclusively) Selectize and the cache. 
 + 
 +**As before, include the template:** 
 +<code> 
 +{include file='include/add_album.inc.tpl'} 
 +</code> 
 + 
 +**Add the receiving select and add button:** 
 +<code html> 
 +<select data-selectize="categories" data-value="{$selected_category|@json_encode|escape:html}" 
 +  data-default="first" name="category" style="width:400px"></select> 
 + 
 +<br>{'... or '|@translate} 
 +<a href="#" data-add-album="category" title="{'create a new album'|translate}"> 
 +  {'create a new album'|@translate}</a> 
 +</code> 
 +''data-add-album'' value refers to the ''name'' of the select. 
 + 
 +**Apply pwgAddAlbum micro-plugin by providing the cache:** 
 +<code javascript> 
 +jQuery('[data-add-album]').pwgAddAlbum({ cache: categoriesCache }); 
 +</code> 
 + 
 +==== Batch Manager, add filters ==== 
 + 
 +We have added 2 trigger_change to add filters in the Batch Manager. The first on batch_manager_register_filters let you register a filter: 
 + 
 +<code php>add_event_handler('batch_manager_register_filters', 'bmab_register_filter'); 
 +function bmab_register_filter($filters) 
 +
 +  if (isset($_POST['filter_added_by_use'])) 
 +  { 
 +    check_input_parameter('filter_added_by', $_POST, false, PATTERN_ID); 
 +     
 +    $filters['added_by'] = $_POST['filter_added_by']; 
 +  } 
 + 
 +  return $filters; 
 +}</code> 
 + 
 +The second trigger_change batch_manager_perform_filters let you define the list of photos that match the filter, and add the set of photos to $filter_sets. 
 + 
 +<code php>add_event_handler('batch_manager_perform_filters', 'bmab_perform_filter'); 
 +function bmab_perform_filter($filter_sets) 
 +
 +  if (isset($_SESSION['bulk_manager_filter']['added_by'])) 
 +  { 
 +    $query = ' 
 +SELECT 
 +    id 
 +  FROM '.IMAGES_TABLE.' 
 +  WHERE added_by = '.$_SESSION['bulk_manager_filter']['added_by'].' 
 +;'; 
 +    $filter_sets[] = array_from_query($query, 'id'); 
 +  } 
 + 
 +  return $filter_sets; 
 +}</code> 
 + 
 +See a full example on http://piwigo.org/dev/browser/extensions/batch_manager_added_by/main.inc.php
  
 ====Take A Tour plugin ==== ====Take A Tour plugin ====
Line 106: Line 216:
 {$THUMB_SRC} template variable is not assigned anymore. Use instead {$current.derivatives.thumb->get_url()} {$THUMB_SRC} template variable is not assigned anymore. Use instead {$current.derivatives.thumb->get_url()}
 ==== search.tpl - major changes ==== ==== search.tpl - major changes ====
-TODO+ 
 +The template search.tpl has deeply modified, so if you have a custom one in your theme, you'd better restart your customization from the new themes/default/template/search.tpl
 
Back to top
dev/changes_in_2.7.1409735428.txt.gz · Last modified: 2014/09/03 11:10 by plg
 
 
github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact