Search in sources :

Example 6 with Skin

use of org.xwiki.skin.Skin in project xwiki-platform by xwiki.

the class InternalTemplateManager method getTemplate.

public Template getTemplate(String templateName) {
    Template template = null;
    // Try from skin
    Skin skin = this.skins.getCurrentSkin(false);
    if (skin != null) {
        template = getTemplate(templateName, skin);
    }
    // Try from base skin if no skin is set
    if (skin == null) {
        Skin baseSkin = this.skins.getCurrentParentSkin(false);
        if (baseSkin != null) {
            template = getTemplate(templateName, baseSkin);
        }
    }
    // Try from /templates/ environment resources
    if (template == null) {
        template = getFileSystemTemplate("/templates/", templateName);
    }
    // Try from current Thread classloader
    if (template == null) {
        template = getClassloaderTemplate("templates/", templateName);
    }
    return template;
}
Also used : Skin(org.xwiki.skin.Skin) Template(org.xwiki.template.Template)

Example 7 with Skin

use of org.xwiki.skin.Skin in project xwiki-platform by xwiki.

the class InternalSkinManager method getCurrentParentSkinId.

public String getCurrentParentSkinId(boolean testRights) {
    // From the context
    String baseSkin = getContextParentId();
    // From the skin
    if (baseSkin == null) {
        Skin skin = getCurrentSkin(testRights);
        if (skin != null) {
            ResourceRepository parent = skin.getParent();
            if (parent != null) {
                baseSkin = parent.getId();
            }
        }
    }
    // From the configuration
    if (baseSkin == null) {
        baseSkin = getDefaultParentSkinId();
    }
    XWikiContext xcontext = this.xcontextProvider.get();
    if (xcontext != null) {
        // TODO: shouldn't we make sure anyone see the skin whatever right he have ?
        if (testRights) {
            XWikiDocument document = this.wikiSkinUtils.getSkinDocument(baseSkin);
            if (document != null) {
                if (!this.authorization.hasAccess(Right.VIEW, document.getDocumentReference())) {
                    this.logger.debug("Cannot access configured wiki skin [{}] due to access rights, using the default skin.", baseSkin);
                    baseSkin = getDefaultParentSkinId();
                }
            }
        }
        // Set found skin in the context
        xcontext.put(CKEY_PARENTSKIN, baseSkin);
    }
    return baseSkin;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) XWikiContext(com.xpn.xwiki.XWikiContext) Skin(org.xwiki.skin.Skin) ResourceRepository(org.xwiki.skin.ResourceRepository)

Aggregations

Skin (org.xwiki.skin.Skin)7 WikiSkin (com.xpn.xwiki.internal.skin.WikiSkin)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 NamingException (javax.naming.NamingException)2 URIException (org.apache.commons.httpclient.URIException)2 HibernateException (org.hibernate.HibernateException)2 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)2 JobException (org.xwiki.job.JobException)2 QueryException (org.xwiki.query.QueryException)2 ParseException (org.xwiki.rendering.parser.ParseException)2 Syntax (org.xwiki.rendering.syntax.Syntax)2 Template (org.xwiki.template.Template)2 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 XWikiURLFactory (com.xpn.xwiki.web.XWikiURLFactory)1 URL (java.net.URL)1