📄 wikiengine.java
字号:
* Returns the JSPWiki working directory set with "jspwiki.workDir". * * @since 2.1.100 * @return The working directory. */ public String getWorkDir() { return m_workDir; } /** * Don't use. * @since 1.8.0 * @deprecated * @return Something magical. */ public String getPluginSearchPath() { // FIXME: This method should not be here, probably. return TextUtil.getStringProperty( m_properties, PluginManager.PROP_SEARCHPATH, null ); } /** * Returns the current template directory. * * @since 1.9.20 * @return The template directory as initialized by the engine. */ public String getTemplateDir() { return m_templateDir; } /** * Returns the current TemplateManager. * * @return A TemplateManager instance. */ public TemplateManager getTemplateManager() { return m_templateManager; } /** * Returns the base URL, telling where this Wiki actually lives. * * @since 1.6.1 * @return The Base URL. */ public String getBaseURL() { return m_baseURL; } /** * Returns the moment when this engine was started. * * @since 2.0.15. * @return The start time of this wiki. */ public Date getStartTime() { return (Date)m_startTime.clone(); } /** * <p> * Returns the basic absolute URL to a page, without any modifications. You * may add any parameters to this. * </p> * <p> * Since 2.3.90 it is safe to call this method with <code>null</code> * pageName, in which case it will default to the front page. * </p> * @since 2.0.3 * @param pageName The name of the page. May be null, in which case defaults to the front page. * @return An absolute URL to the page. */ public String getViewURL( String pageName ) { if( pageName == null ) { pageName = getFrontPage(); } return getURLConstructor().makeURL( WikiContext.VIEW, pageName, true, null ); } /** * Returns the basic URL to an editor. Please use WikiContext.getURL() or * WikiEngine.getURL() instead. * * @see #getURL(String, String, String, boolean) * @see WikiContext#getURL(String, String) * @deprecated * * @param pageName The name of the page. * @return An URI. * * @since 2.0.3 */ public String getEditURL( String pageName ) { return m_urlConstructor.makeURL( WikiContext.EDIT, pageName, false, null ); } /** * Returns the basic attachment URL.Please use WikiContext.getURL() or * WikiEngine.getURL() instead. * * @see #getURL(String, String, String, boolean) * @see WikiContext#getURL(String, String) * @since 2.0.42. * @param attName Attachment name * @deprecated * @return An URI. */ public String getAttachmentURL( String attName ) { return m_urlConstructor.makeURL( WikiContext.ATTACH, attName, false, null ); } /** * Returns an URL if a WikiContext is not available. * * @param context The WikiContext (VIEW, EDIT, etc...) * @param pageName Name of the page, as usual * @param params List of parameters. May be null, if no parameters. * @param absolute If true, will generate an absolute URL regardless of properties setting. * @return An URL (absolute or relative). */ public String getURL( String context, String pageName, String params, boolean absolute ) { if( pageName == null ) pageName = getFrontPage(); return m_urlConstructor.makeURL( context, pageName, absolute, params ); } /** * Returns the default front page, if no page is used. * * @return The front page name. */ public String getFrontPage() { return m_frontPage; } /** * Returns the ServletContext that this particular WikiEngine was * initialized with. <B>It may return null</B>, if the WikiEngine is not * running inside a servlet container! * * @since 1.7.10 * @return ServletContext of the WikiEngine, or null. */ public ServletContext getServletContext() { return m_servletContext; } /** * This is a safe version of the Servlet.Request.getParameter() routine. * Unfortunately, the default version always assumes that the incoming * character set is ISO-8859-1, even though it was something else. * This means that we need to make a new string using the correct * encoding. * <P> * For more information, see: * <A HREF="http://www.jguru.com/faq/view.jsp?EID=137049">JGuru FAQ</A>. * <P> * Incidentally, this is almost the same as encodeName(), below. * I am not yet entirely sure if it's safe to merge the code. * * @param request The servlet request * @param name The parameter name to get. * @return The parameter value or null * @since 1.5.3 * @deprecated JSPWiki now requires servlet API 2.3, which has a better * way of dealing with this stuff. This will be removed in * the near future. */ public String safeGetParameter( ServletRequest request, String name ) { try { String res = request.getParameter( name ); if( res != null ) { res = new String(res.getBytes("ISO-8859-1"), getContentEncoding() ); } return res; } catch( UnsupportedEncodingException e ) { log.fatal( "Unsupported encoding", e ); return ""; } } /** * Returns the query string (the portion after the question mark). * * @param request The HTTP request to parse. * @return The query string. If the query string is null, * returns an empty string. * * @since 2.1.3 */ public String safeGetQueryString( HttpServletRequest request ) { if (request == null) { return ""; } try { String res = request.getQueryString(); if( res != null ) { res = new String(res.getBytes("ISO-8859-1"), getContentEncoding() ); // // Ensure that the 'page=xyz' attribute is removed // FIXME: Is it really the mandate of this routine to // do that? // int pos1 = res.indexOf("page="); if (pos1 >= 0) { String tmpRes = res.substring(0, pos1); int pos2 = res.indexOf("&",pos1) + 1; if ( (pos2 > 0) && (pos2 < res.length()) ) { tmpRes = tmpRes + res.substring(pos2); } res = tmpRes; } } return res; } catch( UnsupportedEncodingException e ) { log.fatal( "Unsupported encoding", e ); return ""; } } /** * Returns an URL to some other Wiki that we know. * * @param wikiName The name of the other wiki. * @return null, if no such reference was found. */ public String getInterWikiURL( String wikiName ) { return TextUtil.getStringProperty(m_properties,PROP_INTERWIKIREF+wikiName,null); } /** * Returns a collection of all supported InterWiki links. * * @return A Collection of Strings. */ public Collection getAllInterWikiLinks() { Vector<String> v = new Vector<String>(); for( Enumeration i = m_properties.propertyNames(); i.hasMoreElements(); ) { String prop = (String) i.nextElement(); if( prop.startsWith( PROP_INTERWIKIREF ) ) { v.add( prop.substring( prop.lastIndexOf(".")+1 ) ); } } return v; } /** * Returns a collection of all image types that get inlined. * * @return A Collection of Strings with a regexp pattern. */ public Collection getAllInlinedImagePatterns() { return JSPWikiMarkupParser.getImagePatterns( this ); } /** * <p>If the page is a special page, then returns a direct URL * to that page. Otherwise returns <code>null</code>. * This method delegates requests to * {@link com.ecyrd.jspwiki.ui.CommandResolver#getSpecialPageReference(String)}. * </p> * <p> * Special pages are defined in jspwiki.properties using the jspwiki.specialPage * setting. They're typically used to give Wiki page names to e.g. custom JSP * pages. * </p> * * @param original The page to check * @return A reference to the page, or null, if there's no special page. */ public String getSpecialPageReference( String original ) { return m_commandResolver.getSpecialPageReference( original ); } /** * Returns the name of the application. * * @return A string describing the name of this application. */ // FIXME: Should use servlet context as a default instead of a constant. public String getApplicationName() { String appName = TextUtil.getStringProperty(m_properties,PROP_APPNAME,Release.APPNAME); return MarkupParser.cleanLink( appName ); } /** * Beautifies the title of the page by appending spaces in suitable * places, if the user has so decreed in the properties when constructing * this WikiEngine. However, attachment names are only beautified by * the name. * * @param title The title to beautify * @return A beautified title (or, if beautification is off, * returns the title without modification) * @since 1.7.11 */ public String beautifyTitle( String title ) { if( m_beautifyTitle ) { try { Attachment att = m_attachmentManager.getAttachmentInfo(title); if(att == null) { return TextUtil.beautifyString( title ); } String parent = TextUtil.beautifyString( att.getParentName() ); return parent + "/" + att.getFileName(); } catch( ProviderException e ) { return title; } } return title; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -