1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

Menus can now be configured independently for different custom theme layouts. (backwards compatible). Custompages can be defined in admin. (no need to edit theme.php any more).

Front-end is working for custompages and layouts, but not the menus yet, but soon!.
This commit is contained in:
CaMer0n
2009-07-07 12:54:47 +00:00
parent bcedb188d2
commit 9225ac471b
4 changed files with 303 additions and 223 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $
| $Revision: 1.16 $ | $Revision: 1.17 $
| $Date: 2009-07-06 05:59:42 $ | $Date: 2009-07-07 12:54:44 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -36,44 +36,47 @@ if($_POST)
} }
$menus_equery = explode('.', e_QUERY); $menus_equery = explode('.', e_QUERY);
$curLayout = $menus_equery[1];
if (isset($_POST['custom_select'])) if (isset($_POST['custom_select']))
{ {
$menus_equery[1] = $_POST['custom_select']; $curLayout = $_POST['custom_select'];
//header("location:".e_SELF."?".$_POST['custom_select']); //header("location:".e_SELF."?".$_POST['custom_select']);
//exit; //exit;
} }
else if (!isset($menus_equery[1])) else if (!isset($curLayout))
{ {
$menus_equery[1] = ''; $curLayout = '';
} }
if ($menus_equery[1] == '' || $menus_equery[1] == 'default_layout')
if ($curLayout == '' || $curLayout == 'default_layout')
{ {
$menus_header = is_array($HEADER) ? $HEADER[$pref['sitetheme_deflayout']] : $HEADER; $menus_header = is_array($HEADER) ? $HEADER[$pref['sitetheme_deflayout']] : $HEADER;
$menus_footer = is_array($FOOTER) ? $FOOTER[$pref['sitetheme_deflayout']] : $FOOTER; $menus_footer = is_array($FOOTER) ? $FOOTER[$pref['sitetheme_deflayout']] : $FOOTER;
} }
else if ($menus_equery[1] == 'custom_layout') else if ($curLayout == 'no_array')
{ {
$menus_header = $CUSTOMHEADER ? $CUSTOMHEADER : $HEADER; $menus_header = $CUSTOMHEADER ? $CUSTOMHEADER : $HEADER;
$menus_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER; $menus_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER;
} }
else if ($menus_equery[1] == 'newsheader_layout') else if ($curLayout == 'newsheader_layout')
{ {
$menus_header = $NEWSHEADER ? $NEWSHEADER : $HEADER; $menus_header = $NEWSHEADER ? $NEWSHEADER : $HEADER;
$menus_footer = $FOOTER; $menus_footer = $FOOTER;
} }
elseif(is_array($HEADER) || is_array($FOOTER)) // 0.8 themes elseif(is_array($HEADER) || is_array($FOOTER)) // 0.8 themes
{ {
$menus_header = (is_array($HEADER) && isset($HEADER[$menus_equery[1]])) ? $HEADER[$menus_equery[1]] : $HEADER; $menus_header = (is_array($HEADER) && isset($HEADER[$curLayout])) ? $HEADER[$curLayout] : $HEADER;
$menus_footer = (is_array($FOOTER) && isset($FOOTER[$menus_equery[1]])) ? $FOOTER[$menus_equery[1]] : $FOOTER; $menus_footer = (is_array($FOOTER) && isset($FOOTER[$curLayout])) ? $FOOTER[$curLayout] : $FOOTER;
} }
else else
{ {
$menus_header = $CUSTOMHEADER[$menus_equery[1]] ? $CUSTOMHEADER[$menus_equery[1]] : $HEADER; $menus_header = $CUSTOMHEADER[$curLayout] ? $CUSTOMHEADER[$curLayout] : $HEADER;
$menus_footer = $CUSTOMFOOTER[$menus_equery[1]] ? $CUSTOMFOOTER[$menus_equery[1]] : $FOOTER; $menus_footer = $CUSTOMFOOTER[$curLayout] ? $CUSTOMFOOTER[$curLayout] : $FOOTER;
} }
@@ -130,31 +133,41 @@ foreach ($menu_array as $menu_value)
// Cams Bit ----------- Activate Multiple Menus --- // Cams Bit ----------- Activate Multiple Menus ---
if($_POST['menuActivate']) if($_POST['menuActivate'])
{ {
foreach ($_POST['menuActivate'] as $k => $v) menuActivate();
{
if (trim($v))
{
$location = $k;
}
} }
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location=".$location); if($_POST['menuSetCustomPages'])
{
menuSetCustomPages($_POST['custompages']);
}
function menuActivate()
{
global $sql, $admin_log, $pref;
$location = key($_POST['menuActivate']);
echo "LAYOUT= ".$_POST['curLayout'] ;
$layout = ($_POST['curLayout'] != $pref['sitetheme_deflayout']) ? $_POST['curLayout'] : "";
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location=".$location." AND menu_layout = '$layout' ");
foreach($_POST['menuselect'] as $sel_mens) foreach($_POST['menuselect'] as $sel_mens)
{ {
//Get info from menu being activated //Get info from menu being activated
if($sql->db_Select("menus", 'menu_name, menu_path' , 'menu_id = '.$sel_mens)) if($sql->db_Select("menus", 'menu_name, menu_path' , "menu_id = ".$sel_mens." "))
{ {
$row=$sql->db_Fetch(); $row=$sql->db_Fetch();
//If menu is not already activated in that area, add the record. //If menu is not already activated in that area, add the record.
if(!$sql->db_Select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = $location"))
if(!$sql->db_Update('menus', "menu_order='{$menu_count}', menu_location = ".$location." WHERE menu_name='".$row['menu_name']."' AND menu_layout = '$layout' LIMIT 1 ",TRUE))
{ {
$qry = " $qry = "
INSERT into #menus INSERT into #menus
(`menu_name`, `menu_location`, `menu_order`, `menu_pages`, `menu_path`) (`menu_name`, `menu_location`, `menu_order`, `menu_pages`, `menu_path`, `menu_layout`)
VALUES ('{$row['menu_name']}', {$location}, {$menu_count}, '', '{$row['menu_path']}') VALUES ('{$row['menu_name']}', {$location}, {$menu_count}, '', '{$row['menu_path']}', '{$layout}')
"; ";
$sql->db_Select_gen($qry); $sql->db_Select_gen($qry,TRUE);
$admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,''); $admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
$menu_count++; $menu_count++;
} }
@@ -162,6 +175,13 @@ if($_POST['menuActivate'])
} }
} }
function menuSetCustomPages($array)
{
global $pref;
$key = key($array);
$pref['sitetheme_custompages'][$key] = $array[$key];
save_prefs();
}
function getMenuPreset($layout) function getMenuPreset($layout)
{ {
@@ -175,7 +195,6 @@ function getMenuPreset($layout)
$temp = $pref['sitetheme_layouts'][$layout]['menuPresets']['area']; $temp = $pref['sitetheme_layouts'][$layout]['menuPresets']['area'];
foreach($temp as $key=>$val) foreach($temp as $key=>$val)
{ {
$iD = $val['@attributes']['id']; $iD = $val['@attributes']['id'];
@@ -185,10 +204,8 @@ function getMenuPreset($layout)
'menu_location' => $iD, 'menu_location' => $iD,
'menu_order' => $k, 'menu_order' => $k,
'menu_name' => $v['@attributes']['name']."_menu", 'menu_name' => $v['@attributes']['name']."_menu",
'menu_class' => $v['@attributes']['userclass'] 'menu_class' => intval(constant(trim($v['@attributes']['userclass'])))
); );
} }
} }
@@ -216,22 +233,38 @@ function checkMenuPreset($array,$name)
if(isset($_POST['menuUsePreset']) && $_POST['menuPreset']) if(isset($_POST['menuUsePreset']) && $_POST['curLayout'])
{ {
$layout = $_POST['menuPreset']; global $pref;
$menuAreas = getMenuPreset($layout); $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.
$sql->db_Update("menus", "menu_location='0' "); // Clear All existing.
foreach($menuAreas as $val) foreach($menuAreas as $val)
{ {
if(!$sql->db_Update("menus", "menu_class='".$val['menu_class']."', menu_order = ".$val['menu_order'].", menu_location='".$val['menu_location']."' WHERE menu_name='".$val['menu_name']."' LIMIT 1"))
if($sql->db_Select("menus", 'menu_name, menu_path' , "menu_name = '".$val['menu_name']."' LIMIT 1"))
{ {
// echo "it failed "; $row=$sql->db_Fetch();
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 ",TRUE))
{
$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}')
";
$sql->db_Select_gen($qry,TRUE);
$admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
} }
} }
}
} }
// ============= // =============
@@ -275,7 +308,7 @@ function showVisibility()
$menu_pages = substr($row['menu_pages'], 2); $menu_pages = substr($row['menu_pages'], 2);
$menu_pages = str_replace("|", "\n", $menu_pages); $menu_pages = str_replace("|", "\n", $menu_pages);
$text = "<div style='text-align:center;'> $text = "<div style='text-align:center;'>
<form method='post' action='".e_SELF."?configure.".$menus_equery[1]."'> <form method='post' action='".e_SELF."?configure.".$curLayout."'>
<table style='width:40%'> <table style='width:40%'>
<tr> <tr>
<td> <td>
@@ -367,30 +400,30 @@ if ($menu_act == "deac")
if ($menu_act == "bot") if ($menu_act == "bot")
{ {
$menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location='{$location}' "); $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}' "); $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}"); $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='{$location}' AND menu_order > {$position} AND menu_layout = '$curLayout' ");
$admin_log->log_event('MENU_06',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,''); $admin_log->log_event('MENU_06',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
} }
if ($menu_act == "top") if ($menu_act == "top")
{ {
$sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_location='{$location}' AND menu_order < {$position}"); $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_location='{$location}' AND menu_order < {$position} AND menu_layout = '$curLayout' ");
$sql->db_Update("menus", "menu_order=1 WHERE menu_id='{$id}' "); $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,''); $admin_log->log_event('MENU_05',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
} }
if ($menu_act == "dec") if ($menu_act == "dec")
{ {
$sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_order='".($position+1)."' AND menu_location='{$location}' "); $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}' "); $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_id='{$id}' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
$admin_log->log_event('MENU_08',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,''); $admin_log->log_event('MENU_08',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
} }
if ($menu_act == "inc") if ($menu_act == "inc")
{ {
$sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_order='".($position-1)."' AND menu_location='{$location}' "); $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}' "); $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_id='{$id}' AND menu_location='{$location}' AND menu_layout = '$curLayout' ");
$admin_log->log_event('MENU_07',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,''); $admin_log->log_event('MENU_07',$location.'[!br!]'.$position.'[!br!]'.$id,E_LOG_INFORMATIVE,'');
} }
@@ -425,12 +458,14 @@ if (strpos(e_QUERY, 'configure') === FALSE)
$menustr .= "&".str_replace(".php", "", $file['fname']); $menustr .= "&".str_replace(".php", "", $file['fname']);
if (!$existing_menu) if (!$existing_menu)
{ // New menu to add to list { // New menu to add to list
$sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}'"); if($sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}', ''"))
{
// Could do admin logging here - but probably not needed // Could do admin logging here - but probably not needed
$message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />"; $message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />";
} }
} }
} }
}
//Reorder all menus into 1...x order //Reorder all menus into 1...x order
if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed
@@ -466,99 +501,35 @@ if ($message != "")
if (strpos(e_QUERY, 'configure') === FALSE) if (strpos(e_QUERY, 'configure') === FALSE)
{ {
$cnt = $sql->db_Select("menus", "*", "menu_location='1' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar. $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' width='100%' style='width: 100%; height: ".(($cnt*80)+600)."px; border: 0px' frameborder='0' scrolling='auto' ></iframe>"; $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>";
echo $ns -> tablerender(MENLAN_35, $text, 'menus_config'); echo $ns -> tablerender(MENLAN_35, $text, 'menus_config');
} }
else // Within the IFrame. else // Within the IFrame.
{ {
echo layout_list(); echo layout_list();
/* menuRenderPage();
if ($CUSTOMPAGES)
{
if ($menu_act != 'adv')
{
$text = "<form method='post' action='".e_SELF."?configure.".$menus_equery[1]."'><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 ($menus_equery[1] == '' || $menus_equery[1] == 'default_layout')
{
$text .= $frm->form_option(MENLAN_31, 'selected', 'default_layout');
}
else
{
$text .= $frm->form_option(MENLAN_31, FALSE, 'default_layout');
} }
if ($NEWSHEADER) // =-----------------------------------------------------------------------------
{
if ($menus_equery[1] == '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 ($menus_equery[1] == $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 ($menus_equery[1] == '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(); function menuRenderPage()
{
global $sql, $ns, $menus_header, $menus_footer, $frm, $curLayout, $pref, $tp, $menu_areas;
$text .= "</td> parseheader($menus_header); // $layouts_str;
</tr>
</table></div>
</form>";
$ns->tablerender(MENLAN_29, $text); $layout = ($curLayout) ? $curLayout : $pref['sitetheme_deflayout'];
}
}
*/
parseheader($menus_header); $layouts_str;
$layout = ($menus_equery[1]) ? $menus_equery[1] : $pref['sitetheme_deflayout'];
$menuPreset = getMenuPreset($layout); $menuPreset = getMenuPreset($layout);
echo "<div style='text-align:center'>"; echo "<div style='text-align:center'>";
echo $frm->form_open("post", e_SELF."?configure.".$menus_equery[1], "menuActivation"); echo $frm->form_open("post", e_SELF."?configure.".$curLayout, "menuActivation");
$text = "<table style='width:80%;margin-left:auto;margin-right:auto'>"; $text = "<table style='width:80%;margin-left:auto;margin-right:auto'>";
$sql->db_Select("menus", "menu_name, menu_id, menu_pages", "1 GROUP BY menu_name ORDER BY menu_name ASC"); $sql->db_Select("menus", "menu_name, menu_id, menu_pages", "1 GROUP BY menu_name ORDER BY menu_name ASC");
@@ -587,36 +558,13 @@ else // Within the IFrame.
$text .= "<tr style='background-color:$color;color:black'> $text .= "<tr style='background-color:$color;color:black'>
<td style='text-align:left'><input type='checkbox' name='menuselect[]' value='{$row['menu_id']}' />".$row['menu_name']."</td> <td style='text-align:left; color:black;'><input type='checkbox' name='menuselect[]' value='{$row['menu_id']}' />".$row['menu_name']."</td>
<td> ".$pdeta."&nbsp;</td> <td style='color:black'> ".$pdeta."&nbsp;</td>
</tr>\n"; </tr>\n";
} }
$text .= "</table></div>"; $text .= "</table></div>";
/* $text .= "<select name='menuselect[]' class='tbox' multiple='multiple' style='height:200px;width:95%'>\n";
while ($row = $sql->db_Fetch())
{
if($row['menu_pages'] == "dbcustom")
{
$row['menu_name'] .= " [".MENLAN_42."]";
}
else
{
$row['menu_name'] = preg_replace("#_menu$#i", "", $row['menu_name']);
if($pnum = checkMenuPreset($menuPreset,$row['menu_name']."_menu"))
{
$row['menu_name'] .= " [".MENLAN_39." {$pnum}]";
}
}
$text .= "<option value='{$row['menu_id']}'>".$row['menu_name']."</option>\n";
}
$text .= "</select>";*/
// $text .= "<br /><br /><span class='smalltext'>".MENLAN_38."</span>";
$text .= "</td><td style='width:50%;vertical-align:top;text-align:center'><br />"; $text .= "</td><td style='width:50%;vertical-align:top;text-align:center'><br />";
foreach ($menu_areas as $menu_act) foreach ($menu_areas as $menu_act)
{ {
@@ -624,11 +572,15 @@ else // Within the IFrame.
} }
if(is_array($pref['sitetheme_layouts'][$layout]['menuPresets'])) 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='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='menuPreset' value='".$layout."' />";
} }
$text .= "<input type='hidden' name='curLayout' value='".$layout."' />";
}
$text .= "</td>"; $text .= "</td>";
@@ -640,23 +592,27 @@ else // Within the IFrame.
parseheader($menus_footer); parseheader($menus_footer);
} }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function layout_list() function layout_list()
{ {
global $frm, $menus_equery, $pref,$HEADER, $CUSTOMHEADER, $CUSTOMFOOTER, $CUSTOMPAGES; global $frm, $curLayout, $menus_equery, $pref, $HEADER, $CUSTOMHEADER, $CUSTOMFOOTER, $CUSTOMPAGES;
$text .= "<form method='post' action='".e_SELF."?configure.".$menus_equery[1]."'>"; $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 .= "<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 .= $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)) if(is_array($HEADER))
{ {
foreach($HEADER as $key=>$val) foreach($HEADER as $key=>$val)
{ {
$default = ($menus_equery[1] == $key || $menus_equery[1] == 'default_layout' ) ? "selected" : FALSE; $default = ($curLayout == $key || $curLayout == 'default_layout' ) ? "selected" : FALSE;
$deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : ""; $deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : "";
$diz = str_replace("_"," ",$key); $diz = str_replace("_"," ",$key);
$text .= $frm->form_option(ucwords($diz).$deftext, $default, $key); $text .= $frm->form_option(ucwords($diz).$deftext, $default, $key);
@@ -669,12 +625,12 @@ function layout_list()
if($CUSTOMHEADER && !is_array($CUSTOMHEADER)) if($CUSTOMHEADER && !is_array($CUSTOMHEADER))
{ {
$CUSTOMHEADER = array('custom_layout'=>$CUSTOMHEADER); $CUSTOMHEADER = array('no_array'=>$CUSTOMHEADER);
} }
if($CUSTOMFOOTER && !is_array($CUSTOMFOOTER)) if($CUSTOMFOOTER && !is_array($CUSTOMFOOTER))
{ {
$CUSTOMFOOTER = array('custom_layout'=> $CUSTOMFOOTER); $CUSTOMFOOTER = array('no_array'=> $CUSTOMFOOTER);
} }
@@ -683,10 +639,11 @@ function layout_list()
$customlist = (is_array($CUSTOMHEADER)) ? array_merge($CUSTOMHEADER,$CUSTOMFOOTER) : $CUSTOMFOOTER; $customlist = (is_array($CUSTOMHEADER)) ? array_merge($CUSTOMHEADER,$CUSTOMFOOTER) : $CUSTOMFOOTER;
foreach($customlist as $key=>$val) foreach($customlist as $key=>$val)
{ {
$default = ($menus_equery[1] == $key || $menus_equery[1] == 'default_layout' ) ? "selected" : FALSE; $selected = ($curLayout == $key || $curLayout == 'default_layout' ) ? "selected='selected'" : "";
$deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : ""; $deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : "";
$diz = str_replace("_"," ",$key); $diz = ($key == "no_array") ? MENLAN_33 : str_replace("_"," ",$key);
$text .= $frm->form_option(ucwords($diz).$deftext, $default, $key); $text .= "<option value='$key' $selected style='color:black'>".ucwords($diz).$deftext."</option>\n";
// $text .= $frm->form_option(ucwords($diz).$deftext, $default, $key);
} }
} }
@@ -696,13 +653,35 @@ function layout_list()
// TO-DO Saving of the custompage preference for each layout. // TO-DO Saving of the custompage preference for each layout.
if($menus_equery[1] && ($menus_equery[1] != $pref['sitetheme_deflayout'])) if($curLayout && ($curLayout != $pref['sitetheme_deflayout']))
{ {
if(is_array($CUSTOMPAGES))
if(!$pref['sitetheme_custompages'][$curLayout])
{ {
$CUSTOMPAGES = $CUSTOMPAGES[".$menus_equery[1]."]; if(isset($pref['sitetheme_layouts'][$curLayout]['customPages']))
{
$custPages = $pref['sitetheme_layouts'][$curLayout]['customPages'];
} }
$text .= "<div style='padding:10px'>Displays on these pages: <input type='text' class='tbox' style='width:90%' name='custompages[".$menus_equery[1]."]' value=\"".$CUSTOMPAGES."\" /></div>"; 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=\"".$custPages."\" />
<input type='submit' name='menuSetCustomPages' value='".LAN_SAVE."' />
</div>";
} }
$text .= "</div> $text .= "</div>
</form>"; </form>";
@@ -713,6 +692,7 @@ function layout_list()
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function parseheader($LAYOUT, $check = FALSE) function parseheader($LAYOUT, $check = FALSE)
{ {
global $curLayout;
// $tmp = explode("\n", $LAYOUT); // $tmp = explode("\n", $LAYOUT);
// Split up using the same function as the shortcode handler // 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 ); $tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
@@ -729,7 +709,7 @@ function parseheader($LAYOUT, $check = FALSE)
} }
else else
{ {
checklayout($tmp[$c]); checklayout($tmp[$c],$curLayout);
} }
} }
else else
@@ -746,10 +726,12 @@ function parseheader($LAYOUT, $check = FALSE)
} }
} }
function checklayout($str) function checklayout($str,$curLayout)
{ // Displays a basic representation of the theme { // Displays a basic representation of the theme
global $pref, $menu_areas, $ns, $PLUGINS_DIRECTORY, $frm, $sc_style, $tp, $menus_equery; global $pref, $menu_areas, $ns, $PLUGINS_DIRECTORY, $frm, $sc_style, $tp, $menus_equery;
$menuLayout = ($curLayout != $pref['sitetheme_deflayout']) ? $curLayout : "";
if (strstr($str, "LOGO")) if (strstr($str, "LOGO"))
{ {
echo $tp -> parseTemplate("{LOGO}"); echo $tp -> parseTemplate("{LOGO}");
@@ -805,12 +787,12 @@ function checklayout($str)
echo "<div style='text-align:center; font-size:14px' class='fborder'><div class='forumheader'><b>".MENLAN_14." ".$menu."</b></div></div><br />"; echo "<div style='text-align:center; font-size:14px' class='fborder'><div class='forumheader'><b>".MENLAN_14." ".$menu."</b></div></div><br />";
$text = "&nbsp;"; $text = "&nbsp;";
$sql9 = new db; $sql9 = new db;
if ($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' ")) if ($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' AND menu_layout = '$menuLayout' "))
{ {
unset($text); unset($text);
echo $frm->form_open("post", e_SELF."?configure.".$menus_equery[1], "frm_menu_".intval($menu)); echo $frm->form_open("post", e_SELF."?configure.".$curLayout, "frm_menu_".intval($menu));
$sql9->db_Select("menus", "*", "menu_location='$menu' ORDER BY menu_order"); $sql9->db_Select("menus", "*", "menu_location='$menu' AND menu_layout='$menuLayout' ORDER BY menu_order");
$menu_count = $sql9->db_Rows(); $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)) { while (list($menu_id, $menu_name, $menu_location, $menu_order, $menu_class, $menu_pages, $menu_path) = $sql9->db_Fetch(MYSQL_NUM)) {
$menu_name = preg_replace("#_menu#i", "", $menu_name); $menu_name = preg_replace("#_menu#i", "", $menu_name);
@@ -873,4 +855,83 @@ function checklayout($str)
} }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
require_once("footer.php"); 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);
}
}
*/
?> ?>

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
| $Revision: 1.17 $ | $Revision: 1.18 $
| $Date: 2009-06-29 21:26:58 $ | $Date: 2009-07-07 12:54:47 $
| $Author: e107steved $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
header("location:../index.php"); header("location:../index.php");
@@ -292,6 +292,7 @@ CREATE TABLE menus (
menu_class varchar(255) NOT NULL default '0', menu_class varchar(255) NOT NULL default '0',
menu_pages text NOT NULL, menu_pages text NOT NULL,
menu_path varchar(100) NOT NULL default '', menu_path varchar(100) NOT NULL default '',
menu_layout varchar(100) NOT NULL default '',
PRIMARY KEY (menu_id) PRIMARY KEY (menu_id)
) TYPE=MyISAM; ) TYPE=MyISAM;
# -------------------------------------------------------- # --------------------------------------------------------

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.38 $ | $Revision: 1.39 $
| $Date: 2009-06-29 21:26:58 $ | $Date: 2009-07-07 12:54:46 $
| $Author: e107steved $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -244,7 +244,7 @@ function update_706_to_800($type='')
// List of changed DB tables (defined in core_sql.php) // List of changed DB tables (defined in core_sql.php)
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster) // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
$changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist'); $changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist', 'menus');
// List of changed DB tables from core plugins (defined in pluginname_sql.php file) // List of changed DB tables from core plugins (defined in pluginname_sql.php file)

