Wiki source code of $services.localization.render('panelwizard.panelwizard')
Version 2.1 by Thomas Coelho (local) on 2022/05/27 15:10
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{velocity output="false"}} |
2 | ## | ||
3 | ## Redirect to force right and left panels layout | ||
4 | ## | ||
5 | #set ($mustRedirect = false) | ||
6 | #set ($redirectQuery = '') | ||
7 | #set ($redirectDoc = $doc.fullName) | ||
8 | #set ($redirectMode = 'view') | ||
9 | #if ($xwiki.exists('XWiki.AdminSheet')) | ||
10 | ## The new administration interface, use XWiki.XWikiPreferences as the container document, and this as an included sheet | ||
11 | #set ($currSpace = $request.getParameter('space')) | ||
12 | #set ($redirectQuery = "$!{request.queryString}&forceLeftPanels=1&forceRightPanels=1§ion=Panels.PanelWizard&$!docvariant") | ||
13 | #set ($redirectMode = 'admin') | ||
14 | #if ($doc.documentReference.name != 'XWikiPreferences' && $doc.documentReference.name != 'WebPreferences') | ||
15 | #set ($redirectDoc = 'XWiki.XWikiPreferences') | ||
16 | #set ($mustRedirect = true) | ||
17 | #end | ||
18 | #else | ||
19 | ## No admin application, use this as the container document | ||
20 | #set ($redirectQuery = "$!{request.queryString}&forceLeftPanels=1&forceRightPanels=1&$!docvariant") | ||
21 | #end | ||
22 | #if (!$request.getParameter('forceLeftPanels') || !$request.getParameter('forceRightPanels')) | ||
23 | #set ($mustRedirect = true) | ||
24 | #end | ||
25 | #if ($mustRedirect) | ||
26 | $response.sendRedirect($xwiki.getDocument($redirectDoc).getURL($redirectMode, $redirectQuery))## | ||
27 | #stop() | ||
28 | #end | ||
29 | ## No redirect needed, display the wizard | ||
30 | #set ($showdata = 0) | ||
31 | #set ($showEmptyPanels = 1) | ||
32 | #if ("$!{currSpace}" != '') | ||
33 | #set ($accessLevel = $xwiki.hasAccessLevel('admin', $xcontext.user, "${currSpace}.WebPreferences")) | ||
34 | #else | ||
35 | #set ($accessLevel = $xwiki.hasAdminRights()) | ||
36 | #end | ||
37 | ## | ||
38 | ## Check for admin right for the current preferences document (XWiki.XWikiPreferences or Space.WebPreferences) | ||
39 | ## | ||
40 | {{/velocity}} | ||
41 | |||
42 | {{velocity output="false"}} | ||
43 | #macro (displayConfigPropertyValue $propName $action) | ||
44 | #set ($output = $doc.display($propName, $action)) | ||
45 | #set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}')) | ||
46 | #set ($output = $stringtool.removeEnd($output, '{{/html}}')) | ||
47 | $output | ||
48 | #end | ||
49 | |||
50 | #macro (displayPageLayoutSection) | ||
51 | <dl> | ||
52 | <dt> | ||
53 | <label>$services.localization.render('panelwizard.panelColumns')</label> | ||
54 | <span class="xHint"> | ||
55 | $services.localization.render('panelwizard.choosepagelayout') | ||
56 | </span> | ||
57 | </dt> | ||
58 | <dd class="row pagelayoutoptions"> | ||
59 | #set ($crtlayout = 0) | ||
60 | #if ($showLeftPanels and $showLeftPanels == '1') | ||
61 | #set ($crtlayout = $crtlayout + 1) | ||
62 | #end | ||
63 | #if ($showRightPanels and $showRightPanels == '1') | ||
64 | #set ($crtlayout = $crtlayout + 2) | ||
65 | #end | ||
66 | <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pagelayoutoption pagelayoutoption0" | ||
67 | #if ($crtlayout == 0) id="selectedoption"#end> | ||
68 | <label>$escapetool.xml($services.localization.render('panelwizard.nosidecolumn'))</label> | ||
69 | <div id="nosidecolumn" class="layoutmaquette"> | ||
70 | <div class="lmcontentcolumn"></div> | ||
71 | </div> | ||
72 | </div> | ||
73 | <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pagelayoutoption pagelayoutoption1" | ||
74 | #if ($crtlayout == 1) id="selectedoption"#end> | ||
75 | <label>$escapetool.xml($services.localization.render('panelwizard.leftcolumn'))</label> | ||
76 | <div id="leftcolumn" class="layoutmaquette"> | ||
77 | <div class="lmleftcolumn"></div> | ||
78 | <div class="lmcontentcolumn"></div> | ||
79 | </div> | ||
80 | </div> | ||
81 | <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pagelayoutoption pagelayoutoption2" | ||
82 | #if ($crtlayout == 2) id="selectedoption"#end> | ||
83 | <label>$escapetool.xml($services.localization.render('panelwizard.rightcolumn'))</label> | ||
84 | <div id="rightcolumn" class="layoutmaquette"> | ||
85 | <div class="lmrightcolumn"></div> | ||
86 | <div class="lmcontentcolumn"></div> | ||
87 | </div> | ||
88 | </div> | ||
89 | <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pagelayoutoption pagelayoutoption3" | ||
90 | #if ($crtlayout == 3) id="selectedoption"#end> | ||
91 | <label>$escapetool.xml($services.localization.render('panelwizard.bothcolumns'))</label> | ||
92 | <div id="bothcolumns" class="layoutmaquette"> | ||
93 | <div class="lmleftcolumn"></div> | ||
94 | <div class="lmrightcolumn"></div> | ||
95 | <div class="lmcontentcolumn"></div> | ||
96 | </div> | ||
97 | </div> | ||
98 | </dd> | ||
99 | <dt> | ||
100 | <label for="XWiki.XWikiPreferences_0_leftPanelsWidth"> | ||
101 | $services.localization.render('XWiki.XWikiPreferences_leftPanelsWidth') | ||
102 | </label> | ||
103 | <span class="xHint"> | ||
104 | $services.localization.render('XWiki.XWikiPreferences_leftPanelsWidth.hint') | ||
105 | </span> | ||
106 | </dt> | ||
107 | <dd>#displayConfigPropertyValue('leftPanelsWidth' 'edit')</dd> | ||
108 | <dt> | ||
109 | <label for="XWiki.XWikiPreferences_0_leftPanels"> | ||
110 | $services.localization.render('XWiki.XWikiPreferences_leftPanels') | ||
111 | </label> | ||
112 | <span class="xHint"> | ||
113 | $services.localization.render('XWiki.XWikiPreferences_leftPanels.hint') | ||
114 | </span> | ||
115 | </dt> | ||
116 | <dd>#displayConfigPropertyValue('leftPanels' 'edit')</dd> | ||
117 | <dt> | ||
118 | <label for="XWiki.XWikiPreferences_0_rightPanelsWidth"> | ||
119 | $services.localization.render('XWiki.XWikiPreferences_rightPanelsWidth') | ||
120 | </label> | ||
121 | <span class="xHint"> | ||
122 | $services.localization.render('XWiki.XWikiPreferences_rightPanelsWidth.hint') | ||
123 | </span> | ||
124 | </dt> | ||
125 | <dd>#displayConfigPropertyValue('rightPanelsWidth' 'edit')</dd> | ||
126 | <dt> | ||
127 | <label for="XWiki.XWikiPreferences_0_rightPanels"> | ||
128 | $services.localization.render('XWiki.XWikiPreferences_rightPanels') | ||
129 | </label> | ||
130 | <span class="xHint"> | ||
131 | $services.localization.render('XWiki.XWikiPreferences_rightPanels.hint') | ||
132 | </span> | ||
133 | </dt> | ||
134 | <dd>#displayConfigPropertyValue('rightPanels' 'edit')</dd> | ||
135 | </dl> | ||
136 | #end | ||
137 | |||
138 | #macro (displayPanelListSection) | ||
139 | (% id="draganddroptooltip" class="hastooltip noitems" title="${services.localization.render('panelwizard.tip')}"%)$services.localization.render('panelwizard.draganddrop')(%%) | ||
140 | #set ($panelClass = $xwiki.getDocument('Panels.PanelClass').xWikiClass) | ||
141 | #set ($categoryList = $panelClass.category.getProperty('values').value.split('[|]')) | ||
142 | #set ($panelsList = $services.query.xwql('from doc.object(Panels.PanelClass) as panel where doc.fullName <> ''Panels.PanelTemplate''').execute()) | ||
143 | #set ($categoryMap = {}) | ||
144 | #foreach ($category in $categoryList) | ||
145 | $!categoryMap.put($category, [])## | ||
146 | #end | ||
147 | #foreach ($item in $panelsList) | ||
148 | ## stats panels can't be seen by non global admins | ||
149 | #if ($xwiki.hasAccessLevel('view', $xcontext.user, $item)) | ||
150 | #set ($obj = $xwiki.getDocument($item).getObject('Panels.PanelClass')) | ||
151 | #if ($obj.type == 'view') | ||
152 | #set ($arrayList = $categoryMap.get($obj.category)) | ||
153 | #if ($arrayList) | ||
154 | #set ($discard = $categoryMap.get($obj.category).add($item)) | ||
155 | ## TODO: uncategorized? | ||
156 | #end | ||
157 | #end | ||
158 | #end | ||
159 | #end | ||
160 | #set ($panelsPerRow = 3) | ||
161 | (% id="dhtmltooltip" style="visibility: hidden;" %)((())) | ||
162 | #if ($request.place) | ||
163 | #set ($ajaxurl = $xwiki.getDocument('Panels.PanelLayoutUpdate').getURL('get', "xpage=plain&outputSyntax=plain&place=$!{escapetool.url($request.place)}&prefsdoc=${escapetool.url($currentDoc)}&form_token=${escapetool.url($services.csrf.getToken())}")) | ||
164 | #else | ||
165 | #set ($ajaxurl = $xwiki.getDocument("Panels.PanelLayoutUpdate").getURL('get', "xpage=plain&outputSyntax=plain&prefsdoc=${escapetool.url($currentDoc)}&form_token=${escapetool.url($services.csrf.getToken())}")) | ||
166 | #end | ||
167 | $xwiki.jsfx.use('js/xwiki/panelwizard/Drag.js')## | ||
168 | $xwiki.jsfx.use('js/xwiki/panelwizard/ieemu.js')## | ||
169 | $xwiki.jsfx.use('js/xwiki/panelwizard/toolTip.js')## | ||
170 | {{html}} | ||
171 | <script> | ||
172 | //<![CDATA[ | ||
173 | window.ajaxurl = "$ajaxurl"; | ||
174 | window.allPanelsPlace = new Object(); | ||
175 | window.panelsavesuccess = "$escapetool.javascript($services.localization.render('panelsavesuccess'))"; | ||
176 | window.panelsaveerror = "$escapetool.javascript($services.localization.render('panelsaveerror'))"; | ||
177 | #set ($counter = 0) | ||
178 | #set ($panelsStatus = {}) | ||
179 | #foreach ($category in $categoryList) | ||
180 | #set ($categPanels = $categoryMap.get($category)) | ||
181 | #foreach ($item in $categPanels) | ||
182 | #set ($discard = $panelsStatus.put($item, 'false')) | ||
183 | #set ($obj = $xwiki.getDocument($item).getObject('Panels.PanelClass')) | ||
184 | window.allPanelsPlace[$counter] = new Object(); | ||
185 | window.allPanelsPlace[$counter]['fullname'] = '$escapetool.javascript($item)'; | ||
186 | #set ($issetleft = 0) | ||
187 | #set ($counterleft = 0) | ||
188 | #set ($issetright = 0) | ||
189 | #set ($counterright = 0) | ||
190 | #foreach ($element in $leftPanels.split(',')) | ||
191 | #if ($item == $element) | ||
192 | window.allPanelsPlace[$counter]['left'] = $counterleft; | ||
193 | #set ($issetleft = 1) | ||
194 | #set ($discard = $panelsStatus.put($item, 'true')) | ||
195 | #end | ||
196 | #set ($counterleft = $counterleft + 1) | ||
197 | #end | ||
198 | #if ($issetleft == 0) | ||
199 | window.allPanelsPlace[$counter]['left'] = -1; | ||
200 | #end | ||
201 | #foreach ($element in $rightPanels.split(',')) | ||
202 | #if ($item == $element) | ||
203 | window.allPanelsPlace[$counter]['right'] = $counterright; | ||
204 | #set ($issetright = 1) | ||
205 | #set ($discard = $panelsStatus.put($item, 'true')) | ||
206 | #end | ||
207 | #set ($counterright = $counterright + 1) | ||
208 | #end | ||
209 | #if ($issetright == 0) | ||
210 | window.allPanelsPlace[$counter]['right'] = -1; | ||
211 | #end | ||
212 | #set ($counter = $counter + 1) | ||
213 | #end | ||
214 | #end | ||
215 | window.showLeftColumn = $showLeftPanels; | ||
216 | window.showRightColumn = $showRightPanels; | ||
217 | #if ($showApplicationPanel) | ||
218 | window.showApplicationPanel = true; | ||
219 | #else | ||
220 | window.showApplicationPanel = false; | ||
221 | #end | ||
222 | require(['scriptaculous-accordion'], function() { | ||
223 | createAccordion({div: 'panellistaccordion', no: 0, height: 512}); | ||
224 | }); | ||
225 | //]]> | ||
226 | </script> | ||
227 | {{/html}} | ||
228 | $xwiki.jsfx.use('js/xwiki/panelwizard/panelWizard.js')## | ||
229 | |||
230 | (% id="allviewpanels" %) | ||
231 | ((( | ||
232 | (% id="panellistaccordion" class="accordion" %) | ||
233 | ((( | ||
234 | #set ($panelCount = 0) | ||
235 | #foreach ($category in $categoryList) | ||
236 | ## start of accordion tab: | ||
237 | (% class="accordionTabTitleBar" id="${category}_header" %) | ||
238 | (((=${category}=))) | ||
239 | ## start of accordion tab content: | ||
240 | (% class="accordionTabContentBox" %) | ||
241 | ((( | ||
242 | #set ($categPanels = $categoryMap.get($category)) | ||
243 | #if ($categPanels.size() == 0) | ||
244 | (%class="noitems"%)$services.localization.render('panelwizard.nopanels')(%%) | ||
245 | #else | ||
246 | #foreach ($item in $categPanels) | ||
247 | #set ($panelDoc = $xwiki.getDocument($item)) | ||
248 | #set ($obj = $panelDoc.getObject('Panels.PanelClass')) | ||
249 | (% class="panelitemc" %) | ||
250 | ((( | ||
251 | (% class="label" %)((($doc.display('name', $obj)))) | ||
252 | (% id="panelContainer${panelCount}" class="panelcontainer" title="${doc.display('description', 'view', $obj, 'xwiki/2.0').replaceAll('^\{\{html(.*?)\}\}', '').replaceAll('\{\{/html\}\}$', '')}" %)(((#if($panelsStatus.get($item) == 'false')#displaypanel($item)#else(% class="panel" %)((()))#end))) | ||
![]() |
2.1 | 253 | (% class="xwikibuttonlink" %)((([[$services.localization.render('edit')>>path:$xwiki.getURL($item, 'edit')]] [[$services.localization.render('delete')>>path:$xwiki.getURL($item, 'delete')]]))) |
![]() |
1.1 | 254 | ))) |
255 | #set ($panelCount = $panelCount + 1) | ||
256 | #end## foreach panel | ||
257 | #end## categPanels.size() | ||
258 | )))## end of accordion tab content - accordionTabContentBox | ||
259 | #end## foreach category | ||
260 | )))## panellistaccordion | ||
261 | )))## allviewpanels | ||
262 | #end | ||
263 | {{/velocity}} | ||
264 | |||
265 | {{velocity}} | ||
266 | {{html clean="false"}} | ||
267 | #if ($accessLevel) | ||
268 | #set ($discard = $xwiki.jsx.use('Panels.PanelWizard')) | ||
269 | #set ($discard = $xwiki.ssx.use('Panels.PanelWizard')) | ||
270 | <ul class="nav nav-tabs" role="tablist" id="panelEditorSteps"> | ||
271 | <li role="presentation" class="active"> | ||
272 | <a href="#PageLayoutSection" aria-controls="PageLayoutSection" role="tab" data-toggle="tab" | ||
273 | >$escapetool.xml($services.localization.render('panelwizard.pagelayout'))</a> | ||
274 | </li> | ||
275 | <li role="presentation"> | ||
276 | <a href="#PanelListSection" aria-controls="PanelListSection" role="tab" data-toggle="tab" | ||
277 | >$escapetool.xml($services.localization.render('panelwizard.panellist'))</a> | ||
278 | </li> | ||
279 | </ul> | ||
280 | <div class="tab-content"> | ||
281 | <div role="tabpanel" class="tab-pane active xform" id="PageLayoutSection"> | ||
282 | #displayPageLayoutSection | ||
283 | </div> | ||
284 | <div role="tabpanel" class="tab-pane" id="PanelListSection"> | ||
285 | {{/html}} | ||
286 | |||
287 | #displayPanelListSection | ||
288 | |||
289 | {{html clean="false"}} | ||
290 | </div> | ||
291 | </div> | ||
292 | <div id="panelwizardbuttons"> | ||
293 | <button class="btn btn-primary" id="saveLayout" | ||
294 | >$services.localization.render('xe.panels.wizard.savenew')</button> | ||
295 | <button class="btn btn-default" id="revertLayout" | ||
296 | >$services.localization.render('xe.panels.wizard.revert')</button> | ||
297 | <a href="$xwiki.getURL('Panels.WebHome')" | ||
298 | >$services.localization.render('xe.panels.wizard.homepage')</a> | ||
299 | </div> | ||
300 | #end | ||
301 | {{/html}} | ||
302 | {{/velocity}} |