source: extensions/meta/admin/admin.php @ 4174

Last change on this file since 4174 was 4174, checked in by ddtddt, 14 years ago

[extensions] meta - Correction bug:1227 - feature:1128 - add description FR

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