Modifications pour le document MacroService
Modifié par Florent Charton le 2026/03/13 11:04
Depuis la version 1.1
modifié par superadmin
sur 2022/06/20 08:49
sur 2022/06/20 08:49
Commentaire de modification :
Install extension [org.xwiki.contrib:application-ckeditor-ui/1.63.1]
À la version 3.1
modifié par Florent Charton
sur 2024/08/08 18:44
sur 2024/08/08 18:44
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.10.11]
Résumé
-
Propriétés de la Page (2 modifications, 0 ajouts, 0 suppressions)
Détails
- Propriétés de la Page
-
- Auteur du document
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. superadmin1 +xwiki:XWiki.fcharton - Contenu
-
... ... @@ -38,6 +38,23 @@ 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 + 41 41 #set ($syntax = $services.rendering.resolveSyntax($syntaxId)) 42 42 #set ($macroDescriptors = $services.rendering.getMacroDescriptors($syntax)) 43 43 #if (!$macroDescriptors) ... ... @@ -56,16 +56,41 @@ 56 56 #set ($discard = $allMacrosExcludedCategories.add("#maybeTranslate('rendering.macroCategory.Internal' 'Internal')")) 57 57 #set ($discard = $allMacrosExcludedCategories.add("#maybeTranslate('rendering.macroCategory.Deprecated' 'Deprecated')")) 58 58 #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 59 59 #set ($macroList = []) 85 + #set ($installedMacros = []) 60 60 #foreach ($macroDescriptor in $macroDescriptors) 87 + #set ($discard = $installedMacros.add($macroDescriptor.id.id)) 88 + 61 61 #set ($macroTranslationKey = "rendering.macro.$macroDescriptor.id") 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 - })) 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 69 69 #end 70 70 #set ($macroList = $resolvedSortTool.sort($macroList, 'name')) 71 71 #set ($discard = $data.put('list', $macroList)) ... ... @@ -84,11 +84,13 @@ 84 84 #set ($macroExtensionsMap = {}) 85 85 #foreach ($extension in $extensions) 86 86 ## TODO: move to a proper generic API to check if an extension can be installed by a given user 87 - # if($services.security.authorization.hasAccess('programming')129 + #set ($extensionInstallAllowed = $services.security.authorization.hasAccess('programming', $xcontext.userReference, $NULL) 88 88 || (($extension.type == 'xar' || $extension.type == 'webjar') 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') 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)) 92 92 #set ($discard = $macroExtensionsList.add({ 93 93 'id' : { 94 94 'id' : $extensionComponent.roleHint ... ... @@ -96,12 +96,17 @@ 96 96 'name': $extensionComponent.roleHint, 97 97 'description': $extension.summary, 98 98 'defaultCategory': '_notinstalled', 143 + 'categories': [{ 144 + 'id' :'_notinstalled', 145 + 'label': $services.localization.render('macroSelector.filter.category.notinstalled') 146 + }], 99 99 'extensionId' : $extension.id.id, 100 100 'extensionVersion' : $extension.id.version.value, 101 101 'extensionType' : $extension.type, 102 102 'extensionRecommended': $extension.recommended, 103 103 'extensionName': $extension.name, 104 - 'extensionSummary': $extension.summary 152 + 'extensionSummary': $extension.summary, 153 + 'extensionInstallAllowed': $extensionInstallAllowed 105 105 })) 106 106 #end 107 107 #end