🌍
English
This shows you the differences between two versions of the page.
dev:changes_in_2.7 [2014/07/07 08:40] mistic100 [trigger_change / trigger_notify] |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Technical changes in Piwigo 2.7 ====== | ||
- | ===== 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**). | ||
- | <code php> | ||
- | // 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' | ||
- | ); | ||
- | </code> | ||
- | |||
- | If the 4th parameter is anything else than a string it is ignored. | ||
- | |||
- | ===== trigger_change / trigger_notify ===== | ||
- | Following what was [[http://piwigo.org/doc/doku.php?id=dev:changes_in_2.6#triggers_functions|announced for Piwigo 2.6]], the functions **trigger_event** and **trigger_action** were deleted. You must use **trigger_change** and **trigger_notify** instead. | ||
- | |||
- | ===== Plugin maintenance class ===== | ||
- | We introduced a new pattern for maintenance of plugins, this uses a PHP class named after your plugin and define din a **maintain.class.php** file with the following methods: | ||
- | |||
- | <code php> | ||
- | /** | ||
- | * 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() { ... } | ||
- | } | ||
- | </code> | ||
- | |||
- | 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 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 | ||
- | |||
- | <code php> | ||
- | conf_update_param('my_key', $my_array, true, | ||
- | create_function('$v', 'return addslashes(json_encode($v));')); | ||
- | |||
- | // here, $conf['my_key'] == $my_array; | ||
- | </code> | ||
- | |||
- | 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 | ||
- | |||
- | ===== 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: | ||
- | <code>{if $comment_add.SHOW_WEBSITE} ... {/if}</code> | ||
- | |||
- | ===== search.tpl - major changes ===== | ||
- | TODO |