Modifications pour le document Macros de résultats Livetable
Modifié par Florent Charton le 2026/03/13 11:03
Depuis la version 1.1
modifié par superadmin
sur 2022/06/20 08:48
sur 2022/06/20 08:48
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-livetable-ui/13.10.6]
À la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:43
sur 2024/08/08 18:43
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-livetable-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
-
... ... @@ -35,7 +35,18 @@ 35 35 ## 36 36 #set($tablelist = []) 37 37 #foreach($colname in $collist) 38 - #livetable_addColumnToQuery($colname) 38 + ## If a classname is defined and the class field corresponding to the column name, 39 + ## we check the type of the field and skip it if it's Password. 40 + #if ($className != '' && $class.get($colname)) 41 + #set ($isPasswordType = $class.get($colname).classType == 'Password') 42 + #set ($isEmailType = $class.get($colname).classType == 'Email') 43 + #set ($emailObfuscated = $services.mail.general.shouldObfuscate()) 44 + #if (!($isPasswordType || ($isEmailType && $emailObfuscated))) 45 + #livetable_addColumnToQuery($colname) 46 + #end 47 + #else 48 + #livetable_addColumnToQuery($colname) 49 + #end 39 39 #end 40 40 ## 41 41 ## Tag filtering ... ... @@ -89,6 +89,8 @@ 89 89 #set($order = "$!request.sort") 90 90 #if ($order == 'doc.location') 91 91 #set ($order = 'doc.fullName') 103 + #elseif ($order == 'email' && $services.mail.general.shouldObfuscate()) 104 + #set ($order = '') 92 92 #end 93 93 #set ($orderSql = '') 94 94 #if($order != '') ... ... @@ -263,7 +263,13 @@ 263 263 ## 264 264 ## TagCloud matching all the documents used by the live table 265 265 ## 266 - #set($allMatchingTags = $xwiki.tag.getTagCountForQuery($allMatchingTagsFrom, $allMatchingTagsWhere, $allMatchingParams)) 279 + ## If all the query parameters are the same as for $tagsMatchingFilters, no need to run the query again. 280 + ## This optimization allows to divide the time to compute the tagcloud by 2 when the table has no filters applied. 281 + #if ($allMatchingTagsFrom.trim() != $tagsMatchingFiltersFrom.trim() || $allMatchingTagsWhere.trim() != $tagsMatchingFiltersWhere.trim() || $tagsMatchingParams != $allMatchingParams) 282 + #set($allMatchingTags = $xwiki.tag.getTagCountForQuery($allMatchingTagsFrom, $allMatchingTagsWhere, $allMatchingParams)) 283 + #else 284 + #set($allMatchingTags = $tagsMatchingFilters) 285 + #end 267 267 ## FIXME: We use a list of maps just because the client expects an array, but we should simply return $allMatchingTags.. 268 268 #set($tags = []) 269 269 #foreach($tag in $allMatchingTags.keySet()) ... ... @@ -298,7 +298,12 @@ 298 298 #set ($query = $query.setLimit($limit).setOffset($offset).bindValues($sqlParams)) 299 299 #set($items = $query.execute()) 300 300 #set($discard = $map.put('totalrows', $query.count())) 301 - #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit))) 320 + #if ($limit > 0) 321 + #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit))) 322 + #else 323 + ## When the limit is 0, it's equivalent to no limit at all and the actual number of returned results can be used. 324 + #set($discard = $map.put('returnedrows', $items.size())) 325 + #end 302 302 #set($discard = $map.put('offset', $mathtool.add($offset, 1))) 303 303 #set($rows = []) 304 304 #foreach($item in $items) ... ... @@ -377,7 +377,6 @@ 377 377 #set($discard = $itemDoc.use($className)) 378 378 #set($discard = $row.put('doc_objectCount', $itemDoc.getObjectNumbers($className))) 379 379 #set($discard = $row.put('doc_edit_url', $itemDoc.getURL($itemDoc.defaultEditMode))) 380 - #set($discard = $row.put('doc_author_url', $xwiki.getURL($translatedDoc.author))) 381 381 #set($discard = $row.put('doc_date', $xwiki.formatDate($translatedDoc.date))) 382 382 #set($discard = $row.put('doc_title', $translatedDoc.plainTitle)) 383 383 #set($rawTitle = $translatedDoc.title) ... ... @@ -384,7 +384,15 @@ 384 384 #if($rawTitle != $row['doc_title']) 385 385 #set($discard = $row.put('doc_title_raw', $rawTitle)) 386 386 #end 387 - #set($discard = $row.put('doc_author', $xwiki.getPlainUserName($translatedDoc.authorReference))) 410 + #set ($metadataAuthor = $translatedDoc.authors.originalMetadataAuthor) 411 + #if ($metadataAuthor == $services.user.getGuestUserReference()) 412 + ## Special handling for guest so that it displays unknown user. 413 + #set($discard = $row.put('doc_author', $xwiki.getPlainUserName($NULL))) 414 + #else 415 + #set($discard = $row.put('doc_author', $xwiki.getPlainUserName($metadataAuthor))) 416 + #end 417 + 418 + #set($discard = $row.put('doc_author_url', $xwiki.getURL($metadataAuthor))) 388 388 #set($discard = $row.put('doc_creationDate', $xwiki.formatDate($translatedDoc.creationDate))) 389 389 #set($discard = $row.put('doc_creator', $xwiki.getPlainUserName($translatedDoc.creatorReference))) 390 390 #set($discard = $row.put('doc_hidden', $translatedDoc.isHidden())) ... ... @@ -437,10 +437,12 @@ 437 437 #set($fieldProperty = $fieldObject.getProperty($colname)) 438 438 #if ($fieldProperty.getPropertyClass().classType == 'Password') 439 439 #set($fieldValue = '********') 471 + #elseif ($fieldProperty.getPropertyClass().classType == 'Email' && $services.mail.general.shouldObfuscate()) 472 + #set ($fieldValue = $services.mail.general.obfuscate("$!fieldProperty.getValue()")) 440 440 #else 441 441 #set($fieldValue = "$!fieldProperty.getValue()") 442 442 #end 443 - #set($fieldDisplayValue = "$ !itemDoc.display($colname, 'view')")476 + #set($fieldDisplayValue = "#unwrapXPropertyDisplay($itemDoc.display($colname, 'view'))") 444 444 #if($fieldDisplayValue == '') 445 445 #set($fieldDisplayValue = $services.localization.render("${request.transprefix}emptyvalue")) 446 446 #end ... ... @@ -452,7 +452,7 @@ 452 452 #set($fieldUrl = '') 453 453 #end 454 454 #end 455 - #set($discard = $row.put($colname, $fieldDisplayValue .replaceFirst($regextool.quote('{{html clean="false" wiki="false"}}'), '').replaceAll("$regextool.quote('{{/html}}')$", '')))488 + #set($discard = $row.put($colname, $fieldDisplayValue)) 456 456 #set($discard = $row.put("${colname}_value", $fieldValue)) 457 457 #set($discard = $row.put("${colname}_url", $fieldUrl)) 458 458 ## Reset to the default class