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

📄 wikiengine.java

📁 wiki建站资源 java编写的 很好用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    }    /**     *  Returns an URL to some other Wiki that we know.     *     *  @return null, if no such reference was found.     */    public String getInterWikiURL( String wikiName )    {        return m_properties.getProperty(PROP_INTERWIKIREF+wikiName);    }    /**     *  Returns a collection of all supported InterWiki links.     */    public Collection getAllInterWikiLinks()    {        Vector v = new Vector();        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.     */    public Collection getAllInlinedImagePatterns()    {        return TranslatorReader.getImagePatterns( this );    }    /**     *  If the page is a special page, then returns a direct URL     *  to that page.  Otherwise returns null.     *  <P>     *  Special pages are non-existant references to other pages.     *  For example, you could define a special page reference     *  "RecentChanges" which would always be redirected to "RecentChanges.jsp"     *  instead of trying to find a Wiki page called "RecentChanges".     */    public String getSpecialPageReference( String original )    {        String propname = PROP_SPECIALPAGE+original;        String specialpage = m_properties.getProperty( propname );        if( specialpage != null )            specialpage = getURL( WikiContext.NONE, specialpage, null, true );                return specialpage;    }    /**     *  Returns the name of the application.     */    // FIXME: Should use servlet context as a default instead of a constant.    public String getApplicationName()    {        String appName = m_properties.getProperty(PROP_APPNAME);        if( appName == null )            return Release.APPNAME;        return 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 not beautified, no     *  matter what.     *     *  @since 1.7.11     */    public String beautifyTitle( String title )    {        if( m_beautifyTitle )        {            try            {                if(m_attachmentManager.getAttachmentInfo(title) == null)                {                    return TextUtil.beautifyString( title );                }            }            catch( ProviderException e )            {                return title;            }        }        return title;    }    /**     *  Beautifies the title of the page by appending non-breaking spaces      *  in suitable places.  This is really suitable only for HTML output,     *  as it uses the &amp;nbsp; -character.     *     *  @since 2.1.127     */    public String beautifyTitleNoBreak( String title )    {        if( m_beautifyTitle )        {            return TextUtil.beautifyString( title, "&nbsp;" );        }        return title;            }    /**     *  Returns true, if the requested page (or an alias) exists.  Will consider     *  any version as existing.  Will also consider attachments.     *     *  @param page WikiName of the page.     */    public boolean pageExists( String page )    {        Attachment att = null;        try        {            if( getSpecialPageReference(page) != null ) return true;            if( getFinalPageName( page ) != null )            {                return true;            }            att = getAttachmentManager().getAttachmentInfo( (WikiContext)null, page );        }        catch( ProviderException e )        {            log.debug("pageExists() failed to find attachments",e);        }        return att != null;    }    /**     *  Returns true, if the requested page (or an alias) exists with the     *  requested version.     *     *  @param page Page name     */    public boolean pageExists( String page, int version )        throws ProviderException    {        if( getSpecialPageReference(page) != null ) return true;        String finalName = getFinalPageName( page );        WikiPage p = null;        if( finalName != null )        {            //            //  Go and check if this particular version of this page            //  exists.            //            p = m_pageManager.getPageInfo( finalName, version );        }        if( p == null )        {            try            {                p = getAttachmentManager().getAttachmentInfo( (WikiContext)null, page, version );            }            catch( ProviderException e )            {                log.debug("pageExists() failed to find attachments",e);            }        }        return (p != null);    }    /**     *  Returns true, if the requested page (or an alias) exists, with the     *  specified version in the WikiPage.     *     *  @since 2.0     */    public boolean pageExists( WikiPage page )        throws ProviderException    {        if( page != null )        {            return pageExists( page.getName(), page.getVersion() );        }        return false;    }    /**     *  Returns the correct page name, or null, if no such     *  page can be found.  Aliases are considered.     *  <P>     *  In some cases, page names can refer to other pages.  For example,     *  when you have matchEnglishPlurals set, then a page name "Foobars"     *  will be transformed into "Foobar", should a page "Foobars" not exist,     *  but the page "Foobar" would.  This method gives you the correct     *  page name to refer to.     *  <P>     *  This facility can also be used to rewrite any page name, for example,     *  by using aliases.  It can also be used to check the existence of any     *  page.     *     *  @since 2.0     *  @param page Page name.     *  @return The rewritten page name, or null, if the page does not exist.     */    public String getFinalPageName( String page )        throws ProviderException    {        boolean isThere = simplePageExists( page );        if( !isThere && m_matchEnglishPlurals )        {            if( page.endsWith("s") )            {                page = page.substring( 0, page.length()-1 );            }            else            {                page += "s";            }            isThere = simplePageExists( page );        }        return isThere ? page : null ;    }    /**     *  Just queries the existing pages directly from the page manager.     *  We also check overridden pages from jspwiki.properties     */    private boolean simplePageExists( String page )        throws ProviderException    {        if( getSpecialPageReference(page) != null ) return true;        return m_pageManager.pageExists( page );    }    /**     *  Turns a WikiName into something that can be      *  called through using an URL.     *     *  @since 1.4.1     */    public String encodeName( String pagename )    {        return TextUtil.urlEncode( pagename, (m_useUTF8 ? "UTF-8" : "ISO-8859-1"));    }    public String decodeName( String pagerequest )    {        try        {            return TextUtil.urlDecode( pagerequest, (m_useUTF8 ? "UTF-8" : "ISO-8859-1") );        }        catch( UnsupportedEncodingException e )        {            throw new InternalWikiException("ISO-8859-1 not a supported encoding!?!  Your platform is borked.");        }    }    /**     *  Returns the IANA name of the character set encoding we're     *  supposed to be using right now.     *     *  @since 1.5.3     */    public String getContentEncoding()    {        if( m_useUTF8 )             return "UTF-8";        return "ISO-8859-1";    }    /**     *  Returns the un-HTMLized text of the latest version of a page.     *  This method also replaces the &lt; and &amp; -characters with     *  their respective HTML entities, thus making it suitable     *  for inclusion on an HTML page.  If you want to have the     *  page text without any conversions, use getPureText().     *     *  @param page WikiName of the page to fetch.     *  @return WikiText.     */    public String getText( String page )    {        return getText( page, WikiPageProvider.LATEST_VERSION );    }    /**     *  Returns the un-HTMLized text of the given version of a page.     *  This method also replaces the &lt; and &amp; -characters with     *  their respective HTML entities, thus making it suitable     *  for inclusion on an HTML page.  If you want to have the     *  page text without any conversions, use getPureText().     *     *     * @param page WikiName of the page to fetch     * @param version  Version of the page to fetch     * @return WikiText.     */    public String getText( String page, int version )    {        String result = getPureText( page, version );        //        //  Replace ampersand first, or else all quotes and stuff        //  get replaced as well with &quot; etc.        //        /*        result = TextUtil.replaceString( result, "&", "&amp;" );        */        result = TextUtil.replaceEntities( result );        return result;    }    /**     *  Returns the un-HTMLized text of the given version of a page in     *  the given context.  USE THIS METHOD if you don't know what     *  doing.     *  <p>     *  This method also replaces the &lt; and &amp; -characters with     *  their respective HTML entities, thus making it suitable     *  for inclusion on an HTML page.  If you want to have the     *  page text without any conversions, use getPureText().     *     *  @since 1.9.15.     */    public String getText( WikiContext context, WikiPage page )    {        return getText( page.getName(), page.getVersion() );    }    /**     *  Returns the pure text of a page, no conversions.  Use this     *  if you are writing something that depends on the parsing     *  of the page.  Note that you should always check for page     *  existence through pageExists() before attempting to fetch     *  the page contents.     *     *  @param page    The name of the page to fetch.     *  @param version If WikiPageProvider.LATEST_VERSION, then uses the      *  latest version.     *  @return The page contents.  If the page does not exist,     *          returns an empty string.     */    // FIXME: Should throw an exception on unknown page/version?    public String getPureText( String page, int version )    {        String result = null;        try        {            result = m_pageManager.getPageText( page, version );        }        catch( ProviderException e )        {            // FIXME        }        finally        {            if( result == null )                result = "";        }        return result;    }    /**     *  Returns the pure text of a page, no conversions.  Use this     *  if you are writing something that depends on the parsing     *  the page. Note that you should always check for page     *  existence through pageExists() before attempting to fetch     *  the page contents.     *       *  @param page A handle to the WikiPage     *  @return String of WikiText.     *  @since 2.1.13.     */    public String getPureText( WikiPage page )    {        return getPureText( page.getName(), page.getVersion() );    }    /**     *  Returns the converted HTML of the page using a different     *  context than the default context.     */

⌨️ 快捷键说明

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