⇒ http://my.opera.com/tech-nova/blog/
Un site qui recense les astuces et évolutions des possibilités de SPIP.
The latest filters and pipelines for programmers
Janvier 2009, par tech-novaThe SPIP team is really active and improve it regularly.
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
note : class, title and rel are optional
usage ;
example :
filtre_balise_img ($img, $alt=« », $class=« ») :
This filter creates an tag
usage :
(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 :
test_plugin_actif (’prefix_of_the_plugin’) :
This function tests if a plugin is activated and returns a boolean.
→ Lire la suite sur le site d’origine…