📄 xwiki.java
字号:
xwiki.sendMessage(sender, recipient, message, context); } public boolean copyDocument(String docname, String targetdocname) throws XWikiException { if (checkProgrammingRights()) return xwiki.copyDocument(docname, targetdocname, null, null, null, false, context); else return false; } public boolean copyDocument(String docname, String targetdocname, String wikilanguage) throws XWikiException { if (checkProgrammingRights()) return xwiki.copyDocument(docname, targetdocname, null, null, wikilanguage, false, context); else return false; } public boolean copyDocument(String docname, String sourceWiki, String targetWiki, String wikilanguage) throws XWikiException { if (checkProgrammingRights()) return xwiki.copyDocument(docname, docname, sourceWiki, targetWiki, wikilanguage, true, context); else return false; } public boolean copyDocument(String docname, String targetdocname, String sourceWiki, String targetWiki, String wikilanguage, boolean reset) throws XWikiException { if (checkProgrammingRights()) return xwiki.copyDocument(docname, targetdocname, sourceWiki, targetWiki, wikilanguage, reset, context); else return false; } public String includeTopic(String topic) throws XWikiException { return includeTopic(topic, true); } public String includeForm(String topic) throws XWikiException { return includeForm(topic, true); } public String includeTopic(String topic, boolean pre) throws XWikiException { if (pre) return "{pre}" + xwiki.include(topic, context, false) + "{/pre}"; else return xwiki.include(topic, context, false); } public String includeForm(String topic, boolean pre) throws XWikiException { if (pre) return "{pre}" + xwiki.include(topic, context, true) + "{/pre}"; else return xwiki.include(topic, context, true); } public boolean hasAccessLevel(String level) { try { return xwiki.getRightService().hasAccessLevel(level, context.getUser(), context.getDoc().getFullName(), context); } catch (Exception e) { return false; } } public boolean hasAccessLevel(String level, String user, String docname) { try { return xwiki.getRightService().hasAccessLevel(level, user, docname, context); } catch (Exception e) { return false; } } public String renderText(String text, Document doc) { return xwiki.getRenderingEngine().renderText(text, doc.getDoc(), context); } public String renderChunk(Chunk chunk, Document doc) { return renderChunk(chunk, false, doc); } public String renderChunk(Chunk chunk, boolean source, Document doc) { StringBuffer buf = new StringBuffer(); chunk.toString(buf, "", "\n"); if (source==true) return buf.toString(); try { return xwiki.getRenderingEngine().renderText(buf.toString(), doc.getDoc(), context); } catch (Exception e) { return buf.toString(); } } public List getSpaces() throws XWikiException { return xwiki.getSpaces(context); } public List getSpaceDocsName(String SpaceName) throws XWikiException { return xwiki.getSpaceDocsName(SpaceName, context); } // Usefull date functions public Date getCurrentDate() { return xwiki.getCurrentDate(); } public Date getDate() { return xwiki.getCurrentDate(); } public int getTimeDelta(long time) { return xwiki.getTimeDelta(time); } public Date getDate(long time) { return xwiki.getDate(time); } public String[] split(String str, String sep) { return xwiki.split(str, sep); } public String printStrackTrace(Throwable e) { return xwiki.printStrackTrace(e); } public String getEncoding() { return xwiki.getEncoding(); } public Object getNull() { return null; } public String getNl() { return "\n"; } public String getAttachmentURL(String fullname, String filename) throws XWikiException { return xwiki.getAttachmentURL(fullname, filename, context); } public String getURL(String fullname, String action) throws XWikiException { return xwiki.getURL(fullname, action, context); } public String getURL(String fullname, String action, String querystring) throws XWikiException { return xwiki.getURL(fullname, action, querystring, context); } public java.lang.Object getService(String className) throws XWikiException { if (hasProgrammingRights()) return xwiki.getService(className); else return null; } public java.lang.Object getPortalService(String className) throws XWikiException { if (hasProgrammingRights()) return xwiki.getPortalService(className); else return null; } public List getArrayList() { return new ArrayList(); } public Map getHashMap() { return new HashMap(); } public void outputImage(BufferedImage image) throws IOException { JPEGImageEncoder encoder; OutputStream ostream = context.getResponse().getOutputStream(); encoder = JPEGCodec.createJPEGEncoder(ostream); encoder.encode(image); ostream.flush(); } public DocumentStats getCurrentMonthXWikiStats(String action) { return context.getWiki().getStatsService(context).getDocMonthStats("", "view", new Date(), context); } public String getRefererText(String referer) { try { return xwiki.getRefererText(referer, context); } catch (Exception e) { return ""; } } public String getShortRefererText(String referer, int length) { try { return xwiki.getRefererText(referer, context).substring(0, length); } catch (Exception e) { return xwiki.getRefererText(referer, context); } } public String getFullNameSQL() { return xwiki.getFullNameSQL(); } public String getUserName(String user) { return xwiki.getUserName(user, null, context); } public String getUserName(String user, String format) { return xwiki.getUserName(user, format, context); } public String getLocalUserName(String user) { try { return xwiki.getUserName(user.substring(user.indexOf(":") + 1), null, context); } catch (Exception e) { return xwiki.getUserName(user, null, context); } } public String getLocalUserName(String user, String format) { try { return xwiki.getUserName(user.substring(user.indexOf(":") + 1), format, context); } catch (Exception e) { return xwiki.getUserName(user, format, context); } } public String formatDate(Date date) { return xwiki.formatDate(date, null, context); } public String formatDate(Date date, String format) { return xwiki.formatDate(date, format, context); } /** * Returns a plugin from the plugin API. Plugin Rights can be verified. * @param name Name of the plugin to retrieve (either short of full class name) * @return a plugin object */ public Api get(String name) { return xwiki.getPluginApi(name, context); } /** * Returns a plugin from the plugin API. Plugin Rights can be verified. * @param name Name of the plugin to retrieve (either short of full class name) * @return a plugin object */ public Api getPlugin(String name) { return xwiki.getPluginApi(name, context); } /** * Returns the recently visited pages for a specific action * @param action ("view" or "edit") * @param size how many recent actions to retrieve * @return a ArrayList of document names */ public java.util.Collection getRecentActions(String action, int size) { XWikiStatsService stats = context.getWiki().getStatsService(context); if (stats==null) return new ArrayList(); else return stats.getRecentActions(action, size, context); } /** * Returns the Advertisement system from the preferences * @return "google" or "none" */ public String getAdType() { return xwiki.getAdType(context); } /** * Returns the Advertisement client ID from the preferences * @return an Ad affiliate ID */ public String getAdClientId() { return xwiki.getAdClientId(context); } /** * Retrieves a int from a String * @param str String to convert to int * @return the int or zero in case of exception */ public int parseInt(String str) { try { return Integer.parseInt(str); } catch (Exception e) { return 0; } } /** * Retrieves a int from a String * @param str String to convert to int * @return the int or zero in case of exception */ public Integer parseInteger(String str) { return new Integer(parseInt(str)); } /** * Retrieves a long from a String * @param str String to convert to long * @return the long or zero in case of exception */ public long parseLong(String str) { try { return Long.parseLong(str); } catch (Exception e) { return 0; } } /** * Retrieves a float from a String * @param str String to convert to float * @return the float or zero in case of exception */ public float parseFloat(String str) { try { return Float.parseFloat(str); } catch (Exception e) { return 0; } } /** * Retrieves a double from a String * @param str String to convert to double * @return the double or zero in case of exception */ public double parseDouble(String str) { try { return Double.parseDouble(str); } catch (Exception e) { return 0; } } /** * Returns the content of an HTTP/HTTPS URL protected using Basic Authentication * @param surl url to retrieve * @param username username for the basic authentication * @param password password for the basic authentication * @return Content of the specified URL * @throws IOException */ public String getURLContent(String surl, String username, String password) throws IOException { try { return xwiki.getURLContent(surl, username, password); } catch (Exception e) { return ""; } } /** * Returns the content of an HTTP/HTTPS URL * @param surl url to retrieve * @return Content of the specified URL * @throws IOException */ public String getURLContent(String surl) throws IOException { try { return xwiki.getURLContent(surl); } catch (Exception e) { return ""; } } /** * Filters text to be include in = or like clause in SQL * @param text text to filter * @return filtered text */ public String sqlfilter(String text) { return Utils.SQLFilter(text); } /** * Returns the list of Macros documents in the specified content * @param defaultweb Default Web to use for relative path names * @param content Content to parse * @return ArrayList of document names */ public List getIncludedMacros(String defaultweb, String content) { return xwiki.getIncludedMacros(defaultweb, content, context); } /** * returns true if xwiki.readonly is set in the configuration file * * @return the value of xwiki.isReadOnly() * * @see #com.xpn.xwiki.XWiki * */ public boolean isReadOnly () { return xwiki.isReadOnly(); } public void setReadOnly (boolean ro) { if (hasAdminRights()) { xwiki.setReadOnly(ro); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -