The latest filters and pipelines for programmers
Wednesday, January 28, 2009 6:35:40 PM
Here is a list of new functions that can help you develop plugins :
supprimer_objets_lies ( array($type, $id) ) :
Type : pipeline
Removes the objects of plugins linked to core objects (used when these core objects are deleted)
// http://doc.spip.org/@action_editer_message_post_supprimer
function action_editer_message_post_supprimer($id_message) {
sql_delete("spip_messages", "id_message=".sql_quote($id_message));
sql_delete("spip_auteurs_messages", "id_message=".sql_quote($id_message));
pipeline('supprimer_objets_lies',array(
array('type'=>'message','id'=>$id_message)
));
}
optimiser_sansref ($table, $id, $sel) :
This pipeline is called in genie/optimiser.php
It completes the removal process of orphelin objects.
(dead links between tables, that results from the suppression of articles, authors, etc)
example :
/**
* Optimizes the database by removing orphelins forums
*
* @param int $n
* @return int
*/
function forum_optimiser_base_disparus ($n){
# detect forums that are linked to an id_rubrique that doesn't exist anymore
$res = sql_select("forum.id_forum AS id",
"spip_forum AS forum
LEFT JOIN spip_rubriques AS rubriques
ON forum.id_rubrique=rubriques.id_rubrique",
"rubriques.id_rubrique IS NULL
AND forum.id_rubrique>0");
$n+= optimiser_sansref ('spip_forum', 'id_forum', $res);
...
return $n;
}
filtre_lien_ou_expose ($url, $text, $on=false, $class="", $title="", $rel="") :
This filter creates a link or a tag <strong class='on'>
note : class, title and rel are optional
usage ; [(#URL|lien_ou_expose{texte,condition_selection_on,class,title,rel})]
example : [(#GET{self}|parametre_url{type,public}|lien_ou_expose{<:onglet_messages_publics:>,#ENV{type,public}|=={public}})]
filtre_balise_img ($img, $alt="", $class="") :
This filter creates an <img> tag
usage : [(#CHEMIN{monimage.png}|balise_img)]
(the opposite of filtre_fichier())
filtre_icone ($link, $text, $template_name, $align="", $function="", $class="") :
This filter is a shortcut for creating icons in the templates of the private area
usage : [(#URL|icone{text,template_name,align,function,class})]
test_plugin_actif ('prefix_of_the_plugin') :
This function tests if a plugin is activated and returns a boolean.








