From 455cf3c68a8591877dad52ae13befeb65b7d8565 Mon Sep 17 00:00:00 2001 From: secretr Date: Fri, 4 May 2012 17:56:21 +0000 Subject: [PATCH] - menu parameters temporary UI solution - various minor fixes and improvements (menu manager) - message handler wont accept emtpy messages now --- e107_admin/menus.php | 13 +-- e107_handlers/menumanager_class.php | 125 +++++++++++++++++++++------- e107_handlers/message_handler.php | 5 +- 3 files changed, 105 insertions(+), 38 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 95aaa9aa5..56d16f47a 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -2,16 +2,14 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2012 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * * - * $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ */ if(isset($_GET['configure'])) @@ -29,7 +27,9 @@ if (!getperms("2")) exit; } -include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); +//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); +e107::coreLan('menus', true); +e107::coreLan('admin', true); $e_sub_cat = 'menus'; @@ -78,6 +78,7 @@ if($_POST) $text .= $men->menuRenderMessage(); $text .= $men->menuSelectLayout(); $text .= $men->menuVisibilityOptions(); + $text .= $men->menuInstanceParameters(); $text .= $men->menuRenderIframe(); $ns -> tablerender(ADLAN_6." :: ".LAN_MENULAYOUT, $text, 'menus_config'); } diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index 7aceaf13e..b6641c77f 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -2,16 +2,14 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2012 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * * - * $Source: /cvs_backup/e107_0.8/e107_handlers/menumanager_class.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ */ if (!defined('e107_INIT')) { exit; } @@ -71,14 +69,16 @@ class e_menuManager { if(isset($_POST['menu_id']) || $_GET['id']) { - $this->menuId = (isset($_POST['menu_id'])) ? intval($_POST['menu_id']) : $_GET['id']; + $this->menuId = (isset($_POST['menu_id'])) ? intval($_POST['menu_id']) : intval($_GET['id']); } - if ($menu_act == "sv" || isset($_POST['class_submit'])) + if (/*$menu_act == "sv" || */isset($_POST['class_submit'])) { - $this->menuSaveVisibility(); - + } + elseif(isset($_POST['parms_submit'])) + { + $this->menuSaveParameters(); } if ($_GET['mode'] == "deac") @@ -155,19 +155,18 @@ class e_menuManager { function menuRenderMessage() { // return $this->menuMessage; - $emessage = &eMessage::getInstance(); - - $text = $emessage->render($message); + $emessage = eMessage::getInstance(); + $text = $emessage->render('menuUi'); // $text .= "ID = ".$this->menuId; return $text; - + } function menuAddMessage($message, $type = E_MESSAGE_INFO, $session = false) { - $emessage = &eMessage::getInstance(); - $emessage->add($message, $type, $session); + $emessage = eMessage::getInstance(); + $emessage->add(array($message, 'menuUi'), $type, $session); } // ------------------------------------------------------------------------- @@ -245,7 +244,7 @@ class e_menuManager { { if (trim($v)) { - $this->menuId = $k; + $this->menuId = intval($k); list($menu_act, $location, $position, $this->menuNewLoc) = explode(".", $_POST['menuAct'][$k]); } } @@ -448,9 +447,48 @@ class e_menuManager { return $link_class; } - - - + /** + * This one will be greatly extended, allowing menus to offer UI and us + * settings per instance later ($parm variable available for menus - same as shortcode's $parm) + */ + function menuInstanceParameters() + { + if(!$_GET['parmsId']) return; + $id = intval($_GET['parmsId']); + $frm = e107::getForm(); + $sql = e107::getDb(); + + if(!$sql->db_Select("menus", "*", "menu_id=".$id)) + { + $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR); + return; + }; + $row = $sql->db_Fetch(); + + // TODO lan + $text = "
+
+
+ Menu parameters ".$row['menu_name']." + + + + +
+ Parameters (query string format): + ".$frm->text('menu_parms', $row['menu_parms'], 900)." +
+
"; + $text .= $frm->admin_button('parms_submit', LAN_SAVE, 'update'); + $text .= " +
+
+
+
"; + return $text; + //$caption = MENLAN_7." ".$row['menu_name']; + //$ns->tablerender($caption, $text); + } function menuVisibilityOptions() @@ -474,11 +512,6 @@ class e_menuManager {
". MENLAN_7." ".$row['menu_name']." - - - - -
@@ -633,7 +666,27 @@ class e_menuManager { return FALSE; } - + + // -------------------------------------------------------------------------- + + function menuSaveParameters() + { + $sql = e107::getDb(); + $parms = $sql->escape(strip_tags($_POST['menu_parms'])); + $check = $sql->db_Update("menus", "menu_parms='".$parms."' WHERE menu_id=".$this->menuId); + + if($check) + { + // FIXME - menu log + //$admin_log->log_event('MENU_02',$_POST['menu_parms'].'[!br!]'.$parms.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); + $this->menuAddMessage(LAN_SAVED,E_MESSAGE_SUCCESS); + } + elseif(false === $check) + { + $this->menuAddMessage(LAN_UPDATED_FAILED,E_MESSAGE_ERROR); + } + else $this->menuAddMessage(LAN_NOCHANGE_NOTSAVED,E_MESSAGE_INFO); + } // -------------------------------------------------------------------------- @@ -1047,13 +1100,20 @@ class e_menuManager { //FIXME extract extract($row); if(!$menu_id){ return; } - + include_once(e_HANDLER.'admin_handler.php'); $menu_name = preg_replace("#_menu#i", "", $menu_name); //TODO we need a CSS class for this $vis = ($menu_class || strlen($menu_pages) > 1) ? " * " : ""; //DEBUG div not allowed in final tags $caption = "
{$menu_name}{$vis}
"; // use theme render style instead - $caption = $menu_name.$vis; + $menuParms = array(); + if(!empty($row['menu_parms'])) parse_str($row['menu_parms'], $menuParms); + if(isset($menuParms['admin_title']) && $menuParms['admin_title']) + { + $caption = deftrue($menuParms['admin_title'], $menuParms['admin_title']).$vis; + } + else $caption = $menu_name.$vis; + $menu_info = "{$menu_location}.{$menu_order}"; $text = ""; @@ -1095,21 +1155,26 @@ class e_menuManager { } } - // $text .= $rs->form_option(MENLAN_20, "", "adv.{$menu_info}"); + // Visibility is an action icon now + //$text .= $rs->form_option(MENLAN_20, "", "adv.{$menu_info}"); $text .= $rs->form_select_close(); //DEBUG remove inline style, switch to simple quoted string for title text value //TODO hardcoded text $text .= '
- + '.ADMIN_VIEW_ICON.' '; if($conf) { - $text .= ' + $text .= ' '.ADMIN_CONFIGURE_ICON.' '; } + + $text .= ' + '._ITAG('edit', 16, 'icon action S16').' + '; $text .= ''.ADMIN_DELETE_ICON.' diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index 4a36cdaae..2d5fa7ffe 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -2,7 +2,7 @@ /* * e107 website system * - * Copyright (C) 2008-2010 e107 Inc (e107.org) + * Copyright (C) 2008-2012 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * @@ -161,7 +161,8 @@ class eMessage $mstack = $message[1]; $msg = $message[0]; } - + if(empty($msg)) return $this; + if(!$session) { if($this->isType($type)) $this->_sysmsg[$type][$mstack][] = $msg;