Skin Module
Last modified by Vincent Massol on 2024/07/05 18:05
Provide APIs to manipulate skin resources |
Type | JAR |
Category | |
Developed by | |
Rating | |
License | GNU 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.
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")