This is an old revision of the document!


Technical changes in Piwigo 2.6

Jquery UI 1.9

Jquery ui effects filename have changed. For example change

footer|combine_script require='jquery.effects.blind'

to

footer|combine_script require='jquery.ui.effect-blind'

We had backward naming compatibility for 2.5 but not for 2.6.

jGrowl CSS file

the file admin/themes/default/uplodify.jgrowl.css was moved to themes/default/js/plugins/jquery.jgrowl.css

use this line to include the file in your template :

{combine_css path="themes/default/js/plugins/jquery.jgrowl.css"}

no changes for the javascript file

Add action buttons

Following http://piwigo.org/doc/doku.php?id=dev:changes_in_2.5#add_action_buttons

Themes have to handle two new template vars : $PLUGIN_INDEX_BUTTONS and $PLUGIN_PICTURE_BUTTONS
Plugins creators SHOULD NOT add <li> or <div> or <span> around their buttons, it's now handled by the theme.

Default implementation is

{if !empty($PLUGIN_INDEX_BUTTONS)}{foreach from=$PLUGIN_INDEX_BUTTONS item=button}<li>{$button}</li>{/foreach}{/if}

in index.tpl and

{if isset($PLUGIN_PICTURE_BUTTONS)}{foreach from=$PLUGIN_PICTURE_BUTTONS item=button}{$button}{/foreach}{/if}

in picture.tpl

TokenInput CSS + config

TokenInput CSS was moved from admin/themes/default/style.css to themes/default/js/plugins/jquery.tokeninput.css. Needs to be explicitly imported with

{combine_css path="themes/default/js/plugins/jquery.tokeninput.css"}

allowCreation parameter was renamed into allowFreeTagging

SwitchBox

SwitchBox are used for derivatives choices, sort options, LanguageSwitch, ThemeSwitch, etc.
Now the JS code is factorized in a function available in themes/default/js/switchbox.js
Usage :

{combine_script id='core.switchbox' load='async' require='jquery' path='themes/default/js/switchbox.js'}
{footer_script require='core.switchbox'}(SwitchBox=window.SwitchBox||[]).push("#sortOrderLink", "#sortOrderBox");{/footer_script}

The CSS is still provided by themes.

Smarty 3

In template/menubar_categories.tpl, replace:

{'</ul></li>'|@str_repeat:$ref_level-$cat.LEVEL}

by

{'</ul></li>'|str_repeat:($ref_level-$cat.LEVEL)}

Added a function translate_dec, replace:

{$pwg->l10n_dec('singular string', 'plural string', $value)}

by

{$value|translate_dec:'singular string':'plural string'}

Generic template for custom pages

Many plugins add a new public page to Piwigo. Lacking of a documented way to do it, everybody was using his own method, causing display issues with some themes.

In Piwigo 2.6 we introduced a simple way to do it.

For plugins developpers

First define in loc_end_section_init trigger :

$page['body_id'] = 'whatever_you_want';
$page['is_external'] = true;

Then when you want to display the content of your page :

$template->set_filename('your_page', realpath(path to your template));
$template->assign_var_from_handle('CONTENT', 'your_page');

Check Skeleton plugin for complete example http://piwigo.org/svn/extensions/skeleton/trunk/include/public_events.inc.php

For themes developpers

There a little modification of index.tpl : you need to add

{if !empty($CONTENT)}{$CONTENT}{/if}

in the main block of the page.

Unified Batch Manager URL

admin.php?page=batch_manager could be accessed with four URL parameters :
&cat=caddie
&cat=recent
&cat=###
&tag=###

This has been replaced by a single parameter filter :
&filter=prefilter-caddie
&filter=prefilter-last_import
&filter=album-##
&filter=tag-##

Now any prefilter (build-in or added by a plugin) can be accessed via this URL parameter. Build-in prefilters are : caddie, favorites, last_import, no_album, no_tag, duplicates, all_photos, no_virtual_album.

Filters can also be combined (comma separated) : &filter=prefilter-no_tag,album-##

l10n / translate + sprintf

l10n function and translate modifier have been improved : you can provide additional arguments to perform a sprintf on the translated string.

Usage is the same as PHP sprintf, it will trigger an Warning if number of arguments and replacers mismatch.

// old way
sprintf(l10n('%d comments'), $nb);
// new way
l10n('%d comments', $nb);
 
// old way
{'%d comments'|translate|sprintf:$nb}
// new way
{'%d comments'|translate:$nb}

(not limited to one argument)

New options for API methods

We introduced a high-level type check in the API class. When declaring your custom methods you can now specify the expected type of each parameter by filling the 'type' option.

Possible values are :
WS_TYPE_BOOL
WS_TYPE_INT
WS_TYPE_FLOAT

For ints and floats you can also use :
WS_TYPE_POSITIVE
WS_TYPE_NOTNULL

And there is the special WS_TYPE_ID for positive and not null integers.

Another new parameters option is 'info' witch allows to display additional information on the API explorer (tools/ws.htm).

Finally you can choose to hide a method from the reflection method (thus the API explorer) by using the option 'hidden'.

Here is an example of method using all these possibilities:

  $service->addMethod(
      'pwg.myMethod',
      'ws_my_method',
      array(
        'param1' =>   array('default'=>null,
                            'flags'=>WS_PARAM_FORCE_ARRAY,
                            'info'=>'Here goes info about <b>param1</b>'),
        'param2' =>   array('type'=>WS_TYPE_ID),
        'param3' =>   array('default'=>2.5,
                            'type'=>WS_TYPE_FLOAT|WS_TYPE_POSITIVE),
        ),
      'My method is awesome.',
      null, // this parameter is for runtime 'include'
      array('hidden'=>true)
    );

Note that parameters without a 'default' value or without the WS_PARAM_OPTIONAL flag are mandatory. If a parameter is mandatory and provided empty, it is considered are lacking and the server will return an error.

 
Back to top
dev/changes_in_2.6.1382447720.txt.gz · Last modified: 2013/10/22 13:15 by mistic100
 
 
github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact