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

File XWikiSkinsDocumentInitializer.java

 

Coverage histogram

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

Code metrics

2
19
2
1
89
47
3
0.16
9.5
2
1.5

Classes

Class Line # Actions
XWikiSkinsDocumentInitializer 43 19 0% 3 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    package com.xpn.xwiki.internal.mandatory;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.model.reference.DocumentReference;
28    import org.xwiki.sheet.SheetBinder;
29   
30    import com.xpn.xwiki.XWiki;
31    import com.xpn.xwiki.doc.XWikiDocument;
32    import com.xpn.xwiki.objects.classes.BaseClass;
33   
34    /**
35    * Update XWiki.XWikiSkins document with all required informations.
36    *
37    * @version $Id: 4c2c00f4952e61b230286f6808e4c7dc2e29cd14 $
38    * @since 4.3M1
39    */
40    @Component
41    @Named("XWiki.XWikiSkins")
42    @Singleton
 
43    public class XWikiSkinsDocumentInitializer extends AbstractMandatoryDocumentInitializer
44    {
45    /**
46    * Used to bind a class to a document sheet.
47    */
48    @Inject
49    @Named("class")
50    private SheetBinder classSheetBinder;
51   
52    /**
53    * Default constructor.
54    */
 
55  60 toggle public XWikiSkinsDocumentInitializer()
56    {
57  60 super(XWiki.SYSTEM_SPACE, "XWikiSkins");
58    }
59   
 
60  92 toggle @Override
61    public boolean updateDocument(XWikiDocument document)
62    {
63  92 boolean needsUpdate = false;
64   
65  92 BaseClass bclass = document.getXClass();
66   
67  92 needsUpdate |= bclass.addTextField("name", "Name", 30);
68  92 needsUpdate |= bclass.addTextField("baseskin", "Base Skin", 30);
69  92 needsUpdate |= bclass.addTextField("logo", "Logo", 30);
70  92 needsUpdate |= bclass.addStaticListField("outputSyntax", "Output Syntax",
71    "html/5.0=HTML 5|xhtml/1.0=XHTML 1.0");
72  92 needsUpdate |= bclass.addTemplateField("style.css", "Style");
73  92 needsUpdate |= bclass.addTemplateField("header.vm", "Header");
74  92 needsUpdate |= bclass.addTemplateField("footer.vm", "Footer");
75  92 needsUpdate |= bclass.addTemplateField("viewheader.vm", "View Header");
76  92 needsUpdate |= bclass.addTemplateField("view.vm", "View");
77  92 needsUpdate |= bclass.addTemplateField("edit.vm", "Edit");
78  92 needsUpdate |= setClassDocumentFields(document, "XWiki Skin Class");
79   
80    // Use XWikiSkinsSheet to display documents having XWikiSkins objects if no other class sheet is specified.
81  92 if (this.classSheetBinder.getSheets(document).isEmpty()) {
82  38 String wikiName = document.getDocumentReference().getWikiReference().getName();
83  38 DocumentReference sheet = new DocumentReference(wikiName, XWiki.SYSTEM_SPACE, "XWikiSkinsSheet");
84  38 needsUpdate |= this.classSheetBinder.bind(document, sheet);
85    }
86   
87  92 return needsUpdate;
88    }
89    }