⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagehelper.java

📁 这个weblogging 设计得比较精巧
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            editorTag.setView("/navbar-horizontal.vm");        }        editorTag.setModel("editor-menu.xml");        return editorTag.emit();    }        //------------------------------------------------------------------------        /**      * Call hybrid EditorNavBarTag to render editor navbar.     * @param model Name of XML file in WEB-INF that contains XML for menu.     * @param template Name of Velocity template in classpath to display menu.     * @return String HTML for menu.     */    public String showMenu(String model, String template)    {        MenuTag menuTag = new MenuTag();        menuTag.setPageContext(mPageContext);        menuTag.setModel(model);        menuTag.setView(template);        return menuTag.emit();    }        //------------------------------------------------- WeblogCalendar methods    /**      * Display weblog calendar.     * @return HTML for calendar.     */    public String showWeblogCalendar()    {        return showWeblogCalendar(false, null);    }    //------------------------------------------------------------------------    /**      * Weblog calendar display implementation.     * @param big Show big archive style calendar.     * @return HTML for calendar.     */    public String showWeblogCalendar( boolean big, String cat )    {        if (PageModel.VELOCITY_NULL.equals(cat)) cat = null;        String ret = null;        try        {            HttpServletRequest request =                (HttpServletRequest)mPageContext.getRequest();            HttpServletResponse response =                (HttpServletResponse)mPageContext.getResponse();            String selfUrl = null;            String pageLink = mRollerReq.getPageLink();            if ( pageLink != null )            {                selfUrl =                     request.getContextPath()+"/page/"+mUsername+"/"+pageLink;            }            else            {                selfUrl = request.getContextPath()+"/page/"+mUsername;            }            // setup weblog calendar model            CalendarModel model = null;            if ( big )            {                model = new BigWeblogCalendarModel(                           mRollerReq, response, selfUrl, cat);            }            else            {                model = new WeblogCalendarModel(                            mRollerReq, response, selfUrl, cat);            }            // save model in JSP page context so CalendarTag can find it            mPageContext.setAttribute("calendarModel",model);            // Create and setup calendar tag            CalendarTag calTag = new CalendarTag();            calTag.setPageContext(mPageContext);            calTag.setName("calendar");            calTag.setModel("calendarModel");            //calTag.setLocale(mRollerReq.getWebsite().getLocaleInstance());            calTag.setLocale(LanguageUtil.getViewLocale(request));            //calTag.setTimeZone(mRollerReq.getWebsite().getTimeZoneInstance());            if ( big )            {                calTag.setClassSuffix("Big");            }            ret = calTag.emit();        }        catch (Exception e)        {            mLogger.error("Unexpected exception",e);        }        return ret;    }        //------------------------------------------------------------------------        /**     * Convenience method, contrived helper for Velocity.     * @param useIds     * @param isAction     * @param path     * @param val1     * @param val2     * @return String     */    public String strutsUrlHelper( boolean useIds, boolean isAction,         String path, String val1, String val2)    {        Hashtable params = new Hashtable();        return strutsUrlHelper( useIds, isAction, path, val1, val2, params);    }        //------------------------------------------------------------------------        /**     * Very contrived helper method for Velocimacros generating Struts links.     * This is really only of use to the showNavBar macro.     * @param useIds     * @param isAction     * @param path     * @param val1     * @param val2     * @return String     */    public String strutsUrlHelper( boolean useIds, boolean isAction,         String path, String val1, String val2, Hashtable params)    {        if (useIds)        {            if (mRollerReq.getFolder() != null)             {                params.put(RollerRequest.FOLDERID_KEY,                mRollerReq.getFolder().getId());            }             if (mUsername != null)            {                params.put(RollerRequest.USERNAME_KEY, mUsername);            }        }                if (StringUtils.isNotEmpty(val1) && !val1.equals("null"))        {            params.clear();            params.put("rmk", val1);            params.put("rmik", val2);        }                String returnUrl = "";        try        {            if (isAction)            {                returnUrl = RequestUtils.computeURL( mPageContext,                                path, null, null, null, params, null, false);            }            else            {                returnUrl = RequestUtils.computeURL( mPageContext,                                null, path, null, null, params, null, false);            }        }        catch (MalformedURLException mue)        {            mLogger.warn("RollerRequest.strutsUrlHelper exception: ", mue);            returnUrl = "<span class=\"error\">ERROR generating link</span>";        }        return returnUrl;    }        /**     * Pass the String through any PagePlugins that have been     * assigned to the PageHelper.     *      * @param str     * @return     */    public String renderPlugins(String str)    {        if (mPagePlugins != null)        {            Iterator iter = mPagePlugins.iterator();            while (iter.hasNext())            {                str = ((PagePlugin)iter.next()).render(str);            }        }        return str;    }        /**     * Pass the String through any PagePlugins that have been     * assigned to the PageHelper, as selected by the Entry.     *      * @param str     * @return     */    public String renderPlugins(WeblogEntryData entry)    {        // we have to make a copy to temporarily store the        // changes wrought by Plugins (otherwise they might        // end up persisted!).        WeblogEntryData copy = new WeblogEntryData(entry);                if (mPagePlugins != null)        {            List entryPlugins = copy.getPluginsList();            // if no Entry plugins, don't bother looping.            if (entryPlugins != null && !entryPlugins.isEmpty())            {                    // need to do this to tell ReadMore not to do its job                // if we are in the "view one Entry" page.                if (mRollerReq == null || mRollerReq.getWeblogEntry() != null)                {                    mSkipFlag = true;                }                                // now loop over mPagePlugins, matching                // against Entry plugins (by name):                // where a match is found render Plugin.                Iterator iter = mPagePlugins.iterator();                PagePlugin pagePlugin = null;                while (iter.hasNext())                {                    pagePlugin = (PagePlugin)iter.next();                    if (entryPlugins.contains(pagePlugin.getName()))                    {                        copy.setText((pagePlugin).render(copy, mSkipFlag));                    }                }            }        }        return copy.getText();    }        /**     * This method returns an array of Locales for each supported     * language available, with the exeception of the language of the      * current locale, if that language is supported.     *      * So, if English and Dutch are supported, and the current Locale is Dutch,     * only English is returned. If the current Locale is Spanish, both English and Dutch are     * returned.     *         * @return     */    public Locale[] getSupportedLanguages()    {        Locale currentLocale =            (Locale) mPageContext.getSession().getAttribute(Globals.LOCALE_KEY);        if (currentLocale==null)         {            currentLocale = mPageContext.getRequest().getLocale();        }                    Locale[] supportedLanguages =            LanguageUtil.getSupportedLanguages(mPageContext.getServletContext());        if (supportedLanguages==null) {            return null;        }                // filter out the current selected language        Vector result = new Vector();        for (int i = 0; i < supportedLanguages.length; i++)        {            if (currentLocale == null                || (!supportedLanguages[i].equals(currentLocale)                && !supportedLanguages[i].equals(                    new Locale(currentLocale.getLanguage())))                )            {                result.add(supportedLanguages[i]);            }        }        return (Locale[]) result.toArray(new Locale[result.size()]);    }    /**     * @return relative URL to page, starting with /username     */     public String getPathInfo()     {        return mRollerReq.getPathInfo();    }        public String getCommentAuthenticatorHtml()    {        RollerContext rctx =             RollerContext.getRollerContext(mRollerReq.getRequest());        return rctx.getCommentAuthenticator().getHtml(            mVelocityContext, mRollerReq.getRequest(), mResponse);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -