1 | <?php |
---|
2 | # ACS |
---|
3 | # (Plugin Spip) |
---|
4 | # http://acs.geomaticien.org |
---|
5 | # |
---|
6 | # Copyright Daniel FAIVRE, 2007-2011 |
---|
7 | # Copyleft: licence GPL - Cf. LICENCES.txt |
---|
8 | |
---|
9 | include_spip('inc/acs_groups'); |
---|
10 | include_spip('inc/acs_version'); |
---|
11 | |
---|
12 | /** |
---|
13 | * Retourne la page d'admin "Pages" |
---|
14 | */ |
---|
15 | |
---|
16 | function acs_adm() { |
---|
17 | if (isset($_POST['changer_model']) && ($_POST['changer_model'] == 'oui')) { |
---|
18 | if ( |
---|
19 | ($GLOBALS['meta']['acsModel'] != $_POST['acsModel']) || |
---|
20 | ($GLOBALS['meta']['acsSqueletteOverACS'] != $_POST['acsSqueletteOverACS']) |
---|
21 | ) { |
---|
22 | ecrire_meta('acsModel', $_POST['acsModel']); |
---|
23 | ecrire_meta('acsSqueletteOverACS', $_POST['acsSqueletteOverACS']); |
---|
24 | $GLOBALS['dossier_squelettes'] = (isset($GLOBALS['meta']['acsSqueletteOverACS']) ? $GLOBALS['meta']['acsSqueletteOverACS'].':' : '')._DIR_PLUGIN_ACS.'models/'.$_POST['acsModel']; |
---|
25 | ecrire_metas(); |
---|
26 | } |
---|
27 | } |
---|
28 | if (isset($_POST['changer_groupes']) && ($_POST['changer_groupes'] == 'oui')) { |
---|
29 | acs_groups_update($_POST['acsGroups']); |
---|
30 | } |
---|
31 | if (isset($_POST['changer_pages']) && ($_POST['changer_pages'] == 'oui')) |
---|
32 | acs_group_update_pages(acs_grid($_POST['group']), $_POST['pages']); |
---|
33 | if (isset($_POST['changer_config']) && ($_POST['changer_config'] == 'oui')) { |
---|
34 | ecrire_meta('ACS_VOIR_PAGES_COMPOSANTS', $_POST['ACS_VOIR_PAGES_COMPOSANTS']); |
---|
35 | ecrire_meta('ACS_VOIR_PAGES_PREVIEW', $_POST['ACS_VOIR_PAGES_PREVIEW']); |
---|
36 | ecrire_meta('ACS_VOIR_ONGLET_VARS', $_POST['ACS_VOIR_ONGLET_VARS']); |
---|
37 | ecrire_meta('ACS_PREVIEW_BACKGROUND', $_POST['ACS_PREVIEW_BACKGROUND']); |
---|
38 | ecrire_metas(); |
---|
39 | } |
---|
40 | |
---|
41 | $r = acs_box(_T('acs:model').' '._T('acs:acs'), |
---|
42 | acs_model() |
---|
43 | , |
---|
44 | _DIR_PLUGIN_ACS.'images/composant-24.gif' |
---|
45 | ); |
---|
46 | /* |
---|
47 | echo "<br>_______________________________________________\$_POST<br>\n"; |
---|
48 | print_r($_POST); |
---|
49 | |
---|
50 | echo "<br>_______________________________________________\$GLOBALS['meta']['ACS_GROUPS']<br>\n"; |
---|
51 | print_r(unserialize($GLOBALS['meta']['ACS_GROUPS'])); |
---|
52 | |
---|
53 | echo "<br>_______________________________________________\$GLOBALS['meta']['ACS_CADENASSE']<br>\n"; |
---|
54 | print_r(unserialize($GLOBALS['meta']['ACS_CADENASSE'])); |
---|
55 | */ |
---|
56 | |
---|
57 | |
---|
58 | // Sauvegarde/restauration |
---|
59 | $acs_sr = charger_fonction('acs_sr', 'inc'); |
---|
60 | $res = ajax_action_greffe("acs_sr", 0, $acs_sr()); |
---|
61 | $r.= '<br />'.acs_box(_T('acs:save').' / '._T('acs:restore'), $res, _DIR_PLUGIN_ACS.'images/sr.png'); |
---|
62 | |
---|
63 | // Bloc des admins |
---|
64 | $editer_acs_admins = charger_fonction('acs_editer_admins', 'inc'); |
---|
65 | $groups = acs_groups(); |
---|
66 | $blocs_cadenas = ''; |
---|
67 | foreach (array_keys($groups) as $grid=>$gr) { |
---|
68 | $ids = implode(',', acs_members($gr)); |
---|
69 | $blocs_cadenas .= $editer_acs_admins('acsadmins', $grid + 1, true, false, $ids, _T('acs:admins').' '.$gr, 'acs&onglet=adm','auteur-24.gif'); |
---|
70 | } |
---|
71 | |
---|
72 | $r .= $editer_acs_admins('acsadmins', 0, true, false, 1, _T('acs:admins').' '._T('acs:acs'), 'acs&onglet=adm',_DIR_PLUGIN_ACS.'images/cadenas-24.gif'). |
---|
73 | '<br />'. |
---|
74 | acs_box(_T('acs:adm').' '._T('acs:acs'), |
---|
75 | '<form name="acs_config" action="?exec=acs" method="post">'. |
---|
76 | '<input type="hidden" name="onglet" value="adm"><input type="hidden" name="changer_groupes" value="oui">'. |
---|
77 | '<table style="width:100%" cellpadding="2px"><tr><td style="width:90%;" >'. |
---|
78 | ctlInput('acsGroups', |
---|
79 | _T('acs:groupes'), |
---|
80 | '<input type="text" name="acsGroups" value="'.implode(', ', array_keys(acs_groups())).'" class="forml" style="width:100%" />' |
---|
81 | ). |
---|
82 | '</td><td style="text-align:'.$GLOBALS['spip_lang_right'].';"><input type="submit" name="'._T('bouton_valider'). |
---|
83 | '" value="'._T('bouton_valider').'" class="fondo" /></td></tr></table>'. |
---|
84 | '</form>'. |
---|
85 | $blocs_cadenas |
---|
86 | , |
---|
87 | _DIR_PLUGIN_ACS.'images/cadenas_gris-24.gif' |
---|
88 | ); |
---|
89 | return $r; |
---|
90 | } |
---|
91 | |
---|
92 | function acs_adm_gauche() { |
---|
93 | return acs_info_box( |
---|
94 | _T('acs:adm'), |
---|
95 | _T('acs:onglet_adm_description').'<br /><br />', |
---|
96 | _T('acs:onglet_adm_help'), |
---|
97 | _T('acs:onglet_adm_info').'<br /><br />', |
---|
98 | _DIR_PLUGIN_ACS."images/cadenas-24.gif", |
---|
99 | false |
---|
100 | ); |
---|
101 | } |
---|
102 | |
---|
103 | function acs_adm_droite() { |
---|
104 | return acs_box( |
---|
105 | _T('acs:acs'), |
---|
106 | '<form name="acs_config" action="?exec=acs&onglet=adm" method="post"> |
---|
107 | <input type="hidden" name="changer_config" value="oui"> |
---|
108 | <input name="ACS_VOIR_ONGLET_VARS" type="checkbox"'. |
---|
109 | ($GLOBALS['meta']['ACS_VOIR_ONGLET_VARS'] ? ' checked' : '').' />'. |
---|
110 | _T('acs:voir_onglet_vars'). |
---|
111 | '<br /><input name="ACS_VOIR_PAGES_COMPOSANTS" type="checkbox"'. |
---|
112 | ($GLOBALS['meta']['ACS_VOIR_PAGES_COMPOSANTS'] ? ' checked' : '').' />'. |
---|
113 | _T('acs:voir_pages_composants'). |
---|
114 | '<br /> |
---|
115 | <input name="ACS_VOIR_PAGES_PREVIEW" type="checkbox"'. |
---|
116 | ($GLOBALS['meta']['ACS_VOIR_PAGES_PREVIEW'] ? ' checked' : '').' />' |
---|
117 | ._T('acs:voir_pages_preview_composants').' |
---|
118 | <br /> |
---|
119 | <table><tr><td><input name="ACS_PREVIEW_BACKGROUND" type="text" class="palette forml" style="width:60px;" value="'.$GLOBALS['meta']['ACS_PREVIEW_BACKGROUND'].'" /></td><td>'._T('acs:preview_background').'</td></tr></table> |
---|
120 | <br /> |
---|
121 | <div style="text-align:'.$GLOBALS['spip_lang_right'].';"><input type="submit" name="'._T('bouton_valider').'" value="'._T('bouton_valider').'" class="fondo" /></div></form><br />'. |
---|
122 | _T('acs:acsDerniereModif').' '.date("Y-m-d H:i:s", lire_meta("acsDerniereModif")). |
---|
123 | '<hr />'. |
---|
124 | _T('version').' <a style="color: black">ACS '.acs_version().'</a> '.(acs_release() ? '('.acs_release().')' : ''). |
---|
125 | '<br />'. |
---|
126 | _T('acs:documentation').': <a href="http://acs.geomaticien.org" target="_new"><img src="'._DIR_PLUGIN_ACS.'images/acs_32x32_help.gif" alt="?" style="vertical-align: middle"/></a>', _DIR_PLUGIN_ACS."images/acs_32x32.gif"); |
---|
127 | } |
---|
128 | |
---|
129 | function acs_model() { |
---|
130 | $r = '<form name="acs_model" action="?exec=acs" method="post">'. |
---|
131 | '<input type="hidden" name="onglet" value="adm"><input type="hidden" name="changer_model" value="oui">'; |
---|
132 | $r .= '<table width="100%"><tr><td>'.ctlInput('acsModel', _T('acs:model'), select_model()); |
---|
133 | $r .= '</td><td>'.ctlInput('acsSqueletteOverACS', _T('acs:squelette'), '<input type="text" name="acsSqueletteOverACS" value="'.$GLOBALS['meta']['acsSqueletteOverACS'].'" class="forml" />').'</td></tr></table><br />'; |
---|
134 | |
---|
135 | $r .= '<div style="text-align:'.$GLOBALS['spip_lang_right'].';"><input type="submit" name="'._T('bouton_valider'). |
---|
136 | '" value="'._T('bouton_valider').'" class="fondo" /></div></form>'; |
---|
137 | return $r; |
---|
138 | } |
---|
139 | |
---|
140 | function ctlInput($nom, $txt, $content) { |
---|
141 | return '<table width="100%"><tr><td style="width: 10%; text-align:'.$GLOBALS['spip_lang_right'].'"><label for "'.$nom.'" title="'.$nom.'" class="label">'.$txt.'</label></td><td>'.$content.'</td></tr></table>'; |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | * Retourne un sélecteur de squelette, |
---|
146 | */ |
---|
147 | function select_model() { |
---|
148 | $r = '<select name="acsModel" class="forml">'; |
---|
149 | foreach(list_models() as $sq) |
---|
150 | $r .= '<option name="'.$sq.'" value="'.$sq.'"'.(($sq == $GLOBALS['meta']['acsModel']) ? ' selected': '').'>'.$sq.'</option>'; |
---|
151 | $r .= '</select>'; |
---|
152 | return $r; |
---|
153 | } |
---|
154 | |
---|
155 | /** |
---|
156 | * Lit la liste des modèles de squelettes |
---|
157 | */ |
---|
158 | function list_models(){ |
---|
159 | $squelettes = array(); |
---|
160 | if ($d = @opendir(_DIR_PLUGIN_ACS.'models')) { |
---|
161 | while (false !== ($file = @readdir($d))) { |
---|
162 | if ($file != "." && $file != ".." && substr($file, 0, 1) != '.' && @is_dir(_DIR_PLUGIN_ACS.'models/'.$file)) { |
---|
163 | $squelettes[] = $file; |
---|
164 | } |
---|
165 | } |
---|
166 | closedir($d); |
---|
167 | sort($squelettes); |
---|
168 | return $squelettes; |
---|
169 | } |
---|
170 | else { |
---|
171 | return 'Impossible d\'ouvrir le dossier de modeles "'._DIR_PLUGIN_ACS.'models"'; |
---|
172 | } |
---|
173 | } |
---|
174 | |
---|
175 | ?> |
---|