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 MAJ2 |
---|
16 | $majm2='meta 2.1.0'; |
---|
17 | $query = ' |
---|
18 | select param,value |
---|
19 | FROM ' . CONFIG_TABLE . ' |
---|
20 | WHERE param = \''.$majm2.'\' |
---|
21 | ;'; |
---|
22 | $result = pwg_query($query); |
---|
23 | |
---|
24 | $row = mysql_fetch_array($result); |
---|
25 | $majparam2=$row['param']; |
---|
26 | $majvalue2=$row['value']; |
---|
27 | |
---|
28 | if (!$majvalue2==1 and !is_adviser()) |
---|
29 | { |
---|
30 | $template->delete_compiled_templates(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
31 | $maj = 'maj'; |
---|
32 | $template->assign( |
---|
33 | $maj, |
---|
34 | array( |
---|
35 | 'meta'=>l10n('meta_name'), |
---|
36 | )); |
---|
37 | if (isset($_POST['maj']) and !is_adviser()) |
---|
38 | { |
---|
39 | |
---|
40 | |
---|
41 | //Gestion MAJ1 |
---|
42 | $majm1='meta 2.0.5'; |
---|
43 | $query = ' |
---|
44 | select param,value |
---|
45 | FROM ' . CONFIG_TABLE . ' |
---|
46 | WHERE param = \''.$majm1.'\' |
---|
47 | ;'; |
---|
48 | $result = pwg_query($query); |
---|
49 | |
---|
50 | $row = mysql_fetch_array($result); |
---|
51 | $majparam1=$row['param']; |
---|
52 | $majvalue1=$row['value']; |
---|
53 | |
---|
54 | if (!$majvalue1==1) |
---|
55 | { |
---|
56 | global $prefixeTable; |
---|
57 | if (!defined('meta_img_TABLE')) define('meta_img_TABLE', $prefixeTable.'meta_img'); |
---|
58 | $query = "CREATE TABLE IF NOT EXISTS ". meta_img_TABLE ." ( |
---|
59 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
60 | metaKeyimg VARCHAR( 255 ) NOT NULL , |
---|
61 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
62 | $result = pwg_query($query); |
---|
63 | |
---|
64 | if (!defined('meta_cat_TABLE')) define('meta_cat_TABLE', $prefixeTable.'meta_cat'); |
---|
65 | $query = "CREATE TABLE IF NOT EXISTS ". meta_cat_TABLE ." ( |
---|
66 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
67 | metaKeycat VARCHAR( 255 ) NOT NULL , |
---|
68 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
69 | $result = pwg_query($query); |
---|
70 | |
---|
71 | $query = ' |
---|
72 | select id |
---|
73 | FROM ' . CATEGORIES_TABLE . ' |
---|
74 | ORDER BY id DESC;'; |
---|
75 | $result = pwg_query($query); |
---|
76 | $row = mysql_fetch_array($result); |
---|
77 | |
---|
78 | $comp=$row['id']+1; |
---|
79 | $i=1; |
---|
80 | |
---|
81 | while($i < $comp) |
---|
82 | { |
---|
83 | $query = ' |
---|
84 | select id,metaKeywords |
---|
85 | FROM ' . CATEGORIES_TABLE . ' |
---|
86 | WHERE id = \''.$i.'\''; |
---|
87 | $result = pwg_query($query); |
---|
88 | $row = mysql_fetch_array($result); |
---|
89 | |
---|
90 | if(!$row['id']==0 and !$row['metaKeywords']==0) |
---|
91 | { |
---|
92 | $query = ' |
---|
93 | INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat)VALUES ('.$row['id'].',"'.$row['metaKeywords'].'");'; |
---|
94 | $result = pwg_query($query); |
---|
95 | } |
---|
96 | ++$i; |
---|
97 | } |
---|
98 | |
---|
99 | $query = ' ALTER TABLE '. CATEGORIES_TABLE .' DROP COLUMN `metaKeywords`'; |
---|
100 | pwg_query($query); |
---|
101 | |
---|
102 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm1.'",1,"MAJ meta");'; |
---|
103 | pwg_query($query); |
---|
104 | $majvalue1==1; |
---|
105 | $maj =0; |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | $q = ' |
---|
110 | ALTER TABLE '.meta_cat_TABLE.' ADD COLUMN metadescat VARCHAR( 255 ) NOT NULL '; |
---|
111 | pwg_query($q); |
---|
112 | |
---|
113 | $q = ' |
---|
114 | ALTER TABLE '.meta_img_TABLE.' ADD COLUMN metadesimg VARCHAR( 255 ) NOT NULL '; |
---|
115 | pwg_query($q); |
---|
116 | |
---|
117 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm2.'",1,"MAJ meta");'; |
---|
118 | pwg_query($query); |
---|
119 | |
---|
120 | $template->delete_compiled_templates(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
121 | |
---|
122 | array_push($page['infos'], l10n('meta_majt')); |
---|
123 | |
---|
124 | $majvalue2==1; |
---|
125 | $maj =0; |
---|
126 | } |
---|
127 | |
---|
128 | } |
---|
129 | else{ |
---|
130 | |
---|
131 | // Gestion des onglets |
---|
132 | if (!isset($_GET['tab'])) |
---|
133 | $page['tab'] = 'gestion'; |
---|
134 | else |
---|
135 | $page['tab'] = $_GET['tab']; |
---|
136 | |
---|
137 | $tabsheet = new tabsheet(); |
---|
138 | $tabsheet->add('gestion', |
---|
139 | l10n('meta_onglet_gestion'), |
---|
140 | $my_base_url.'&tab=gestion'); |
---|
141 | $tabsheet->add('categorie', |
---|
142 | l10n('meta_onglet_categorie'), |
---|
143 | $my_base_url.'&tab=categorie'); |
---|
144 | $tabsheet->add('image', |
---|
145 | l10n('meta_onglet_image'), |
---|
146 | $my_base_url.'&tab=image'); |
---|
147 | $tabsheet->add('description', |
---|
148 | l10n('meta_onglet_description'), |
---|
149 | $my_base_url.'&tab=description'); |
---|
150 | $tabsheet->select($page['tab']); |
---|
151 | $tabsheet->assign(); |
---|
152 | |
---|
153 | // Onglet gestion des meta |
---|
154 | switch ($page['tab']) |
---|
155 | { |
---|
156 | case 'gestion': |
---|
157 | |
---|
158 | //charge la liste des meta |
---|
159 | $groups = array(); |
---|
160 | $query = ' |
---|
161 | select id,metaname |
---|
162 | FROM ' . meta_TABLE . ' |
---|
163 | ORDER BY metaname ASC;'; |
---|
164 | $result = pwg_query($query); |
---|
165 | |
---|
166 | while ($row = mysql_fetch_array($result)) |
---|
167 | { |
---|
168 | $groups[$row['id']] = $row['metaname']; |
---|
169 | } |
---|
170 | |
---|
171 | $selected = 0; |
---|
172 | $options[] = l10n('meta_select2'); |
---|
173 | $options['a'] = '----------------------'; |
---|
174 | |
---|
175 | |
---|
176 | foreach ($groups as $metalist => $metalist2) |
---|
177 | { |
---|
178 | $options[$metalist] = $metalist2; |
---|
179 | } |
---|
180 | $template->assign( |
---|
181 | 'gestionA', |
---|
182 | array( |
---|
183 | 'OPTIONS' => $options, |
---|
184 | 'SELECTED' => $selected |
---|
185 | )); |
---|
186 | |
---|
187 | |
---|
188 | //edit de meta |
---|
189 | if (isset($_POST['submitchoixmeta']) and is_numeric($_POST['metalist']) and (!$_POST['metalist'])==0 and !is_adviser()) |
---|
190 | { |
---|
191 | $lire=$_POST['metalist']; |
---|
192 | $query = ' |
---|
193 | select id,metaname,metaval |
---|
194 | FROM ' . meta_TABLE . ' |
---|
195 | WHERE id = \''.$lire.'\' |
---|
196 | ;'; |
---|
197 | $result = pwg_query($query); |
---|
198 | |
---|
199 | $row = mysql_fetch_array($result); |
---|
200 | $chname=$row['metaname']; |
---|
201 | $chval=$row['metaval']; |
---|
202 | |
---|
203 | $selected2 = ""; |
---|
204 | |
---|
205 | $template->assign( |
---|
206 | 'meta_edit', |
---|
207 | array( |
---|
208 | 'VALUE' => $chname, |
---|
209 | 'CONTENT' => $chval, |
---|
210 | 'SELECTED' => $selected2 |
---|
211 | )); |
---|
212 | } |
---|
213 | |
---|
214 | //insértion de meta dans la table |
---|
215 | if (isset($_POST['submitinsmeta']) and !is_adviser()) |
---|
216 | { |
---|
217 | $query = ' |
---|
218 | UPDATE ' . meta_TABLE . ' |
---|
219 | SET metaval= \''.$_POST['inser'].'\' |
---|
220 | WHERE metaname = \''.$_POST['invisible'].'\' |
---|
221 | ;'; |
---|
222 | $result = pwg_query($query); |
---|
223 | } |
---|
224 | |
---|
225 | break; |
---|
226 | |
---|
227 | // Onglet gestion des meta categorie |
---|
228 | case 'categorie': |
---|
229 | |
---|
230 | //charge la liste des catégories |
---|
231 | $groups = array(); |
---|
232 | $query = ' |
---|
233 | select id,name |
---|
234 | FROM ' . CATEGORIES_TABLE . ' |
---|
235 | ORDER BY id ASC;'; |
---|
236 | $result = pwg_query($query); |
---|
237 | |
---|
238 | while ($row = mysql_fetch_array($result)) |
---|
239 | { |
---|
240 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
241 | } |
---|
242 | |
---|
243 | $selected = 0; |
---|
244 | $options[] = l10n('meta_select3'); |
---|
245 | $options['a'] = '----------------------'; |
---|
246 | |
---|
247 | foreach($groups as $listid => $listid2) |
---|
248 | { |
---|
249 | $options[$listid] = $listid2; |
---|
250 | } |
---|
251 | $template->assign( |
---|
252 | 'gestionB', |
---|
253 | array( |
---|
254 | 'OPTIONS' => $options, |
---|
255 | 'SELECTED' => $selected |
---|
256 | )); |
---|
257 | |
---|
258 | |
---|
259 | //edit de categorie |
---|
260 | if (isset($_POST['submitchoixcat'])and is_numeric($_POST['metacat']) and (!$_POST['metacat'])==0 and !is_adviser()) |
---|
261 | { |
---|
262 | $lire=$_POST['metacat']; |
---|
263 | $query = ' |
---|
264 | select id,name,comment |
---|
265 | FROM ' . CATEGORIES_TABLE . ' |
---|
266 | WHERE id = \''.$lire.'\' |
---|
267 | ;'; |
---|
268 | $result = pwg_query($query); |
---|
269 | |
---|
270 | $row = mysql_fetch_array($result); |
---|
271 | $idcat=$row['id']; |
---|
272 | $chnamecat=$row['name']; |
---|
273 | $chdescat=$row['comment']; |
---|
274 | $query = ' |
---|
275 | select id,metaKeycat,metadescat |
---|
276 | FROM ' . meta_cat_TABLE . ' |
---|
277 | WHERE id = \''.$lire.'\' |
---|
278 | ;'; |
---|
279 | $result = pwg_query($query); |
---|
280 | $row = mysql_fetch_array($result); |
---|
281 | $idmetaKeycat=$row['id']; |
---|
282 | $chvalcat=$row['metaKeycat']; |
---|
283 | $chvalcatdes=$row['metadescat']; |
---|
284 | |
---|
285 | $selected3 = 0; |
---|
286 | |
---|
287 | $template->assign( |
---|
288 | 'cat_edit', |
---|
289 | array( |
---|
290 | 'DESC' => $chdescat, |
---|
291 | 'VALUE' => $idcat, |
---|
292 | 'VALUEN' => $chnamecat, |
---|
293 | 'CONTENT' => $chvalcat, |
---|
294 | 'CONTENT2' => $chvalcatdes, |
---|
295 | 'SELECTED' => $selected3 |
---|
296 | )); |
---|
297 | } |
---|
298 | |
---|
299 | //insértion de meta de cat dans la table meta_cat |
---|
300 | if (isset($_POST['submitinscat']) and !is_adviser()) |
---|
301 | { |
---|
302 | $query = ' |
---|
303 | DELETE |
---|
304 | FROM ' . meta_cat_TABLE . ' |
---|
305 | WHERE id = \''.$_POST['invisible'].'\' |
---|
306 | ;'; |
---|
307 | $result = pwg_query($query); |
---|
308 | $q = ' |
---|
309 | INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES ('.$_POST['invisible'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
310 | pwg_query($q); |
---|
311 | } |
---|
312 | |
---|
313 | break; |
---|
314 | |
---|
315 | // Onglet gestion des meta keywords images |
---|
316 | case 'image': |
---|
317 | |
---|
318 | //charge la liste des images |
---|
319 | $groups = array(); |
---|
320 | $query = ' |
---|
321 | select id,name |
---|
322 | FROM ' . IMAGES_TABLE . ' |
---|
323 | ORDER BY id ASC;'; |
---|
324 | $result = pwg_query($query); |
---|
325 | |
---|
326 | while ($row = mysql_fetch_array($result)) |
---|
327 | { |
---|
328 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
329 | } |
---|
330 | |
---|
331 | $selected = 0; |
---|
332 | $options[] = l10n('meta_selecti3'); |
---|
333 | $options['a'] = '----------------------'; |
---|
334 | |
---|
335 | foreach($groups as $listid => $listid2) |
---|
336 | { |
---|
337 | $options[$listid] = $listid2; |
---|
338 | } |
---|
339 | $template->assign( |
---|
340 | 'gestionC', |
---|
341 | array( |
---|
342 | 'OPTIONS' => $options, |
---|
343 | 'SELECTED' => $selected |
---|
344 | )); |
---|
345 | |
---|
346 | //edit de la meta l'image |
---|
347 | if (isset($_POST['submitchoiximg'])and is_numeric($_POST['metaimg']) and (!$_POST['metaimg'])==0 and !is_adviser()) |
---|
348 | { |
---|
349 | $lire=$_POST['metaimg']; |
---|
350 | $query = ' |
---|
351 | select id,name,comment,path |
---|
352 | FROM ' . IMAGES_TABLE . ' |
---|
353 | WHERE id = \''.$lire.'\' |
---|
354 | ;'; |
---|
355 | $result = pwg_query($query); |
---|
356 | |
---|
357 | $row = mysql_fetch_array($result); |
---|
358 | $idimg=$row['id']; |
---|
359 | $chnameimg=$row['name']; |
---|
360 | $chdescimg=$row['comment']; |
---|
361 | $rootimg=$row['path']; |
---|
362 | |
---|
363 | $query = ' |
---|
364 | select id,metaKeyimg,metadesimg |
---|
365 | FROM ' . meta_img_TABLE . ' |
---|
366 | WHERE id = \''.$lire.'\' |
---|
367 | ;'; |
---|
368 | $result = pwg_query($query); |
---|
369 | $row = mysql_fetch_array($result); |
---|
370 | $idmetaKeyimg=$row['id']; |
---|
371 | $chvalimg=$row['metaKeyimg']; |
---|
372 | $chvalimgdes=$row['metadesimg']; |
---|
373 | |
---|
374 | $selected3 = 0; |
---|
375 | |
---|
376 | $template->assign( |
---|
377 | 'img_edit', |
---|
378 | array( |
---|
379 | 'RIMG' => $rootimg, |
---|
380 | 'DESC' => $chdescimg, |
---|
381 | 'VALUE' => $idimg, |
---|
382 | 'VALUEN' => $chnameimg, |
---|
383 | 'CONTENT' => $chvalimg, |
---|
384 | 'CONTENT2' => $chvalimgdes, |
---|
385 | 'SELECTED' => $selected3 |
---|
386 | )); |
---|
387 | } |
---|
388 | |
---|
389 | //insértion de meta img dans la table img |
---|
390 | if (isset($_POST['submitinsimg']) and !is_adviser()) |
---|
391 | { |
---|
392 | $query = ' |
---|
393 | DELETE |
---|
394 | FROM ' . meta_img_TABLE . ' |
---|
395 | WHERE id = \''.$_POST['invisible'].'\' |
---|
396 | ;'; |
---|
397 | $result = pwg_query($query); |
---|
398 | $q = ' |
---|
399 | INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES ('.$_POST['invisible'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; |
---|
400 | pwg_query($q); |
---|
401 | } |
---|
402 | |
---|
403 | break; |
---|
404 | |
---|
405 | // Onglet description |
---|
406 | case 'description': |
---|
407 | |
---|
408 | $blockdesc = 'description'; |
---|
409 | $template->assign( |
---|
410 | $blockdesc, |
---|
411 | array( |
---|
412 | 'meta'=>l10n('meta_name'), |
---|
413 | )); |
---|
414 | break; |
---|
415 | |
---|
416 | } |
---|
417 | } |
---|
418 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
419 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
420 | ?> |
---|