# Исходный код вики Доступные макросы

Редактировал(а) Alexandr Fokin 2025/09/20 12:18

Последние авторы

author | version | line-number | content
--- | --- | --- | ---
|  | 1 | {{velocity}}
|  | 2 | ## If the translation key exists, use its value, otherwise use to the provided fallback value.
|  | 3 | #macro (translateOrElse $translationKey $fallback)
|  | 4 | #if($services.localization.get($translationKey))
|  | 5 | $services.rendering.escape($services.localization.render($translationKey), 'xwiki/2.1')##
|  | 6 | #else
|  | 7 | $services.rendering.escape($fallback, 'xwiki/2.1')##
|  | 8 | #end
|  | 9 | #end
|  | 10 |
|  | 11 | ## Find all wiki macros sp that we can find if a registered macro is a wiki macro
|  | 12 | #set ($wikiMacroDocuments = $services.query.xwql("from doc.object(XWiki.WikiMacroClass) as macros").execute())
|  | 13 | #set ($wikiMacroMap = {})
|  | 14 | #foreach($macroDocumentName in $wikiMacroDocuments)
|  | 15 | #set ($macroDocument = $xwiki.getDocument($macroDocumentName))
|  | 16 | #set ($macroObject = $macroDocument.getObject("XWiki.WikiMacroClass"))
|  | 17 | #set ($discard = $wikiMacroMap.put($macroObject.id, [$macroDocument.documentReference.toString(), $macroObject.visibility]))
|  | 18 | #end
|  | 19 | |={{translation key='help.macroList.id'/}}|={{translation key='help.macroList.name'/}}|={{translation key='help.macroList.categories'/}}|={{translation key='help.macroList.description'/}}|={{translation key='help.macroList.visibility'/}}
|  | 20 | #foreach ($descriptor in $collectiontool.sort($services.rendering.getMacroDescriptors('xwiki/2.1'), 'id.id:asc'))
|  | 21 | #set ($wikiMacroData = $wikiMacroMap.get($descriptor.id.id))
|  | 22 | #if ("$!wikiMacroData" != '')
|  | 23 | #set ($displayId = "[[$services.rendering.escape($services.rendering.escape($descriptor.id, 'xwiki/2.1'), 'xwiki/2.1')>>$wikiMacroData.get(0)]]")
|  | 24 | #set ($displayVisibility = $wikiMacroData.get(1))
|  | 25 | #else
|  | 26 | #set ($displayId = $services.rendering.escape($descriptor.id, 'xwiki/2.1'))
|  | 27 | #set ($displayVisibility = $services.localization.render('XWiki.WikiMacroClass_visibility_Global'))
|  | 28 | #end
|  | 29 | |$displayId|##
|  | 30 | #translateOrElse("rendering.macro.${descriptor.id.id}.name", $descriptor.name)
|  | 31 | |##
|  | 32 | #foreach($category in $services.rendering.getMacroCategories($descriptor.id))
|  | 33 | #if($foreach.index>0), #end##
|  | 34 | #translateOrElse("rendering.macroCategory.$category", $category)
|  | 35 | #end##
|  | 36 | |##
|  | 37 | #translateOrElse("rendering.macro.${descriptor.id.id}.description", $descriptor.description)
|  | 38 | |$services.rendering.escape($displayVisibility, 'xwiki/2.1')
|  | 39 | #end
|  | 40 | {{/velocity}}

## Приложения