📄 setmainmenuitem.bsh
字号:
/* * $Id: setmainmenuitem.bsh 5462 2005-08-05 18:35:48Z jonesde $ * * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * *//** * * @author <a href="mailto:byersa@automationgroups.com">Al Byers</a> * @version $Rev: 5462 $ * @since 3.0 * A commonly called script to find the "current" entity (either Content or DataResource * usually) from either a cached key or overridden by current values in the parameter map * or request attributes. */import org.ofbiz.base.util.*;import org.ofbiz.entity.*;import org.ofbiz.security.*;import org.ofbiz.service.*;import org.ofbiz.entity.model.*;import org.ofbiz.widget.html.*;import org.ofbiz.widget.form.*;import org.ofbiz.widget.menu.*;import org.ofbiz.content.ContentManagementWorker;import java.lang.StringBuffer;import javax.servlet.*;import javax.servlet.http.*;LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");entityName = page.getProperty("entityName");pageName = page.getPageName();menuDefFile = page.getProperty("mainMenuDefFile");menuName = page.getProperty("mainMenuName");menuSig = menuDefFile + "__" + menuName;paramMap = UtilHttp.getParameterMap(request);menuWrapper = HtmlMenuWrapper.getMenuWrapper( request, response, session, menuDefFile, menuName, "HtmlMenuWrapper"); modelMenu = menuWrapper.getModelMenu();pubPt = ContentManagementWorker.getFromSomewhere("pubPt", paramMap, request, context);ModelMenu currentModelMenu = menuWrapper.getModelMenu();if (currentModelMenu != null) {StringBuffer buffer = new StringBuffer();currentModelMenu.dump(buffer); if (UtilValidate.isNotEmpty(pubPt)) { ServletContext servletContext = session.getServletContext(); rootPubPt = (String) servletContext.getAttribute("webSiteId"); Map allPublishPointMap = session.getAttribute("allPublishPoints"); if (allPublishPointMap == null || allPublishPointMap.size() == 0) { allPublishPointMap = new HashMap(); ContentManagementWorker.getAllPublishPointMap(delegator, rootPubPt, allPublishPointMap); session.setAttribute("allPublishPoints", allPublishPointMap ); } menuContext = new HashMap(); menuContext.put("parameters", paramMap); menuContext.put("locale", UtilHttp.getLocale(request)); menuItemValue = allPublishPointMap.get(pubPt); Debug.logInfo("in setmainmenuitem(6), menuItemValue:" + menuItemValue,""); menuItemContentId = menuItemValue.get("contentId"); parentMenuItemValue = ContentManagementWorker.getParentWebSitePublishPointValue(delegator, menuItemContentId); parentMenuItemContentId = parentMenuItemValue.get("contentId"); Debug.logInfo("in setmainmenuitem(6), menuItemContentId:" + menuItemContentId,""); Debug.logInfo("in setmainmenuitem(6), parentMenuItemContentId:" + parentMenuItemContentId,""); // This is part of a very ugly way to identify the top WebSitePublishPoint in a section // It is the one below the root, so if the root is the parentMenuItemContentId, then // the menuItemContentId should be taken as the subRoot for the purpose of getting the menu // and subSite items. if (parentMenuItemContentId != null && parentMenuItemContentId.equals(rootPubPt)) parentMenuItemContentId = menuItemContentId; menuItem = modelMenu.getModelMenuItemByContentId(parentMenuItemContentId, (Map)new HashMap()); String menuItemName = menuItem.getName();//Debug.logInfo("in setmainmenuitem, pubPt:" + pubPt,"");//Debug.logInfo("in setmainmenuitem, menuItemName:" + menuItemName,""); if (UtilValidate.isNotEmpty(menuItemName)) { currentModelMenu.setCurrentMenuItemName(menuItemName); menuWrapper.putInContext(menuItemName, "pubPt", pubPt); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -