Version 3.1 by Leon Poon on 2019/06/16 14:44

Hide last authors
Leon Poon 1.1 1 {{include reference="XWiki.ConfigurableClassMacros" /}}
2
3 {{velocity output="false"}}
4 #if ($request.xaction == 'switchContext')
5 $response.sendRedirect($request.target)
6 #stop
7 #end
8
9 #set ($adminAction = 'admin')
10 #set ($crtCategoryId = "$!{request.category}")
11 #if ($crtCategoryId != '')
12 #set ($crtCategoryId = $mathtool.toInteger($crtCategoryId))
13 #end
14 #set ($crtSectionId = "$!{request.section}")
15
16 ##
17 ## Admin menu map
18 ##
Leon Poon 3.1 19 ## displayInSection: menu.name | sectionOrder: 200 | page: Menu.MenuConfigurationSection
20 ## displayInSection: panels.applications | sectionOrder: 400 | page: PanelsCode.ApplicationsPanelConfigurable
21 ## displayInSection: panels.navigation | sectionOrder: 500 | page: PanelsCode.NavigationConfigurationSection
Leon Poon 1.1 22 #set($adminMenu = [
23 {
24 'id' : 'lf',
25 'icon': 'columns',
26 'displayBeforeCategory': 'content',
27 'children': [
28 {'id' : 'Themes', 'perSpace' : true, 'order' : 100},
Leon Poon 3.1 29 {'id' : 'Panels.PanelWizard', 'perSpace' : true, 'order' : 300},
30 {'id' : 'Presentation', 'perSpace' : true, 'order' : 600}
Leon Poon 1.1 31 ]
32 },
33 {
34 'id' : 'usersgroups',
35 'icon': 'group',
36 'displayBeforeCategory': 'extensionmanager',
37 'children': [
38 {'id' : 'Users', 'order' : 100},
39 {'id' : 'Groups', 'order' : 200},
40 {'id' : 'Rights', 'perSpace' : false, 'order' : 300},
41 {'id' : 'PageAndChildrenRights', 'perSpace' : true, 'order' : 300, 'global': false},
42 {'id' : 'PageRights', 'perSpace' : true, 'order' : 350, 'global': false},
43 {'id' : 'UserProfile', 'order' : 400},
44 {'id' : 'Registration', 'order' : 500}
45 ]
46 },
47 {
48 'id' : 'other',
49 'icon': 'wrench',
50 'children' : []
51 }
52 ])
53
54 ##
55 ## Fill in the list of custom applications to configure
56 ##
57 #findCustomSectionsToConfigure($adminMenu)
58 ##
59 ## Filter only the sections that are valid in the context
60 ##
61 #set ($categoriesToRemove = [])
62 #foreach ($category in $adminMenu)
63 #set ($sectionsToRemove = [])
64 #foreach ($section in $category.children)
65 #if ($editor == 'spaceadmin' && !$section.perSpace)
66 #set ($discard = $sectionsToRemove.add($section))
67 #elseif ($editor == 'globaladmin' && "$!section.global" == "false")
68 ## For retro-compatibility, all sections are global unless the 'global' field is explicitly marked as false
69 #set ($discard = $sectionsToRemove.add($section))
70 #end
71 #end
72 #set ($discard = $category.children.removeAll($sectionsToRemove))
73 #if ($category.children.size() == 0)
74 #set ($discard = $categoriesToRemove.add($category))
75 #end
76 #end
77 #set ($discard = $adminMenu.removeAll($categoriesToRemove))
78 #if ("$!crtCategoryId" != '' && $crtCategoryId >= $adminMenu.size())
79 #set ($crtCategoryId = '')
80 #end
81
82 ##
83 ## Prepare the Admin menu map for processing
84 ##
85 #set ($filteredAdminMenu = [])
86 #set ($crtSection = $NULL)
87 #set ($crtCategory = $NULL)
88 #foreach ($category in $adminMenu)
89 ## "Standard" URLs and icons for categories
90 #set ($category.url = $xwiki.getURL($currentDoc, $adminAction, "category=${mathtool.sub($velocityCount, 1)}"))
91 #if ($xwiki.getDocument('XWiki.AdminSheet').getAttachment("${category.id}.png"))
92 #set ($category.iconReference = "XWiki.AdminSheet@${category.id}.png")
93 #else
94 #set ($category.iconReference = "XWiki.ConfigurableClass@DefaultAdminSectionIcon.png")
95 #end
96 #set ($category.description = $services.localization.render("admin.${category.id}.description").trim())
97 #set ($category.cssClass = "${category.id}Icon")
98 #set ($category.name = $services.localization.render("admin.${category.id}").trim())
99 #if ("$!{crtCategoryId}" != '' && $velocityCount == $mathtool.add($crtCategoryId, 1))
100 #set ($crtCategory = $category)
101 #end
102 ##
103 ## Process each admin section
104 #set ($filteredCategoryChildren = [])
105 #foreach ($section in $category.children)
106 #if ($xwiki.exists($section.id) || $xwiki.exists("XWiki.Admin${section.id}Sheet"))
107 #if ($crtSectionId == $section.id)
108 #set ($crtSection = $section)
109 #set ($crtCategory = $category)
110 #end
111 #set ($section.iconReference = '')
112 #if ($section.id.indexOf('.') > 0)
113 #set ($sectionDoc = $xwiki.getDocument($section.id))
114 #set ($section.name = $sectionDoc.getDisplayTitle())
115 #if ($sectionDoc.getAttachment('icon.png'))
116 #set ($section.iconReference = "${sectionDoc}@icon.png")
117 #else
118 #set ($section.iconReference = 'XWiki.ConfigurableClass@DefaultAdminSectionIcon.png')
119 #end
120 #else
121 #set ($sectionDoc = $xwiki.getDocument('XWiki.AdminSheet'))
122 #set ($section.name = $services.localization.render("admin.${section.id.toLowerCase()}"))
123 #set ($iconName = "${section.id.toLowerCase()}.png")
124 #if ($sectionDoc.getAttachment($iconName))
125 #set ($section.iconReference = "${sectionDoc}@${iconName}")
126 #else
127 #set ($section.iconReference = 'XWiki.ConfigurableClass@DefaultAdminSectionIcon.png')
128 #end
129 #end
130 #set ($query = "editor=$escapetool.url(${editor})&section=$escapetool.url(${section.id})")
131 #if ($editor != 'globaladmin')
132 #set ($query = $query + "&space=$escapetool.url(${currentSpace})")
133 #end
134 #set ($action = "$!{section.action}")
135 #if ($action == '')
136 #set ($action = $adminAction)
137 #end
138 #set ($section.url = $xwiki.getURL($currentDoc, $action, $query))
139 #set ($key = "admin.${section.id.toLowerCase()}.description")
140 #if ($services.localization.get($key))
141 #set ($section.description = $services.localization.render($key))
142 #end
143 #set ($discard = $filteredCategoryChildren.add($section))
144 #elseif ($section.configurable)
145 #if ($section.readOnly)
146 #set ($section.cssClass = 'readOnly')
147 #end
148 #if ($crtSectionId == $section.id)
149 #set ($crtSection = $section)
150 #set ($crtCategory = $category)
151 #end
152 #set ($discard = $filteredCategoryChildren.add($section))
153 #end
154 #end
155 #set ($category.children = $filteredCategoryChildren)
156 #if ($filteredCategoryChildren.size() > 0)
157 #set ($discard = $filteredAdminMenu.add($category))
158 #end
159 #end
160 #set ($adminMenu = $filteredAdminMenu)
161
162 ## Mark the active category/section. We use this flag when displaying the menu.
163 #if ($crtCategory)
164 #set ($crtCategory.active = true)
165 #if ($crtSection)
166 #set ($crtSection.active = true)
167 #else
168 #set ($crtSectionId = $NULL)
169 #end
170 #else
171 #set ($crtCategoryId = $NULL)
172 #end
173
174 #**
175 * Displays the sections from an administration category
176 *
177 * Expected format:
178 * sections = vector of items
179 * item = map with the following fields:
180 * 'id' : mandatory
181 * 'name' : the text displayed for the corresponding menu item;
182 * optional, defaults to
183 * $services.localization.render("$!{translationPrefix}${item.id}")
184 * 'description' : the description displayed for the corresponding section;
185 * optional
186 * 'link' : the "action" of the menu item; mandatory
187 * 'cssClass' : a specific css class for the menu item for custom
188 * styling; optional, defaults to ''
189 *
190 * @param $sections the sections list, in the format described above
191 * @param $translationPrefix the translation prefix added to the id of each
192 * item, in order to generate the name and description; ignored when
193 * name or description are specified
194 *#
195 #macro(admin_displayCategory $sections $translationPrefix)
196 (% class="admin-category" %)
197 #set ($sortedSections = [])
198 #sortCollectionOfMapsByField($sections, 'order', 9999, 'asc', $sortedSections)
199 #foreach ($section in $sortedSections)
200 * [[[[image:${section.iconReference}]] **${section.name}**>>path:${section.url}]] (% class="description" %)$!{section.description}
201 #end
202 #end
203
204
205 #**
206 * Displays the administration categories
207 *
208 * Expected format:
209 * sections = vector of items
210 * item = map with the following fields:
211 * 'id' : mandatory
212 * 'name' : the text displayed for the corresponding menu item;
213 * optional, defaults to
214 * $services.localization.render("$!{translationPrefix}${item.id}")
215 * 'description' : the description displayed for the corresponding section;
216 * optional
217 * 'link' : the "action" of the menu item; mandatory
218 * 'cssClass' : a specific css class for the menu item for custom
219 * styling; optional, defaults to ''
220 *
221 * @param $sections the sections list, in the format described above
222 * @param $translationPrefix the translation prefix added to the id of each
223 * item, in order to generate the name and description; ignored when
224 * name or description are specified
225 *#
226 #macro(admin_displayCategories $adminMenu $translationPrefix)
227 (% class="admin-category" %)
228 #foreach ($category in $adminMenu)
229 * [[[[image:${category.iconReference}]] **${category.name}**>>path:${category.url}]] (% class="description" %)$!{category.description}
230 #end
231 #end
232
233 #macro (verticalNavigation $menu $options)
234 {{html clean="false"}}
235 <div id="$!options.id" class="panel-group $!options.cssClass" role="tablist" aria-multiselectable="true">
236 <div class="panel xform">
Leon Poon 3.1 237 <label for="adminsearchmenu" class="hidden">$services.localization.render('search')</label>
238 <input type="text" class="form-control panel-group-filter" autocomplete="off" id="adminsearchmenu"
Leon Poon 1.1 239 placeholder="$escapetool.xml($services.localization.render('administration.menu.search.hint'))" />
240 </div>
241 #foreach ($item in $menu)
242 #verticalNavigationItem($item $options)
243 #end
244 <div class="panel panel-default noitems hidden">
245 <div class="panel-heading collapsed">
246 $escapetool.xml($services.localization.render('administration.menu.search.noResults'))
247 </div>
248 </div>
249 </div>
250 {{/html}}
251 #end
252
253 #macro (verticalNavigationItem $item $options)
254 #set ($escapedId = $escapetool.xml($item.id))
255 #set ($name = "$!item.name")
256 #if ($name == '')
257 #set ($name = $services.localization.render("$!options.translationPrefix$item.id"))
258 #end
259 #set ($isActive = $item.active == true)
260 #set ($hasChildren = $item.children && $item.children.size() > 0)
261 #if ($hasChildren)
262 #set ($children = [])
263 #sortCollectionOfMapsByField($item.children, 'order', 99999, 'asc', $children)
264 <div class="panel panel-default">
265 <a class="panel-heading#if (!$isActive) collapsed#end" role="tab" id="panel-heading-$escapedId"
266 href="$!item.url" data-toggle="collapse"#if ("$!options.id" != '') data-parent="#$options.id" #end
267 data-target="#panel-body-$escapedId" aria-expanded="$isActive" aria-controls="panel-body-$escapedId"
268 title="$!escapetool.xml($item.description)">$!services.icon.renderHTML($item.icon)$escapetool.xml($name)</a>
269 <div class="panel-collapse collapse#if ($isActive) in#end" role="tabpanel" id="panel-body-$escapedId"
270 aria-labelledby="panel-heading-$escapedId">
271 <div class="list-group">
272 #foreach ($child in $children)
273 #verticalNavigationItem($child $options)
274 #end
275 </div>
276 </div>
277 </div>
278 #else
279 <a class="list-group-item#if ($isActive) active#end" data-id="$escapedId"
280 href="$!item.url" title="$!escapetool.xml($item.description)"
281 >$!services.icon.renderHTML($item.icon)$escapetool.xml($name)</a>
282 #end
283 #end
284 {{/velocity}}
285
286 {{velocity}}
287 ##**************************************************************************************************
288 ## Administration Sheet, used to display a common UI for some wiki features (presentation, users,
289 ## groups, rights etc.) at global / space level and also for several applications.
290 ##**************************************************************************************************
291 #if($xcontext.action == 'view')
292 $response.sendRedirect($xwiki.getURL($doc.getFullName(), 'admin', $request.getQueryString()))##
293 #else
294 $xwiki.jsx.use('XWiki.AdminSheet')##
295 ## Construct the SSX parameter map.
296 #set ($parameterMap = {})
297 #if ($themeDoc)
298 #set ($discard = $parameterMap.put('colorTheme', $themeDocFullName))
299 #end
300 $xwiki.ssx.use('XWiki.AdminSheet', $parameterMap)##
301 #if ("$!crtSectionId" != '' && $crtSectionId.indexOf('.') > 0 && $xwiki.exists($crtSectionId))
302 #set ($sectionName = $xwiki.getDocument($crtSectionId).getDisplayTitle())
303 #elseif ($crtSectionId != '' && $services.localization.get("admin.${crtSectionId.toLowerCase()}"))
304 #set ($sectionName = $services.localization.render("admin.${crtSectionId.toLowerCase()}"))
305 #elseif ("$!crtSectionId" != '')
306 #set ($sectionName = $crtSectionId)
307 #elseif ("$!crtCategoryId" != '')
308 #set ($sectionName = $services.localization.render("admin.$crtCategory.id"))
309 #elseif ($editor == 'globaladmin')
310 #set ($sectionName = $services.wiki.getById($xcontext.database).prettyName)
311 #if ("$!sectionName" == '')
312 #set ($sectionName = $xcontext.database)
313 #end
314 #else
315 #set ($sectionName = $currentSpace)
316 #end
317
318 {{html}}
319 #template('hierarchy.vm')
320 {{/html}}
321
322 ## Determine the administration level.
323 #set ($level = '')
Leon Poon 2.1 324 #if ($doc.documentReference.name == 'WebPreferences')
Leon Poon 1.1 325 #set ($level = '.page')
326 #elseif ($doc.fullName == 'XWiki.XWikiPreferences')
327 #if ($xcontext.isMainWiki())
328 #set ($level = '.global')
329 #else
330 #set ($level = '.wiki')
331 #end
332 #end
333 (% id="document-title" %)(((
334 = $services.localization.render("administration.sectionTitle$level", [$sectionName]) =
335 ## Display the category/section description below the title.
336 #set ($categoryOrSectionId = $crtCategory.id)
337 #if ("$!crtSection.id" != '')
338 #set ($categoryOrSectionId = $crtSection.id)
339 #end
340 #set ($descriptionTranslationKey = "admin.$!{categoryOrSectionId.toLowerCase()}.description")
341 #if ($services.localization.get($descriptionTranslationKey))
342 (% class = "noitems" %)(((
343 $services.localization.render($descriptionTranslationKey)
344 )))
345 #end
346
347 ----
348 )))
349
350 #verticalNavigation($adminMenu {
351 'id': 'administration-menu',
352 'translationPrefix': 'admin.',
353 'cssClass': 'admin-menu'
354 })
355
356 ##-----------------------------------------
357 ## admin-page display
358 ##-----------------------------------------
359 #if(!$crtSection && !$crtCategory)
360 #admin_displayCategories($adminMenu)
361 #elseif (!$crtSection)
362 #admin_displayCategory($crtCategory.children)
363 #else
364 (% id="admin-page-content" %)(((
365 ##------------------------------------------------------------------------------------------------------------
366 ## The Administration allows editing other pages from different applications inside the admin context (UI)
367 ##------------------------------------------------------------------------------------------------------------
368 #if ("$!{request.editmode}" == 'inline' && $xwiki.exists($section))
369 #set ($discard = $xcontext.setDisplayMode('edit'))
370 {{html clean="false"}}{{include reference="XWiki.AdminInlineSheet" /}}{{/html}}
371 #elseif ($xwiki.exists("XWiki.Admin${section}Sheet"))
372 ## Custom XE administration section
373 {{include reference="XWiki.Admin${section}Sheet" /}}
374 #elseif ($xwiki.exists($section))
375 {{html clean="false"}}#includeForm($section){{/html}}
376 #end
377 #if ($crtSection.configurable)
378
379 {{include reference="XWiki.ConfigurableClass" /}}
380 #end
381 ))) ## admin-page-content
382 #end
383 #end
384 {{/velocity}}