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

📄 xwiki.java

📁 xwiki 源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        return textarea.toString();    }    public String getHTMLArea(String content, XWikiContext context) {        Filter filter = new CharacterFilter();        filter.removeAttribute("'");        String scontent = filter.process(content);        scontent = context.getUtil().substitute("s/\\r\\n/<br class=\"htmlarea\"\\/>/g", scontent);        textarea textarea = new textarea();        int rows = 25;        try {            rows = context.getWiki().getUserPreferenceAsInt("editbox_height", context);        } catch (Exception e) {        }        textarea.setRows(rows);        int cols = 80;        try {            context.getWiki().getUserPreferenceAsInt("editbox_width", context);        } catch (Exception e) {        }        textarea.setCols(cols);        textarea.setFilter(filter);        textarea.setName("content");        textarea.setID("content");        textarea.addElement(scontent);        return textarea.toString();    }    public List getClassList(XWikiContext context) throws XWikiException {        return getStore().getClassList(context);    }    /*    public String[] getClassList() throws XWikiException {    List list = store.getClassList();    String[] array = new String[list.size()];    for (int i=0;i<list.size();i++)    array[i] = (String)list.get(i);    return array;    }    */    public List search(String sql, XWikiContext context) throws XWikiException {        return getStore().search(sql, 0, 0, context);    }    public List search(String sql, int nb, int start, XWikiContext context) throws XWikiException {        return getStore().search(sql, nb, start, context);    }    public List search(String sql, Object[][] whereParams, XWikiContext context) throws XWikiException {        return getStore().search(sql, 0, 0, whereParams, context);    }    public List search(String sql, int nb, int start, Object[][] whereParams, XWikiContext context) throws XWikiException {        return getStore().search(sql, nb, start, whereParams, context);    }    public boolean isTest() {        return test;    }    public void setTest(boolean test) {        this.test = test;    }    public String parseContent(String content, XWikiContext context) {        if ((content != null) && (!content.equals("")))        // Let's use this template            return XWikiVelocityRenderer.evaluate(content, context.getDoc().getFullName(), (VelocityContext) context.get("vcontext"), context);        else            return "";    }    public String parseTemplate(String template, XWikiContext context) {        try {            String skin = getSkin(context);            String result = parseTemplate(template, skin, context);            if (result != null)                return result;            // If we could not find the template in the skin            // let's try in the base skin (as long as the base skin is not the same as the skin)            String baseskin = getBaseSkin(context);            if (!skin.equals(baseskin)) {                result = parseTemplate(template, baseskin, context);                if (result != null)                    return result;            }            // If we still could not find the template in the skin or in the base skin            // let's try in the base skin (as long as the default base skin is not the same as the skin or the base skin            String defaultbaseskin = getDefaultBaseSkin(context);            if ((!baseskin.equals(defaultbaseskin)) && (!skin.equals(defaultbaseskin))) {                result = parseTemplate(template, defaultbaseskin, context);                if (result != null)                    return result;            }        } catch (Exception e) {        }        try {            String content = getResourceContent("/templates/" + template);            return XWikiVelocityRenderer.evaluate(content, "", (VelocityContext) context.get("vcontext"), context);        } catch (Exception e) {            return "";        }    }    public String parseTemplate(String template, String skin, XWikiContext context) {        try {            String path = "/skins/" + skin + "/" + template;            String content = getResourceContent(path);            return XWikiVelocityRenderer.evaluate(content, "", (VelocityContext) context.get("vcontext"), context);        } catch (Exception e) {        }        try {            XWikiDocument doc = getDocument(skin, context);            if (!doc.isNew()) {                BaseObject object = doc.getObject("XWiki.XWikiSkins", 0);                if (object != null) {                    String content = object.getStringValue(template);                    if ((content != null) && (!content.equals(""))) {                        // Let's use this template                        return XWikiVelocityRenderer.evaluate(content, "", (VelocityContext) context.get("vcontext"), context);                    }                }            }        } catch (Exception e) {        }        return null;    }    /**     * Designed to include dynamic content, such as Servlets or JSPs, inside Velocity     * templates; works by creating a RequestDispatcher, buffering the output,     * then returning it as a string.     *     * @author LBlaze     */    public String invokeServletAndReturnAsString(String url, XWikiContext xwikiContext) {        HttpServletRequest servletRequest = xwikiContext.getRequest();        HttpServletResponse servletResponse = xwikiContext.getResponse();        try        {            return IncludeServletAsString.invokeServletAndReturnAsString(                    url,                    servletRequest,                    servletResponse);        }        catch(Exception e)        {            log.warn("Exception including url: "+url, e);            return "Exception including \""+url+"\", see logs for details.";        }    }    public String getSkinFile(String filename, XWikiContext context) {        XWikiURLFactory urlf = context.getURLFactory();        try {            String skin = getSkin(context);            String result = getSkinFile(filename, skin, context);            if (result != null)                return result;            String baseskin = getBaseSkin(context);            if (!skin.equals(baseskin)) {                result = getSkinFile(filename, baseskin, context);                if (result != null)                    return result;            }            URL url = urlf.createSkinURL(filename, "default", context);            return urlf.getURL(url, context);        } catch (Exception e) {        }        return "../../../skins/default/" + filename;    }    public String getSkinFile(String filename, String skin, XWikiContext context) {        XWikiURLFactory urlf = context.getURLFactory();        try {            String path = "skins/" + skin + "/" + filename;            if (resourceExists(path)) {                URL url = urlf.createSkinURL(filename, skin, context);                return urlf.getURL(url, context);            }        } catch (Exception e) {        }        try {            XWikiDocument doc = getDocument(skin, context);            if (!doc.isNew()) {                BaseObject object = doc.getObject("XWiki.XWikiSkins", 0);                if (object != null) {                    String content = object.getStringValue(filename);                    if ((content != null) && (!content.equals(""))) {                        URL url = urlf.createSkinURL(filename, doc.getWeb(), doc.getName(), context);                        return urlf.getURL(url, context);                    }                }                // Read XWikiAttachment                XWikiAttachment attachment = null;                List list = doc.getAttachmentList();                String shortname = filename.substring(0, filename.indexOf(".") + 1);                attachment = doc.getAttachment(shortname);                if (attachment != null) {                    URL url = urlf.createSkinURL(filename, doc.getWeb(), doc.getName(), context);                    return urlf.getURL(url, context);                }            }        } catch (Exception e) {        }        return null;    }    public String getSkin(XWikiContext context) {        String skin = "";        try {            // Try to get it from context            skin = (String) context.get("skin");            if (skin != null)                return skin;            // Try to get it from URL            if (context.getRequest() != null) {                skin = context.getRequest().getParameter("skin");            }            if ((skin == null) || (skin.equals(""))) {                skin = getWebPreference("skin", "", context);            }            if (skin.equals("")) {                skin = Param("xwiki.defaultskin", "default");            }        } catch (Exception e) {            skin = "default";        }        context.put("skin", skin);        return skin;    }    public String getDefaultBaseSkin(XWikiContext context) {        String defaultbaseskin = Param("xwiki.defaultbaseskin", "");        if (defaultbaseskin.equals("")) {            defaultbaseskin = Param("xwiki.defaultskin", "default");        }        return defaultbaseskin;    }    public String getBaseSkin(XWikiContext context) {        return getBaseSkin(context, false);    }    public String getBaseSkin(XWikiContext context, boolean fromRenderSkin) {        String baseskin = "";        try {            // Try to get it from context            baseskin = (String) context.get("baseskin");            if (baseskin != null)                return baseskin;            else                baseskin = "";            // Let's get the base skin doc itself            if (fromRenderSkin) {                baseskin = context.getDoc().getStringValue("XWiki.XWikiSkins", "baseskin");            }            if (baseskin.equals("")) {                // Let's get the base skin from the skin itself                String skin = getSkin(context);                skin = getSkin(context);                XWikiDocument doc = getDocument(skin, context);                baseskin = doc.getStringValue("XWiki.XWikiSkins", "baseskin");            }            if (baseskin.equals("")) {                baseskin = getDefaultBaseSkin(context);            }        } catch (Exception e) {            baseskin = "default";        }        context.put("baseskin", baseskin);        return baseskin;    }    public String getWebCopyright(XWikiContext context) {        try {            String result = getXWikiPreference("webcopyright", "", context);            if (!result.trim().equals(""))                return result;        } catch (Exception e) {        }        return "Copyright 2004 (c) Contributing Authors";    }    public String getXWikiPreference(String prefname, XWikiContext context) {        return getXWikiPreference(prefname, "", context);    }    public String getXWikiPreference(String prefname, String default_value, XWikiContext context) {        try {            XWikiDocument doc = getDocument("XWiki.XWikiPreferences", context);            // First we try to get a translated preference object            BaseObject object = doc.getObject("XWiki.XWikiPreferences", "language", context.getLanguage(), true);            String result = "";            try {                result = object.getStringValue(prefname);            } catch (Exception e) {            }            // If empty we take it from the default pref object            if (result.equals(""))                result = doc.getxWikiObject().getStringValue(prefname);            if (!result.equals(""))                return result;        } catch (Exception e) {        }        return default_value;    }    public String getWebPreference(String prefname, XWikiContext context) {        return getWebPreference(prefname, "", context);    }    public String getWebPreference(String prefname, String default_value, XWikiContext context) {        try {            XWikiDocument currentdoc = (XWikiDocument) context.get("doc");            XWikiDocument doc = getDocument(currentdoc.getWeb() + ".WebPreferences", context);            // First we try to get a translated preference object            BaseObject object = doc.getObject("XWiki.XWikiPreferences", "language", context.getLanguage());            String result = "";

⌨️ 快捷键说明

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