1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.skinx

File CssSkinFileExtensionPlugin.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

4
15
7
1
129
55
9
0.6
2.14
7
1.29

Classes

Class Line # Actions
CssSkinFileExtensionPlugin 38 15 0% 9 0
1.0100%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20   
21    package com.xpn.xwiki.plugin.skinx;
22   
23    import java.util.Collections;
24    import java.util.Set;
25   
26    import org.apache.commons.lang3.StringUtils;
27   
28    import com.xpn.xwiki.XWikiContext;
29    import com.xpn.xwiki.api.Api;
30    import com.xpn.xwiki.plugin.XWikiPluginInterface;
31   
32    /**
33    * CSs Skin File Extension plugin to use css files from the skin.
34    *
35    * @version $Id: 1c3764f6897ec787dc0fff3588d1c172465c9550 $
36    * @since 1.6
37    */
 
38    public class CssSkinFileExtensionPlugin extends AbstractSkinExtensionPlugin
39    {
40    /**
41    * The identifier for this plugin; used for accessing the plugin from velocity, and as the action returning the
42    * extension content.
43    */
44    public static final String PLUGIN_NAME = "ssfx";
45   
46    /**
47    * XWiki plugin constructor.
48    *
49    * @param name The name of the plugin, which can be used for retrieving the plugin API from velocity. Unused.
50    * @param className The canonical classname of the plugin. Unused.
51    * @param context The current request context.
52    * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
53    */
 
54  32 toggle public CssSkinFileExtensionPlugin(String name, String className, XWikiContext context)
55    {
56  32 super(name, className, context);
57    }
58   
 
59  5507 toggle @Override
60    public String getName()
61    {
62  5507 return PLUGIN_NAME;
63    }
64   
 
65  5443 toggle @Override
66    public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
67    {
68  5443 return new SkinFileExtensionPluginApi((AbstractSkinExtensionPlugin) plugin, context);
69    }
70   
 
71  5225 toggle @Override
72    public String getLink(String filename, XWikiContext context)
73    {
74  5226 boolean forceSkinAction = (Boolean) getParametersForResource(filename, context).get("forceSkinAction");
75  5226 StringBuilder result = new StringBuilder("<link rel='stylesheet' type='text/css' href='");
76  5226 result.append(context.getWiki().getSkinFile(filename, forceSkinAction, context));
77  5227 if (forceSkinAction) {
78  5202 String parameters = StringUtils.removeStart(parametersAsQueryString(filename, context), "&amp;");
79  5200 if (!StringUtils.isEmpty(parameters)) {
80  1404 result.append("?").append(parameters);
81    }
82    }
83  5227 result.append("'/>");
84  5225 return result.toString();
85    }
86   
87    /**
88    * {@inheritDoc}
89    * <p>
90    * We must override this method since the plugin manager only calls it for classes that provide their own
91    * implementation, and not an inherited one.
92    * </p>
93    *
94    * @see AbstractSkinExtensionPlugin#endParsing(String, XWikiContext)
95    */
 
96  6892 toggle @Override
97    public String endParsing(String content, XWikiContext context)
98    {
99  6892 return super.endParsing(content, context);
100    }
101   
102    /**
103    * {@inheritDoc}
104    * <p>
105    * There is no support for always used skinfile-based extensions.
106    * </p>
107    *
108    * @see AbstractSkinExtensionPlugin#getAlwaysUsedExtensions(XWikiContext)
109    */
 
110  6890 toggle @Override
111    public Set<String> getAlwaysUsedExtensions(XWikiContext context)
112    {
113  6891 return Collections.emptySet();
114    }
115   
116    /**
117    * {@inheritDoc}
118    * <p>
119    * Not supported for skinfile-based extensions.
120    * </p>
121    *
122    * @see com.xpn.xwiki.plugin.skinx.AbstractSkinExtensionPlugin#hasPageExtensions(com.xpn.xwiki.XWikiContext)
123    */
 
124  6891 toggle @Override
125    public boolean hasPageExtensions(XWikiContext context)
126    {
127  6892 return false;
128    }
129    }