Notes of a geek on SPIP

define(SPIP): A powerfull CMS that rocks !

Subscribe to RSS feed

Posts tagged with "private area"

The latest filters and pipelines for programmers

, , , ...

The 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 <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.

[Howto] Control of the uploaded picture size

,

You can limit the size of the uploaded pictures with the constants (in mes_options.php) :
define('_IMG_MAX_SIZE', 0); # size in Kb
define('_IMG_MAX_WIDTH', 0); # width in pixels 
define('_IMG_MAX_HEIGHT', 0); # height in pixels

For documents it's :
define('_DOC_MAX_SIZE', 0); # size in Kb

If the limitations are not respected, the upload is aborted and an error message is displayed

[11922] Customize the keyword box in the private area

, , ,

With this commit, some keyword groups can be displayed/hidden in specific sections.
The customization can be done with autoriser_xxx_editermots($action,$what,$id,$who,$opts.
$opts contains the id of the concerned keyword group, and also the fields of this group that can be displayed.
By default, the function only checks if the author is authorized to this group.

Easter egg on the private area

, ,

"You can even create a specific template in the private area.
For exemple, this template

/squelette/prive/editer/article-23.html

is used to edit articles which are in the section number 23 (and it's subsections)
(works also to display them)"

from http://thread.gmane.org/gmane.comp.web.spip.devel/46774/focus=46786

#URL_ECRIRE just discovered

, ,

I barely know what #URL_PAGE is.
But not #URL_ECRIRE,.. until today wink

This helper, like #URL_ACTION_AUTEUR, enables us to link your website to the private area.

#URL_ECRIRE{naviguer}
returns ecrire/?exec=naviguer

#URL_ECRIRE{naviguer, args}
returns ecrire/?exec=naviguer&args
(it's like #URL_PAGE in fact)

#URL_ACTION_AUTEUR{converser,args,redirectme}
returns ecrire/?action=converser&args&hash=xxx&redirect=redirectme

Combined with a filter like |parametre_url, you can do whatever you want :

For example :

<a href="#URL_PAGE{identifiants,focus=nom_inscription}&mode=(#URL_SITE_SPIP|tester_config{1comite})"
(in dist/login.html)
that returns <a href="spip.php?page=identifiants&focus=nom_inscription&mode=.."

It should possible to write
#URL_ECRIRE{forum_envoi,statut=prive&id=363&script=articles#formulaire}

but you can also use this :
[(#URL_PAGE{my_backend}|parametre_url{id_mot,#ID_MOT}|parametre_url{id_rubrique,#_:ID_RUBRIQUE})]
to generate <a href="spip.php?page=my_backend&id_mot=32&id_rubrique&..


Any idea about what to do about it ? smile

FAQ : I want to update the url value after having changed the title of my article

, , ,

Long title for a frequent problem wink .

when a title of an article is changed, the url isn't automatically recalculated.

It's interresting if you don't want to lost backlinks, but it can be disturbing because the url may not correspond to the content of the linked page.

Here is the trick : Just clic on the link 'See online' when you display the article inside the private area. It will not only clear the cached content for this page, but it will also force the url to be recalculated according to the title field.

[10805] private area : object pages in templates

, , ,

Big change in the private area API :

afficher_contenu_objet() is simplified and know uses a customizable template for every (standard?) table.
The result of this template uses a pipeline ('afficher_contenu_objet'), and so plugins can modify it .

This commit creates a directory 'dist/contenu/' that contains article.html, breve.html, etc.
Really usefull for customisation of the private area, no ?

[10829] scaffolding for every table

,

Scaffolding is a great feature that enables to view the content of the non-standard spip tables.
When you are the website admin (member of _ID_WEBMESTRES), you can write :
http...?page=table:tableName

Actually, it's still minimal but quite functionnal :
- a table with as many columns as of the SQL table fields
- The tag #PAGINATION enables to scroll lines per block of ten
- The first (or last) row of a table enables the table to be sorted depending on the selected column, either ascending or descending order. The field type is taken into account in this order.
- The url can filter one or more values for every field, simply by specifying "&fieldname=.."
- For each field described in SQL as a reference to another table, a link to another scaffolding for this table is specified.

source : [10996] and [10645]