1 | <?php |
---|
2 | |
---|
3 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
4 | |
---|
5 | function selection_objet_affiche_gauche($flux) { |
---|
6 | include_spip('inc/config'); |
---|
7 | $objet = $flux["args"]["exec"]; |
---|
8 | /*Desactivé car il y a u problème avec les cadres et block_depliables dans l'inclure |
---|
9 | * //Exception pour les documents |
---|
10 | if($objet=='document_edit')$objet='document' ; */ |
---|
11 | $args=$flux['args']; |
---|
12 | |
---|
13 | $objets_selection=lire_config('selection_objet/selection_rubrique_objet',array()); |
---|
14 | $exceptions=charger_fonction('exceptions','inc'); |
---|
15 | $exception_objet=$exceptions('objet'); |
---|
16 | $objet_ancien=$objet; |
---|
17 | if($exception_objet[$objet]){ |
---|
18 | $objet=$exception_objet[$objet]; |
---|
19 | $table='spip_'.$objet; |
---|
20 | } |
---|
21 | else $table='spip_'.$objet.'s'; |
---|
22 | |
---|
23 | $contexte['id_objet']=$flux["args"]['id_'.$objet]?$flux["args"]['id_'.$objet]:_request('id_'.$objet); |
---|
24 | if(in_array($objet_ancien,$objets_selection)){ |
---|
25 | $contexte['objet']=$objet; |
---|
26 | $objets_cibles=lire_config('selection_objet/objets_cible',array()); |
---|
27 | if($objet=='rubrique' OR $objet=='article'){ |
---|
28 | $contexte['langue']=sql_getfetsel('lang',$table,'id_'.$objet.'='.$contexte['id_objet']); |
---|
29 | $contexte['lang'] = $contexte['langue']; |
---|
30 | } |
---|
31 | if($objet=='rubrique'){ |
---|
32 | if (!$trad_rub=test_plugin_actif('tradrub')) $contexte['langue']=lire_config('langues_multilingue'); |
---|
33 | elseif(!$contexte['langue']){ |
---|
34 | if(!$trad_rub=test_plugin_actif('tradrub')) $contexte['langue']=lire_config('langues_multilingue'); |
---|
35 | } |
---|
36 | } |
---|
37 | $contexte['objet_dest']=$objet_dest; |
---|
38 | $contexte['objets_cibles']=$objets_cibles; |
---|
39 | $flux["data"].= recuperer_fond("prive/squelettes/navigation/affiche_gauche", $contexte); |
---|
40 | } |
---|
41 | |
---|
42 | return $flux; |
---|
43 | } |
---|
44 | |
---|
45 | function selection_objet_affiche_milieu ($flux="") { |
---|
46 | include_spip('inc/config'); |
---|
47 | $objet = $flux["args"]["exec"]; |
---|
48 | //Exception pour les documents |
---|
49 | if($objet=='document_edit')$objet='document' ; |
---|
50 | $args=$flux["args"]; |
---|
51 | $objets_cibles=lire_config('selection_objet/objets_cible',array()); |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | if(in_array($objet,$objets_cibles)){ |
---|
56 | //Les tables non conforme |
---|
57 | $exceptions=charger_fonction('exceptions','inc'); |
---|
58 | $exception_objet=$exceptions(); |
---|
59 | if($exception_objet['objet'][$objet]){ |
---|
60 | $objet=$exception_objet['objet'][$objet]; |
---|
61 | $table='spip_'.$objet; |
---|
62 | } |
---|
63 | else $table='spip_'.$objet.'s'; |
---|
64 | if(!$champ_titre=$exception_objet['titre'][$objet]) $champ_titre='titre'; |
---|
65 | |
---|
66 | $id_objet=$args['id_'.$objet]; |
---|
67 | if($objet=='site')$id_objet=$args['id_syndic']; |
---|
68 | $data = $flux["data"]; |
---|
69 | $special=array('article','rubrique'); |
---|
70 | if(in_array($objet,$special)) $choisies= picker_selected(lire_config('selection_objet/selection_'.$objet.'_dest',array()),$objet); |
---|
71 | else $choisies=lire_config('selection_objet/selection_'.$objet.'_dest',array()); |
---|
72 | |
---|
73 | if(in_array($id_objet,$choisies) OR !$choisies){ |
---|
74 | $contexte = array('id_objet_dest'=>$id_objet,'objet_dest'=>$objet,'champ_titre'=>$champ_titre); |
---|
75 | $tables=lister_tables_objets_sql(); |
---|
76 | if($tables[$table]['field']['lang']) $contexte['langue']=array(sql_getfetsel('lang',$table,'id_'.$objet.'='.$id_objet)); |
---|
77 | elseif($objet!='document') $contexte['langue']=array($args['lang']); |
---|
78 | else $contexte['langue']=array(); |
---|
79 | if($objet=='rubrique'){ |
---|
80 | if (!$trad_rub=test_plugin_actif('tradrub')) $contexte['langue']=explode(',',lire_config('langues_multilingue')); |
---|
81 | } |
---|
82 | $flux["data"] .= recuperer_fond('prive/objets/liste/selection_interface', $contexte,array('ajax'=>'tableau_so')); |
---|
83 | } |
---|
84 | } |
---|
85 | return $flux; |
---|
86 | } |
---|
87 | |
---|
88 | function selection_objet_formulaire_charger($flux){ |
---|
89 | $form=$flux['args']['form']; |
---|
90 | if($form == 'configurer_selection_objet'){ |
---|
91 | //emprunté de a2a preparé les type_liens pour le formulaire |
---|
92 | include_spip('inc/config'); |
---|
93 | if(!$cfg['type_liens']=_request('type_liens')){ |
---|
94 | $types_lien=lire_config('selection_objet/type_liens',array()); |
---|
95 | $flux['data']['type_liens']=''; |
---|
96 | foreach ($types_lien as $key => $value) { |
---|
97 | if($key)$flux['data']['type_liens'].="$key,$value\n"; |
---|
98 | } |
---|
99 | |
---|
100 | } |
---|
101 | |
---|
102 | //également les type_liens_OBJET |
---|
103 | |
---|
104 | $objets_cibles=lire_config('selection_objet/objets_cible',array()); |
---|
105 | |
---|
106 | foreach($objets_cibles as $objet){ |
---|
107 | if($types_lien=lire_config('selection_objet/type_liens_'.$objet)){ |
---|
108 | $flux['data']['type_liens_'.$objet]=''; |
---|
109 | foreach ($types_lien as $key => $value) { |
---|
110 | if($key)$flux['data']['type_liens_'.$objet].="$key,$value\n"; |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | } |
---|
115 | } |
---|
116 | return $flux; |
---|
117 | } |
---|
118 | |
---|
119 | function selection_objet_formulaire_traiter($flux){ |
---|
120 | // Si on est sur le formulaire client qui est sur la page identification |
---|
121 | $form=$flux['args']['form']; |
---|
122 | if($form == 'configurer_selection_objet'){ |
---|
123 | include_spip('inc/config'); |
---|
124 | $cfg=lire_config('selection_objet'); |
---|
125 | $cfg['type_liens'] = types_liaisons2array(_request('type_liens')); |
---|
126 | |
---|
127 | if(!$objets_cibles=$cfg['objets_cible'])$objets_cibles=array(); |
---|
128 | |
---|
129 | foreach($objets_cibles as $objet){ |
---|
130 | if(_request('type_liens_'.$objet))$cfg['type_liens_'.$objet] = types_liaisons2array(_request('type_liens_'.$objet)); |
---|
131 | } |
---|
132 | |
---|
133 | ecrire_config('selection_objet',$cfg); |
---|
134 | } |
---|
135 | return $flux; |
---|
136 | } |
---|
137 | |
---|
138 | function selection_objet_jqueryui_plugins($scripts){ |
---|
139 | $scripts[] = 'jquery.ui.autocomplete'; |
---|
140 | $scripts[] = "jquery.ui.widget"; |
---|
141 | $scripts[] = "jquery.ui.mouse"; |
---|
142 | $scripts[] = "jquery.ui.sortable"; |
---|
143 | return $scripts; |
---|
144 | } |
---|
145 | |
---|
146 | function types_liaisons2array($type){ |
---|
147 | $tableau = array(); |
---|
148 | $lignes = explode("\n",$type); |
---|
149 | foreach ($lignes as $l){ |
---|
150 | $donnees= explode(',',$l); |
---|
151 | if ($donnees[1]) |
---|
152 | $tableau[trim($donnees[0])] = trim ($donnees[1]); |
---|
153 | else |
---|
154 | $tableau[trim($donnees[0])] = ''; |
---|
155 | } |
---|
156 | |
---|
157 | return $tableau; |
---|
158 | } |
---|
159 | ?> |
---|