ajouter_onglets

This pipeline is used to add tabs to the exec pages in the private zone. It is not so nearly useful since the creation of the <onglet> tag in the plugin.xml file (see Defining page tabs).

return pipeline('ajouter_onglets', array('data'=>$onglets,'args'=>$script));

The "ajouter_onglets" pipeline accepts a table of couples of "tab identifier / tab description" (PHP class of Bouton), but also an identifier for the tab toolbar (in args).

// add a tab to SPIP's configuration page
function plugin_ajouter_onglets($flux){
    if ($flux['args']=='identifiant')
        $flux['data']['identifiant_bouton']= new Bouton("mon/image.png", "titre de l'onglet"), 'url');
    return $flux;
}

The third url parameter for the Bouton class is optional. By default it will be an "exec" page with the same name as the provided identifier (ecrire/?exec=identifier).

In the exec pages, a toolbar is called with two arguments: the identifier of the desired toolbar and the identifier of the active tab:

echo barre_onglets("tab toolbar identifier", "active tab identifier");
echo barre_onglets("configuration", "contents");

Example

The "Agenda" plugin modifies the default tabs for SPIP’s calendar by using this pipeline:

function agenda_ajouter_onglets($flux) {
if($flux['args']=='calendrier'){
    $flux['data']['agenda']= new Bouton(
        _DIR_PLUGIN_AGENDA . '/img_pack/agenda-24.png',
        _T('agenda:agenda'),
        generer_url_ecrire("calendrier","type=semaine"));
    $flux['data']['calendrier'] = new Bouton(
        'cal-rv.png',
        _T('agenda:activite_editoriale'),
        generer_url_ecrire("calendrier", "mode=editorial&type=semaine"));
}
return $flux;
}

Migration to the new system
To rewrite this example in the new system, 2 things need to be separated: the declaration of the button, and the authorisation to see it or not. The declaration is made in the plugin.xml file:

<onglet id="agenda" parent="calendrier">
    <icone>img_pack/agenda-24.png</icone>
    <titre>agenda:agenda</titre>   
    <url>calendrier</url>
    <args>type=semaine</args>  
</onglet>
<onglet id="calendrier" parent="calendrier">
    <icone>cal-rv.png</icone>
    <titre>agenda:activite_editoriale</titre>  
    <url>calendrier</url>
    <args>mode=editorial&type=semaine</args>   
</onglet>

The authorisation is relocated into a special function (use the autoriser pipeline to define it):

function autoriser_calendrier_onglet_dist($faire, $type, $id, $qui, $opt) {
    return true;
}
function autoriser_agenda_onglet_dist($faire, $type, $id, $qui, $opt) {
    return true;
}

Author Mark Baber Published : Updated : 31/05/10

Translations : English, français