4 * (c) 2007-2009 Cedric Morin
5 * Distribue sous licence GPL
9 if (!defined("_ECRIRE_INC_VERSION")) return;
11 // lister les exec ou apparait l'interface de composition et le type correspondant
12 // peut etre etendu par des plugins
13 $GLOBALS['compositions_exec']['naviguer'] = 'rubrique';
14 $GLOBALS['compositions_exec']['articles'] = 'article';
15 $GLOBALS['compositions_exec']['mots_edit'] = 'mot';
16 $GLOBALS['compositions_exec']['sites'] = 'site';
17 $GLOBALS['compositions_exec']['breves_voir'] = 'breve';
18 $GLOBALS['compositions_exec']['auteur_infos'] = 'auteur';
21 * Fonction vide pour le pipeline homonyme
23 function compositions_autoriser(){}
26 * Autorisation de modifier la composition
28 * @param <type> $faire
35 function autoriser_styliser_dist($faire, $type='', $id=0, $qui = NULL, $opt = NULL){
36 include_spip('compositions_fonctions');
37 if (!autoriser('modifier',$type,$id,$qui,$opt))
39 if (compositions_verrouiller($type, $id) AND !autoriser('webmestre'))
46 * Pipeline styliser pour definir le fond d'un objet en fonction de sa composition
51 function compositions_styliser($flux){
52 include_spip('compositions_fonctions');
53 if (compositions_styliser_auto()){
54 if (!defined('_DIR_PLUGIN_Z')){
55 $type = $flux['args']['fond']; // on fait l'approximation fond=type
56 // si le type n'est pas l'objet d'une composition, ne rien faire
57 if (in_array($type,compositions_types())){
58 $contexte = isset($flux['args']['contexte'])?
$flux['args']['contexte']:$GLOBALS['contexte'];
59 $serveur = $flux['args']['connect'];
61 $ext = $flux['args']['ext'];
62 $_id_table = id_table_objet($type);
64 if ($id = $contexte[$_id_table] AND $composition = compositions_determiner($type,$id,$serveur)){
65 if ($fond = compositions_selectionner($composition, $type, '', $ext, true, "")){
66 $flux['data'] = substr($fond, 0, - strlen(".$ext"));
72 $contexte = isset($flux['args']['contexte'])?
$flux['args']['contexte']:$GLOBALS['contexte'];
73 if (!test_espace_prive()
74 AND preg_match(',(^|/)contenu/([^/]*)$,i',$flux['args']['fond'],$regs)
76 AND in_array($type,compositions_types())){
77 $serveur = $flux['args']['connect'];
79 $ext = $flux['args']['ext'];
80 $_id_table = id_table_objet($type);
82 if ($id = $contexte[$_id_table] AND $composition = compositions_determiner($type,$id,$serveur)){
83 if ($fond = compositions_selectionner($composition, $type, '', $ext, true, "")){
84 $flux['data'] = substr($fond, 0, - strlen(".$ext"));
94 * Affichage du formulaire de selection de la composition
99 function compositions_affiche_milieu($flux){
100 $exec = $flux['args']['exec'];
101 if (isset($GLOBALS['compositions_exec'][$exec])){
102 $type = $GLOBALS['compositions_exec'][$exec];
103 $_id = id_table_objet($type);
104 if ($id = $flux['args'][$_id]) {
105 $config = unserialize($GLOBALS['meta']['compositions']);
106 $aut = autoriser('styliser',$type,$id);
107 include_spip('compositions_fonctions');
108 if (($config['masquer_formulaire'] != 'oui' OR $aut)
109 AND (is_array(reset(compositions_lister_disponibles($type))) OR ($type == 'rubrique' AND $config['tout_verrouiller'] != 'oui'))
111 $deplie = $aut ?
false : -1;
112 $ids = 'formulaire_editer_composition_objet-' . "$type-$id";
113 $bouton = bouton_block_depliable(strtoupper(_T('compositions:composition')), $deplie, $ids);
114 $flux['data'] .= debut_cadre('e', chemin('compositions-24.png','images/'),'',$bouton, '', '', true);
115 $flux['data'] .= recuperer_fond('prive/editer/compositions', array_merge($_GET, array('type'=>$type,'id'=>$id)));
116 $flux['data'] .= fin_cadre();
124 function compositions_compositions_lister_disponibles($flux){return $flux;}