# Wiki source code of TemplateProviderEditSheet

Last modified by Alexandru Colesnicov on 2019/03/27 19:06
Export
Office Formats
Export as PDF
Other Formats
Export as HTML

Show last authors

author | version | line-number | content
--- | --- | --- | ---
1 | {{include reference="XWiki.TemplateProviderMacros" /}}
2 |
3 | {{include reference="AppWithinMinutes.VelocityMacros" /}}
4 |
5 | {{velocity}}
6 | #if ("$!request.wizard" == 'true')
7 | {{include reference="AppWithinMinutes.WizardStep" /}}
8 | #end
9 | {{/velocity}}
10 |
11 | {{velocity output="false"}}
12 | #set ($appDescriptorClassName = 'AppWithinMinutes.LiveTableClass')
13 |
14 | #macro (updateHiddenTemplateProviderProperties)
15 | #set ($prefix = $stringtool.removeEnd($doc.documentReference.name, 'TemplateProvider'))
16 | #set ($discard = $doc.setTitle("$prefix Template Provider"))
17 | #set ($templateProviderObj = $doc.getObject('XWiki.TemplateProviderClass'))
18 | #set ($discard = $templateProviderObj.set('name', "${prefix.toLowerCase()}.entry.name"))
19 | #set ($discard = $templateProviderObj.set('template', $stringtool.removeEnd($doc.fullName, 'Provider')))
20 | #end
21 |
22 | #macro (initVisibleTemplateProviderProperties $templateProviderObj)
23 | #getAppReference
24 | #set ($localStringAppRef = $services.model.serialize($appReference, 'local'))
25 | #set ($icon = 'application')
26 | #foreach ($uix in $services.uix.getExtensions('org.xwiki.platform.panels.Applications'))
27 | #if ($uix.id == "platform.panels.${localStringAppRef}Application" && $uix.parameters.icon.startsWith('icon:'))
28 | ## Use the application icon by default if set.
29 | #set ($icon = $stringtool.removeStart($uix.parameters.icon, 'icon:'))
30 | #end
31 | #end
32 | #set ($discard = $templateProviderObj.set('icon', $icon))
33 | #set ($homePageRef = $services.model.resolveDocument('', 'default', $appReference))
34 | ## We recommend the users to create the entries in the application space by default because:
35 | ## * for most applications it's better to keep the entries in the same place
36 | ## * if the application is not yet created the application space doesn't exist so the user cannot select it from the
37 | ## tree unless we select it by default
38 | #set ($creationRestrictions = [$services.model.serialize($appReference, 'local')])
39 | #set ($creationRestrictionsAreSuggestions = 1)
40 | #if ($xwiki.exists($homePageRef))
41 | ## We are (most probably) editing an existing application. Initialize the entry location based on the information
42 | ## stored on the application home page.
43 | #set ($dataSpace = $xwiki.getDocument($homePageRef).getValue('dataSpace'))
44 | #set ($dataSpaceReference = $services.model.resolveSpace($dataSpace, 'explicit', $appReference))
45 | #set ($creationRestrictions = [$services.model.serialize($dataSpaceReference, 'local')])
46 | #set ($creationRestrictionsAreSuggestions = 0)
47 | ## Preserve the old behavior.
48 | #set ($discard = $templateProviderObj.set('terminal', 1))
49 | #end
50 | #set ($discard = $templateProviderObj.set('creationRestrictions', $creationRestrictions))
51 | #set ($discard = $templateProviderObj.set('creationRestrictionsAreSuggestions', $creationRestrictionsAreSuggestions))
52 | #end
53 |
54 | #macro (maybeAddXRedirectToNextWizardStep)
55 | #if ("$!request.wizard" == 'true')
56 | ## Add redirect to next wizard step.
57 | #getAppReference
58 | #set ($homePageRef = $services.model.resolveDocument('', 'default', $appReference))
59 | #set ($queryString = {"wizard" : true})
60 | #if (!$xwiki.exists($homePageRef))
61 | #set ($classReference = "${stringtool.removeEnd($doc.fullName, 'TemplateProvider')}Class")
62 | #set ($wikiHomePageRef = $services.model.resolveDocument('', 'default'))
63 | #set ($wikiHomePage = $services.model.serialize($wikiHomePageRef, 'local'))
64 | #set ($discard = $queryString.putAll({
65 | 'template': 'AppWithinMinutes.LiveTableTemplate',
66 | "${appDescriptorClassName}_0_class": $classReference,
67 | 'title': $appReference.name,
68 | 'parent': $wikiHomePage
69 | }))
70 | #end
71 | #set ($queryString = $escapetool.url($queryString))
72 | <input type="hidden" name="xredirect" value="$escapetool.xml($xwiki.getURL($homePageRef, 'edit', $queryString))" />
73 | #end
74 | #end
75 |
76 | #macro (displayEditForm)
77 | #set ($discard = $xwiki.ssx.use('XWiki.TemplateProviderMacros'))
78 | #set ($discard = $xwiki.jsx.use('XWiki.TemplateProviderMacros'))
79 | #updateHiddenTemplateProviderProperties
80 | #if ($doc.isNew())
81 | #initVisibleTemplateProviderProperties($templateProviderObj)
82 | #end
83 | <div class="hidden">
84 | <input type="hidden" name="title" value="$escapetool.xml($doc.title)" />
85 | <input type="hidden" name="xhidden" value="1" />
86 | #foreach ($property in ['name', 'template', 'action'])
87 | #displayPropertyValue($property 'hidden')
88 | #end
89 | #maybeAddXRedirectToNextWizardStep
90 | </div>
91 | <div class="xform row templateProviderSheet">
92 | <div class="xHint col-xs-12">
93 | $services.icon.renderHTML('info')
94 | $services.localization.render('appWithinMinutes.templateProviderEditor.hint')
95 | </div>
96 | ##
97 | ## Left side
98 | ##
99 | <div class="col-xs-12 col-md-6">
100 | <dl>
101 | ##
102 | ## Icon
103 | ##
104 | <dt>
105 | <label for="XWiki.TemplateProviderClass_0_icon">
106 | $escapetool.xml($doc.displayPrettyName('icon'))
107 | </label>
108 | <span class="xHint">
109 | $services.localization.render('appWithinMinutes.templateProviderEditor.icon.hint')
110 | </span>
111 | </dt>
112 | <dd>#displayPropertyValue('icon')</dd>
113 | ##
114 | ## Description
115 | ##
116 | <dt>
117 | <label for="XWiki.TemplateProviderClass_0_description">
118 | $escapetool.xml($doc.displayPrettyName('description'))
119 | </label>
120 | <span class="xHint">
121 | $services.localization.render('appWithinMinutes.templateProviderEditor.description.hint')
122 | </span>
123 | </dt>
124 | <dd>#displayPropertyValue('description')</dd>
125 | ##
126 | ## Visibility Restrictions
127 | ##
128 | <dt>
129 | <label>
130 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.visibilityRestrictions.name'))
131 | </label>
132 | <span class="xHint">
133 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.visibilityRestrictions.hint'))
134 | </span>
135 | </dt>
136 | <dd>#displayPathsPropertyValue('visibilityRestrictions')</dd>
137 | </dl>
138 | </div>
139 | ##
140 | ## Right side
141 | ##
142 | <div class="col-xs-12 col-md-6">
143 | <dl>
144 | ##
145 | ## Creation Restrictions
146 | ##
147 | <dt>
148 | <label for="XWiki.TemplateProviderClass_0_creationRestrictions">
149 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictions.name'))
150 | </label>
151 | <span class="xHint">
152 | $services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictions.hint')
153 | </span>
154 | </dt>
155 | <dd>#displayPathsPropertyValue('creationRestrictions')</dd>
156 | ##
157 | ## Creation Restrictions As Suggestions
158 | ##
159 | <dt>
160 | <label for="XWiki.TemplateProviderClass_0_creationRestrictionsAreSuggestions">
161 | #displayPropertyValue('creationRestrictionsAreSuggestions')
162 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictionsAreSuggestions.name'))
163 | </label>
164 | <span class="xHint">
165 | $services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictionsAreSuggestions.hint')
166 | </span>
167 | </dt>
168 | <dd></dd>
169 | ##
170 | ## Terminal page creation - Advanced user
171 | ##
172 | #if ($isAdvancedUser || $isSuperAdmin)
173 | <dt>
174 | <label for="XWiki.TemplateProviderClass_0_terminal">
175 | $escapetool.xml($doc.displayPrettyName('terminal'))
176 | </label>
177 | <span class="xHint">
178 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.terminal.hint'))
179 | </span>
180 | </dt>
181 | <dd>#displayPropertyValue('terminal')</dd>
182 | #else
183 | <dd>#displayPropertyValue('terminal' 'hidden')</dd>
184 | #end
185 | </dl>
186 | </div>
187 | #locationPickerModal
188 | </div>
189 | #end
190 |
191 | #macro (doEdit)
192 | #if ("$!request.wizard" == 'true')
193 | #appWizardHeader('entries')
194 | ## Compute the application title to be used as the wizard step title.
195 | #getAppTitle
196 | #end
197 | #displayEditForm
198 | #if ("$!request.wizard" == 'true')
199 | #appWizardFooter('entries')
200 | #end
201 | #end
202 | {{/velocity}}
203 |
204 | {{velocity}}
205 | #if ($doc.getObject('XWiki.TemplateProviderClass'))
206 | {{html clean="false"}}
207 | #doEdit
208 | {{/html}}
209 |
210 | {{iconPicker id="XWiki\\.TemplateProviderClass_0_icon" prefix="" /}}
211 | #end
212 | {{/velocity}}

# Applications

# Tips

Press the x+x+x+a key combo to toggle the Advanced mode and x+x+x+h to toggle the display of hidden pages.

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support

XWiki Debian 11.5