This pipeline is used to add buttons to the private zone navigation menu. It is not really so useful since the creation of the <bouton>
tag in the plugin.xml
file (see Defining buttons).
$boutons_admin = pipeline('ajouter_boutons', $boutons_admin);
The "ajouter_boutons" pipeline accepts a parameter table of "button identifer / button description" couples (with a PHP class of Bouton(Button)). A button can declare a sub-menu in the "submenu" variable of the Bouton(Button) class. You must create an instance of the Bouton
class to define this:
function plugin_ajouter_boutons($boutons_admin){
$boutons_admin['identifier'] =
new Bouton('image/du_bouton.png', 'Button title', 'url');
$boutons_admin['identifier']->sousmenu['other_identifier'] =
new Bouton('image/du_bouton.png', 'Button title', 'url');
return $boutons_admin;
}
The third url
parameter of the Bouton
class is optional. By default, it will be an "exec" page with the same name as the identifier provided (ecrire/?exec=identifier
).
Example
The "Thelia" plugin, which makes it possible to interface SPIP with the Thélia software package, uses this pipeline to add a link to the Thélia catalogue to the "Édition" menu (with the "naviguer" identifier):
function spip_thelia_ajouter_boutons($boutons_admin) {
// if you are admin
if ($GLOBALS['visiteur_session']['statut'] == "0minirezo") {
$boutons_admin['naviguer']->sousmenu['spip_thelia_catalogue'] =
new Bouton(_DIR_PLUGIN_SPIP_THELIA . 'img_pack/logo_thelia_petit.png', 'Catalogue Thélia');
}
return $boutons_admin;
}
Migration to the new system
To rewrite this example to the new system, two things would need to be separated: the button declaration, and the authorisation to view it or not (in this case, authorisation is only for administrators). The declaration is written in the plugin.xml
file:
<bouton id="spip_thelia_catalogue" parent="naviguer">
<icone>smg_pack/logo_thelia_petit.png</icone>
<titre>title language string</titre>
</bouton>
The authorisation component is built with a special authorisation function (use the autoriser pipeline to define this):
function autoriser_spip_thelia_catalogue_bouton_dist($faire, $type, $id, $qui, $opt) {
return ($qui['statut'] == '0minirezo');
}