Changeset 35805 in spip-zone


Ignore:
Timestamp:
Mar 4, 2010, 9:47:48 PM (14 years ago)
Author:
cedric@…
Message:

2 evolutions :

  • la liste des blocs qui constituent Z est personalisable par la globale z_blocs. Le premier bloc est celui qui pilote les autres, soit par defaut :

$GLOBALSz_blocs? = array('contenu','navigation','extra','head');

  • une balise #SI_PAGE qui permet de tester facilement dans les squelettes internes que l'on est sur une page donnee (sans tester type et composition).

Ex : [(#SI_PAGE{sommaire}) Hop ! ]

Un test
Increment de la version

Location:
_squelettes_/zpip
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • _squelettes_/zpip/plugin.xml

    r35062 r35805  
    44        <icon>img/zpip-128.png</icon>
    55        <licence>GNU/GPL</licence>
    6         <version>1.3.0</version>
     6        <version>1.4.0</version>
    77        <etat>stable</etat>
    88        <description>
  • _squelettes_/zpip/z_pipelines.php

    r35542 r35805  
    2020 */
    2121function Z_styliser($flux){
    22         $dir_dist = array('navigation','extra','head');
     22        $z_blocs = isset($GLOBALS['z_blocs'])?$GLOBALS['z_blocs']:array('contenu','navigation','extra','head');
     23        $contenu = array_shift($z_blocs); // contenu par defaut
    2324
    2425        $squelette = $flux['data'];
     
    2627                AND $fond = $flux['args']['fond']
    2728                AND $ext = $flux['args']['ext']){
    28                 if ($flux['args']['contexte'][_SPIP_PAGE] == $fond) {
     29
     30                // si on est sur un ?page=XX non trouve
     31          if ($flux['args']['contexte'][_SPIP_PAGE] == $fond) {
    2932                        // si c'est un objet spip, associe a une table, utiliser le fond homonyme
    3033                        if (z_scaffoldable($fond)){
    3134                                $flux['data'] = substr(find_in_path("objet.$ext"), 0, - strlen(".$ext"));
    3235                        }
     36                        // sinon, si brancher sur contenu/page-xx si elle existe
    3337                        else {
    34                                 $base = "contenu/page-".$fond.".".$ext;
     38                                $base = "$contenu/page-".$fond.".".$ext;
    3539                                if ($base = find_in_path($base)){
    3640                                        $flux['data'] = substr(find_in_path("page.$ext"), 0, - strlen(".$ext"));
     
    3842                        }
    3943                }
     44
    4045                // scaffolding :
    41                 // si c'est un fond de contenu d'un objet spip
     46                // si c'est un fond de contenu d'un objet en base
    4247                // generer un fond automatique a la volee pour les webmestres
    43                 elseif (strncmp($fond, "contenu/", 8)==0
     48                elseif (strncmp($fond, "$contenu/", strlen($contenu)+1)==0
    4449                        AND include_spip('inc/autoriser')
     50                        AND isset($GLOBALS['visiteur_session']['id_auteur']) // performance
    4551                        AND autoriser('webmestre')){
    46                         $type = substr($fond,8);
     52                        $type = substr($fond,strlen($contenu)+1);
    4753                        if ($is = z_scaffoldable($type))
    4854                                $flux['data'] = z_scaffolding($type,$is[0],$is[1],$is[2],$ext);
    4955                }
     56
     57                // sinon, si on demande un fond non trouve dans un des autres blocs
     58                // et si il y a bien un contenu correspondant ou scaffoldable
     59                // se rabbatre sur le dist.html du bloc concerne
    5060                else{
    5161                        if ( $dir = explode('/',$fond)
    5262                                AND $dir = reset($dir)
    53                                 AND in_array($dir,$dir_dist)){
     63                                AND in_array($dir,$z_blocs)){
    5464                                $type = substr($fond,strlen("$dir/"));
    55                                 if (find_in_path("contenu/$type.$ext") OR z_scaffoldable($type))
     65                                if (find_in_path("$contenu/$type.$ext") OR z_scaffoldable($type))
    5666                                        $flux['data'] = substr(find_in_path("$dir/dist.$ext"), 0, - strlen(".$ext"));
    5767                        }
     
    6979}
    7080
     81/**
     82 * Tester si un type est scaffoldable
     83 * cad si il correspond bien a un objet en base
     84 *
     85 * @staticvar array $scaffoldable
     86 * @param string $type
     87 * @return bool
     88 */
    7189function z_scaffoldable($type){
    7290        static $scaffoldable = array();
     
    84102                return $scaffoldable[$type] = false;
    85103}
     104
     105
     106/**
     107 * Generer a la volee un fond a partir d'une table de contenu
     108 *
     109 * @param string $type
     110 * @param string $table
     111 * @param string $table_sql
     112 * @param array $desc
     113 * @param string $ext
     114 * @return string
     115 */
    86116function z_scaffolding($type,$table,$table_sql,$desc,$ext){
    87117        include_spip('public/interfaces');
     
    173203}
    174204
     205/**
     206 * Ajouter le inc-insert-head du theme si il existe
     207 *
     208 * @param string $flux
     209 * @return string
     210 */
    175211function Z_insert_head($flux){
    176212        if (find_in_path('inc-insert-head.html')){
     
    238274}
    239275
     276/**
     277 * Tester la presence sur une page
     278 * @param <type> $p
     279 * @return <type>
     280 */
     281function balise_SI_PAGE_dist($p) {
     282        $_page = interprete_argument_balise(1,$p);
     283        $p->code = "(((\$Pile[0][_SPIP_PAGE]==(\$zp=$_page)) OR (\$Pile[0]['composition']==\$zp AND \$Pile[0]['type']=='page'))?' ':'')";
     284        $p->interdire_scripts = false;
     285        return $p;
     286}
     287
    240288?>
Note: See TracChangeset for help on using the changeset viewer.