From 7723d9b83630579a62e44cfe0da41e1a686f57c3 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sun, 5 Jul 2009 11:57:40 +0000 Subject: [PATCH] admin->menus is now functioning correctly with theme.xml. Support for choosing the default layout and menuPresets is working. Still to do - storage of menu placement and custompages for each layout. --- e107_admin/menus.php | 255 ++++++++++++++++++--- e107_handlers/theme_handler.php | 42 +++- e107_languages/English/admin/lan_menus.php | 13 +- e107_themes/e107v4a/theme.xml | 12 +- 4 files changed, 281 insertions(+), 41 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 6b6885235..e68f36157 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $ -| $Revision: 1.14 $ -| $Date: 2009-01-27 12:00:56 $ -| $Author: lisa_ $ +| $Revision: 1.15 $ +| $Date: 2009-07-05 11:57:40 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ require_once("../class2.php"); @@ -51,38 +51,41 @@ if (isset($_POST['custom_select'])) if ($menus_equery[1] == '' || $menus_equery[1] == 'default_layout') { - $menus_header = $HEADER; - $menus_footer = $FOOTER; + $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') { - $menus_header = $CUSTOMHEADER ? $CUSTOMHEADER : - $HEADER; - $menus_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : - $FOOTER; + $menus_header = $CUSTOMHEADER ? $CUSTOMHEADER : $HEADER; + $menus_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER; } else if ($menus_equery[1] == 'newsheader_layout') { - $menus_header = $NEWSHEADER ? $NEWSHEADER : - $HEADER; + $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; + +} 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[$menus_equery[1]] ? $CUSTOMHEADER[$menus_equery[1]] : $HEADER; + $menus_footer = $CUSTOMFOOTER[$menus_equery[1]] ? $CUSTOMFOOTER[$menus_equery[1]] : $FOOTER; } -$layouts_str = $HEADER.$FOOTER; +// $layouts_str = $HEADER.$FOOTER; +$layouts_str = $menus_header.$menus_footer; + if ($NEWSHEADER) { $layouts_str .= $NEWSHEADER; } -if ($CUSTOMPAGES) +/*if ($CUSTOMPAGES) { if (is_array($CUSTOMPAGES)) { @@ -109,7 +112,7 @@ if ($CUSTOMPAGES) $layouts_str .= $CUSTOMFOOTER; } } -} +}*/ $menu_array = parseheader($layouts_str, 'check'); @@ -158,6 +161,79 @@ if($_POST['menuActivate']) } } } + + +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) + { + $menuArea[] = array( + 'menu_location' => $iD, + 'menu_order' => $k, + 'menu_name' => $v['@attributes']['name']."_menu", + 'menu_class' => $v['@attributes']['userclass'] + ); + + + } + } + + 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['menuPreset']) +{ + $layout = $_POST['menuPreset']; + $menuAreas = getMenuPreset($layout); + + + + $sql->db_Update("menus", "menu_location='0' "); // 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")) + { + // echo "it failed "; + } + } + +} + // ============= if (isset($_POST['menuAct'])) @@ -376,15 +452,19 @@ if ($message != "") { echo $ns -> tablerender('Updated', "
".$message."


"); } + + 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. - $text = ""; + + $text = ""; echo $ns -> tablerender(MENLAN_35, $text, 'menus_config'); } -else +else // Within the IFrame. { - + echo layout_list(); + /* if ($CUSTOMPAGES) { if ($menu_act != 'adv') @@ -459,38 +539,87 @@ else $ns->tablerender(MENLAN_29, $text); } } +*/ + + parseheader($menus_header); $layouts_str; + + $layout = ($menus_equery[1]) ? $menus_equery[1] : $pref['sitetheme_deflayout']; + $menuPreset = getMenuPreset($layout); - parseheader($menus_header); echo "
"; echo $frm->form_open("post", e_SELF."?configure.".$menus_equery[1], "menuActivation"); - $text = ""; + $text = "
"; $sql->db_Select("menus", "menu_name, menu_id, menu_pages", "1 GROUP BY menu_name ORDER BY menu_name ASC"); $text .= ""; $text .= ""; $text .= "
".MENLAN_36."......".MENLAN_37."
"; - $text .= "\n"; while ($row = $sql->db_Fetch()) { + $pdeta = ""; + $color = ($color == "white") ? "#DDDDDD" : "white"; if($row['menu_pages'] == "dbcustom") { - $row['menu_name'] .= " [custom]"; + $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 .= " + + + \n"; + + } + $text .= "
".$row['menu_name']." ".$pdeta." 
"; + +/* $text .= ""; - $text .= "

".MENLAN_38.""; + $text .= "";*/ + // $text .= "

".MENLAN_38.""; $text .= "

"; foreach ($menu_areas as $menu_act) { - $text .= "

\n"; + $text .= "

\n"; } + + + if(is_array($pref['sitetheme_layouts'][$layout]['menuPresets'])) + { + $text .= "toJS(MENLAN_41)."')\" />

\n"; // Use Menu Presets + $text .= ""; + } + $text .= "
"; @@ -501,6 +630,76 @@ else parseheader($menus_footer); } +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// +function layout_list() +{ + global $frm, $menus_equery, $pref,$HEADER, $CUSTOMHEADER, $CUSTOMFOOTER, $CUSTOMPAGES; + + + $text .= "
"; + $text .= "
".MENLAN_30." "; + $text .= $frm->form_select_open('custom_select', 'onchange="this.form.submit()"'); + + + + if(is_array($HEADER)) + { + foreach($HEADER as $key=>$val) + { + $default = ($menus_equery[1] == $key || $menus_equery[1] == '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('custom_layout'=>$CUSTOMHEADER); + } + + if($CUSTOMFOOTER && !is_array($CUSTOMFOOTER)) + { + $CUSTOMFOOTER = array('custom_layout'=> $CUSTOMFOOTER); + + } + + if(is_array($CUSTOMHEADER) || is_array($CUSTOMFOOTER)) + { + $customlist = (is_array($CUSTOMHEADER)) ? array_merge($CUSTOMHEADER,$CUSTOMFOOTER) : $CUSTOMFOOTER; + foreach($customlist as $key=>$val) + { + $default = ($menus_equery[1] == $key || $menus_equery[1] == 'default_layout' ) ? "selected" : FALSE; + $deftext = ($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : ""; + $diz = str_replace("_"," ",$key); + $text .= $frm->form_option(ucwords($diz).$deftext, $default, $key); + } + } + + + + $text .= ""; + + // TO-DO Saving of the custompage preference for each layout. + + if($menus_equery[1] && ($menus_equery[1] != $pref['sitetheme_deflayout'])) + { + if(is_array($CUSTOMPAGES)) + { + $CUSTOMPAGES = $CUSTOMPAGES[".$menus_equery[1]."]; + } + $text .= "
Displays on these pages:
"; + } + $text .= "
+
"; + return $text; + +} + //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// function parseheader($LAYOUT, $check = FALSE) { diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 110aeb83d..c544260ec 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $ -| $Revision: 1.14 $ -| $Date: 2008-12-07 21:41:04 $ -| $Author: e107steved $ +| $Revision: 1.15 $ +| $Date: 2009-07-05 11:57:40 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -347,13 +347,14 @@ class themeHandler{ "; if($mode == 1) { - if(!$pref['theme_deflayout']) + if(!$pref['sitetheme_deflayout']) { - $pref['theme_deflayout'] = ($val['@attributes']['default']) ? $key : ""; + $pref['sitetheme_deflayout'] = ($val['@attributes']['default']=='true') ? $key : ""; + // echo "------------- NODEFAULT"; } $itext .= " - + "; } @@ -361,7 +362,7 @@ class themeHandler{ $itext .= ($val['@attributes']['previewFull']) ? "" : ""; $itext .= $val['@attributes']['title']; $itext .= ($val['@attributes']['previewFull']) ? "" : ""; - $itext .= ($pref['theme_deflayout'] == $key) ? " (default)" : ""; + $itext .= ($pref['sitetheme_deflayout'] == $key) ? " (default)" : ""; $itext .= " ".$val['@attributes']['requiredPlugins']."  "; @@ -481,14 +482,36 @@ class themeHandler{ { global $pref, $e107cache, $ns; $themeArray = $this -> getThemes("id"); + $pref['sitetheme'] = $themeArray[$this -> id]; $pref['themecss'] ='style.css'; + $pref['sitetheme_deflayout'] = $this->findDefault($themeArray[$this -> id]); + $pref['sitetheme_layouts'] = is_array($this->themeArray[$pref['sitetheme']]['layouts']) ? $this->themeArray[$pref['sitetheme']]['layouts'] : array(); + $e107cache->clear_sys(); - save_prefs(); + save_prefs(); + $this->theme_adminlog('01',$pref['sitetheme'].', '.$pref['themecss']); $ns->tablerender("Admin Message", "
".TPVLAN_3." '".$themeArray[$this -> id]."'.

"); } + function findDefault($theme) + { + if(varset($_POST['layout_default'])) + { + return $_POST['layout_default']; + } + + $l = $this->themeArray[$theme]; + foreach($l['layouts'] as $key=>$val) + { + if(isset($val['@attributes']['default']) && ($val['@attributes']['default'] == "true")) + { + return $key; + } + } + } + function setAdminTheme() { global $pref, $e107cache, $ns; @@ -506,7 +529,8 @@ class themeHandler{ global $pref, $e107cache, $ns; $pref['themecss'] = $_POST['themecss']; $pref['image_preload'] = $_POST['image_preload']; - $pref['theme_deflayout'] = $_POST['layout_default']; + $pref['sitetheme_deflayout'] = $_POST['layout_default']; + $e107cache->clear_sys(); save_prefs(); $this->theme_adminlog('03',$pref['image_preload'].', '.$pref['themecss']); diff --git a/e107_languages/English/admin/lan_menus.php b/e107_languages/English/admin/lan_menus.php index 6c385a305..075d523d6 100644 --- a/e107_languages/English/admin/lan_menus.php +++ b/e107_languages/English/admin/lan_menus.php @@ -4,9 +4,9 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_menus.php,v $ -| $Revision: 1.1.1.1 $ -| $Date: 2006-12-02 04:34:41 $ -| $Author: mcfly_e107 $ +| $Revision: 1.2 $ +| $Date: 2009-07-05 11:57:40 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ define("MENLAN_1", "Visible to all"); @@ -52,5 +52,12 @@ define("MENLAN_36", "Choose the menu(s) to activate"); define("MENLAN_37", "and where to activate them."); define("MENLAN_38", "Hold down CTRL to select multiple menus."); +// -- + +define("MENLAN_39", "Preset Area"); +define("MENLAN_40", "Use Menu Presets"); +define("MENLAN_41", "The position of all your menus for this layout will be lost. Do you still wish to continue?"); +define("MENLAN_42", "Custom"); + ?> \ No newline at end of file diff --git a/e107_themes/e107v4a/theme.xml b/e107_themes/e107v4a/theme.xml index 9758f98bb..cf12b80e0 100644 --- a/e107_themes/e107v4a/theme.xml +++ b/e107_themes/e107v4a/theme.xml @@ -17,6 +17,16 @@ - + + + + + + + + + + + \ No newline at end of file