Изменения документа Document Tree Macros

Редактировал(а) Давид Гавриков 2024/10/22 15:18

От версии 5.1
отредактировано Давид Гавриков
на 2024/10/22 15:18
Изменить комментарий: Install extension [org.xwiki.platform:xwiki-platform-index-tree-macro/16.8.0]
К версии 2.1
отредактировано Андрей Ганьков
на 2022/08/01 10:37
Изменить комментарий: Install extension [org.xwiki.platform:xwiki-platform-index-tree-macro/14.6]

Сводка

Подробности

Свойства страницы
Автор документа
... ... @@ -1,1 +1,1 @@
1 -XWiki.gavrikof
1 +XWiki.gav
Содержимое
... ... @@ -76,11 +76,7 @@
76 76  #macro (handleDocumentTreeRequest)
77 77   #if ($request.action)
78 78   #if ($services.csrf.isTokenValid($request.form_token))
79 - #if ($request.action == 'create' && $request.type == 'addDocument')
80 - #handleNewNodeCreationRequest()
81 - #else
82 - $response.sendError(400, 'The specified action is not supported.')
83 - #end
79 + $response.sendError(400, 'The specified action is not supported.')
84 84   #elseif ($isAjaxRequest)
85 85   $response.sendError(403, 'The CSRF token is missing.')
86 86   #else
... ... @@ -106,22 +106,6 @@
106 106   #end
107 107  #end
108 108  
109 -#macro (handleNewNodeCreationRequest)
110 - #set ($cleanId = $stringtool.substring($request.id, $stringtool.length('document:')))
111 - #set ($parentReference = $services.model.resolveDocument($cleanId))
112 - #set ($requestedName = $request.name)
113 - #set ($transformedName = $services.modelvalidation.transformName($requestedName))
114 - #set ($spaceReference = $services.model.createSpaceReference($transformedName, $parentReference.lastSpaceReference))
115 - #set ($documentReference = $services.model.createDocumentReference('WebHome', $spaceReference))
116 - #set ($data = [])
117 - #addDocumentNode($documentReference, $data)
118 - ## We want to allow opening the node to add another hierarchy.
119 - #set ($data[0].children = true)
120 - ## We want to display the actual requested name as node name.
121 - #set ($data[0].text = $requestedName)
122 - #jsonResponse($data)
123 -#end
124 -
125 125  #macro (postProcessDocumentTreeData $data)
126 126   ## This is just a hook to allow post processing the document tree data.
127 127  #end
... ... @@ -336,6 +336,10 @@
336 336   #if ($canViewDoc && $docTreeConfig.showDocumentTitle)
337 337   ## Display the translated title.
338 338   #set ($translatedDocument = $xwiki.getDocument($documentReference).translatedDocument)
319 + ## Make sure the displayed title is not affected by the sheet request parameter (e.g. when $translatedDocument is
320 + ## the current document). By setting the title (even if we don't change it) the internal document instance is cloned
321 + ## so it's going to be different than the current document instance (which is the target of the sheet parameter).
322 + #set ($discard = $translatedDocument.setTitle($translatedDocument.title))
339 339   #set ($plainTitle = $translatedDocument.plainTitle)
340 340   #if (!$stringtool.isBlank($plainTitle))
341 341   #set ($label = $plainTitle)
... ... @@ -372,18 +372,14 @@
372 372  #end
373 373  
374 374  #macro (addAddDocumentNode $documentReference $siblings)
375 - ## FIXME: This URL is wrong, it should use the $documentReference as the parent for creation of the node:
376 - ## the reference is already an existing doc, so it shouldn't be the one used for creation.
377 377   #set ($discard = $siblings.add({
378 378   'id': "addDocument:$services.model.serialize($documentReference, 'default')",
379 - 'text': $services.localization.render('index.documentTree.addDocument'),
361 + 'text': 'New page...',
380 380   'icon': 'fa fa-plus-circle',
381 381   'children': false,
382 382   'data': {
383 383   'type': 'addDocument',
384 - 'validChildren': [],
385 - 'hasContextMenu': true,
386 - 'canRename': true
366 + 'validChildren': []
387 387   },
388 388   'a_attr': {
389 389   'href': $xwiki.getURL($documentReference, 'create')
... ... @@ -1146,7 +1146,6 @@
1146 1146  #macro (searchAttachmentsSolr $text $limit $return)
1147 1147   #set ($params = [
1148 1148   'fq=type:ATTACHMENT',
1149 - 'fq=locale:*',
1150 1150   'qf=filename^4 attcontent',
1151 1151   'fl=type wiki spaces name filename'
1152 1152   ])