1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00
php-e107/e107_admin/menus.php

936 lines
28 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <EFBFBD>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $
| $Revision: 1.21 $
| $Date: 2009-07-08 06:58:00 $
| $Author: e107coders $
2006-12-02 04:36:16 +00:00
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
if (!getperms("2"))
{
2006-12-02 04:36:16 +00:00
header("location:".e_BASE."index.php");
exit;
}
$e_sub_cat = 'menus';
require_once("auth.php");
require_once(e_HANDLER."form_handler.php");
require_once(e_HANDLER."file_class.php");
$frm = new form;
if($_POST)
{
2008-06-24 20:53:07 +00:00
// print_a($_POST);
// exit;
2008-12-17 20:42:30 +00:00
$e107cache->clear_sys("menus_");
2006-12-02 04:36:16 +00:00
}
$menus_equery = explode('.', e_QUERY);
$curLayout = $menus_equery[1];
2006-12-02 04:36:16 +00:00
if (isset($_POST['custom_select']))
2007-03-06 19:59:36 +00:00
{
$curLayout = $_POST['custom_select'];
2006-12-02 04:36:16 +00:00
//header("location:".e_SELF."?".$_POST['custom_select']);
//exit;
2007-03-06 19:59:36 +00:00
}
else if (!isset($curLayout))
2007-03-06 19:59:36 +00:00
{
$curLayout = '';
2006-12-02 04:36:16 +00:00
}
2007-03-06 19:59:36 +00:00
if ($curLayout == '' || $curLayout == 'default_layout')
2007-03-06 19:59:36 +00:00
{
$menus_header = is_array($HEADER) ? $HEADER[$pref['sitetheme_deflayout']] : $HEADER;
$menus_footer = is_array($FOOTER) ? $FOOTER[$pref['sitetheme_deflayout']] : $FOOTER;
2006-12-02 04:36:16 +00:00
}
else if ($curLayout == 'no_array')
2007-03-06 19:59:36 +00:00
{
$menus_header = $CUSTOMHEADER ? $CUSTOMHEADER : $HEADER;
$menus_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER;
2006-12-02 04:36:16 +00:00
}
else if ($curLayout == 'newsheader_layout')
2007-03-06 19:59:36 +00:00
{
$menus_header = $NEWSHEADER ? $NEWSHEADER : $HEADER;
2006-12-02 04:36:16 +00:00
$menus_footer = $FOOTER;
}
elseif(is_array($HEADER) || is_array($FOOTER)) // 0.8 themes
{
$menus_header = (is_array($HEADER) && isset($HEADER[$curLayout])) ? $HEADER[$curLayout] : $HEADER;
$menus_footer = (is_array($FOOTER) && isset($FOOTER[$curLayout])) ? $FOOTER[$curLayout] : $FOOTER;
}
else
2007-03-06 19:59:36 +00:00
{
$menus_header = $CUSTOMHEADER[$curLayout] ? $CUSTOMHEADER[$curLayout] : $HEADER;
$menus_footer = $CUSTOMFOOTER[$curLayout] ? $CUSTOMFOOTER[$curLayout] : $FOOTER;
2006-12-02 04:36:16 +00:00
}
2007-03-06 19:59:36 +00:00
// $layouts_str = $HEADER.$FOOTER;
$layouts_str = $menus_header.$menus_footer;
if ($NEWSHEADER)
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$layouts_str .= $NEWSHEADER;
}
/*if ($CUSTOMPAGES)
2008-12-06 22:14:37 +00:00
{
if (is_array($CUSTOMPAGES))
2008-12-06 22:14:37 +00:00
{
foreach ($CUSTOMPAGES as $custom_extract_key => $custom_extract_value)
2008-12-06 22:14:37 +00:00
{
if ($CUSTOMHEADER[$custom_extract_key])
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$layouts_str .= $CUSTOMHEADER[$custom_extract_key];
}
if ($CUSTOMFOOTER[$custom_extract_key])
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$layouts_str .= $CUSTOMFOOTER[$custom_extract_key];
}
}
}
else
2008-12-06 22:14:37 +00:00
{
if ($CUSTOMHEADER)
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$layouts_str .= $CUSTOMHEADER;
}
if ($CUSTOMFOOTER)
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$layouts_str .= $CUSTOMFOOTER;
}
}
}*/
2006-12-02 04:36:16 +00:00
2008-12-06 22:14:37 +00:00
2006-12-02 04:36:16 +00:00
$menu_array = parseheader($layouts_str, 'check');
sort($menu_array, SORT_NUMERIC);
$menu_check = 'set';
foreach ($menu_array as $menu_value)
2008-12-06 22:14:37 +00:00
{
if ($menu_value != $menu_check)
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$menu_areas[] = $menu_value;
}
$menu_check = $menu_value;
}
// Cams Bit ----------- Activate Multiple Menus ---
if($_POST['menuActivate'])
{
menuActivate();
}
if($_POST['menuSetCustomPages'])
{
menuSetCustomPages($_POST['custompages']);
}
function menuActivate()
{
global $sql, $admin_log, $pref;
$location = key($_POST['menuActivate']);
$layout = ($_POST['curLayout'] != $pref['sitetheme_deflayout']) ? $_POST['curLayout'] : "";
2006-12-02 04:36:16 +00:00
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location=".$location." AND menu_layout = '$layout' ");
2006-12-02 04:36:16 +00:00
foreach($_POST['menuselect'] as $sel_mens)
{
//Get info from menu being activated
if($sql->db_Select("menus", 'menu_name, menu_path' , "menu_id = ".$sel_mens." "))
{
$row=$sql->db_Fetch();
//If menu is not already activated in that area, add the record.
2009-07-08 01:28:55 +00:00
if(!$sql->db_Select('menus', 'menu_name,menu_path', " menu_name='".$row['menu_name']."' AND menu_layout = '$layout' AND menu_location = ".$location." LIMIT 1 "))
{
$qry = "
INSERT into #menus
(`menu_name`, `menu_location`, `menu_order`, `menu_pages`, `menu_path`, `menu_layout`)
VALUES ('{$row['menu_name']}', {$location}, {$menu_count}, '', '{$row['menu_path']}', '{$layout}')
";
$sql->db_Select_gen($qry);
2008-12-06 22:14:37 +00:00
$admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
$menu_count++;
}
}
2006-12-02 04:36:16 +00:00
}
}
function menuSetCustomPages($array)
{
global $pref;
$key = key($array);
$pref['sitetheme_custompages'][$key] = array_filter(explode(" ",$array[$key]));
save_prefs();
}
function getMenuPreset($layout)
{
global $pref;
// print_a($pref['sitetheme_layouts'][$layout]['menuPresets']);
if(!isset($pref['sitetheme_layouts'][$layout]['menuPresets']))
{
return;
}
$temp = $pref['sitetheme_layouts'][$layout]['menuPresets']['area'];
foreach($temp as $key=>$val)
{
$iD = $val['@attributes']['id'];
foreach($val['menu'] as $k=>$v)
{
$uclass = (defined(trim($v['@attributes']['userclass']))) ? constant(trim($v['@attributes']['userclass'])) : 0;
$menuArea[] = array(
'menu_location' => $iD,
'menu_order' => $k,
'menu_name' => $v['@attributes']['name']."_menu",
'menu_class' => intval($uclass)
);
}
}
return $menuArea;
}
function checkMenuPreset($array,$name)
{
if(!is_array($array))
{
return;
}
foreach($array as $key=>$val)
{
if($val['menu_name']==$name)
{
return $val['menu_location'];
}
}
return FALSE;
}
if(isset($_POST['menuUsePreset']) && $_POST['curLayout'])
{
global $pref;
$layout = ($_POST['curLayout'] != $pref['sitetheme_deflayout']) ? $_POST['curLayout'] : "";
$menuAreas = getMenuPreset($_POST['curLayout']);
$sql->db_Update("menus", "menu_location='0' WHERE menu_layout = '$layout' "); // Clear All existing.
foreach($menuAreas as $val)
{
if($sql->db_Select("menus", 'menu_name, menu_path' , "menu_name = '".$val['menu_name']."' LIMIT 1"))
{
$row=$sql->db_Fetch();
2009-07-07 22:56:13 +00:00
if(!$sql->db_Update('menus', "menu_order='{$val['menu_order']}', menu_location = ".$val['menu_location'].", menu_class= ".$val['menu_class']." WHERE menu_name='".$val['menu_name']."' AND menu_layout = '$layout' LIMIT 1 "))
{
$qry = "
INSERT into #menus
(`menu_name`, `menu_location`, `menu_order`, `menu_pages`,`menu_class`, `menu_path`, `menu_layout`)
VALUES ('{$val['menu_name']}', {$val['menu_location']}, {$val['menu_order']}, '', '{$val['menu_class']}', '{$row['menu_path']}', '{$layout}')
";
2009-07-07 22:56:13 +00:00
$sql->db_Select_gen($qry);
$admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
}
}
}
}
2006-12-02 04:36:16 +00:00
// =============
if (isset($_POST['menuAct']))
{
foreach ($_POST['menuAct'] as $k => $v)
{
if (trim($v))
{
$id = $k;
list($menu_act, $location, $position, $newloc) = explode(".", $_POST['menuAct'][$k]);
2006-12-02 04:36:16 +00:00
}
}
2006-12-02 04:36:16 +00:00
}
if ($menu_act == 'config')
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
if($newloc)
{
$newloc = ".".$newloc;
}
$newurl = $PLUGINS_DIRECTORY.$location."/{$position}{$newloc}.php";
$newurl = SITEURL.str_replace("//", "/", $newurl);
2008-12-06 22:14:37 +00:00
echo "<script> top.location.href = '{$newurl}'; </script> ";
2006-12-02 04:36:16 +00:00
exit;
}
if ($menu_act == "adv")
2008-12-06 22:14:37 +00:00
{
2009-07-06 05:59:42 +00:00
showVisibility();
}
function showVisibility()
{
global $sql,$ns;
2006-12-02 04:36:16 +00:00
require_once(e_HANDLER."userclass_class.php");
$sql->db_Select("menus", "*", "menu_id=".$id);
2006-12-02 04:36:16 +00:00
$row = $sql->db_Fetch();
$listtype = substr($row['menu_pages'], 0, 1);
$menu_pages = substr($row['menu_pages'], 2);
2006-12-02 04:36:16 +00:00
$menu_pages = str_replace("|", "\n", $menu_pages);
$text = "<div style='text-align:center;'>
<form method='post' action='".e_SELF."?configure.".$curLayout."'>
2006-12-02 04:36:16 +00:00
<table style='width:40%'>
<tr>
<td>
<input type='hidden' name='menuAct[{$row['menu_id']}]' value='sv.{$row['menu_id']}' />
2006-12-02 04:36:16 +00:00
".MENLAN_4." ".
r_userclass('menu_class', $row['menu_class'], "off", "public,member,guest,admin,main,classes,nobody")."
2006-12-02 04:36:16 +00:00
</td>
</tr>
<tr><td><br />";
$checked = ($listtype == 1) ? " checked='checked' " : "";
2006-12-02 04:36:16 +00:00
$text .= "<input type='radio' {$checked} name='listtype' value='1' /> ".MENLAN_26."<br />";
$checked = ($listtype == 2) ? " checked='checked' " : "";
2006-12-02 04:36:16 +00:00
$text .= "<input type='radio' {$checked} name='listtype' value='2' /> ".MENLAN_27."<br /><br />".MENLAN_28."<br />";
$text .= "<textarea name='pagelist' cols='60' rows='10' class='tbox'>$menu_pages</textarea>";
$text .= "
<tr>
<td style='text-align:center'><br />
<input class='button' type='submit' name='class_submit' value='".MENLAN_6."' />
</td>
</tr>
</table>
</form>
</div>";
$caption = MENLAN_7." ".$row['menu_name'];
2006-12-02 04:36:16 +00:00
$ns->tablerender($caption, $text);
2009-07-06 05:59:42 +00:00
2006-12-02 04:36:16 +00:00
}
2009-07-06 05:59:42 +00:00
2006-12-02 04:36:16 +00:00
unset($message);
if ($menu_act == "sv")
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$pagelist = explode("\r\n", $_POST['pagelist']);
for ($i = 0 ; $i < count($pagelist) ; $i++)
2008-12-06 22:14:37 +00:00
{
2006-12-02 04:36:16 +00:00
$pagelist[$i] = trim($pagelist[$i]);
}
$plist = implode("|", $pagelist);
$pageparms = $_POST['listtype'].'-'.$plist;
$pageparms = preg_replace("#\|$#", "", $pageparms);
2008-12-06 22:14:37 +00:00
$pageparms = (trim($_POST['pagelist']) == '') ? '' : $pageparms;
$sql->db_Update("menus", "menu_class='".$_POST['menu_class']."', menu_pages='{$pageparms}' WHERE menu_id=".intval($id));
$admin_log->log_event('MENU_02',$_POST['menu_class'].'[!br!]'.$pageparms.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
2006-12-02 04:36:16 +00:00
$message = "<br />".MENLAN_8."<br />";
}
if ($menu_act == "move")
2008-12-06 22:14:37 +00:00
{
// Get current menu name
if($sql->db_Select('menus', 'menu_name', 'menu_id='.$id, 'default'))
{
$row = $sql->db_Fetch();
//Check to see if menu is already active in the new area, if not then move it
if(!$sql->db_Select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = ".$newloc))
{
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location=".$newloc);
2008-12-06 22:14:37 +00:00
$sql->db_Update("menus", "menu_location='{$newloc}', menu_order=".($menu_count+1)." WHERE menu_id=".$id);
$sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='{$location}' AND menu_order > {$position}");
}
2008-12-06 22:14:37 +00:00
$admin_log->log_event('MENU_03',$row['menu_name'].'[!br!]'.$newloc.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
}
2006-12-02 04:36:16 +00:00
}
if ($menu_act == "deac")
2008-12-06 22:14:37 +00:00
{
// Get current menu name
if($sql->db_Select('menus', 'menu_name', 'menu_id='.$id, 'default'))
{
$row = $sql->db_Fetch();
//Check to see if there is already a menu with location = 0 (to maintain BC)
if($sql->db_Select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = 0"))
{
//menu_location=0 already exists, we can just delete this record
$sql->db_Delete('menus', 'menu_id='.$id);
}
else
{
//menu_location=0 does NOT exist, let's just convert this to it
$sql->db_Update("menus", "menu_location=0, menu_order=0, menu_class=0, menu_pages='' WHERE menu_id=".$id);
}
//Move all other menus up
2008-12-06 22:14:37 +00:00
$sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location={$location} AND menu_order > {$position}");
$admin_log->log_event('MENU_04',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
}
2006-12-02 04:36:16 +00:00
}
if ($menu_act == "bot")
2008-12-06 22:14:37 +00:00
{
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location='{$location}' AND menu_layout = '$curLayout' ");
$sql->db_Update("menus", "menu_order=".($menu_count+1)." WHERE menu_order='{$position}' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
$sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='{$location}' AND menu_order > {$position} AND menu_layout = '$curLayout' ");
2008-12-06 22:14:37 +00:00
$admin_log->log_event('MENU_06',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
2006-12-02 04:36:16 +00:00
}
if ($menu_act == "top")
2008-12-06 22:14:37 +00:00
{
$sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_location='{$location}' AND menu_order < {$position} AND menu_layout = '$curLayout' ");
2008-12-06 22:14:37 +00:00
$sql->db_Update("menus", "menu_order=1 WHERE menu_id='{$id}' ");
$admin_log->log_event('MENU_05',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
2006-12-02 04:36:16 +00:00
}
if ($menu_act == "dec")
2008-12-06 22:14:37 +00:00
{
$sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_order='".($position+1)."' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
$sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_id='{$id}' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
2008-12-06 22:14:37 +00:00
$admin_log->log_event('MENU_08',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
2006-12-02 04:36:16 +00:00
}
if ($menu_act == "inc")
2008-12-06 22:14:37 +00:00
{
$sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_order='".($position-1)."' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
$sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_id='{$id}' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
2008-12-06 22:14:37 +00:00
$admin_log->log_event('MENU_07',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
2006-12-02 04:36:16 +00:00
}
if (strpos(e_QUERY, 'configure') === FALSE)
{ // Scan plugin directories to see if menus to add
2006-12-02 04:36:16 +00:00
$efile = new e_file;
$efile->dirFilter = array('/', 'CVS', '.svn', 'languages');
$fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2);
foreach($fileList as $file)
{
list($parent_dir) = explode('/',str_replace(e_PLUGIN,"",$file['path']));
$file['path'] = str_replace(e_PLUGIN,"",$file['path']);
$file['fname'] = str_replace(".php","",$file['fname']);
$valid_menu = FALSE;
$existing_menu = $sql->db_Count("menus", "(*)", "WHERE menu_name='{$file['fname']}'");
if (file_exists(e_PLUGIN.$parent_dir."/plugin.xml") ||
file_exists(e_PLUGIN.$parent_dir."/plugin.php"))
{
// include(e_PLUGIN.$parent_dir."/plugin.php");
if (isset($pref['plug_installed'][$parent_dir]))
// if ($sql->db_Select("plugin", "*", "plugin_path='".$eplug_folder."' AND plugin_installflag='1' "))
{ // Its a 'new style' plugin with a plugin.php file, or an even newer one with plugin.xml file - only include if plugin installed
$valid_menu = TRUE; // Whether new or existing, include in list
}
}
else
{ // Just add the menu anyway
$valid_menu = TRUE;
}
if ($valid_menu)
{
$menustr .= "&".str_replace(".php", "", $file['fname']);
if (!$existing_menu)
{ // New menu to add to list
if($sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}', ''"))
{
// Could do admin logging here - but probably not needed
$message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />";
}
2006-12-02 04:36:16 +00:00
}
}
2006-12-02 04:36:16 +00:00
}
//Reorder all menus into 1...x order
if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed
foreach ($menu_areas as $menu_act)
{
if ($sql->db_Select("menus", "menu_id", "menu_location={$menu_act} ORDER BY menu_order ASC"))
{
$c = 1;
while ($row = $sql->db_Fetch())
{
$sql2->db_Update("menus", "menu_order={$c} WHERE menu_id=".$row['menu_id']);
$c++;
}
2006-12-02 04:36:16 +00:00
}
}
$sql->db_Select("menus", "*", "menu_path NOT REGEXP('[0-9]+') ");
while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->db_Fetch(MYSQL_NUM))
2006-12-02 04:36:16 +00:00
{
if (stristr($menustr, $menu_name) === FALSE)
{
$sql2->db_Delete("menus", "menu_name='$menu_name'");
$message .= "<b>".MENLAN_11." - ".$menu_name."</b><br />";
}
2006-12-02 04:36:16 +00:00
}
}
if ($message != "")
{
echo $ns -> tablerender('Updated', "<div style='text-align:center'><b>".$message."</b></div><br /><br />");
}
2006-12-02 04:36:16 +00:00
if (strpos(e_QUERY, 'configure') === FALSE)
{
$cnt = $sql->db_Select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar.
$text .= "COUNT = ".$cnt;
$text = "<iframe id='menu_iframe' src='".e_SELF."?configure.$curLayout' width='100%' style='width: 100%; height: ".(($cnt*80)+600)."px; border: 0px' frameborder='0' scrolling='auto' ></iframe>";
2006-12-02 04:36:16 +00:00
echo $ns -> tablerender(MENLAN_35, $text, 'menus_config');
}
else // Within the IFrame.
2006-12-02 04:36:16 +00:00
{
echo layout_list();
menuRenderPage();
2006-12-02 04:36:16 +00:00
}
2006-12-02 04:36:16 +00:00
// =-----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
function menuRenderPage()
{
global $sql, $ns, $menus_header, $menus_footer, $frm, $curLayout, $pref, $tp, $menu_areas;
parseheader($menus_header); // $layouts_str;
$layout = ($curLayout) ? $curLayout : $pref['sitetheme_deflayout'];
$menuPreset = getMenuPreset($layout);
2006-12-02 04:36:16 +00:00
echo "<div style='text-align:center'>";
echo $frm->form_open("post", e_SELF."?configure.".$curLayout, "menuActivation");
$text = "<table style='width:80%;margin-left:auto;margin-right:auto'>";
2006-12-02 04:36:16 +00:00
$sql->db_Select("menus", "menu_name, menu_id, menu_pages", "1 GROUP BY menu_name ORDER BY menu_name ASC");
2006-12-02 04:36:16 +00:00
$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>";
$text .= "<tr><td style='width:50%;vertical-align:top;text-align:center'>";
$text .= "<div style='border:1px inset black;height:200px;display:block;overflow:auto;margin-bottom:20px'>
<table style='width:100%;margin-left:auto;margin-right:auto' cellspacing='0' cellpadding='0'>\n";
while ($row = $sql->db_Fetch())
{
$pdeta = "";
$color = ($color == "white") ? "#DDDDDD" : "white";
if($row['menu_pages'] == "dbcustom")
{
$pdeta = MENLAN_42;
}
else
{
$row['menu_name'] = preg_replace("#_menu$#i", "", $row['menu_name']);
if($pnum = checkMenuPreset($menuPreset,$row['menu_name']."_menu"))
{
$pdeta = MENLAN_39." {$pnum}";
}
}
$text .= "<tr style='background-color:$color;color:black'>
<td style='text-align:left; color:black;'><input type='checkbox' name='menuselect[]' value='{$row['menu_id']}' />".$row['menu_name']."</td>
<td style='color:black'> ".$pdeta."&nbsp;</td>
</tr>\n";
}
$text .= "</table></div>";
2006-12-02 04:36:16 +00:00
$text .= "</td><td style='width:50%;vertical-align:top;text-align:center'><br />";
foreach ($menu_areas as $menu_act)
{
$text .= "<input type='submit' class='button' id='menuActivate_".trim($menu_act)."' name='menuActivate[".trim($menu_act)."]' value='".MENLAN_13." ".trim($menu_act)."' /><br /><br />\n";
}
if($layout)
{
if(isset($pref['sitetheme_layouts'][$layout]['menuPresets']))
{
$text .= "<input type='submit' class='button' name='menuUsePreset' value=\"".MENLAN_40."\" onclick=\"return jsconfirm('".$tp->toJS(MENLAN_41)."')\" /><br /><br />\n"; // Use Menu Presets
$text .= "<input type='hidden' name='menuPreset' value='".$layout."' />";
}
$text .= "<input type='hidden' name='curLayout' value='".$layout."' />";
}
2006-12-02 04:36:16 +00:00
$text .= "</td>";
$text .= "</tr></table>";
echo $ns -> tablerender(MENLAN_22, $text);
echo $frm->form_close();
echo "</div>";
parseheader($menus_footer);
}
2006-12-02 04:36:16 +00:00
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function layout_list()
{
global $frm, $curLayout, $menus_equery, $pref, $HEADER, $CUSTOMHEADER, $CUSTOMFOOTER, $CUSTOMPAGES;
$text .= "<form method='post' action='".e_SELF."?configure.".$curLayout."'>";
$text .= "<div style='color:white;background-color:black;width:99%;left:0px;position:relative;display:block;padding:15px;text-align:center'>".MENLAN_30." ";
// $text .= $frm->form_select_open('custom_select', 'onchange="this.form.submit()"');
$text .= "<select style='color:black' name='custom_select' onchange=\"this.form.submit()\">\n";
if(is_array($HEADER))
{
foreach($HEADER as $key=>$val)
{
$default = ($curLayout == $key || $curLayout == 'default_layout' ) ? "selected" : FALSE;
$deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : "";
$diz = str_replace("_"," ",$key);
$text .= $frm->form_option(ucwords($diz).$deftext, $default, $key);
}
}
else
{
$text .= $frm->form_option(MENLAN_31, '', '');
}
if($CUSTOMHEADER && !is_array($CUSTOMHEADER))
{
$CUSTOMHEADER = array('no_array'=>$CUSTOMHEADER);
}
if($CUSTOMFOOTER && !is_array($CUSTOMFOOTER))
{
$CUSTOMFOOTER = array('no_array'=> $CUSTOMFOOTER);
}
if(is_array($CUSTOMHEADER) || is_array($CUSTOMFOOTER))
{
$customlist = (is_array($CUSTOMHEADER)) ? array_merge($CUSTOMHEADER,$CUSTOMFOOTER) : $CUSTOMFOOTER;
foreach($customlist as $key=>$val)
{
$selected = ($curLayout == $key || $curLayout == 'default_layout' ) ? "selected='selected'" : "";
$deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : "";
$diz = ($key == "no_array") ? MENLAN_33 : str_replace("_"," ",$key);
$text .= "<option value='$key' $selected style='color:black'>".ucwords($diz).$deftext."</option>\n";
// $text .= $frm->form_option(ucwords($diz).$deftext, $default, $key);
}
}
$text .= "</select>";
// TO-DO Saving of the custompage preference for each layout.
if($curLayout && ($curLayout != $pref['sitetheme_deflayout']))
{
if(!isset($pref['sitetheme_custompages'][$curLayout]))
{
if(isset($pref['sitetheme_layouts'][$curLayout]['customPages']))
{
$custPages = $pref['sitetheme_layouts'][$curLayout]['customPages'];
}
elseif(isset($CUSTOMPAGES[$curLayout]) && $curLayout !='no_array')
{
$custPages = $CUSTOMPAGES[$curLayout];
}
elseif($CUSTOMPAGES)
{
$custPages = $CUSTOMPAGES;
}
menuSetCustomPages(array($curLayout=>$custPages));
}
else
{
$custPages = $pref['sitetheme_custompages'][$curLayout];
}
$text .= "<div style='padding:10px'>Displays on these pages: <input type='text' style='width:80%;color:black;background-color:white' name='custompages[".$curLayout."]' value=\"".implode(" ",$custPages)."\" />
<input type='submit' name='menuSetCustomPages' value='".LAN_SAVE."' />
</div>";
}
$text .= "</div>
</form>";
return $text;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function parseheader($LAYOUT, $check = FALSE)
2008-06-24 20:53:07 +00:00
{
global $curLayout;
2008-06-24 20:53:07 +00:00
// $tmp = explode("\n", $LAYOUT);
// Split up using the same function as the shortcode handler
$tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
for ($c = 0; $c < count($tmp); $c++)
2008-06-24 20:53:07 +00:00
{
if (preg_match("/[\{|\}]/", $tmp[$c]))
2008-06-24 20:53:07 +00:00
{
if ($check)
2008-06-24 20:53:07 +00:00
{
if (strstr($tmp[$c], "{MENU="))
2008-06-24 20:53:07 +00:00
{
$str[] = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $tmp[$c]);
2006-12-02 04:36:16 +00:00
}
}
else
2008-06-24 20:53:07 +00:00
{
checklayout($tmp[$c],$curLayout);
2008-06-24 20:53:07 +00:00
}
}
else
2008-06-24 20:53:07 +00:00
{
if (!$check)
2008-06-24 20:53:07 +00:00
{
echo $tmp[$c];
}
2006-12-02 04:36:16 +00:00
}
2008-06-24 20:53:07 +00:00
}
if ($check)
2008-06-24 20:53:07 +00:00
{
return $str;
}
2006-12-02 04:36:16 +00:00
}
function checklayout($str,$curLayout)
2007-03-06 19:59:36 +00:00
{ // Displays a basic representation of the theme
global $pref, $menu_areas, $ns, $PLUGINS_DIRECTORY, $frm, $sc_style, $tp, $menus_equery;
2006-12-02 04:36:16 +00:00
$menuLayout = ($curLayout != $pref['sitetheme_deflayout']) ? $curLayout : "";
if (strstr($str, "LOGO"))
2007-03-06 19:59:36 +00:00
{
echo $tp -> parseTemplate("{LOGO}");
}
else if(strstr($str, "SITENAME"))
2007-03-06 19:59:36 +00:00
{
echo "<div style='padding: 2px'>[SiteName]</div>";
2006-12-02 04:36:16 +00:00
}
else if (strstr($str, "SITETAG"))
2007-03-06 19:59:36 +00:00
{
echo "<div style='padding: 2px'>[SiteTag]</div>";
2006-12-02 04:36:16 +00:00
}
else if (strstr($str, "SITELINKS"))
2007-03-06 19:59:36 +00:00
{
echo "<div style='padding: 2px; text-align: center'>[SiteLinks]</div>";
2006-12-02 04:36:16 +00:00
}
else if (strstr($str, "LANGUAGELINKS"))
2007-03-06 19:59:36 +00:00
{
echo "<div class=text style='padding: 2px; text-align: center'>[Language]</div>";
2006-12-02 04:36:16 +00:00
}
else if (strstr($str, "CUSTOM"))
2007-03-06 19:59:36 +00:00
{
$cust = preg_replace("/\W*\{CUSTOM=(.*?)(\+.*)?\}\W*/si", "\\1", $str);
echo "<div style='padding: 2px'>[".$cust."]</div>";
2006-12-02 04:36:16 +00:00
}
// Display embedded Plugin information.
2007-03-06 19:59:36 +00:00
else if (strstr($str, "PLUGIN"))
{
2006-12-02 04:36:16 +00:00
$plug = preg_replace("/\{PLUGIN=(.*?)\}/si", "\\1", $str);
$plug = trim($plug);
2007-03-06 19:59:36 +00:00
if (file_exists((e_PLUGIN."{$plug}/{$plug}_config.php")))
{
$link = e_PLUGIN."{$plug}/{$plug}_config.php";
2006-12-02 04:36:16 +00:00
}
2007-03-06 19:59:36 +00:00
if(file_exists((e_PLUGIN.$plug."/config.php")))
{
$link = e_PLUGIN.$plug."/config.php";
2006-12-02 04:36:16 +00:00
}
$plugtext = ($link) ? "(".MENLAN_34.":<a href='$link' title='".MENLAN_16."'>".MENLAN_16."</a>)" : "(".MENLAN_34.")" ;
echo "<br />";
$ns -> tablerender($plug, $plugtext);
}
else if (strstr($str, "MENU"))
2007-03-06 19:59:36 +00:00
{
2006-12-02 04:36:16 +00:00
$ns = new e107table;
$menu = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $str);
if (isset($sc_style['MENU']['pre']) && strpos($str, 'ret') !== false)
2007-03-06 19:59:36 +00:00
{
echo $sc_style['MENU']['pre'];
2006-12-02 04:36:16 +00:00
}
echo "<div style='text-align:center; font-size:14px' class='fborder'><div class='forumheader'><b>".MENLAN_14." ".$menu."</b></div></div><br />";
$text = "&nbsp;";
$sql9 = new db;
if ($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' AND menu_layout = '$menuLayout' "))
2007-03-06 19:59:36 +00:00
{
2006-12-02 04:36:16 +00:00
unset($text);
echo $frm->form_open("post", e_SELF."?configure.".$curLayout, "frm_menu_".intval($menu));
2006-12-02 04:36:16 +00:00
$sql9->db_Select("menus", "*", "menu_location='$menu' AND menu_layout='$menuLayout' ORDER BY menu_order");
2006-12-02 04:36:16 +00:00
$menu_count = $sql9->db_Rows();
while (list($menu_id, $menu_name, $menu_location, $menu_order, $menu_class, $menu_pages, $menu_path) = $sql9->db_Fetch(MYSQL_NUM)) {
2006-12-02 04:36:16 +00:00
$menu_name = preg_replace("#_menu#i", "", $menu_name);
$vis = ($menu_class || strlen($menu_pages) > 1) ? " <span style='color:red'>*</span> " :
"";
$caption = "<div style='text-align:center'>{$menu_name}{$vis}</div>";
$menu_info = "{$menu_location}.{$menu_order}";
$text = "";
$conf = '';
if (file_exists(e_PLUGIN."{$menu_path}/{$menu_name}_menu_config.php"))
{
2007-03-06 19:59:36 +00:00
$conf = "config.{$menu_path}.{$menu_name}_menu_config";
2006-12-02 04:36:16 +00:00
}
if($conf == '' && file_exists(e_PLUGIN."{$menu_path}/config.php"))
{
2007-03-06 19:59:36 +00:00
$conf = "config.{$menu_path}.config";
2006-12-02 04:36:16 +00:00
}
$text .= "<select id='menuAct_$menu_id' name='menuAct[$menu_id]' class='tbox' onchange='this.form.submit()' >";
$text .= $frm->form_option(MENLAN_25, TRUE, " ");
$text .= $frm->form_option(MENLAN_15, "", "deac.{$menu_info}");
if ($conf) {
$text .= $frm->form_option(MENLAN_16, "", $conf);
}
if ($menu_order != 1) {
$text .= $frm->form_option(MENLAN_17, "", "inc.{$menu_info}");
$text .= $frm->form_option(MENLAN_24, "", "top.{$menu_info}");
}
if ($menu_count != $menu_order) {
$text .= $frm->form_option(MENLAN_18, "", "dec.{$menu_info}");
$text .= $frm->form_option(MENLAN_23, "", "bot.{$menu_info}");
}
foreach ($menu_areas as $menu_act) {
if ($menu != $menu_act) {
$text .= $frm->form_option(MENLAN_19." ".$menu_act, "", "move.{$menu_info}.".$menu_act);
}
}
$text .= $frm->form_option(MENLAN_20, "", "adv.{$menu_info}");
$text .= $frm->form_select_close();
$ns->tablerender($caption, $text);
echo "<div><br /></div>";
}
echo $frm->form_close();
}
if(isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false) {
echo $sc_style['MENU']['post'];
}
}
else if (strstr($str, "SETSTYLE")) {
$tmp = explode("=", $str);
$style = preg_replace("/\{SETSTYLE=(.*?)\}/si", "\\1", $str);
}
else if (strstr($str, "SITEDISCLAIMER")) {
echo "[Sitedisclaimer]";
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
require_once("footer.php");
/*
if ($CUSTOMPAGES)
{
if ($menu_act != 'adv')
{
$text = "<form method='post' action='".e_SELF."?configure.".$curLayout."'><div style='width: 100%'>
<table class='fborder' style='".ADMIN_WIDTH."'>
<tr>
<td class='forumheader3' style='width: 90%'>
".MENLAN_30."
</td>
<td class='forumheader3' style='width: 10%; text-align: center;'>";
$text .= $frm->form_select_open('custom_select', 'onchange="this.form.submit()"');
if ($curLayout == '' || $curLayout == 'default_layout')
{
$text .= $frm->form_option(MENLAN_31, 'selected', 'default_layout');
}
else
{
$text .= $frm->form_option(MENLAN_31, FALSE, 'default_layout');
}
if ($NEWSHEADER)
{
if ($curLayout == 'newsheader_layout')
{
$text .= $frm->form_option(MENLAN_32, 'selected', 'newsheader_layout');
}
else
{
$text .= $frm->form_option(MENLAN_32, FALSE, 'newsheader_layout');
}
}
if ($CUSTOMPAGES)
{
if (is_array($CUSTOMPAGES))
{
foreach ($CUSTOMPAGES as $custom_pages_key => $custom_pages_value)
{
if ($curLayout == $custom_pages_key)
{
$text .= $frm->form_option($custom_pages_key, 'selected', $custom_pages_key);
}
else
{
$text .= $frm->form_option($custom_pages_key, FALSE, $custom_pages_key);
}
}
}
else
{
if ($curLayout == 'custom_layout')
{
$text .= $frm->form_option(MENLAN_33, 'selected', 'custom_layout');
}
else
{
$text .= $frm->form_option(MENLAN_33, FALSE, 'custom_layout');
}
}
}
$text .= $frm->form_select_close();
$text .= "</td>
</tr>
</table></div>
</form>";
$ns->tablerender(MENLAN_29, $text);
}
}
*/
2006-12-02 04:36:16 +00:00
?>