router vers les /dist.html // ou scaffolding ou page automatique les contenus if (!$squelette){ // Cas de figure où on a déclaré type-composition.html dans un bloc, mais où type.html n'existe pas if (isset($flux['args']['contexte']['composition']) AND $dir = explode('/',$fond) AND $dir = reset($dir) AND in_array($dir,$z_blocs) AND $f=find_in_path($fond."-".$flux['args']['contexte']['composition'].".$ext")){ $flux['data'] = substr($f,0,-strlen(".$ext")); } // si on est sur un ?page=XX non trouve elseif ($flux['args']['contexte'][_SPIP_PAGE] == $fond OR $flux['args']['contexte']['type'] == $fond) { // si c'est un objet spip, associe a une table, utiliser le fond homonyme if (z_scaffoldable($fond)){ $flux['data'] = substr(find_in_path("objet.$ext"), 0, - strlen(".$ext")); } // sinon, brancher sur contenu/page-xx si elle existe // si on est sur un ?page=XX non trouve elseif ($flux['args']['contexte'][_SPIP_PAGE] == $fond) { $base = "$z_contenu/page-".$fond.".".$ext; if ($base = find_in_path($base)){ $flux['data'] = substr(find_in_path("page.$ext"), 0, - strlen(".$ext")); } } } // scaffolding : // si c'est un fond de contenu d'un objet en base // generer un fond automatique a la volee pour les webmestres elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu)+1)==0 AND include_spip('inc/autoriser') AND isset($GLOBALS['visiteur_session']['id_auteur']) // performance AND autoriser('webmestre')){ $type = substr($fond,strlen($z_contenu)+1); if ($is = z_scaffoldable($type)) $flux['data'] = z_scaffolding($type,$is[0],$is[1],$is[2],$ext); } // sinon, si on demande un fond non trouve dans un des autres blocs // et si il y a bien un contenu correspondant ou scaffoldable // se rabbatre sur le dist.html du bloc concerne else{ if ( $dir = explode('/',$fond) AND $dir = reset($dir) AND $dir !== $z_contenu AND in_array($dir,$z_blocs)){ $type = substr($fond,strlen("$dir/")); if (find_in_path("$z_contenu/$type.$ext") OR z_scaffoldable($type)) $flux['data'] = substr(find_in_path("$dir/dist.$ext"), 0, - strlen(".$ext")); } } $squelette = $flux['data']; } if ($fond=='body' AND substr($squelette,-strlen($fond))==$fond){ if (isset($flux['args']['contexte']['type']) AND ( (isset($flux['args']['contexte']['composition']) AND file_exists(($f=$squelette."-".$flux['args']['contexte']['type']."-".$flux['args']['contexte']['composition']).".$ext")) OR file_exists(($f=$squelette."-".$flux['args']['contexte']['type']).".$ext") )) $flux['data'] = $f; } // chercher le fond correspondant a la composition elseif (isset($flux['args']['contexte']['composition']) AND substr($squelette,-strlen($fond))==$fond AND $dir = explode('/',$fond) AND $dir = reset($dir) AND in_array($dir,$z_blocs) AND $f=find_in_path($fond."-".$flux['args']['contexte']['composition'].".$ext")){ $flux['data'] = substr($f,0,-strlen(".$ext")); } return $flux; } /** * Tester si un type est scaffoldable * cad si il correspond bien a un objet en base * * @staticvar array $scaffoldable * @param string $type * @return bool */ function z_scaffoldable($type){ static $scaffoldable = array(); if (isset($scaffoldable[$type])) return $scaffoldable[$type]; if (preg_match(',[^\w],',$type)) return $scaffoldable[$type] = false; if ($table = table_objet($type) AND $type == objet_type($table) AND $trouver_table = charger_fonction('trouver_table','base') AND ($desc = $trouver_table($table) OR $desc = $trouver_table($table_sql = $GLOBALS['table_prefix']."_$table")) ) return $scaffoldable[$type] = array($table,$desc['table'],$desc); else return $scaffoldable[$type] = false; } /** * Generer a la volee un fond a partir d'une table de contenu * * @param string $type * @param string $table * @param string $table_sql * @param array $desc * @param string $ext * @return string */ function z_scaffolding($type,$table,$table_sql,$desc,$ext){ include_spip('public/interfaces'); $primary = id_table_objet($type); if (!$primary AND isset($desc['key']["PRIMARY KEY"])){ $primary = $desc['key']["PRIMARY KEY"]; } // reperer un titre $titre = 'titre'; if (isset($GLOBALS['table_titre'][$table])){ $titre = explode(' ',$GLOBALS['table_titre'][$table]); $titre = explode(',',reset($titre)); $titre = reset($titre); } if (isset($desc['field'][$titre])){ unset($desc['field'][$titre]); $titre="

#".strtoupper($titre)."

"; } else $titre=""; // reperer une date $date = "date"; if (isset($GLOBALS['table_date'][$table])) $date = $GLOBALS['table_date'][$table]; if (isset($desc['field'][$date])){ unset($desc['field'][$date]); $date = strtoupper($date); $date="

[(#$date|nom_jour) ][(#$date|affdate)][, <:par_auteur:> (#LESAUTEURS)]

"; } else $date = ""; $content = array(); foreach($desc['field'] as $champ=>$z){ if (!in_array($champ,array('maj','statut','idx',$primary))){ $content[] = "[
$champ
(#".strtoupper($champ)."|image_reduire{500,0})
]"; } } $content = implode("\n\t",$content); $scaffold = "#CACHE{0} [(#REM) Fil d'Ariane ]

<:accueil_site:>[ > (#TITRE|couper{80})]

$titre $date
$content
[

<:info_notes:>

(#NOTES)
] "; $dir = sous_repertoire(_DIR_CACHE,"scaffold",false); $dir = sous_repertoire($dir,"contenu",false); $f = $dir."$type"; ecrire_fichier("$f.$ext",$scaffold); return $f; } /** * Surcharger les intertires avant que le core ne les utilise * pour y mettre la class h3 * une seule fois suffit ! * * @param string $flux * @return string */ function Z_pre_propre($flux){ static $init = false; if (!$init){ if (isset($GLOBALS['debut_intertitre']) and $GLOBALS['debut_intertitre']){ $intertitre = $GLOBALS['debut_intertitre']; $class = extraire_attribut($GLOBALS['debut_intertitre'],'class'); $class = ($class ? " $class":""); $GLOBALS['debut_intertitre'] = inserer_attribut($GLOBALS['debut_intertitre'], 'class', "h3$class"); foreach($GLOBALS['spip_raccourcis_typo'] as $k=>$v){ $GLOBALS['spip_raccourcis_typo'][$k] = str_replace($intertitre,$GLOBALS['debut_intertitre'],$GLOBALS['spip_raccourcis_typo'][$k]); } } else { $GLOBALS['debut_intertitre'] = '

'; $GLOBALS['fin_intertitre'] = '

'; } $init = true; } return $flux; } /** * Ajouter le inc-insert-head du theme si il existe * * @param string $flux * @return string */ function Z_insert_head($flux){ if (find_in_path('inc-insert-head.html')){ $flux .= recuperer_fond('inc-insert-head',array()); } return $flux; } // // fonction standard de calcul de la balise #INTRODUCTION // mais retourne toujours dans un

comme propre // // http://doc.spip.org/@filtre_introduction_dist if (!function_exists('filtre_introduction')){ // securite function filtre_introduction($descriptif, $texte, $longueur, $connect) { include_spip('public/composer'); $texte = filtre_introduction_dist($descriptif, $texte, $longueur, $connect); if ($GLOBALS['toujours_paragrapher'] AND strpos($texte,"

")===FALSE) // Fermer les paragraphes ; mais ne pas en creer si un seul $texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']); return $texte; } } /** * Tester la presence sur une page * @param object $p * @return object */ if (!function_exists('balise_SI_PAGE_dist')){ function balise_SI_PAGE_dist($p) { $_page = interprete_argument_balise(1,$p); $p->code = "(((\$Pile[0][_SPIP_PAGE]==(\$zp=$_page)) OR (\$Pile[0]['composition']==\$zp AND \$Pile[0]['type']=='page'))?' ':'')"; $p->interdire_scripts = false; return $p; } } ?>