From c7766556110d439d08489f8a040d3062346e18c5 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sat, 11 Jul 2009 01:48:40 +0000 Subject: [PATCH] More menu-manager enhancements and fixes. --- class2.php | 8 +- e107_admin/menus.php | 345 +++++++++++++++++++++++++++++++------------ 2 files changed, 252 insertions(+), 101 deletions(-) diff --git a/class2.php b/class2.php index 967995a76..b3d29a37f 100644 --- a/class2.php +++ b/class2.php @@ -9,9 +9,9 @@ * General purpose file * * $Source: /cvs_backup/e107_0.8/class2.php,v $ -* $Revision: 1.105 $ -* $Date: 2009-07-09 21:22:52 $ -* $Author: e107steved $ +* $Revision: 1.106 $ +* $Date: 2009-07-11 01:48:40 $ +* $Author: e107coders $ * */ // @@ -1064,7 +1064,7 @@ $theme_pref = varset($pref['sitetheme_pref']); // here we USE the theme if ($inAdminDir) { - if (file_exists(THEME.'admin_theme.php')) + if (file_exists(THEME.'admin_theme.php') && (strpos(e_SELF.'?'.e_QUERY, $ADMIN_DIRECTORY. 'menus.php?configure')===FALSE)) // no admin theme when previewing. { require_once(THEME.'admin_theme.php'); } diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 7395eb349..98dec43e1 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.25 $ -| $Date: 2009-07-10 14:58:17 $ +| $Revision: 1.26 $ +| $Date: 2009-07-11 01:48:40 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -27,15 +27,13 @@ $e_sub_cat = 'menus'; require_once(e_HANDLER."file_class.php"); require_once(e_HANDLER."form_handler.php"); +require_once (e_HANDLER.'message_handler.php'); - - $frm = new form; + $rs = new form; + $frm = new e_form(); $men = new menuManager(); // use 1 for dragdrop. - - - if(isset($_GET['ajax'])) { $men->menuSaveAjax(); @@ -66,22 +64,28 @@ if($_POST) 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 = ""; - $ns -> tablerender(MENLAN_35, $text, 'menus_config'); + $text .= $men->menuRenderMessage(); + $text .= $men->menuSelectLayout(); + $text .= $men->menuVisibilityOptions(); + $text .= $men->menuRenderIframe(); + $ns -> tablerender(MENLAN_35, $text, 'menus_config'); + // $text .= ""; + } else // Within the IFrame. { - if($menu->debug) - { - echo "
+ +/* echo "
e_QUERY = ".e_QUERY."
curLayout = ".$men->curLayout."
- dbLayout = ".$men->dbLayout."
-
"; - } + dbLayout = ".$men->dbLayout."
"; + + print_a($_POST); + echo " +
";*/ + + - echo $men->menuSelectLayout(); $men->menuRenderPage(); } @@ -99,11 +103,16 @@ class menuManager{ var $menuActivateLoc; var $menuActivateIds; var $debug; + var $menuMessage; function menuManager($dragdrop=FALSE) { global $pref, $HEADER,$FOOTER, $NEWSHEADER; + + $this->debug = FALSE; + + $this->dragDrop = $dragdrop; @@ -122,6 +131,10 @@ class menuManager{ { $this->curLayout = $_POST['custom_select']; } + elseif($_GET['lay']) + { + $this->curLayout = $_GET['lay']; + } else { $tmp = explode('.', e_QUERY); @@ -130,10 +143,27 @@ class menuManager{ $this->dbLayout = ($this->curLayout !=$pref['sitetheme_deflayout']) ? $this->curLayout : ""; //menu_layout is left blank when it's default. + if(isset($_POST['menu_id']) || $_GET['id']) + { + $this->menuId = (isset($_POST['menu_id'])) ? intval($_POST['menu_id']) : $_GET['id']; + } + if ($menu_act == "sv" || isset($_POST['class_submit'])) + { + $this->menuSaveVisibility(); + } + if ($_GET['mode'] == "deac") + { + $this->menuDeactivate(); + } + + if ($_GET['mode'] == "conf") + { + $this->menuGoConfig(); + } $this->menuGrabLayout(); @@ -174,6 +204,42 @@ class menuManager{ } +// ------------------------------------------------------------------------- + + function menuRenderIframe($url='') + { + global $ns,$sql; + if(!$url) + { + $url = e_SELF."?configure.".$this->curLayout; + } + + $cnt = $sql->db_Select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar. + + $text .= ""; + + return $text; + } + + + function menuRenderMessage() + { + // return $this->menuMessage; + $emessage = &eMessage::getInstance(); + + $text = $emessage->render($message); + // $text .= "ID = ".$this->menuId; + return $text; + + } + + + function menuAddMessage($message, $type = E_MESSAGE_INFO, $session = false) + { + $emessage = &eMessage::getInstance(); + $emessage->add($message, $type, $session); + } + // ------------------------------------------------------------------------- function menuGrabLayout() @@ -190,22 +256,50 @@ class menuManager{ } elseif($this->curLayout && $this->curLayout != "legacyCustom" && (isset($CUSTOMHEADER[$this->curLayout]) || isset($CUSTOMHEADER[$this->curLayout]))) // 0.7 themes { - // echo " MODE 0.7"; + // echo " MODE 0.7 ".$this->curLayout; $HEADER = ($CUSTOMHEADER[$this->curLayout]) ? $CUSTOMHEADER[$this->curLayout] : $HEADER; $FOOTER = ($CUSTOMFOOTER[$this->curLayout]) ? $CUSTOMFOOTER[$this->curLayout] : $FOOTER; } - elseif($this->curLayout && isset($HEADER[$this->curLayout]) && isset($FOOTER[$this->curLayout])) // 0.8 themes - we use only $HEADER and $FOOTER arrays. + elseif($this->curLayout && is_array($HEADER) && isset($HEADER[$this->curLayout]) && isset($FOOTER[$this->curLayout])) // 0.8 themes - we use only $HEADER and $FOOTER arrays. { - // echo " MODE 0.8"; + // echo " MODE 0.8 ".$this->curLayout; + $HEADER = $HEADER[$this->curLayout]; $FOOTER = $FOOTER[$this->curLayout]; + } // Almost the same code as found in templates/header_default.php --------- } + function menuGoConfig() + { + if(!$_GET['path'] || ($_GET['mode'] != "conf")) + { + return; + } + $file = urldecode($_GET['path']).".php"; + $newurl = e_PLUGIN_ABS.$file; + + /* + + + + return ""; + +*/ + header("Location: ".$newurl); + exit; + // echo "URL = ".$newurl; + // $newurl = $PLUGINS_DIRECTORY.$location."/{$position}{$this->menuNewLoc}.php"; + // $newurl = SITEURL.str_replace("//", "/", $newurl); + // echo " "; + // exit; + + + } // ----------------------------------------------------------------------------- @@ -227,29 +321,18 @@ class menuManager{ if ($menu_act == 'config') { - if($this->menuNewLoc) - { - $this->menuNewLoc = ".".$this->menuNewLoc; - } - $newurl = $PLUGINS_DIRECTORY.$location."/{$position}{$this->menuNewLoc}.php"; - $newurl = SITEURL.str_replace("//", "/", $newurl); - echo " "; - exit; - } - - - - - - if ($menu_act == "sv") - { - $this->menuSaveVisibility(); } + + + + + + if ($menu_act == "adv") { - $this->menuVisibilityOptions(); + // $this->menuVisibilityOptions(); } if ($menu_act == "move") @@ -257,10 +340,7 @@ class menuManager{ $this->menuMove(); } - if ($menu_act == "deac") - { - $this->menuDeactivate(); - } + if ($menu_act == "bot") { @@ -411,17 +491,30 @@ class menuManager{ function menuVisibilityOptions() { - global $sql,$ns; + if(!$_GET['vis']) return; + + global $sql,$ns,$frm; require_once(e_HANDLER."userclass_class.php"); - $sql->db_Select("menus", "*", "menu_id=".$this->menuId); + if(!$sql->db_Select("menus", "*", "menu_id=".intval($_GET['vis']))) + { + $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR); + return; + }; $row = $sql->db_Fetch(); $listtype = substr($row['menu_pages'], 0, 1); $menu_pages = substr($row['menu_pages'], 2); $menu_pages = str_replace("|", "\n", $menu_pages); $text = "
-
- + +
+ ". MENLAN_7." ".$row['menu_name']." +
+ + + + + - - + $text .= "
@@ -435,15 +528,18 @@ class menuManager{ $checked = ($listtype == 2) ? " checked='checked' " : ""; $text .= " ".MENLAN_27."

".MENLAN_28."
"; $text .= ""; - $text .= " -

- -
+
"; + // + $text .= $frm->admin_button('class_submit', MENLAN_6, 'update'); + + $text .= " +
+
"; + return $text; $caption = MENLAN_7." ".$row['menu_name']; $ns->tablerender($caption, $text); } @@ -575,15 +671,14 @@ class menuManager{ { $admin_log->log_event('MENU_02',$_POST['menu_class'].'[!br!]'.$pageparms.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); $message = "
".MENLAN_8."
"; + $this->menuAddMessage($message,E_MESSAGE_SUCCESS); } else { $message = "the update failed"; - + $this->menuAddMessage($message,E_MESSAGE_ERROR); } - echo $message; - } @@ -648,7 +743,7 @@ class menuManager{ function menuRenderPage() { - global $sql, $ns, $HEADER, $FOOTER, $frm, $pref, $tp; + global $sql, $ns, $HEADER, $FOOTER, $rs, $pref, $tp; echo "
"; $this->parseheader($HEADER); // $layouts_str; @@ -658,7 +753,7 @@ class menuManager{ echo "
"; - echo $frm->form_open("post", e_SELF."?configure.".$this->curLayout, "menuActivation"); + echo $rs->form_open("post", e_SELF."?configure.".$this->curLayout, "menuActivation"); $text = ""; @@ -705,7 +800,7 @@ class menuManager{ } else { - $text .= "
+ $text .= "
dbLayout."' style='border:1px outset black;text-align:left;color:black'>
".$row['menu_name']." $pdeta
"; @@ -737,7 +832,7 @@ class menuManager{ $text .= "
"; $ns -> tablerender(MENLAN_22, $text); - echo $frm->form_close(); + echo $rs->form_close(); echo "
"; @@ -757,11 +852,17 @@ class menuManager{ //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// function menuSelectLayout() { - global $frm, $pref; + global $rs, $pref; $text .= "
"; - $text .= "
".MENLAN_30." "; - $text .= "\n"; // window.frames['menu_iframe'].location=this.options[selectedIndex].value ??? + + // $text .= "\n"; // window.frames['menu_iframe'].location=this.options[selectedIndex].value ??? + $search = array("_","legacyDefault","legacyCustom"); $replace = array(" ",MENLAN_31,MENLAN_33); @@ -769,12 +870,14 @@ class menuManager{ foreach($pref['sitetheme_layouts'] as $key=>$val) { + $url = ""; $layoutName = str_replace($search,$replace,$key); $layoutName .=($key==$pref['sitetheme_deflayout']) ? " (".MENLAN_31.")" : ""; $selected = ($this->curLayout == $key || ($key==$pref['sitetheme_deflayout'] && $this->curLayout=='')) ? "selected='selected'" : FALSE; - // $val = ".e_SELF."?configure."."; - $text .= ""; + $url = e_SELF."?lay="; + $url .= $key; + $text .= ""; } $text .= " @@ -820,7 +923,7 @@ class menuManager{ function checklayout($str) { // Displays a basic representation of the theme - global $pref, $ns, $PLUGINS_DIRECTORY, $frm, $sc_style, $tp, $menu_order; + global $pref, $ns, $PLUGINS_DIRECTORY, $rs, $sc_style, $tp, $menu_order; $menuLayout = ($this->curLayout != $pref['sitetheme_deflayout']) ? $this->curLayout : ""; @@ -887,7 +990,7 @@ class menuManager{ if ($sql9->db_Count("menus", "(*)", " WHERE menu_location='$menu' AND menu_layout = '".$this->dbLayout."' ")) { unset($text); - echo $frm->form_open("post", e_SELF."?configure.".$this->curLayout, "frm_menu_".intval($menu)); + echo $rs->form_open("post", e_SELF."?configure.".$this->curLayout, "frm_menu_".intval($menu)); $MODE = 1; @@ -896,7 +999,7 @@ class menuManager{ while ($row = $sql9->db_Fetch(MYSQL_ASSOC)) { echo "\n\n\n \n\n -
+
dbLayout."'>
"; @@ -909,7 +1012,7 @@ class menuManager{ } - echo $frm->form_close(); + echo $rs->form_close(); } echo "
"; if(isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false) { @@ -928,7 +1031,7 @@ class menuManager{ function menuRenderMenu($row,$menu_count ) { - global $ns,$frm,$menu,$menu_info,$menu_act; + global $ns,$rs,$menu,$menu_info,$menu_act; // $menu_count is empty in here extract($row); if(!$menu_id){ return; } @@ -940,40 +1043,57 @@ class menuManager{ $text = ""; $conf = ''; - if (file_exists(e_PLUGIN."{$menu_path}/{$menu_name}_menu_config.php")) + if (file_exists(e_PLUGIN."{$menu_path}{$menu_name}_menu_config.php")) { - $conf = "config.{$menu_path}.{$menu_name}_menu_config"; + $conf = "{$menu_path}.{$menu_name}_menu_config"; } - if($conf == '' && file_exists(e_PLUGIN."{$menu_path}/config.php")) + if($conf == '' && file_exists(e_PLUGIN."{$menu_path}config.php")) { - $conf = "config.{$menu_path}.config"; + $conf = "{$menu_path}config"; } $text .= "