1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | global $template, $conf, $user; |
---|
4 | include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php'); |
---|
5 | load_language('plugin.lang', meta_PATH); |
---|
6 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
7 | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | Check Access and exit when user status is not ok | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | check_status(ACCESS_ADMINISTRATOR); |
---|
12 | |
---|
13 | //-------------------------------------------------------- sections definitions |
---|
14 | |
---|
15 | // Gestion des onglets |
---|
16 | if (!isset($_GET['tab'])) |
---|
17 | $page['tab'] = 'gestion'; |
---|
18 | else |
---|
19 | $page['tab'] = $_GET['tab']; |
---|
20 | |
---|
21 | $tabsheet = new tabsheet(); |
---|
22 | $tabsheet->add('gestion', |
---|
23 | l10n('meta_onglet_gestion'), |
---|
24 | $my_base_url.'&tab=gestion'); |
---|
25 | $tabsheet->add('categorie', |
---|
26 | l10n('meta_onglet_categorie'), |
---|
27 | $my_base_url.'&tab=categorie'); |
---|
28 | $tabsheet->add('image', |
---|
29 | l10n('meta_onglet_image'), |
---|
30 | $my_base_url.'&tab=image'); |
---|
31 | $tabsheet->add('description', |
---|
32 | l10n('meta_onglet_description'), |
---|
33 | $my_base_url.'&tab=description'); |
---|
34 | $tabsheet->select($page['tab']); |
---|
35 | $tabsheet->assign(); |
---|
36 | |
---|
37 | // Onglet gestion des meta |
---|
38 | switch ($page['tab']) |
---|
39 | { |
---|
40 | case 'gestion': |
---|
41 | |
---|
42 | //charge la liste des meta |
---|
43 | $groups = array(); |
---|
44 | $query = ' |
---|
45 | select id,metaname |
---|
46 | FROM ' . meta_TABLE . ' |
---|
47 | ORDER BY metaname ASC;'; |
---|
48 | $result = pwg_query($query); |
---|
49 | |
---|
50 | while ($row = mysql_fetch_array($result)) |
---|
51 | { |
---|
52 | $groups[$row['id']] = $row['metaname']; |
---|
53 | } |
---|
54 | |
---|
55 | $selected = 0; |
---|
56 | $options[] = l10n('meta_select2'); |
---|
57 | $options['a'] = '----------------------'; |
---|
58 | |
---|
59 | |
---|
60 | foreach ($groups as $metalist => $metalist2) |
---|
61 | { |
---|
62 | $options[$metalist] = $metalist2; |
---|
63 | } |
---|
64 | $template->assign( |
---|
65 | 'gestionA', |
---|
66 | array( |
---|
67 | 'OPTIONS' => $options, |
---|
68 | 'SELECTED' => $selected |
---|
69 | )); |
---|
70 | |
---|
71 | |
---|
72 | //edit de meta |
---|
73 | if (isset($_POST['submitchoixmeta']) and is_numeric($_POST['metalist']) and (!$_POST['metalist'])==0 and !is_adviser()) |
---|
74 | { |
---|
75 | $lire=$_POST['metalist']; |
---|
76 | $query = ' |
---|
77 | select id,metaname,metaval |
---|
78 | FROM ' . meta_TABLE . ' |
---|
79 | WHERE id = \''.$lire.'\' |
---|
80 | ;'; |
---|
81 | $result = pwg_query($query); |
---|
82 | |
---|
83 | $row = mysql_fetch_array($result); |
---|
84 | $chname=$row['metaname']; |
---|
85 | $chval=$row['metaval']; |
---|
86 | |
---|
87 | $selected2 = ""; |
---|
88 | |
---|
89 | $template->assign( |
---|
90 | 'meta_edit', |
---|
91 | array( |
---|
92 | 'VALUE' => $chname, |
---|
93 | 'CONTENT' => $chval, |
---|
94 | 'SELECTED' => $selected2 |
---|
95 | )); |
---|
96 | } |
---|
97 | |
---|
98 | //insértion de meta dans la table |
---|
99 | if (isset($_POST['submitinsmeta']) and !is_adviser()) |
---|
100 | { |
---|
101 | $query = ' |
---|
102 | UPDATE ' . meta_TABLE . ' |
---|
103 | SET metaval= \''.$_POST['inser'].'\' |
---|
104 | WHERE metaname = \''.$_POST['invisible'].'\' |
---|
105 | ;'; |
---|
106 | $result = pwg_query($query); |
---|
107 | } |
---|
108 | |
---|
109 | break; |
---|
110 | |
---|
111 | // Onglet gestion des meta categorie |
---|
112 | case 'categorie': |
---|
113 | |
---|
114 | //charge la liste des catégories |
---|
115 | $groups = array(); |
---|
116 | $query = ' |
---|
117 | select id,name |
---|
118 | FROM ' . CATEGORIES_TABLE . ' |
---|
119 | ORDER BY id ASC;'; |
---|
120 | $result = pwg_query($query); |
---|
121 | |
---|
122 | while ($row = mysql_fetch_array($result)) |
---|
123 | { |
---|
124 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
125 | } |
---|
126 | |
---|
127 | $selected = 0; |
---|
128 | $options[] = l10n('meta_select3'); |
---|
129 | $options['a'] = '----------------------'; |
---|
130 | |
---|
131 | foreach($groups as $listid => $listid2) |
---|
132 | { |
---|
133 | $options[$listid] = $listid2; |
---|
134 | } |
---|
135 | $template->assign( |
---|
136 | 'gestionB', |
---|
137 | array( |
---|
138 | 'OPTIONS' => $options, |
---|
139 | 'SELECTED' => $selected |
---|
140 | )); |
---|
141 | |
---|
142 | |
---|
143 | //edit de categorie |
---|
144 | if (isset($_POST['submitchoixcat'])and is_numeric($_POST['metacat']) and (!$_POST['metacat'])==0 and !is_adviser()) |
---|
145 | { |
---|
146 | $lire=$_POST['metacat']; |
---|
147 | $query = ' |
---|
148 | select id,name,comment |
---|
149 | FROM ' . CATEGORIES_TABLE . ' |
---|
150 | WHERE id = \''.$lire.'\' |
---|
151 | ;'; |
---|
152 | $result = pwg_query($query); |
---|
153 | |
---|
154 | $row = mysql_fetch_array($result); |
---|
155 | $idcat=$row['id']; |
---|
156 | $chnamecat=$row['name']; |
---|
157 | $chdescat=$row['comment']; |
---|
158 | $query = ' |
---|
159 | select id,metaKeycat,metadescat |
---|
160 | FROM ' . meta_cat_TABLE . ' |
---|
161 | WHERE id = \''.$lire.'\' |
---|
162 | ;'; |
---|
163 | $result = pwg_query($query); |
---|
164 | $row = mysql_fetch_array($result); |
---|
165 | $idmetaKeycat=$row['id']; |
---|
166 | $chvalcat=$row['metaKeycat']; |
---|
167 | $chvalcatdes=$row['metadescat']; |
---|
168 | |
---|
169 | $selected3 = 0; |
---|
170 | |
---|
171 | $template->assign( |
---|
172 | 'cat_edit', |
---|
173 | array( |
---|
174 | 'DESC' => $chdescat, |
---|
175 | 'VALUE' => $idcat, |
---|
176 | 'VALUEN' => $chnamecat, |
---|
177 | 'CONTENT' => $chvalcat, |
---|
178 | 'CONTENT2' => $chvalcatdes, |
---|
179 | 'SELECTED' => $selected3 |
---|
180 | )); |
---|
181 | } |
---|
182 | |
---|
183 | //insértion de meta de cat dans la table meta_cat |
---|
184 | if (isset($_POST['submitinscat']) and !is_adviser()) |
---|
185 | { |
---|
186 | $query = ' |
---|
187 | DELETE |
---|
188 | FROM ' . meta_cat_TABLE . ' |
---|
189 | WHERE id = \''.$_POST['invisible'].'\' |
---|
190 | ;'; |
---|
191 | $result = pwg_query($query); |
---|
192 | $q = ' |
---|
193 | INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES ('.$_POST['invisible'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
194 | pwg_query($q); |
---|
195 | } |
---|
196 | |
---|
197 | break; |
---|
198 | |
---|
199 | // Onglet gestion des meta keywords images |
---|
200 | case 'image': |
---|
201 | |
---|
202 | //charge la liste des images |
---|
203 | $groups = array(); |
---|
204 | $query = ' |
---|
205 | select id,name |
---|
206 | FROM ' . IMAGES_TABLE . ' |
---|
207 | ORDER BY id ASC;'; |
---|
208 | $result = pwg_query($query); |
---|
209 | |
---|
210 | while ($row = mysql_fetch_array($result)) |
---|
211 | { |
---|
212 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
213 | } |
---|
214 | |
---|
215 | $selected = 0; |
---|
216 | $options[] = l10n('meta_selecti3'); |
---|
217 | $options['a'] = '----------------------'; |
---|
218 | |
---|
219 | foreach($groups as $listid => $listid2) |
---|
220 | { |
---|
221 | $options[$listid] = $listid2; |
---|
222 | } |
---|
223 | $template->assign( |
---|
224 | 'gestionC', |
---|
225 | array( |
---|
226 | 'OPTIONS' => $options, |
---|
227 | 'SELECTED' => $selected |
---|
228 | )); |
---|
229 | |
---|
230 | //edit de la meta l'image |
---|
231 | if (isset($_POST['submitchoiximg'])and is_numeric($_POST['metaimg']) and (!$_POST['metaimg'])==0 and !is_adviser()) |
---|
232 | { |
---|
233 | $lire=$_POST['metaimg']; |
---|
234 | $query = ' |
---|
235 | select id,name,comment,path |
---|
236 | FROM ' . IMAGES_TABLE . ' |
---|
237 | WHERE id = \''.$lire.'\' |
---|
238 | ;'; |
---|
239 | $result = pwg_query($query); |
---|
240 | |
---|
241 | $row = mysql_fetch_array($result); |
---|
242 | $idimg=$row['id']; |
---|
243 | $chnameimg=$row['name']; |
---|
244 | $chdescimg=$row['comment']; |
---|
245 | $rootimg=$row['path']; |
---|
246 | |
---|
247 | $query = ' |
---|
248 | select id,metaKeyimg,metadesimg |
---|
249 | FROM ' . meta_img_TABLE . ' |
---|
250 | WHERE id = \''.$lire.'\' |
---|
251 | ;'; |
---|
252 | $result = pwg_query($query); |
---|
253 | $row = mysql_fetch_array($result); |
---|
254 | $idmetaKeyimg=$row['id']; |
---|
255 | $chvalimg=$row['metaKeyimg']; |
---|
256 | $chvalimgdes=$row['metadesimg']; |
---|
257 | |
---|
258 | $selected3 = 0; |
---|
259 | |
---|
260 | $template->assign( |
---|
261 | 'img_edit', |
---|
262 | array( |
---|
263 | 'RIMG' => $rootimg, |
---|
264 | 'DESC' => $chdescimg, |
---|
265 | 'VALUE' => $idimg, |
---|
266 | 'VALUEN' => $chnameimg, |
---|
267 | 'CONTENT' => $chvalimg, |
---|
268 | 'CONTENT2' => $chvalimgdes, |
---|
269 | 'SELECTED' => $selected3 |
---|
270 | )); |
---|
271 | } |
---|
272 | |
---|
273 | //insértion de meta img dans la table img |
---|
274 | if (isset($_POST['submitinsimg']) and !is_adviser()) |
---|
275 | { |
---|
276 | $query = ' |
---|
277 | DELETE |
---|
278 | FROM ' . meta_img_TABLE . ' |
---|
279 | WHERE id = \''.$_POST['invisible'].'\' |
---|
280 | ;'; |
---|
281 | $result = pwg_query($query); |
---|
282 | $q = ' |
---|
283 | INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES ('.$_POST['invisible'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
284 | pwg_query($q); |
---|
285 | } |
---|
286 | |
---|
287 | break; |
---|
288 | |
---|
289 | // Onglet description |
---|
290 | case 'description': |
---|
291 | |
---|
292 | $blockdesc = 'description'; |
---|
293 | $template->assign( |
---|
294 | $blockdesc, |
---|
295 | array( |
---|
296 | 'meta'=>l10n('meta_name'), |
---|
297 | )); |
---|
298 | break; |
---|
299 | |
---|
300 | } |
---|
301 | |
---|
302 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
303 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
304 | ?> |
---|