1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) |
---|
4 | die('Hacking attempt!'); |
---|
5 | global $template, $conf, $user; |
---|
6 | include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php'); |
---|
7 | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | Check Access and exit when user status is not ok | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | check_status(ACCESS_ADMINISTRATOR); |
---|
12 | |
---|
13 | //-------------------------------------------------------- sections definitions |
---|
14 | // TAB gest |
---|
15 | if (!isset($_GET['tab'])) |
---|
16 | $page['tab'] = 'gestion'; |
---|
17 | else |
---|
18 | $page['tab'] = $_GET['tab']; |
---|
19 | $tabsheet = new tabsheet(); |
---|
20 | $tabsheet->add('gestion', l10n('meta_onglet_gestion'), META_ADMIN . '-gestion'); |
---|
21 | $tabsheet->add('persometa', l10n('Personal Metadata'), META_ADMIN . '-persometa'); |
---|
22 | $MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); |
---|
23 | if ($MPC['state'] == 'active') { |
---|
24 | $tabsheet->add('contactmeta', l10n('Contact page Metadata'), META_ADMIN . '-contactmeta'); |
---|
25 | } |
---|
26 | $MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';")); |
---|
27 | if ($MAP['state'] == 'active') { |
---|
28 | $tabsheet->add('AdditionalPagesmeta', l10n('Additional Pages Metadata'), META_ADMIN . '-AdditionalPagesmeta'); |
---|
29 | } |
---|
30 | $tabsheet->add('description', l10n('meta_onglet_description'), META_ADMIN . '-description'); |
---|
31 | $tabsheet->select($page['tab']); |
---|
32 | $tabsheet->assign(); |
---|
33 | |
---|
34 | switch ($page['tab']) { |
---|
35 | case 'gestion': |
---|
36 | $groups = array(); |
---|
37 | $query = 'SELECT id,metaname FROM ' . meta_TABLE . ' ORDER BY metaname ASC;'; |
---|
38 | $result = pwg_query($query); |
---|
39 | while ($row = pwg_db_fetch_assoc($result)){ |
---|
40 | $groups[$row['id']] = $row['metaname']; |
---|
41 | } |
---|
42 | $selected = 0; |
---|
43 | $options[] = l10n('meta_select2'); |
---|
44 | $options['a'] = '----------------------'; |
---|
45 | foreach ($groups as $metalist => $metalist2) { |
---|
46 | $options[$metalist] = $metalist2; |
---|
47 | } |
---|
48 | $template->assign( |
---|
49 | 'gestionA', array( |
---|
50 | 'OPTIONS' => $options, |
---|
51 | 'SELECTED' => $selected |
---|
52 | )); |
---|
53 | |
---|
54 | if (isset($_POST['submitchoixmeta']) and is_numeric($_POST['metalist']) and ( !$_POST['metalist']) == 0){ |
---|
55 | $lire = $_POST['metalist']; |
---|
56 | $query = 'SELECT id,metaname,metaval FROM ' . meta_TABLE . ' WHERE id = \'' . $lire . '\';'; |
---|
57 | $result = pwg_query($query); |
---|
58 | $row = pwg_db_fetch_assoc($result); |
---|
59 | $template->assign( |
---|
60 | 'meta_edit', array( |
---|
61 | 'VALUE' => $row['metaname'], |
---|
62 | 'CONTENT' => $row['metaval'], |
---|
63 | 'SELECTED' => "" |
---|
64 | )); |
---|
65 | } |
---|
66 | |
---|
67 | if (isset($_POST['submitinsmeta'])){ |
---|
68 | $query = 'UPDATE ' . meta_TABLE . ' SET metaval= \'' . $_POST['inser'] . '\' WHERE metaname = \'' . $_POST['invisible'] . '\';'; |
---|
69 | $result = pwg_query($query); |
---|
70 | array_push($page['infos'], l10n('Metadata updated')); |
---|
71 | } |
---|
72 | break; |
---|
73 | |
---|
74 | case 'description': |
---|
75 | $template->assign( |
---|
76 | 'description', array( |
---|
77 | 'meta' => l10n('meta_name'), |
---|
78 | )); |
---|
79 | break; |
---|
80 | |
---|
81 | case 'persometa': |
---|
82 | $template->assign( |
---|
83 | 'metapersoT', array( |
---|
84 | 'meta' => l10n('meta_name'), |
---|
85 | )); |
---|
86 | $admin_base_url = META_ADMIN . '-persometa'; |
---|
87 | $metapersos = pwg_query("SELECT * FROM " . METAPERSO_TABLE . ";"); |
---|
88 | if (pwg_db_num_rows($metapersos)) { |
---|
89 | while ($metaperso = pwg_db_fetch_assoc($metapersos)){ |
---|
90 | $items = array( |
---|
91 | 'METANAME' => $metaperso['metaname'], |
---|
92 | 'METAVAL' => $metaperso['metaval'], |
---|
93 | 'METATYPE' => $metaperso['metatype'], |
---|
94 | 'U_DELETE' => $admin_base_url . '&delete=' . $metaperso['id'], |
---|
95 | 'U_EDIT' => $admin_base_url . '&edit=' . $metaperso['id'], |
---|
96 | ); |
---|
97 | $template->append('metapersos', $items); |
---|
98 | } |
---|
99 | } |
---|
100 | if (isset($_POST['submitaddpersonalmeta'])) { |
---|
101 | $template->assign( |
---|
102 | 'meta_edit2', array( |
---|
103 | 'meta' => l10n('meta_name'), |
---|
104 | 'METAID' => 0, |
---|
105 | )); |
---|
106 | } |
---|
107 | |
---|
108 | if (isset($_POST['submitaddmetaperso'])) { |
---|
109 | $query = 'DELETE FROM ' . METAPERSO_TABLE . ' WHERE id = ' . $_POST['invisibleID'] . ';'; |
---|
110 | $result = pwg_query($query); |
---|
111 | $q = 'INSERT INTO ' . $prefixeTable . 'metaperso(metaname,metaval,metatype)VALUES ("' . $_POST['insername'] . '","' . $_POST['inserval'] . '","' . $_POST['insertype'] . '");'; |
---|
112 | pwg_query($q); |
---|
113 | $_SESSION['page_infos'] = array(l10n('Personal metadata update')); |
---|
114 | redirect($admin_base_url); |
---|
115 | } |
---|
116 | |
---|
117 | if (isset($_GET['edit'])) { |
---|
118 | check_input_parameter('edit', $_GET, false, PATTERN_ID); |
---|
119 | $query = 'SELECT id,metaname,metaval,metatype FROM ' . METAPERSO_TABLE . ' WHERE id = \'' . $_GET['edit'] . '\';'; |
---|
120 | $result = pwg_query($query); |
---|
121 | $row = pwg_db_fetch_assoc($result); |
---|
122 | $template->assign( |
---|
123 | 'meta_edit2', array( |
---|
124 | 'METAID' => $row['id'], |
---|
125 | 'METANAME' => $row['metaname'], |
---|
126 | 'METAVAL' => $row['metaval'], |
---|
127 | 'METATYPE' => $row['metatype'], |
---|
128 | )); |
---|
129 | } |
---|
130 | |
---|
131 | if (isset($_GET['delete'])) { |
---|
132 | check_input_parameter('delete', $_GET, false, PATTERN_ID); |
---|
133 | $query = 'DELETE FROM ' . METAPERSO_TABLE . ' WHERE id = ' . $_GET['delete'] . ';'; |
---|
134 | pwg_query($query); |
---|
135 | $_SESSION['page_infos'] = array(l10n('Personal metadata update')); |
---|
136 | redirect($admin_base_url); |
---|
137 | } |
---|
138 | break; |
---|
139 | |
---|
140 | case 'contactmeta': |
---|
141 | if (empty($conf['contactmeta'])){ |
---|
142 | $conf['contactmeta'] = ','; |
---|
143 | } |
---|
144 | $metacontact = explode(',', $conf['contactmeta']); |
---|
145 | $template->assign('contactmetaT', array('CMKEY' => $metacontact[0], 'CMDESC' => $metacontact[1],)); |
---|
146 | if (isset($_POST['submitcm'])){ |
---|
147 | $INSCM = $_POST['inser'] . "," . $_POST['inser2']; |
---|
148 | conf_update_param('contactmeta', $INSCM); |
---|
149 | array_push($page['infos'], l10n('Metadata updated')); |
---|
150 | $template->assign('contactmetaT', array('CMKEY' => stripslashes($_POST['inser']), 'CMDESC' => stripslashes($_POST['inser2']))); |
---|
151 | } |
---|
152 | break; |
---|
153 | |
---|
154 | case 'AdditionalPagesmeta': |
---|
155 | if (!defined('TITLE_AP_TABLE')) |
---|
156 | define('TITLE_AP_TABLE', $prefixeTable . 'title_ap'); |
---|
157 | $groups = array(); |
---|
158 | $query = 'SELECT id,title FROM ' . ADD_PAGES_TABLE . ' ORDER BY id ASC;'; |
---|
159 | $result = pwg_query($query); |
---|
160 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
161 | $groups[$row['id']] = $row['id'] . ' : ' . $row['title']; |
---|
162 | } |
---|
163 | $selected = 0; |
---|
164 | $options[] = l10n('Choose it page'); |
---|
165 | $options['a'] = '----------------------'; |
---|
166 | foreach ($groups as $listid => $listid2) { |
---|
167 | $options[$listid] = $listid2; |
---|
168 | } |
---|
169 | $template->assign( |
---|
170 | 'gestionC', array( |
---|
171 | 'OPTIONS' => $options, |
---|
172 | 'SELECTED' => $selected |
---|
173 | )); |
---|
174 | |
---|
175 | if (isset($_POST['submitchoixAP'])and is_numeric($_POST['APchoix']) and ( !$_POST['APchoix']) == 0){ |
---|
176 | $lire = $_POST['APchoix']; |
---|
177 | $query = 'SELECT id,metaKeyap,metadesap FROM ' . META_AP_TABLE . ' WHERE id = \'' . $lire . '\';'; |
---|
178 | $result = pwg_query($query); |
---|
179 | $row = pwg_db_fetch_assoc($result); |
---|
180 | $metaKeyapap = $row['metaKeyap']; |
---|
181 | $metadesap = $row['metadesap']; |
---|
182 | $query = 'SELECT id,title FROM ' . ADD_PAGES_TABLE . ' WHERE id = \'' . $lire . '\';'; |
---|
183 | $result = pwg_query($query); |
---|
184 | $row = pwg_db_fetch_assoc($result); |
---|
185 | $idap = $row['id']; |
---|
186 | $nameap = $row['title']; |
---|
187 | $template->assign( |
---|
188 | 'ap_edit', array( |
---|
189 | 'VALUE' => $idap, |
---|
190 | 'VALUEN' => $nameap, |
---|
191 | 'CONTENTMKAP' => $metaKeyapap, |
---|
192 | 'CONTENTMDAP' => $metadesap, |
---|
193 | 'SELECTED' => 0 |
---|
194 | )); |
---|
195 | } |
---|
196 | |
---|
197 | if (isset($_POST['submitinsapm'])) { |
---|
198 | $query = 'DELETE FROM ' . META_AP_TABLE . ' WHERE id = \'' . $_POST['invisible'] . '\';'; |
---|
199 | $result = pwg_query($query); |
---|
200 | $q = 'INSERT INTO ' . $prefixeTable . 'meta_ap(id,metaKeyap,metadesap)VALUES (' . $_POST['invisible'] . ',"' . $_POST['inser'] . '","' . $_POST['inser2'] . '");'; |
---|
201 | pwg_query($q); |
---|
202 | array_push($page['infos'], l10n('Metadata updated')); |
---|
203 | } |
---|
204 | break; |
---|
205 | } |
---|
206 | |
---|
207 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
208 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
209 | ?> |
---|