Changeset 29429 for extensions
- Timestamp:
- Sep 8, 2014, 7:24:59 AM (10 years ago)
- Location:
- extensions/meta
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/meta/admin/admin.php
r28236 r29429 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 2 3 if (!defined('PHPWG_ROOT_PATH')) 4 die('Hacking attempt!'); 3 5 global $template, $conf, $user; 4 include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php');6 include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php'); 5 7 load_language('plugin.lang', meta_PATH); 6 8 $my_base_url = get_admin_plugin_menu_link(__FILE__); … … 12 14 13 15 //-------------------------------------------------------- sections definitions 14 15 16 // TAB gest 16 17 if (!isset($_GET['tab'])) … … 18 19 else 19 20 $page['tab'] = $_GET['tab']; 20 21 21 $tabsheet = new tabsheet(); 22 $tabsheet->add('gestion', 23 l10n('meta_onglet_gestion'), 24 $my_base_url.'&tab=gestion'); 25 $tabsheet->add('persometa', 26 l10n('Personal Metadata'), 27 $my_base_url.'&tab=persometa'); 28 29 $MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); 30 if($MPC['state'] == 'active') 31 { 32 $tabsheet->add('contactmeta', 33 l10n('Contact page Metadata'), 34 $my_base_url.'&tab=contactmeta'); 35 } 36 $MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';")); 37 if($MAP['state'] == 'active') 38 { 39 $tabsheet->add('AdditionalPagesmeta', 40 l10n('Additional Pages Metadata'), 41 $my_base_url.'&tab=AdditionalPagesmeta'); 42 } 43 44 $tabsheet->add('description', 45 l10n('meta_onglet_description'), 46 $my_base_url.'&tab=description'); 22 $tabsheet->add('gestion', l10n('meta_onglet_gestion'), $my_base_url . '&tab=gestion'); 23 $tabsheet->add('persometa', l10n('Personal Metadata'), $my_base_url . '&tab=persometa'); 24 25 $MPC = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ContactForm';")); 26 if ($MPC['state'] == 'active') { 27 $tabsheet->add('contactmeta', l10n('Contact page Metadata'), $my_base_url . '&tab=contactmeta'); 28 } 29 $MAP = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'AdditionalPages';")); 30 if ($MAP['state'] == 'active') { 31 $tabsheet->add('AdditionalPagesmeta', l10n('Additional Pages Metadata'), $my_base_url . '&tab=AdditionalPagesmeta'); 32 } 33 34 $tabsheet->add('description', l10n('meta_onglet_description'), $my_base_url . '&tab=description'); 47 35 $tabsheet->select($page['tab']); 48 36 $tabsheet->assign(); 49 37 50 38 // Tab gest 51 switch ($page['tab']) 52 { 53 case 'gestion': 39 switch ($page['tab']) { 40 case 'gestion': 54 41 55 42 //read metadata list 56 $groups = array();57 $query = '43 $groups = array(); 44 $query = ' 58 45 select id,metaname 59 46 FROM ' . meta_TABLE . ' 60 47 ORDER BY metaname ASC;'; 61 $result = pwg_query($query); 62 63 while ($row = pwg_db_fetch_assoc($result)) 64 { 65 $groups[$row['id']] = $row['metaname']; 66 } 67 68 $selected = 0; 69 $options[] = l10n('meta_select2'); 70 $options['a'] = '----------------------'; 71 72 73 foreach ($groups as $metalist => $metalist2) 74 { 75 $options[$metalist] = $metalist2; 76 } 77 $template->assign( 78 'gestionA', 79 array( 80 'OPTIONS' => $options, 81 'SELECTED' => $selected 82 )); 83 48 $result = pwg_query($query); 49 while ($row = pwg_db_fetch_assoc($result)) { 50 $groups[$row['id']] = $row['metaname']; 51 } 52 $selected = 0; 53 $options[] = l10n('meta_select2'); 54 $options['a'] = '----------------------'; 55 56 foreach ($groups as $metalist => $metalist2) { 57 $options[$metalist] = $metalist2; 58 } 59 $template->assign( 60 'gestionA', array( 61 'OPTIONS' => $options, 62 'SELECTED' => $selected 63 )); 84 64 85 65 //edit meta 86 if (isset($_POST['submitchoixmeta']) and is_numeric($_POST['metalist']) and (!$_POST['metalist'])==0) 87 { 88 $lire=$_POST['metalist']; 89 $query = ' 66 if (isset($_POST['submitchoixmeta']) and is_numeric($_POST['metalist']) and ( !$_POST['metalist']) == 0) { 67 $lire = $_POST['metalist']; 68 $query = ' 90 69 select id,metaname,metaval 91 70 FROM ' . meta_TABLE . ' 92 WHERE id = \''.$lire.'\' 93 ;'; 94 $result = pwg_query($query); 95 96 $row = pwg_db_fetch_assoc($result); 97 $chname=$row['metaname']; 98 $chval=$row['metaval']; 99 100 $selected2 = ""; 101 102 $template->assign( 103 'meta_edit', 104 array( 105 'VALUE' => $chname, 106 'CONTENT' => $chval, 107 'SELECTED' => $selected2 108 )); 109 } 71 WHERE id = \'' . $lire . '\' 72 ;'; 73 $result = pwg_query($query); 74 75 $row = pwg_db_fetch_assoc($result); 76 $chname = $row['metaname']; 77 $chval = $row['metaval']; 78 79 $selected2 = ""; 80 81 $template->assign( 82 'meta_edit', array( 83 'VALUE' => $chname, 84 'CONTENT' => $chval, 85 'SELECTED' => $selected2 86 )); 87 } 110 88 111 89 //inser metadata in table 112 if (isset($_POST['submitinsmeta'])) 113 { 114 $query = ' 90 if (isset($_POST['submitinsmeta'])) { 91 $query = ' 115 92 UPDATE ' . meta_TABLE . ' 116 SET metaval= \'' .$_POST['inser'].'\'117 WHERE metaname = \'' .$_POST['invisible'].'\'93 SET metaval= \'' . $_POST['inser'] . '\' 94 WHERE metaname = \'' . $_POST['invisible'] . '\' 118 95 ;'; 119 $result = pwg_query($query); 120 array_push($page['infos'], l10n('Metadata updated')); 121 } 122 123 break; 96 $result = pwg_query($query); 97 array_push($page['infos'], l10n('Metadata updated')); 98 } 99 break; 124 100 125 101 //description TAB 126 case 'description': 127 128 $blockdesc = 'description'; 129 $template->assign( 130 $blockdesc, 131 array( 132 'meta'=>l10n('meta_name'), 133 )); 134 break; 102 case 'description': 103 $blockdesc = 'description'; 104 $template->assign( 105 $blockdesc, array( 106 'meta' => l10n('meta_name'), 107 )); 108 break; 135 109 136 110 // TAB personnal metadata 137 case 'persometa': 138 139 $template->assign( 140 'metapersoT', 141 array( 142 'meta'=>l10n('meta_name'), 143 )); 144 $admin_base_url = $my_base_url.'&tab=persometa'; 145 $metapersos = pwg_query("SELECT * FROM `". METAPERSO_TABLE .";"); 146 147 if (pwg_db_num_rows($metapersos)) { 148 while ($metaperso = pwg_db_fetch_assoc($metapersos)) 149 { 150 $items = array( 151 'METANAME' => $metaperso['metaname'], 152 'METAVAL' => $metaperso['metaval'], 153 'METATYPE' => $metaperso['metatype'], 154 'U_DELETE' => $admin_base_url.'&delete='.$metaperso['id'], 155 'U_EDIT' => $admin_base_url.'&edit='.$metaperso['id'], 156 ); 157 158 $template->append('metapersos', $items); 159 } 160 } 161 if (isset($_POST['submitaddpersonalmeta'])) 162 { 163 $template->assign( 164 'meta_edit2', 165 array( 166 'meta'=>l10n('meta_name'), 167 'METAID' => 0, 168 )); 169 } 170 171 if (isset($_POST['submitaddmetaperso'])) 172 { 173 $query = ' 111 case 'persometa': 112 $template->assign( 113 'metapersoT', array( 114 'meta' => l10n('meta_name'), 115 )); 116 $admin_base_url = $my_base_url . '&tab=persometa'; 117 $metapersos = pwg_query("SELECT * FROM `" . METAPERSO_TABLE . ";"); 118 119 if (pwg_db_num_rows($metapersos)) { 120 while ($metaperso = pwg_db_fetch_assoc($metapersos)) { 121 $items = array( 122 'METANAME' => $metaperso['metaname'], 123 'METAVAL' => $metaperso['metaval'], 124 'METATYPE' => $metaperso['metatype'], 125 'U_DELETE' => $admin_base_url . '&delete=' . $metaperso['id'], 126 'U_EDIT' => $admin_base_url . '&edit=' . $metaperso['id'], 127 ); 128 129 $template->append('metapersos', $items); 130 } 131 } 132 if (isset($_POST['submitaddpersonalmeta'])) { 133 $template->assign( 134 'meta_edit2', array( 135 'meta' => l10n('meta_name'), 136 'METAID' => 0, 137 )); 138 } 139 140 if (isset($_POST['submitaddmetaperso'])) { 141 $query = ' 174 142 DELETE 175 143 FROM ' . METAPERSO_TABLE . ' 176 WHERE id = '.$_POST['invisibleID'].' 177 ;'; 178 $result = pwg_query($query); 179 180 181 $q = ' 182 INSERT INTO ' . $prefixeTable . 'metaperso(metaname,metaval,metatype)VALUES ("'.$_POST['insername'].'","'.$_POST['inserval'].'","'.$_POST['insertype'].'");'; 183 pwg_query($q); 184 $_SESSION['page_infos'] = array(l10n('Personal metadata update')); 185 redirect($admin_base_url); 186 } 187 188 if (isset($_GET['edit'])) 189 { 190 check_input_parameter('edit', $_GET, false, PATTERN_ID); 191 192 $query = ' 144 WHERE id = ' . $_POST['invisibleID'] . ' 145 ;'; 146 $result = pwg_query($query); 147 $q = ' 148 INSERT INTO ' . $prefixeTable . 'metaperso(metaname,metaval,metatype)VALUES ("' . $_POST['insername'] . '","' . $_POST['inserval'] . '","' . $_POST['insertype'] . '");'; 149 pwg_query($q); 150 $_SESSION['page_infos'] = array(l10n('Personal metadata update')); 151 redirect($admin_base_url); 152 } 153 154 if (isset($_GET['edit'])) { 155 check_input_parameter('edit', $_GET, false, PATTERN_ID); 156 157 $query = ' 193 158 select id,metaname,metaval,metatype 194 159 FROM ' . METAPERSO_TABLE . ' 195 WHERE id = \''.$_GET['edit'].'\' 196 ;'; 197 $result = pwg_query($query); 198 $row = pwg_db_fetch_assoc($result); 199 $template->assign( 200 'meta_edit2', 201 array( 202 'METAID' => $row['id'], 203 'METANAME' => $row['metaname'], 204 'METAVAL' => $row['metaval'], 205 'METATYPE' => $row['metatype'], 206 )); 207 208 } 209 210 if (isset($_GET['delete'])) 211 { 212 check_input_parameter('delete', $_GET, false, PATTERN_ID); 213 214 $query = ' 160 WHERE id = \'' . $_GET['edit'] . '\' 161 ;'; 162 $result = pwg_query($query); 163 $row = pwg_db_fetch_assoc($result); 164 $template->assign( 165 'meta_edit2', array( 166 'METAID' => $row['id'], 167 'METANAME' => $row['metaname'], 168 'METAVAL' => $row['metaval'], 169 'METATYPE' => $row['metatype'], 170 )); 171 } 172 173 if (isset($_GET['delete'])) { 174 check_input_parameter('delete', $_GET, false, PATTERN_ID); 175 $query = ' 215 176 DELETE 216 FROM ' .METAPERSO_TABLE.'217 WHERE id = ' .$_GET['delete'].'177 FROM ' . METAPERSO_TABLE . ' 178 WHERE id = ' . $_GET['delete'] . ' 218 179 ;'; 219 pwg_query($query); 220 221 $_SESSION['page_infos'] = array(l10n('Personal metadata update')); 222 redirect($admin_base_url); 223 } 224 225 226 break; 227 228 case 'contactmeta': 229 if (empty($conf['contactmeta'])) 230 { 231 $conf['contactmeta'] = ','; 232 } 233 234 $metacontact = explode(',', $conf['contactmeta']); 235 236 $template->assign('contactmetaT', 237 array('CMKEY' => $metacontact[0],'CMDESC' => $metacontact[1],)); 238 239 if (isset($_POST['submitcm'])) 240 { 241 $INSCM = $_POST['inser'].",".$_POST['inser2']; 242 conf_update_param('contactmeta', $INSCM); 243 array_push($page['infos'], l10n('Metadata updated')); 244 $template->assign( 245 'contactmetaT', 246 array('CMKEY' => stripslashes($_POST['inser']),'CMDESC' => stripslashes($_POST['inser2']))); 247 } 248 249 break; 250 251 case 'AdditionalPagesmeta': 252 if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap'); 253 $groups = array(); 254 $query = ' 180 pwg_query($query); 181 182 $_SESSION['page_infos'] = array(l10n('Personal metadata update')); 183 redirect($admin_base_url); 184 } 185 break; 186 187 case 'contactmeta': 188 if (empty($conf['contactmeta'])) { 189 $conf['contactmeta'] = ','; 190 } 191 $metacontact = explode(',', $conf['contactmeta']); 192 $template->assign('contactmetaT', array('CMKEY' => $metacontact[0], 'CMDESC' => $metacontact[1],)); 193 194 if (isset($_POST['submitcm'])) { 195 $INSCM = $_POST['inser'] . "," . $_POST['inser2']; 196 conf_update_param('contactmeta', $INSCM); 197 array_push($page['infos'], l10n('Metadata updated')); 198 $template->assign( 199 'contactmetaT', array('CMKEY' => stripslashes($_POST['inser']), 'CMDESC' => stripslashes($_POST['inser2']))); 200 } 201 break; 202 203 case 'AdditionalPagesmeta': 204 if (!defined('TITLE_AP_TABLE')) 205 define('TITLE_AP_TABLE', $prefixeTable . 'title_ap'); 206 $groups = array(); 207 $query = ' 255 208 select id,title 256 209 FROM ' . ADD_PAGES_TABLE . ' 257 210 ORDER BY id ASC;'; 258 $result = pwg_query($query); 259 260 while ($row = pwg_db_fetch_assoc($result)) 261 { 262 $groups[$row['id']] = $row['id'].' : '.$row['title']; 263 } 264 265 $selected = 0; 266 $options[] = l10n('Choose it page'); 267 $options['a'] = '----------------------'; 268 269 foreach($groups as $listid => $listid2) 270 { 271 $options[$listid] = $listid2; 272 } 273 $template->assign( 274 'gestionC', 275 array( 276 'OPTIONS' => $options, 277 'SELECTED' => $selected 278 )); 279 280 if (isset($_POST['submitchoixAP'])and is_numeric($_POST['APchoix']) and (!$_POST['APchoix'])==0) 281 { 282 $lire=$_POST['APchoix']; 283 $query = ' 211 $result = pwg_query($query); 212 while ($row = pwg_db_fetch_assoc($result)) { 213 $groups[$row['id']] = $row['id'] . ' : ' . $row['title']; 214 } 215 216 $selected = 0; 217 $options[] = l10n('Choose it page'); 218 $options['a'] = '----------------------'; 219 220 foreach ($groups as $listid => $listid2) { 221 $options[$listid] = $listid2; 222 } 223 $template->assign( 224 'gestionC', array( 225 'OPTIONS' => $options, 226 'SELECTED' => $selected 227 )); 228 229 if (isset($_POST['submitchoixAP'])and is_numeric($_POST['APchoix']) and ( !$_POST['APchoix']) == 0) { 230 $lire = $_POST['APchoix']; 231 $query = ' 284 232 select id,metaKeyap,metadesap 285 233 FROM ' . META_AP_TABLE . ' 286 WHERE id = \'' .$lire.'\'287 ;'; 288 $result = pwg_query($query);289 $row = pwg_db_fetch_assoc($result);290 $metaKeyapap=$row['metaKeyap'];291 $metadesap=$row['metadesap'];292 293 $query = '234 WHERE id = \'' . $lire . '\' 235 ;'; 236 $result = pwg_query($query); 237 $row = pwg_db_fetch_assoc($result); 238 $metaKeyapap = $row['metaKeyap']; 239 $metadesap = $row['metadesap']; 240 241 $query = ' 294 242 select id,title 295 243 FROM ' . ADD_PAGES_TABLE . ' 296 WHERE id = \'' .$lire.'\'244 WHERE id = \'' . $lire . '\' 297 245 ;'; 298 $result = pwg_query($query); 299 $row = pwg_db_fetch_assoc($result); 300 $idap=$row['id']; 301 $nameap=$row['title']; 302 303 $selected3 = 0; 304 305 $template->assign( 306 'ap_edit', 307 array( 308 'VALUE' => $idap, 309 'VALUEN' => $nameap, 310 'CONTENTMKAP' => $metaKeyapap, 311 'CONTENTMDAP' => $metadesap, 312 'SELECTED' => $selected3 313 )); 314 } 315 316 if (isset($_POST['submitinsapm'])) 317 { 318 $query = ' 246 $result = pwg_query($query); 247 $row = pwg_db_fetch_assoc($result); 248 $idap = $row['id']; 249 $nameap = $row['title']; 250 251 $selected3 = 0; 252 253 $template->assign( 254 'ap_edit', array( 255 'VALUE' => $idap, 256 'VALUEN' => $nameap, 257 'CONTENTMKAP' => $metaKeyapap, 258 'CONTENTMDAP' => $metadesap, 259 'SELECTED' => $selected3 260 )); 261 } 262 263 if (isset($_POST['submitinsapm'])) { 264 $query = ' 319 265 DELETE 320 266 FROM ' . META_AP_TABLE . ' 321 WHERE id = \''.$_POST['invisible'].'\' 322 ;'; 323 $result = pwg_query($query); 324 $q = ' 325 INSERT INTO ' . $prefixeTable . 'meta_ap(id,metaKeyap,metadesap)VALUES ('.$_POST['invisible'].',"'.$_POST['inser'].'","'.$_POST['inser2'].'");'; 326 pwg_query($q); 327 array_push($page['infos'], l10n('Metadata updated')); 328 } 329 330 break; 331 332 } 333 334 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 267 WHERE id = \'' . $_POST['invisible'] . '\' 268 ;'; 269 $result = pwg_query($query); 270 $q = ' 271 INSERT INTO ' . $prefixeTable . 'meta_ap(id,metaKeyap,metadesap)VALUES (' . $_POST['invisible'] . ',"' . $_POST['inser'] . '","' . $_POST['inser2'] . '");'; 272 pwg_query($q); 273 array_push($page['infos'], l10n('Metadata updated')); 274 } 275 break; 276 } 277 278 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 335 279 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 336 280 ?> -
extensions/meta/initadmin.php
r22769 r29429 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 2 3 if (!defined('PHPWG_ROOT_PATH')) 4 die('Hacking attempt!'); 3 5 4 6 5 7 //Add link menu 6 8 add_event_handler('get_admin_plugin_menu_links', 'meta_admin_menu'); 7 function meta_admin_menu($menu) 8 {9 load_language('plugin.lang', meta_PATH);10 array_push($menu, array(11 12 'URL' => get_admin_plugin_menu_link(meta_PATH . 'admin/admin.php')));13 return $menu;9 10 function meta_admin_menu($menu) { 11 load_language('plugin.lang', meta_PATH); 12 array_push($menu, array( 13 'NAME' => l10n('Manage tag Metadata'), 14 'URL' => get_admin_plugin_menu_link(meta_PATH . 'admin/admin.php'))); 15 return $menu; 14 16 } 15 17 18 //add prefiltre photo 19 add_event_handler('loc_begin_admin', 'metaPadminf', 55); 20 add_event_handler('loc_begin_admin_page', 'metaPadminA', 55); 16 21 17 //add prefiltre photo 18 add_event_handler('loc_begin_admin', 'metaPadminf',55); 19 add_event_handler('loc_begin_admin_page', 'metaPadminA',55); 22 function metaPadminf() { 23 global $template; 24 $template->set_prefilter('picture_modify', 'metaPadminfT'); 25 } 20 26 21 function metaPadminf() 22 { 23 global $template; 24 $template->set_prefilter('picture_modify', 'metaPadminfT'); 25 } 27 function metaPadminfT($content, &$smarty) { 28 $search = '#</form>#'; 26 29 27 function metaPadminfT($content, &$smarty) 28 { 29 $search = '#</form>#'; 30 31 $replacement = ' 30 $replacement = ' 32 31 <div> 33 32 <fieldset> … … 48 47 </form>'; 49 48 50 return preg_replace($search, $replacement, $content); 51 } 52 53 function metaPadminA() 54 { 55 load_language('plugin.lang', meta_PATH); 56 if (isset($_GET['image_id'])) 57 { 58 global $template, $prefixeTable; 59 $query = ' 49 return preg_replace($search, $replacement, $content); 50 } 51 52 function metaPadminA() { 53 load_language('plugin.lang', meta_PATH); 54 if (isset($_GET['image_id'])) { 55 global $template, $prefixeTable; 56 $query = ' 60 57 select id,metaKeyimg,metadesimg 61 58 FROM ' . meta_img_TABLE . ' 62 WHERE id = ' .$_GET['image_id'].'59 WHERE id = ' . $_GET['image_id'] . ' 63 60 ;'; 64 $result = pwg_query($query); 65 $row = pwg_db_fetch_assoc($result); 66 $chvalimg=$row['metaKeyimg']; 67 $chvalimgdes=$row['metadesimg']; 68 69 $template->assign( 70 array( 71 'metaCONTENT' => $chvalimg, 72 'metaCONTENT2' => $chvalimgdes, 73 )); 74 } 75 76 if (isset($_POST['submetaphoto'])) 77 { 78 $query = ' 61 $result = pwg_query($query); 62 $row = pwg_db_fetch_assoc($result); 63 $chvalimg = $row['metaKeyimg']; 64 $chvalimgdes = $row['metadesimg']; 65 66 $template->assign( 67 array( 68 'metaCONTENT' => $chvalimg, 69 'metaCONTENT2' => $chvalimgdes, 70 )); 71 } 72 73 if (isset($_POST['submetaphoto'])) { 74 $query = ' 79 75 DELETE 80 76 FROM ' . meta_img_TABLE . ' 81 WHERE id = ' .$_GET['image_id'].'77 WHERE id = ' . $_GET['image_id'] . ' 82 78 ;'; 83 $result = pwg_query($query);84 85 INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES (' .$_GET['image_id'].',"'.$_POST['insermetaKP'].'","'.$_POST['insermetaDP'].'");';86 pwg_query($q);87 88 $template->assign(89 array(90 'metaCONTENT' => $_POST['insermetaKP'],91 'metaCONTENT2' => $_POST['insermetaDP'],92 ));93 }94 95 79 $result = pwg_query($query); 80 $q = ' 81 INSERT INTO ' . $prefixeTable . 'meta_img(id,metaKeyimg,metadesimg)VALUES (' . $_GET['image_id'] . ',"' . $_POST['insermetaKP'] . '","' . $_POST['insermetaDP'] . '");'; 82 pwg_query($q); 83 84 $template->assign( 85 array( 86 'metaCONTENT' => $_POST['insermetaKP'], 87 'metaCONTENT2' => $_POST['insermetaDP'], 88 )); 89 } 90 } 91 96 92 //add prefiltre album 97 93 add_event_handler('loc_end_cat_modify', 'metaAadminf'); 98 94 add_event_handler('loc_end_cat_modify', 'metaAadminA'); 99 95 100 function metaAadminf() 101 { 102 global $template; 103 $template->set_prefilter('album_properties', 'metaAadminfT'); 104 } 96 function metaAadminf() { 97 global $template; 98 $template->set_prefilter('album_properties', 'metaAadminfT'); 99 } 105 100 106 function metaAadminfT($content, &$smarty) 107 { 108 $search = '#</form>#'; 109 110 $replacement = ' 101 function metaAadminfT($content, &$smarty) { 102 $search = '#</form>#'; 103 104 $replacement = ' 111 105 <div> 112 106 … … 129 123 '; 130 124 131 return preg_replace($search, $replacement, $content);132 125 return preg_replace($search, $replacement, $content); 126 } 133 127 134 function metaAadminA() 135 { 136 load_language('plugin.lang', meta_PATH); 137 if (isset($_GET['cat_id'])) 138 { 139 global $template, $prefixeTable; 140 $query = ' 128 function metaAadminA() { 129 load_language('plugin.lang', meta_PATH); 130 if (isset($_GET['cat_id'])) { 131 global $template, $prefixeTable; 132 $query = ' 141 133 select id,metaKeycat,metadescat 142 134 FROM ' . meta_cat_TABLE . ' 143 WHERE id = ' .$_GET['cat_id'].'135 WHERE id = ' . $_GET['cat_id'] . ' 144 136 ;'; 145 $result = pwg_query($query); 146 $row = pwg_db_fetch_assoc($result); 147 $chvalcat=$row['metaKeycat']; 148 $chvalcatdes=$row['metadescat']; 149 150 $template->assign( 151 array( 152 'metaCONTENT' => $chvalcat, 153 'metaCONTENT2' => $chvalcatdes, 154 )); 155 } 156 157 if (isset($_POST['submetaalbum'])) 158 { 159 $query = ' 137 $result = pwg_query($query); 138 $row = pwg_db_fetch_assoc($result); 139 $chvalcat = $row['metaKeycat']; 140 $chvalcatdes = $row['metadescat']; 141 142 $template->assign( 143 array( 144 'metaCONTENT' => $chvalcat, 145 'metaCONTENT2' => $chvalcatdes, 146 )); 147 } 148 149 if (isset($_POST['submetaalbum'])) { 150 $query = ' 160 151 DELETE 161 152 FROM ' . meta_cat_TABLE . ' 162 WHERE id = ' .$_GET['cat_id'].'153 WHERE id = ' . $_GET['cat_id'] . ' 163 154 ;'; 164 $result = pwg_query($query);165 166 INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES (' .$_GET['cat_id'].',"'.$_POST['insermetaKA'].'","'.$_POST['insermetaDA'].'");';167 pwg_query($q);155 $result = pwg_query($query); 156 $q = ' 157 INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat,metadescat)VALUES (' . $_GET['cat_id'] . ',"' . $_POST['insermetaKA'] . '","' . $_POST['insermetaDA'] . '");'; 158 pwg_query($q); 168 159 169 $template->assign(170 array(171 'metaCONTENT' => $_POST['insermetaKA'],172 173 ));174 }175 160 $template->assign( 161 array( 162 'metaCONTENT' => $_POST['insermetaKA'], 163 'metaCONTENT2' => $_POST['insermetaDA'], 164 )); 165 } 166 } 176 167 177 168 ?> -
extensions/meta/main.inc.php
r29428 r29429 1 1 <?php 2 2 3 /* 3 4 Plugin Name: meta … … 26 27 include_once(dirname(__FILE__) . '/initadmin.php'); 27 28 } 28 29 29 30 30 //Gestion des meta dans le header … … 163 163 function add_metacat() { 164 164 global $template, $page, $meta_infos; 165 166 165 //meta categories 167 166 if (!empty($page['category']['id'])) { … … 194 193 function add_metaimg() { 195 194 global $template, $page, $meta_infos; 196 197 //meta images 195 //meta images 198 196 if (!empty($page['image_id'])) { 199 197 $query = ' … … 219 217 if (!empty($row['metadesimg'])) { 220 218 $template->assign('PLUG_META', $photoDesED); 221 } else {219 } else { 222 220 $meta_infosph = array(); 223 221 $meta_infosph['title'] = $template->get_template_vars('PAGE_TITLE'); … … 225 223 $meta_infosph['descimg'] = $template->get_template_vars('COMMENT_IMG'); 226 224 if (!empty($meta_infosph['descimg'])) { 227 $template->assign('PLUG_META', strip_tags($meta_infosph['descimg']) .' - '.$meta_infosph['title']);228 } else{229 $template->assign('PLUG_META', $meta_infosph['title'] .' - '.$meta_infosph['gt']);225 $template->assign('PLUG_META', strip_tags($meta_infosph['descimg']) . ' - ' . $meta_infosph['title']); 226 } else { 227 $template->assign('PLUG_META', $meta_infosph['title'] . ' - ' . $meta_infosph['gt']); 230 228 } 231 229 } … … 235 233 function set_meta_back() { 236 234 global $template, $meta_infos; 237 238 235 $template->assign 239 236 (array -
extensions/meta/maintain.inc.php
r28236 r29429 1 1 <?php 2 2 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');4 5 function plugin_activate() 6 {7 8 define('meta_DIR', basename(dirname(__FILE__)));9 define('meta_PATH', PHPWG_PLUGINS_PATH . meta_DIR . '/');10 define('meta_TABLE', $prefixeTable . 'meta');11 define('meta_img_TABLE', $prefixeTable . 'meta_img');12 define('meta_cat_TABLE', $prefixeTable . 'meta_cat');13 define('METAPERSO_TABLE', $prefixeTable.'metaperso');14 15 $query = "CREATE TABLE IF NOT EXISTS ". METAPERSO_TABLE ." (3 if (!defined('PHPWG_ROOT_PATH')) 4 die('Hacking attempt!'); 5 6 function plugin_activate() { 7 global $prefixeTable, $template; 8 define('meta_DIR', basename(dirname(__FILE__))); 9 define('meta_PATH', PHPWG_PLUGINS_PATH . meta_DIR . '/'); 10 define('meta_TABLE', $prefixeTable . 'meta'); 11 define('meta_img_TABLE', $prefixeTable . 'meta_img'); 12 define('meta_cat_TABLE', $prefixeTable . 'meta_cat'); 13 define('METAPERSO_TABLE', $prefixeTable . 'metaperso'); 14 15 $query = "CREATE TABLE IF NOT EXISTS " . METAPERSO_TABLE . " ( 16 16 id SMALLINT( 5 ) UNSIGNED NOT NULL auto_increment, 17 17 metaname VARCHAR( 255 ) NOT NULL , … … 19 19 metatype VARCHAR( 255 ) NOT NULL , 20 20 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 21 22 23 if (!isset($conf['contactmeta']))24 {25 conf_update_param('contactmeta', ',');26 } 27 28 if (!defined('META_AP_TABLE')) define('META_AP_TABLE', $prefixeTable.'meta_ap');29 $query = "CREATE TABLE IF NOT EXISTS ". META_AP_TABLE ." (21 $result = pwg_query($query); 22 23 if (!isset($conf['contactmeta'])) { 24 conf_update_param('contactmeta', ','); 25 } 26 27 if (!defined('META_AP_TABLE')) 28 define('META_AP_TABLE', $prefixeTable . 'meta_ap'); 29 $query = "CREATE TABLE IF NOT EXISTS " . META_AP_TABLE . " ( 30 30 id SMALLINT( 5 ) UNSIGNED NOT NULL , 31 31 metaKeyap VARCHAR( 255 ) NOT NULL , 32 32 metadesap VARCHAR( 255 ) NOT NULL , 33 33 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 34 $result = pwg_query($query); 35 36 34 $result = pwg_query($query); 35 37 36 //Gestion MAJ2 38 $majm2='meta 2.1.0';39 $query = '37 $majm2 = 'meta 2.1.0'; 38 $query = ' 40 39 select param,value 41 40 FROM ' . CONFIG_TABLE . ' 42 WHERE param = \'' .$majm2.'\'41 WHERE param = \'' . $majm2 . '\' 43 42 ;'; 44 $result = pwg_query($query); 45 46 $row = pwg_db_fetch_assoc($result); 47 $majparam2=$row['param']; 48 $majvalue2=$row['value']; 49 50 if (!$majvalue2==1) 51 { 43 $result = pwg_query($query); 44 45 $row = pwg_db_fetch_assoc($result); 46 $majparam2 = $row['param']; 47 $majvalue2 = $row['value']; 48 49 if (!$majvalue2 == 1) { 52 50 53 51 //Gestion MAJ1 54 $majm1='meta 2.0.5';55 $query = '52 $majm1 = 'meta 2.0.5'; 53 $query = ' 56 54 select param,value 57 55 FROM ' . CONFIG_TABLE . ' 58 WHERE param = \'' .$majm1.'\'56 WHERE param = \'' . $majm1 . '\' 59 57 ;'; 60 $result = pwg_query($query);61 62 $row = pwg_db_fetch_assoc($result);63 $majparam1=$row['param'];64 $majvalue1=$row['value'];65 66 if (!$majvalue1==1) 67 { 68 if (!defined('meta_img_TABLE')) define('meta_img_TABLE', $prefixeTable.'meta_img');69 $query = "CREATE TABLE IF NOT EXISTS ". meta_img_TABLE ." (58 $result = pwg_query($query); 59 60 $row = pwg_db_fetch_assoc($result); 61 $majparam1 = $row['param']; 62 $majvalue1 = $row['value']; 63 64 if (!$majvalue1 == 1) { 65 if (!defined('meta_img_TABLE')) 66 define('meta_img_TABLE', $prefixeTable . 'meta_img'); 67 $query = "CREATE TABLE IF NOT EXISTS " . meta_img_TABLE . " ( 70 68 id SMALLINT( 5 ) UNSIGNED NOT NULL , 71 69 metaKeyimg VARCHAR( 255 ) NOT NULL , 72 70 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 73 $result = pwg_query($query); 74 75 if (!defined('meta_cat_TABLE')) define('meta_cat_TABLE', $prefixeTable.'meta_cat'); 76 $query = "CREATE TABLE IF NOT EXISTS ". meta_cat_TABLE ." ( 71 $result = pwg_query($query); 72 73 if (!defined('meta_cat_TABLE')) 74 define('meta_cat_TABLE', $prefixeTable . 'meta_cat'); 75 $query = "CREATE TABLE IF NOT EXISTS " . meta_cat_TABLE . " ( 77 76 id SMALLINT( 5 ) UNSIGNED NOT NULL , 78 77 metaKeycat VARCHAR( 255 ) NOT NULL , 79 78 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 80 81 82 79 $result = pwg_query($query); 80 81 $query = ' 83 82 select id 84 83 FROM ' . CATEGORIES_TABLE . ' 85 84 ORDER BY id DESC;'; 86 $result = pwg_query($query); 87 $row = pwg_db_fetch_assoc($result); 88 89 $comp=$row['id']+1; 90 $i=1; 91 92 while($i < $comp) 93 { 94 $query = ' 85 $result = pwg_query($query); 86 $row = pwg_db_fetch_assoc($result); 87 88 $comp = $row['id'] + 1; 89 $i = 1; 90 91 while ($i < $comp) { 92 $query = ' 95 93 select id,metaKeywords 96 94 FROM ' . CATEGORIES_TABLE . ' 97 WHERE id = \''.$i.'\''; 98 $result = pwg_query($query); 99 $row = pwg_db_fetch_assoc($result); 100 101 if(!$row['id']==0 and !$row['metaKeywords']==0) 102 { 103 $query = ' 104 INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat)VALUES ('.$row['id'].',"'.$row['metaKeywords'].'");'; 105 $result = pwg_query($query); 106 } 107 ++$i; 108 } 109 110 $query = ' ALTER TABLE '. CATEGORIES_TABLE .' DROP COLUMN `metaKeywords`'; 111 pwg_query($query); 112 113 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm1.'",1,"MAJ meta");'; 114 pwg_query($query); 115 $majvalue1==1; 116 $maj =0; 117 } 118 119 120 $q = ' 121 ALTER TABLE '.meta_cat_TABLE.' ADD COLUMN metadescat VARCHAR( 255 ) NOT NULL '; 122 pwg_query($q); 123 124 $q = ' 125 ALTER TABLE '.meta_img_TABLE.' ADD COLUMN metadesimg VARCHAR( 255 ) NOT NULL '; 126 pwg_query($q); 127 128 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm2.'",1,"MAJ meta");'; 129 pwg_query($query); 130 131 $template->delete_compiled_templates(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 132 133 $majvalue2==1; 134 $maj =0; 135 } 95 WHERE id = \'' . $i . '\''; 96 $result = pwg_query($query); 97 $row = pwg_db_fetch_assoc($result); 98 99 if (!$row['id'] == 0 and ! $row['metaKeywords'] == 0) { 100 $query = ' 101 INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat)VALUES (' . $row['id'] . ',"' . $row['metaKeywords'] . '");'; 102 $result = pwg_query($query); 103 } 104 ++$i; 105 } 106 107 $query = ' ALTER TABLE ' . CATEGORIES_TABLE . ' DROP COLUMN `metaKeywords`'; 108 pwg_query($query); 109 110 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("' . $majm1 . '",1,"MAJ meta");'; 111 pwg_query($query); 112 $majvalue1 == 1; 113 $maj = 0; 114 } 115 116 $q = ' 117 ALTER TABLE ' . meta_cat_TABLE . ' ADD COLUMN metadescat VARCHAR( 255 ) NOT NULL '; 118 pwg_query($q); 119 120 $q = ' 121 ALTER TABLE ' . meta_img_TABLE . ' ADD COLUMN metadesimg VARCHAR( 255 ) NOT NULL '; 122 pwg_query($q); 123 124 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("' . $majm2 . '",1,"MAJ meta");'; 125 pwg_query($query); 126 127 $template->delete_compiled_templates(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 128 129 $majvalue2 == 1; 130 $maj = 0; 131 } 136 132 } 137 133 138 function plugin_install() 139 { 140 global $conf, $prefixeTable; 141 134 function plugin_install() { 135 global $conf, $prefixeTable; 142 136 $q = 'CREATE TABLE ' . $prefixeTable . 'meta( 143 137 id SMALLINT( 5 ) UNSIGNED NOT NULL , … … 147 141 PRIMARY KEY (id))DEFAULT CHARSET=utf8;'; 148 142 pwg_query($q); 149 150 143 144 $q = ' 151 145 INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (1,"author","","name");'; 152 146 pwg_query($q); 153 154 147 148 $q = ' 155 149 INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (2,"keywords","","name");'; 156 150 pwg_query($q); 157 158 151 152 $q = ' 159 153 INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (3,"Description","","name");'; 160 154 pwg_query($q); 161 162 155 156 $q = ' 163 157 INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (4,"robots","follow","name");'; 164 158 pwg_query($q); 165 159 166 if (!defined('meta_img_TABLE')) define('meta_img_TABLE', $prefixeTable.'meta_img'); 167 $query = "CREATE TABLE IF NOT EXISTS ". meta_img_TABLE ." ( 160 if (!defined('meta_img_TABLE')) 161 define('meta_img_TABLE', $prefixeTable . 'meta_img'); 162 $query = "CREATE TABLE IF NOT EXISTS " . meta_img_TABLE . " ( 168 163 id SMALLINT( 5 ) UNSIGNED NOT NULL , 169 164 metaKeyimg VARCHAR( 255 ) NOT NULL , 170 165 metadesimg VARCHAR( 255 ) NOT NULL , 171 166 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 172 $result = pwg_query($query); 173 174 if (!defined('meta_cat_TABLE')) define('meta_cat_TABLE', $prefixeTable.'meta_cat'); 175 $query = "CREATE TABLE IF NOT EXISTS ". meta_cat_TABLE ." ( 167 $result = pwg_query($query); 168 169 if (!defined('meta_cat_TABLE')) 170 define('meta_cat_TABLE', $prefixeTable . 'meta_cat'); 171 $query = "CREATE TABLE IF NOT EXISTS " . meta_cat_TABLE . " ( 176 172 id SMALLINT( 5 ) UNSIGNED NOT NULL , 177 173 metaKeycat VARCHAR( 255 ) NOT NULL , 178 174 metadescat VARCHAR( 255 ) NOT NULL , 179 175 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 180 $result = pwg_query($query); 181 182 if (!defined('METAPERSO_TABLE')) define('METAPERSO_TABLE', $prefixeTable.'metaperso'); 183 $query = "CREATE TABLE IF NOT EXISTS ". METAPERSO_TABLE ." ( 176 $result = pwg_query($query); 177 178 if (!defined('METAPERSO_TABLE')) 179 define('METAPERSO_TABLE', $prefixeTable . 'metaperso'); 180 $query = "CREATE TABLE IF NOT EXISTS " . METAPERSO_TABLE . " ( 184 181 id SMALLINT( 5 ) UNSIGNED NOT NULL auto_increment, 185 182 metaname VARCHAR( 255 ) NOT NULL , … … 187 184 metatype VARCHAR( 255 ) NOT NULL , 188 185 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 189 190 191 $majm1='meta 2.0.5';192 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm1.'",1,"MAJ meta");';186 $result = pwg_query($query); 187 188 $majm1 = 'meta 2.0.5'; 189 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("' . $majm1 . '",1,"MAJ meta");'; 193 190 pwg_query($query); 194 191 195 $majm2='meta 2.1.0'; 196 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm2.'",1,"MAJ meta");'; 197 pwg_query($query); 198 199 200 201 if (empty($conf['contactmeta'])) 202 { 203 conf_update_param('contactmeta', ''); 204 } 205 206 if (!defined('META_AP_TABLE')) define('META_AP_TABLE', $prefixeTable.'meta_ap'); 207 $query = "CREATE TABLE IF NOT EXISTS ". META_AP_TABLE ." ( 192 $majm2 = 'meta 2.1.0'; 193 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("' . $majm2 . '",1,"MAJ meta");'; 194 pwg_query($query); 195 196 if (empty($conf['contactmeta'])) { 197 conf_update_param('contactmeta', ''); 198 } 199 200 if (!defined('META_AP_TABLE')) 201 define('META_AP_TABLE', $prefixeTable . 'meta_ap'); 202 $query = "CREATE TABLE IF NOT EXISTS " . META_AP_TABLE . " ( 208 203 id SMALLINT( 5 ) UNSIGNED NOT NULL , 209 204 metaKeyap VARCHAR( 255 ) NOT NULL , 210 205 metadesap VARCHAR( 255 ) NOT NULL , 211 206 PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; 212 $result = pwg_query($query); 213 214 215 207 $result = pwg_query($query); 216 208 } 217 209 218 function plugin_uninstall() 219 { 220 221 $majm1='meta 2.0.5'; 222 $majm2='meta 2.1.0'; 223 224 global $prefixeTable; 225 226 $q = 'DROP TABLE ' . $prefixeTable . 'meta;'; 227 pwg_query($q); 228 229 $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="'.$majm1.'" LIMIT 1;'; 230 pwg_query($q); 231 232 $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="'.$majm2.'" LIMIT 1;'; 233 pwg_query($q); 234 235 $q = 'DROP TABLE ' . $prefixeTable . 'meta_img;'; 236 pwg_query($q); 237 238 $q = 'DROP TABLE ' . $prefixeTable . 'meta_cat;'; 239 pwg_query($q); 240 241 conf_delete_param('contactmeta'); 210 function plugin_uninstall() { 211 212 $majm1 = 'meta 2.0.5'; 213 $majm2 = 'meta 2.1.0'; 214 215 global $prefixeTable; 216 217 $q = 'DROP TABLE ' . $prefixeTable . 'meta;'; 218 pwg_query($q); 219 220 $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="' . $majm1 . '" LIMIT 1;'; 221 pwg_query($q); 222 223 $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="' . $majm2 . '" LIMIT 1;'; 224 pwg_query($q); 225 226 $q = 'DROP TABLE ' . $prefixeTable . 'meta_img;'; 227 pwg_query($q); 228 229 $q = 'DROP TABLE ' . $prefixeTable . 'meta_cat;'; 230 pwg_query($q); 231 232 conf_delete_param('contactmeta'); 242 233 } 243 234 244 245 235 ?> -
extensions/meta/persometa.tpl
r22769 r29429 1 1 {foreach from=$metapersos item=metaperso} 2 2 <meta {$metaperso.METATYPE}="{$metaperso.METANAME}" content="{$metaperso.METAVAL}"> 3 {/foreach} 3 {/foreach}
Note: See TracChangeset
for help on using the changeset viewer.