diff --git a/e107_admin/menus.php b/e107_admin/menus.php index f0b64b73a..c6a080a0d 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $ -| $Revision: 1.16 $ -| $Date: 2009-07-06 05:59:42 $ +| $Revision: 1.17 $ +| $Date: 2009-07-07 12:54:44 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -36,44 +36,47 @@ if($_POST) } $menus_equery = explode('.', e_QUERY); +$curLayout = $menus_equery[1]; if (isset($_POST['custom_select'])) { - $menus_equery[1] = $_POST['custom_select']; + $curLayout = $_POST['custom_select']; //header("location:".e_SELF."?".$_POST['custom_select']); //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_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_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER; } -else if ($menus_equery[1] == 'newsheader_layout') +else if ($curLayout == 'newsheader_layout') { $menus_header = $NEWSHEADER ? $NEWSHEADER : $HEADER; $menus_footer = $FOOTER; } 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_footer = (is_array($FOOTER) && isset($FOOTER[$menus_equery[1]])) ? $FOOTER[$menus_equery[1]] : $FOOTER; + $menus_header = (is_array($HEADER) && isset($HEADER[$curLayout])) ? $HEADER[$curLayout] : $HEADER; + $menus_footer = (is_array($FOOTER) && isset($FOOTER[$curLayout])) ? $FOOTER[$curLayout] : $FOOTER; } else { - $menus_header = $CUSTOMHEADER[$menus_equery[1]] ? $CUSTOMHEADER[$menus_equery[1]] : $HEADER; - $menus_footer = $CUSTOMFOOTER[$menus_equery[1]] ? $CUSTOMFOOTER[$menus_equery[1]] : $FOOTER; + $menus_header = $CUSTOMHEADER[$curLayout] ? $CUSTOMHEADER[$curLayout] : $HEADER; + $menus_footer = $CUSTOMFOOTER[$curLayout] ? $CUSTOMFOOTER[$curLayout] : $FOOTER; } @@ -130,31 +133,41 @@ foreach ($menu_array as $menu_value) // Cams Bit ----------- Activate Multiple Menus --- if($_POST['menuActivate']) { - foreach ($_POST['menuActivate'] as $k => $v) - { - if (trim($v)) - { - $location = $k; - } - } + menuActivate(); - $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) { //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(); //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 = " INSERT into #menus - (`menu_name`, `menu_location`, `menu_order`, `menu_pages`, `menu_path`) - VALUES ('{$row['menu_name']}', {$location}, {$menu_count}, '', '{$row['menu_path']}') + (`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); + $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,''); $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) { @@ -175,7 +195,6 @@ function getMenuPreset($layout) $temp = $pref['sitetheme_layouts'][$layout]['menuPresets']['area']; - foreach($temp as $key=>$val) { $iD = $val['@attributes']['id']; @@ -185,10 +204,8 @@ function getMenuPreset($layout) 'menu_location' => $iD, 'menu_order' => $k, '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']; - $menuAreas = getMenuPreset($layout); + global $pref; + $layout = ($_POST['curLayout'] != $pref['sitetheme_deflayout']) ? $_POST['curLayout'] : ""; + $menuAreas = getMenuPreset($_POST['curLayout']); - - - $sql->db_Update("menus", "menu_location='0' "); // Clear All existing. + $sql->db_Update("menus", "menu_location='0' WHERE menu_layout = '$layout' "); // Clear All existing. 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 = str_replace("|", "\n", $menu_pages); $text = "