This is an old revision of the document!


Technical changes in Piwigo 2.7

About Plugins / PHP

trigger_change / trigger_notify

Following what was announced for Piwigo 2.6, the functions trigger_event and trigger_action were deleted. You must use trigger_change and trigger_notify instead.

add_event_handler() 4th parameter

The fourth parameter of add_event_handler function was used to tell the number of parameters which will be transmitted to the callback. This is no longer used: all parameters given to trigger_change or trigger_notify are always transmitted to all callback.

But the fourth parameter is still used: if a string is given it will be used as a file path included just before the callback (with include_once).

// procedural
add_event_handler('init', 'my_init',
  EVENT_HANDLER_PRIORITY_NEUTRAL,
  MY_PLUGIN_PATH . 'include/callbacks.php'
  );
 
// OOP with static method
add_event_handler('init', array('MyClass', 'init'),
  EVENT_HANDLER_PRIORITY_NEUTRAL,
  MY_PLUGIN_PATH . 'include/myclass.php'
  );

If the 4th parameter is anything else than a string it is ignored.

Plugin maintenance class

We introduced a new pattern for maintenance of plugins, this uses a PHP class named after your plugin and define in a maintain.class.php file with the following methods:

/**
 * PLUGINID must be replaced by the directory name of your plugin
 */
class PLUGINID_maintain extends PluginMaintain
{
  function install($plugin_version, &$errors=array()) { ... }
  function activate($plugin_version, &$errors=array()) { ... }
  function update($old_version, $new_version, &$errors=array()) { ... }
  function deactivate() { ... }
  function uninstall() { ... }
}

The update method can be called outside the automatic update process, for example if plugin files are manually replaced with a newer version, this ensure full support on hosts which block auto-update.

The old file maintain.inc.php is still supported and will never be removed.

conf_update_param

conf_update_param function has been enhanced:

  • if an array or object is provided as a value, it will be serialized and escaped before database insertion
  • provide true as third parameter to update the $conf global as well (with unserialized value)
  • if you prefer JSON over PHP serial you can provide a custom serializer as fourth parameter
conf_update_param('my_key', $my_array, true,
  create_function('$v', 'return addslashes(json_encode($v));'));
 
// here, $conf['my_key'] == $my_array;

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

TODO

Take A Tour plugin

The plugin allow external sources like plugins to start their own tour. Check admin.tpl and teh files tour.tpl and config.inc.php of the existing tours to get familiar with the system, but here some explanations:

  • the launch is made throught $_GET or $POST_ and require a pwg_token
  • $_REQUEST['submited_tour_path'] contains the path to the config.inc.php file, and is relative to root_of_piwigo/plugins/TakeATour/ (e.g. $_GET['submited_tour_path']=../MyPlugin/tour/introduction )
  • config.inc.php contains AT LEAST the value of $TOUR_PATH which is the path to the tpl file and which is relativ eto the root of Piwigo (e.g. $TOUR_PATH = PHPWG_PLUGINS_PATH.'MyPlugin/tours/introduction/mytour.tpl';). config.inc.php is loaded before the parsing of the tpl of the tour and in the init event: so it will contains direct code to assign vars to your tpl, and can also contains additionnal add_event_handler: these add_event_handler are currently used as prefilter to add css id as anchors for steps.
  • and so the tpl file should be made using the existing tours as examples: the script used is http://bootstraptour.com/ where you can found a doc

Take A Tour loads the js and css needed, you just have to provide a config.inc.php and a tpl file and to load the language (it's recommended using the new option force_fallback like load_language('plugin.lang', PHPWG_PLUGINS_PATH .'MyPlugin/', array('force_fallback'⇒'en_UK')); because empty text means that the step will be skiped)

The plugin allows also the customization of the content of existing tours:

  • $conf['enable_synchronization'] is taken into account, no need to worry about that
  • but anything else can be changed by simply adding custom language files (see LocalFiles Editor)
  • steps in a tour can be skipped by simply emptying the content and title of that step
  • tours can be hidden in the admin of Take A Tour with the array $conf['TakeATour_tour_ignored']

About Themes / tpl and CSS

picture.tpl - disable website field

We added an option to disable or enable the website field on comment add form. You must wrap the field in a IF block:

{if $comment_add.SHOW_WEBSITE} ... {/if}

{$THUMB_SRC} template variable is not assigned anymore. Use instead {$current.derivatives.thumb→get_url()}

search.tpl - major changes

TODO

 
Back to top
dev/changes_in_2.7.1405438461.txt.gz · Last modified: 2014/07/15 17:34 by flop25
 
 
github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact