Modifications pour le document MacroService

Modifié par Florent Charton le 2026/03/13 11:04

Depuis la version 3.1
modifié par Florent Charton
sur 2024/08/08 18:44
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.10.11]
À la version 1.1
modifié par superadmin
sur 2022/06/20 08:49
Commentaire de modification : Install extension [org.xwiki.contrib:application-ckeditor-ui/1.63.1]

Résumé

Détails

Propriétés de la Page
Auteur du document
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.fcharton
1 +XWiki.superadmin
Contenu
... ... @@ -38,23 +38,6 @@
38 38  ## }
39 39  ## ================================================================
40 40  #macro (getMacroList $syntaxId)
41 -
42 - ## Loads the css resources to display the macros list
43 - ## TODO: Refactor once we add support for loading css files from javascript without velocity.
44 - #if ($xcontext.action == 'get')
45 - #template('display_macros.vm')
46 - #initRequiredSkinExtensions()
47 - #end
48 -
49 - #set ($discard = $xwiki.linkx.use($services.webjars.url('selectize.js', 'css/selectize.bootstrap3.css'),
50 - {'type': 'text/css', 'rel': 'stylesheet'}))
51 - #set ($discard = $xwiki.ssfx.use('uicomponents/suggest/xwiki.selectize.css', true))
52 -
53 - #if ($xcontext.action == 'get')
54 - #getRequiredSkinExtensions($requiredSkinExtensions)
55 - #set ($discard = $response.setHeader('X-XWIKI-HTML-HEAD', $requiredSkinExtensions))
56 - #end
57 -
58 58   #set ($syntax = $services.rendering.resolveSyntax($syntaxId))
59 59   #set ($macroDescriptors = $services.rendering.getMacroDescriptors($syntax))
60 60   #if (!$macroDescriptors)
... ... @@ -73,41 +73,16 @@
73 73   #set ($discard = $allMacrosExcludedCategories.add("#maybeTranslate('rendering.macroCategory.Internal' 'Internal')"))
74 74   #set ($discard = $allMacrosExcludedCategories.add("#maybeTranslate('rendering.macroCategory.Deprecated' 'Deprecated')"))
75 75   #set ($discard = $data.put('options', { 'allMacrosExcludedCategories' : $allMacrosExcludedCategories }))
76 - ## If the current user do not want to display hidden documents, we initialize the set of hidden default
77 - ## categories.
78 - ## TODO: Make the list of hidden by default categories configurable from the administration (XWIKI-19993).
79 - #if(!$services.user.getProperties().displayHiddenDocuments())
80 - #set ($hiddenCategories = $services.rendering.getHiddenMacroCategories())
81 - #else
82 - #set ($hiddenCategories = [])
83 - #end
84 84   #set ($macroList = [])
85 - #set ($installedMacros = [])
86 86   #foreach ($macroDescriptor in $macroDescriptors)
87 - #set ($discard = $installedMacros.add($macroDescriptor.id.id))
88 -
89 89   #set ($macroTranslationKey = "rendering.macro.$macroDescriptor.id")
90 - #set ($categories = [])
91 - #set ($hidden = false)
92 - #foreach ($category in $services.rendering.getMacroCategories($macroDescriptor.id))
93 - #set ($macroCategoryTranslationKey = "rendering.macroCategory.$category")
94 - #set ($hidden = $hidden || $hiddenCategories.contains($category))
95 - #set ($discard = $categories.add({
96 - 'id': $category,
97 - 'label': "#maybeTranslate($macroCategoryTranslationKey $category)"
98 - }))
99 - #end
100 -
101 - #if (!$hidden)
102 - #set ($defaultCategoryTranslation = "rendering.macroCategory.${macroDescriptor.defaultCategory}")
103 - #set ($discard = $macroList.add({
104 - 'id': $macroDescriptor.id,
105 - 'name': "#maybeTranslate(""${macroTranslationKey}.name"" $macroDescriptor.name)",
106 - 'description': "#maybeTranslate(""${macroTranslationKey}.description"" $macroDescriptor.description)",
107 - 'defaultCategory': "#maybeTranslate($defaultCategoryTranslation $macroDescriptor.defaultCategory)",
108 - 'categories': $categories
109 - }))
110 - #end
62 + #set ($macroCategoryTranslationKey = "rendering.macroCategory.$macroDescriptor.defaultCategory")
63 + #set ($discard = $macroList.add({
64 + 'id': $macroDescriptor.id,
65 + 'name': "#maybeTranslate(""${macroTranslationKey}.name"" $macroDescriptor.name)",
66 + 'description': "#maybeTranslate(""${macroTranslationKey}.description"" $macroDescriptor.description)",
67 + 'defaultCategory': "#maybeTranslate($macroCategoryTranslationKey $macroDescriptor.defaultCategory)"
68 + }))
111 111   #end
112 112   #set ($macroList = $resolvedSortTool.sort($macroList, 'name'))
113 113   #set ($discard = $data.put('list', $macroList))
... ... @@ -126,13 +126,11 @@
126 126   #set ($macroExtensionsMap = {})
127 127   #foreach ($extension in $extensions)
128 128   ## TODO: move to a proper generic API to check if an extension can be installed by a given user
129 - #set ($extensionInstallAllowed = $services.security.authorization.hasAccess('programming', $xcontext.userReference, $NULL)
87 + #if ($services.security.authorization.hasAccess('programming')
130 130   || (($extension.type == 'xar' || $extension.type == 'webjar')
131 - && $services.security.authorization.hasAccess('admin', $xcontext.userReference, "wiki:$xcontext.database") && $services.extension.isAllowed($extension, "wiki:$xcontext.database")))
132 - #foreach ($extensionComponent in $extension.getComponents())
133 - #if ($extensionComponent.roleType == 'org.xwiki.rendering.macro.Macro')
134 - ## Skip macros identifiers for which a macro is already installed
135 - #if (!$installedMacros.contains($extensionComponent.roleHint))
89 + && $services.security.authorization.hasAccess('admin', "wiki:$xcontext.database") && $services.extension.isAllowed($extension, "wiki:$xcontext.database")))
90 + #foreach ($extensionComponent in $extension.getComponents())
91 + #if ($extensionComponent.roleType == 'org.xwiki.rendering.macro.Macro')
136 136   #set ($discard = $macroExtensionsList.add({
137 137   'id' : {
138 138   'id' : $extensionComponent.roleHint
... ... @@ -140,17 +140,12 @@
140 140   'name': $extensionComponent.roleHint,
141 141   'description': $extension.summary,
142 142   'defaultCategory': '_notinstalled',
143 - 'categories': [{
144 - 'id' :'_notinstalled',
145 - 'label': $services.localization.render('macroSelector.filter.category.notinstalled')
146 - }],
147 147   'extensionId' : $extension.id.id,
148 148   'extensionVersion' : $extension.id.version.value,
149 149   'extensionType' : $extension.type,
150 150   'extensionRecommended': $extension.recommended,
151 151   'extensionName': $extension.name,
152 - 'extensionSummary': $extension.summary,
153 - 'extensionInstallAllowed': $extensionInstallAllowed
104 + 'extensionSummary': $extension.summary
154 154   }))
155 155   #end
156 156   #end