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