View File

@@ -6,8 +6,8 @@
| Released under the terms and conditions of the GNU General Public License (http://gnu.org). | Released under the terms and conditions of the GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $ | $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $
| $Revision: 1.30 $ | $Revision: 1.31 $
| $Date: 2009-07-05 21:20:30 $ | $Date: 2009-07-07 12:54:47 $
| $Author: e107coders $ | $Author: e107coders $
+-----------------------------------------------------------------------------------------------+ +-----------------------------------------------------------------------------------------------+
*/ */
@@ -445,55 +445,73 @@ if ($e107_popup != 1) {
// //
// M: Send top of body for custom pages and for news // M: Send top of body for custom pages and for news
// //
$def = varset($pref['sitetheme_deflayout']);
if(is_array($HEADER) && isset($HEADER[$def]) && isset($FOOTER[$def])) // ---------- New in 0.8 -------------------------------------------------------
$def = ""; // no custom pages found yet.
function checkCustomPages($urlBits) // Function for checking URL matches.
{ {
$HEADER = $HEADER[$def]; if(is_array($urlBits)) return FALSE;
$FOOTER = $FOOTER[$def];
$tpages = explode(" ",$urlBits);
foreach($tpages as $kpage)
{
if ($kpage && (strstr(e_SELF, $kpage) || strstr(e_SELF."?".e_QUERY,$kpage)))
{
return TRUE;
}
}
} }
if(isset($CUSTOMPAGES)) if(is_array($pref['sitetheme_custompages'])) // check if we match a page in layout custompages.
{ {
if (is_array($CUSTOMPAGES)) foreach($pref['sitetheme_custompages'] as $layout=>$cusPages)
{ {
foreach ($CUSTOMPAGES as $cust_key => $cust_value) if(checkCustomPages($cusPages))
{ {
$custompage[$cust_key] = explode(' ', $cust_value); $def = ($layout) ? $layout : "no_array";
}
}
else
{
$custompage['no_array'] = explode(' ', $CUSTOMPAGES);
}
}
else
{
$custompage['no_array'] = array();
}
$ph = FALSE;
if (e_PAGE == 'news.php' && isset($NEWSHEADER)) {
parseheader($NEWSHEADER);
} else {
$full_query = e_SELF."?".e_QUERY."!";
foreach ($custompage as $key_extract => $cust_extract) {
foreach ($cust_extract as $key => $kpage) {
if ($kpage && (strstr(e_SELF, $kpage) || strstr($full_query,$kpage))) {
$ph = TRUE;
if ($key_extract=='no_array') {
$cust_header = $CUSTOMHEADER ? $CUSTOMHEADER : $HEADER;
$cust_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER;
} else {
$cust_header = $CUSTOMHEADER[$key_extract] ? $CUSTOMHEADER[$key_extract] : $HEADER;
$cust_footer = $CUSTOMFOOTER[$key_extract] ? $CUSTOMFOOTER[$key_extract] : $FOOTER;
}
break; break;
} }
} }
} }
parseheader(($ph ? $cust_header : $HEADER));
if(!$def) // no custompage match, so load the default.
{
$def = varset($pref['sitetheme_deflayout']); // default layout.
} }
// The Above should be put into Class2, so it can interact with the menu loading.
if($def && is_array($HEADER) && isset($HEADER[$def]) && isset($FOOTER[$def])) // 0.8 themes - we always use $HEADER and $FOOTER.
{
$HEADER = $HEADER[$def];
$FOOTER = $FOOTER[$def];
}
elseif($def && $def != "no_array" && (isset($CUSTOMHEADER[$def]) || isset($CUSTOMHEADER[$def]))) // 0.7 themes
{
$HEADER = ($CUSTOMHEADER[$def]) ? $CUSTOMHEADER[$def] : $HEADER;
$FOOTER = ($CUSTOMFOOTER[$def]) ? $CUSTOMFOOTER[$def] : $FOOTER;
}
elseif($def && (isset($CUSTOMHEADER) || isset($CUSTOMFOOTER)) ) // 0.6 themes.
{
$HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
$FOOTER = ($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
}
if (e_PAGE == 'news.php' && isset($NEWSHEADER))
{
parseheader($NEWSHEADER);
}
else
{
parseheader($HEADER);
}
unset($def);
// -----------------------------------------------------------------------------
// //
// N: Send other top-of-body HTML // N: Send other top-of-body HTML