[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_admin/menus.php,v $ 14 | $Revision: 1.50 $ 15 | $Date: 2007/02/10 13:36:27 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 require_once ("../class2.php"); 20 if (!getperms("2")) { 21 header("location:".e_BASE."index.php"); 22 exit; 23 } 24 $e_sub_cat = 'menus'; 25 require_once ("auth.php"); 26 require_once(e_HANDLER."form_handler.php"); 27 require_once(e_HANDLER."file_class.php"); 28 $frm = new form; 29 30 if($_POST) { 31 $e107cache->clear("menus_"); 32 } 33 34 $menus_equery = explode('.', e_QUERY); 35 36 if (isset($_POST['custom_select'])) { 37 $menus_equery[1] = $_POST['custom_select']; 38 //header("location:".e_SELF."?".$_POST['custom_select']); 39 //exit; 40 } else if (!isset($menus_equery[1])) { 41 $menus_equery[1] = ''; 42 } 43 44 if ($menus_equery[1] == '' || $menus_equery[1] == 'default_layout') { 45 $menus_header = $HEADER; 46 $menus_footer = $FOOTER; 47 } 48 else if ($menus_equery[1] == 'custom_layout') { 49 $menus_header = $CUSTOMHEADER ? $CUSTOMHEADER : 50 $HEADER; 51 $menus_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : 52 $FOOTER; 53 } 54 else if ($menus_equery[1] == 'newsheader_layout') { 55 $menus_header = $NEWSHEADER ? $NEWSHEADER : 56 $HEADER; 57 $menus_footer = $FOOTER; 58 } else { 59 $menus_header = $CUSTOMHEADER[$menus_equery[1]] ? $CUSTOMHEADER[$menus_equery[1]] : 60 $HEADER; 61 $menus_footer = $CUSTOMFOOTER[$menus_equery[1]] ? $CUSTOMFOOTER[$menus_equery[1]] : 62 $FOOTER; 63 } 64 65 $layouts_str = $HEADER.$FOOTER; 66 if ($NEWSHEADER) { 67 $layouts_str .= $NEWSHEADER; 68 } 69 70 if ($CUSTOMPAGES) { 71 if (is_array($CUSTOMPAGES)) { 72 foreach ($CUSTOMPAGES as $custom_extract_key => $custom_extract_value) { 73 if ($CUSTOMHEADER[$custom_extract_key]) { 74 $layouts_str .= $CUSTOMHEADER[$custom_extract_key]; 75 } 76 if ($CUSTOMFOOTER[$custom_extract_key]) { 77 $layouts_str .= $CUSTOMFOOTER[$custom_extract_key]; 78 } 79 } 80 } else { 81 if ($CUSTOMHEADER) { 82 $layouts_str .= $CUSTOMHEADER; 83 } 84 if ($CUSTOMFOOTER) { 85 $layouts_str .= $CUSTOMFOOTER; 86 } 87 } 88 } 89 90 $menu_array = parseheader($layouts_str, 'check'); 91 sort($menu_array, SORT_NUMERIC); 92 $menu_check = 'set'; 93 foreach ($menu_array as $menu_value) { 94 if ($menu_value != $menu_check) { 95 $menu_areas[] = $menu_value; 96 } 97 $menu_check = $menu_value; 98 } 99 100 // Cams Bit ----------- Activate Multiple Menus --- 101 if($_POST['menuActivate']) 102 { 103 foreach ($_POST['menuActivate'] as $k => $v) 104 { 105 if (trim($v)) 106 { 107 $location = $k; 108 } 109 } 110 111 $menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location='$location' "); 112 113 foreach($_POST['menuselect'] as $sel_mens) 114 { 115 $sql->db_Update("menus", "menu_location='$location', menu_order='".($menu_count+1)."' WHERE menu_id='$sel_mens' "); 116 $menu_count++; 117 } 118 } 119 // ============= 120 121 if (isset($_POST['menuAct'])) 122 { 123 foreach ($_POST['menuAct'] as $k => $v) 124 { 125 if (trim($v)) 126 { 127 $id = $k; 128 list($menu_act, $location, $position, $newloc) = explode(".", $_POST['menuAct'][$k]); 129 } 130 } 131 } 132 133 if ($menu_act == 'config') { 134 if($newloc) 135 { 136 $newloc = ".".$newloc; 137 } 138 $newurl = $PLUGINS_DIRECTORY.$location."/{$position}{$newloc}.php"; 139 $newurl = SITEURL.str_replace("//", "/", $newurl); 140 echo "<script> top.location.href = '$newurl'; </script> "; 141 exit; 142 } 143 144 if ($menu_act == "adv") { 145 require_once(e_HANDLER."userclass_class.php"); 146 $sql->db_Select("menus", "*", "menu_id='$id' "); 147 $row = $sql->db_Fetch(); 148 extract($row); 149 $listtype = substr($menu_pages, 0, 1); 150 $menu_pages = substr($menu_pages, 2); 151 $menu_pages = str_replace("|", "\n", $menu_pages); 152 $text = "<div style='text-align:center;'> 153 <form method='post' action='".e_SELF."?configure.".$menus_equery[1]."'>\n 154 <table style='width:40%'> 155 <tr> 156 <td> 157 <input type='hidden' name='menuAct[$menu_id]' value='sv.$menu_id' /> 158 ".MENLAN_4." ". 159 r_userclass('menu_class', $menu_class, "off", "public,member,guest,admin,main,classes,nobody")." 160 </td> 161 </tr> 162 <tr><td><br />"; 163 $checked = ($listtype == 1) ? " checked='checked' " : 164 ""; 165 $text .= "<input type='radio' {$checked} name='listtype' value='1' /> ".MENLAN_26."<br />"; 166 $checked = ($listtype == 2) ? " checked='checked' " : 167 ""; 168 $text .= "<input type='radio' {$checked} name='listtype' value='2' /> ".MENLAN_27."<br /><br />".MENLAN_28."<br />"; 169 $text .= "<textarea name='pagelist' cols='60' rows='10' class='tbox'>$menu_pages</textarea>"; 170 $text .= " 171 <tr> 172 <td style='text-align:center'><br /> 173 <input class='button' type='submit' name='class_submit' value='".MENLAN_6."' /> 174 </td> 175 </tr> 176 </table> 177 </form> 178 </div>"; 179 $caption = MENLAN_7." ".$menu_name; 180 $ns->tablerender($caption, $text); 181 } 182 183 unset($message); 184 185 if ($menu_act == "sv") { 186 $pagelist = explode("\r\n", $_POST['pagelist']); 187 for ($i = 0 ; $i < count($pagelist) ; $i++) { 188 $pagelist[$i] = trim($pagelist[$i]); 189 } 190 $plist = implode("|", $pagelist); 191 $pageparms = $_POST['listtype'].'-'.$plist; 192 $pageparms = preg_replace("#\|$#", "", $pageparms); 193 $pageparms = (trim($_POST['pagelist']) == '') ? '' : 194 $pageparms; 195 $sql->db_Update("menus", "menu_class='".$_POST['menu_class']."', menu_pages='{$pageparms}' WHERE menu_id='$id' "); 196 $message = "<br />".MENLAN_8."<br />"; 197 } 198 199 if ($menu_act == "move") { 200 $menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location='$newloc' "); 201 $sql->db_Update("menus", "menu_location='$newloc', menu_order='".($menu_count+1)."' WHERE menu_id='$id' "); 202 $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='$location' AND menu_order > $position"); 203 } 204 205 if ($menu_act == "deac") { 206 $sql->db_Update("menus", "menu_location='0', menu_order='0' WHERE menu_id='$id' "); 207 $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='$location' AND menu_order > $position"); 208 } 209 210 if ($menu_act == "bot") { 211 $menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location='$location' "); 212 $sql->db_Update("menus", "menu_order=".($menu_count+1)." WHERE menu_order='$position' AND menu_location='$location' "); 213 $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='$location' AND menu_order > $position"); 214 } 215 216 if ($menu_act == "top") { 217 $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_location='$location' AND menu_order < $position"); 218 $sql->db_Update("menus", "menu_order=1 WHERE menu_id='$id' "); 219 } 220 221 if ($menu_act == "dec") { 222 $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_order='".($position+1)."' AND menu_location='$location' "); 223 $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_id='$id' AND menu_location='$location' "); 224 } 225 226 if ($menu_act == "inc") { 227 $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_order='".($position-1)."' AND menu_location='$location' "); 228 $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_id='$id' AND menu_location='$location' "); 229 } 230 231 if (strpos(e_QUERY, 'configure') === FALSE) 232 { // Scan plugin directories to see if menus to add 233 $efile = new e_file; 234 $fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2); 235 foreach($fileList as $file) 236 { 237 list($parent_dir) = explode('/',str_replace(e_PLUGIN,"",$file['path'])); 238 $file['path'] = str_replace(e_PLUGIN,"",$file['path']); 239 $file['fname'] = str_replace(".php","",$file['fname']); 240 $valid_menu = FALSE; 241 $existing_menu = $sql->db_Count("menus", "(*)", "WHERE menu_name='{$file['fname']}'"); 242 if (file_exists(e_PLUGIN.$parent_dir."/plugin.php")) 243 { 244 include(e_PLUGIN.$parent_dir."/plugin.php"); 245 if ($sql->db_Select("plugin", "*", "plugin_path='".$eplug_folder."' AND plugin_installflag='1' ")) 246 { // Its a 'new style' plugin with a plugin.php file - ionly include if plugin installed 247 $valid_menu = TRUE; // Whether new or existing, include in list 248 } 249 } 250 else 251 { // Just add the menu anyway 252 $valid_menu = TRUE; 253 } 254 if ($valid_menu) 255 { 256 $menustr .= "&".str_replace(".php", "", $file['fname']); 257 if (!$existing_menu) 258 { // New menu to add to list 259 $sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}'"); 260 $message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />"; 261 } 262 } 263 } 264 265 if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed 266 foreach ($menu_areas as $menu_act) { 267 if ($sql->db_Select("menus", "*", "menu_location='$menu_act' ORDER BY menu_order ASC")) { 268 $c = 1; 269 while ($row = $sql->db_Fetch()) { 270 extract($row); 271 $sql2->db_Update("menus", "menu_order='$c' WHERE menu_id='$menu_id' "); 272 $c++; 273 } 274 } 275 } 276 277 $sql->db_Select("menus", "*", "menu_path NOT REGEXP('[0-9]+') "); 278 while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->db_Fetch()) 279 { 280 if (stristr($menustr, $menu_name) === FALSE) 281 { 282 $sql2->db_Delete("menus", "menu_name='$menu_name'"); 283 $message .= "<b>".MENLAN_11." - ".$menu_name."</b><br />"; 284 } 285 } 286 } 287 288 foreach ($menu_areas as $menu_act) { 289 $menus_sql[] = "menu_location!='".$menu_act."'"; 290 } 291 292 if ($message != "") 293 { 294 echo $ns -> tablerender('Updated', "<div style='text-align:center'><b>".$message."</b></div><br /><br />"); 295 } 296 if (strpos(e_QUERY, 'configure') === FALSE) 297 { 298 $cnt = $sql->db_Select("menus", "*", "menu_location='1' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar. 299 $text = "<iframe src='".e_SELF."?configure' width='100%' style='width: 100%; height: ".(($cnt*80)+600)."px; border: 0px' frameborder='0' scrolling='auto' ></iframe>"; 300 echo $ns -> tablerender(MENLAN_35, $text, 'menus_config'); 301 } 302 else 303 { 304 305 $menus_query = implode(' && ', $menus_sql); 306 $sql->db_Update("menus", "menu_location='0', menu_order='0' WHERE ".$menus_query); 307 308 if ($CUSTOMPAGES) { 309 if ($menu_act != 'adv') { 310 $text = "<form method='post' action='".e_SELF."?configure.".$menus_equery[1]."'><div style='width: 100%'> 311 <table class='fborder' style='".ADMIN_WIDTH."'> 312 <tr> 313 <td class='forumheader3' style='width: 90%'> 314 ".MENLAN_30." 315 </td> 316 <td class='forumheader3' style='width: 10%; text-align: center;'>"; 317 318 $text .= $frm->form_select_open('custom_select', 'onchange="this.form.submit()"'); 319 320 if ($menus_equery[1] == '' || $menus_equery[1] == 'default_layout') { 321 $text .= $frm->form_option(MENLAN_31, 'selected', 'default_layout'); 322 } else { 323 $text .= $frm->form_option(MENLAN_31, FALSE, 'default_layout'); 324 } 325 326 if ($NEWSHEADER) { 327 if ($menus_equery[1] == 'newsheader_layout') { 328 $text .= $frm->form_option(MENLAN_32, 'selected', 'newsheader_layout'); 329 } else { 330 $text .= $frm->form_option(MENLAN_32, FALSE, 'newsheader_layout'); 331 } 332 } 333 334 if ($CUSTOMPAGES) { 335 if (is_array($CUSTOMPAGES)) { 336 foreach ($CUSTOMPAGES as $custom_pages_key => $custom_pages_value) { 337 if ($menus_equery[1] == $custom_pages_key) { 338 $text .= $frm->form_option($custom_pages_key, 'selected', $custom_pages_key); 339 } else { 340 $text .= $frm->form_option($custom_pages_key, FALSE, $custom_pages_key); 341 } 342 } 343 } else { 344 if ($menus_equery[1] == 'custom_layout') { 345 $text .= $frm->form_option(MENLAN_33, 'selected', 'custom_layout'); 346 } else { 347 $text .= $frm->form_option(MENLAN_33, FALSE, 'custom_layout'); 348 } 349 } 350 } 351 352 $text .= $frm->form_select_close(); 353 354 $text .= "</td> 355 </tr> 356 </table></div> 357 </form>"; 358 359 $ns->tablerender(MENLAN_29, $text); 360 } 361 } 362 363 364 parseheader($menus_header); 365 echo "<div style='text-align:center'>"; 366 echo $frm->form_open("post", e_SELF."?configure.".$menus_equery[1], "menuActivation"); 367 $text = "<table style='margin-left:auto;margin-right:auto'>"; 368 369 $sql->db_Select("menus", "*", "menu_location='0' ORDER BY menu_name "); 370 $text .= "<tr><td style='width:50%;text-align:center;padding-bottom:4px'>".MENLAN_36."...</td><td style='width:50%;padding-bottom:4px;text-align:center'>...".MENLAN_37."</td></tr>"; 371 $text .= "<tr><td style='width:50%;vertical-align:top;text-align:center'>"; 372 373 $text .= "<select name='menuselect[]' class='tbox' multiple='multiple' style='height:200px;width:95%'>"; 374 while ($row = $sql->db_Fetch()) 375 { 376 extract($row); 377 if($menu_pages == "dbcustom") 378 { 379 $menu_name .= " [custom]"; 380 } 381 else 382 { 383 $menu_name = preg_replace("#_menu#i", "", $menu_name); 384 } 385 $text .= "<option value='$menu_id'>$menu_name</option>\n"; 386 387 } 388 $text .= "</select>"; 389 $text .= "<br /><br /><span class='smalltext'>".MENLAN_38."</span>"; 390 $text .= "</td><td style='width:50%;vertical-align:top;text-align:center'><br />"; 391 foreach ($menu_areas as $menu_act) { 392 $text .= "<input type='submit' class='button' id='menuAct_".trim($menu_act)."' name='menuActivate[".trim($menu_act)."]' value='".MENLAN_13." ".trim($menu_act)."' /><br /><br />\n"; 393 } 394 $text .= "</td>"; 395 396 $text .= "</tr></table>"; 397 echo $ns -> tablerender(MENLAN_22, $text); 398 echo $frm->form_close(); 399 echo "</div>"; 400 401 parseheader($menus_footer); 402 } 403 404 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 405 function parseheader($LAYOUT, $check = FALSE) { 406 $tmp = explode("\n", $LAYOUT); 407 for ($c = 0; $c < count($tmp); $c++) { 408 if (preg_match("/[\{|\}]/", $tmp[$c])) { 409 if ($check) { 410 if (strstr($tmp[$c], "{MENU=")) { 411 $str[] = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $tmp[$c]); 412 } 413 } else { 414 checklayout($tmp[$c]); 415 } 416 } else { 417 if (!$check) { 418 echo $tmp[$c]; 419 } 420 } 421 } 422 if ($check) { 423 return $str; 424 } 425 } 426 427 function checklayout($str) { 428 global $pref, $menu_areas, $ns, $PLUGINS_DIRECTORY, $frm, $sc_style, $tp; 429 430 if (strstr($str, "LOGO")) { 431 echo $tp -> parseTemplate("{LOGO}"); 432 } 433 else if(strstr($str, "SITENAME")) { 434 echo "<div style='padding: 2px'>[SiteName]</div>"; 435 } 436 else if (strstr($str, "SITETAG")) { 437 echo "<div style='padding: 2px'>[SiteTag]</div>"; 438 } 439 else if (strstr($str, "SITELINKS")) { 440 echo "<div style='padding: 2px; text-align: center'>[SiteLinks]</div>"; 441 } 442 else if (strstr($str, "LANGUAGELINKS")) { 443 echo "<div class=text style='padding: 2px; text-align: center'>[Language]</div>"; } 444 else if (strstr($str, "CUSTOM")) { 445 $cust = preg_replace("/\W*\{CUSTOM=(.*?)(\+.*)?\}\W*/si", "\\1", $str); 446 echo "<div style='padding: 2px'>[".$cust."]</div>"; 447 } 448 // Display embedded Plugin information. 449 else if (strstr($str, "PLUGIN")){ 450 $plug = preg_replace("/\{PLUGIN=(.*?)\}/si", "\\1", $str); 451 $plug = trim($plug); 452 if (file_exists((e_PLUGIN."{$plug}/{$plug}_config.php"))){ 453 $link = e_PLUGIN."{$plug}/{$plug}_config.php"; 454 } 455 456 if(file_exists((e_PLUGIN.$plug."/config.php"))){ 457 $link = e_PLUGIN.$plug."/config.php"; 458 } 459 460 $plugtext = ($link) ? "(".MENLAN_34.":<a href='$link' title='".MENLAN_16."'>".MENLAN_16."</a>)" : "(".MENLAN_34.")" ; 461 echo "<br />"; 462 $ns -> tablerender($plug, $plugtext); 463 } 464 else if (strstr($str, "MENU")) { 465 $ns = new e107table; 466 $menu = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $str); 467 if (isset($sc_style['MENU']['pre']) && strpos($str, 'ret') !== false) { 468 echo $sc_style['MENU']['pre']; 469 } 470 echo "<div style='text-align:center; font-size:14px' class='fborder'><div class='forumheader'><b>".MENLAN_14." ".$menu."</b></div></div><br />"; 471 $text = " "; 472 $sql9 = new db; 473 if ($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' ")) { 474 unset($text); 475 echo $frm->form_open("post", e_SELF."?configure.".$menus_equery[1], "frm_menu_".intval($menu)); 476 477 $sql9->db_Select("menus", "*", "menu_location='$menu' ORDER BY menu_order"); 478 $menu_count = $sql9->db_Rows(); 479 while (list($menu_id, $menu_name, $menu_location, $menu_order, $menu_class, $menu_pages, $menu_path) = $sql9->db_Fetch()) { 480 $menu_name = preg_replace("#_menu#i", "", $menu_name); 481 $vis = ($menu_class || strlen($menu_pages) > 1) ? " <span style='color:red'>*</span> " : 482 ""; 483 $caption = "<div style='text-align:center'>{$menu_name}{$vis}</div>"; 484 $menu_info = "{$menu_location}.{$menu_order}"; 485 486 $text = ""; 487 $conf = ''; 488 if (file_exists(e_PLUGIN."{$menu_path}/{$menu_name}_menu_config.php")) 489 { 490 $conf = "config.{$menu_path}.{$menu_name}_menu_config"; 491 } 492 493 if($conf == '' && file_exists(e_PLUGIN."{$menu_path}/config.php")) 494 { 495 $conf = "config.{$menu_path}.config"; 496 } 497 498 $text .= "<select id='menuAct_$menu_id' name='menuAct[$menu_id]' class='tbox' onchange='this.form.submit()' >"; 499 $text .= $frm->form_option(MENLAN_25, TRUE, " "); 500 $text .= $frm->form_option(MENLAN_15, "", "deac.{$menu_info}"); 501 502 if ($conf) { 503 $text .= $frm->form_option(MENLAN_16, "", $conf); 504 } 505 506 if ($menu_order != 1) { 507 $text .= $frm->form_option(MENLAN_17, "", "inc.{$menu_info}"); 508 $text .= $frm->form_option(MENLAN_24, "", "top.{$menu_info}"); 509 } 510 if ($menu_count != $menu_order) { 511 $text .= $frm->form_option(MENLAN_18, "", "dec.{$menu_info}"); 512 $text .= $frm->form_option(MENLAN_23, "", "bot.{$menu_info}"); 513 } 514 foreach ($menu_areas as $menu_act) { 515 if ($menu != $menu_act) { 516 $text .= $frm->form_option(MENLAN_19." ".$menu_act, "", "move.{$menu_info}.".$menu_act); 517 } 518 } 519 $text .= $frm->form_option(MENLAN_20, "", "adv.{$menu_info}"); 520 $text .= $frm->form_select_close(); 521 $ns->tablerender($caption, $text); 522 echo "<div><br /></div>"; 523 } 524 echo $frm->form_close(); 525 } 526 if(isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false) { 527 echo $sc_style['MENU']['post']; 528 } 529 } 530 else if (strstr($str, "SETSTYLE")) { 531 $tmp = explode("=", $str); 532 $style = preg_replace("/\{SETSTYLE=(.*?)\}/si", "\\1", $str); 533 } 534 else if (strstr($str, "SITEDISCLAIMER")) { 535 echo "[Sitedisclaimer]"; 536 } 537 } 538 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 539 require_once ("footer.php"); 540 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |