Skin Module

Last modified by Vincent Massol on 2021/03/17 21:35

cogProvide APIs to manipulate skin resources
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Compatibility

Since 7.0M1

Table of contents

Description

This module provide API and tools to navigate in skin resources.

If you search documentation related to "Skin Extensions" see Skin Extension Plugin.

The main entry point of this module is the org.xwiki.skin.SkinManager component.

Each skin is represented by org.xwiki.skin.Skin interface which is in most part a org.xwiki.skin.ResourceRepository. As its name indicated it provide APIs to navigate in the resource located in the skin, it's also take into account skin inheritance when searching a resource.

See the module javadoc for more details.

Java examples

  • get the skin with id "xwiki:Main.MySkin":
    import org.xwiki.skin.SkinManager;
    import org.xwiki.skin.Skin;

    ...

    @Inject
    SkinManager skinManager;

    ...

    Skin myWikiSkin = skinManager.getSkin("xwiki:Main.MySkin");
  • get the current skin:
    import org.xwiki.skin.SkinManager;
    import org.xwiki.skin.Skin;

    ...

    @Inject
    SkinManager skinManager;

    ...

    // We don't care if the current user have the right to access the current skin so we put false
    Skin currentSkin = skinManager.getCurrentSkin(false);
  • recursively search a the resource myscript.js in the current skin:
    import org.xwiki.skin.SkinManager;
    import org.xwiki.skin.Skin;
    import org.xwiki.skin.Resource;

    ...

    @Inject
    SkinManager skinManager;

    ...

    // We want the first skin that works for current user
    Skin currentSkin = skinManager.getCurrentSkin(true);

    // The resource is the skin or one of its parents
    Resource myresource = currentSkin.getResource("myscript.js")
    // Print the skin where the resource was found
    System.out.println(myresource.getRepository());

    // The resource is the skin itself only
    Resource myskinresource = currentSkin.getLocalResource("myscript.js")
Tags:
    

Get Connected