Modifications pour le document Macros de résultats Livetable

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

Depuis la version 4.1
modifié par Florent Charton
sur 2026/01/08 10:56
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-livetable-ui/17.4.8]
À la version 1.1
modifié par superadmin
sur 2022/06/20 08:48
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-livetable-ui/13.10.6]

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
... ... @@ -35,18 +35,7 @@
35 35   ##
36 36   #set($tablelist = [])
37 37   #foreach($colname in $collist)
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
38 + #livetable_addColumnToQuery($colname)
50 50   #end
51 51   ##
52 52   ## Tag filtering
... ... @@ -100,8 +100,6 @@
100 100   #set($order = "$!request.sort")
101 101   #if ($order == 'doc.location')
102 102   #set ($order = 'doc.fullName')
103 - #elseif ($order == 'email' && $services.mail.general.shouldObfuscate())
104 - #set ($order = '')
105 105   #end
106 106   #set ($orderSql = '')
107 107   #if($order != '')
... ... @@ -276,13 +276,7 @@
276 276   ##
277 277   ## TagCloud matching all the documents used by the live table
278 278   ##
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
266 + #set($allMatchingTags = $xwiki.tag.getTagCountForQuery($allMatchingTagsFrom, $allMatchingTagsWhere, $allMatchingParams))
286 286   ## FIXME: We use a list of maps just because the client expects an array, but we should simply return $allMatchingTags..
287 287   #set($tags = [])
288 288   #foreach($tag in $allMatchingTags.keySet())
... ... @@ -305,7 +305,10 @@
305 305   #if(!$offset || $offset < 0)
306 306   #set($offset = 0)
307 307   #end
308 - #getAndValidateQueryLimitFromRequest('limit', 15, $limit)
289 + #set($limit = $numbertool.toNumber($request.get('limit')).intValue())
290 + #if(!$limit)
291 + #set ($limit = 15)
292 + #end
309 309   #set($query = $services.query.hql($sql))
310 310   ## Apply query filters if defined. Otherwise use default.
311 311   #foreach ($queryFilter in $stringtool.split($!request.queryFilters, ', '))
... ... @@ -314,12 +314,7 @@
314 314   #set ($query = $query.setLimit($limit).setOffset($offset).bindValues($sqlParams))
315 315   #set($items = $query.execute())
316 316   #set($discard = $map.put('totalrows', $query.count()))
317 - #if ($limit > 0)
318 - #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit)))
319 - #else
320 - ## When the limit is 0, it's equivalent to no limit at all and the actual number of returned results can be used.
321 - #set($discard = $map.put('returnedrows', $items.size()))
322 - #end
301 + #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit)))
323 323   #set($discard = $map.put('offset', $mathtool.add($offset, 1)))
324 324   #set($rows = [])
325 325   #foreach($item in $items)
... ... @@ -398,6 +398,7 @@
398 398   #set($discard = $itemDoc.use($className))
399 399   #set($discard = $row.put('doc_objectCount', $itemDoc.getObjectNumbers($className)))
400 400   #set($discard = $row.put('doc_edit_url', $itemDoc.getURL($itemDoc.defaultEditMode)))
380 + #set($discard = $row.put('doc_author_url', $xwiki.getURL($translatedDoc.author)))
401 401   #set($discard = $row.put('doc_date', $xwiki.formatDate($translatedDoc.date)))
402 402   #set($discard = $row.put('doc_title', $translatedDoc.plainTitle))
403 403   #set($rawTitle = $translatedDoc.title)
... ... @@ -404,15 +404,7 @@
404 404   #if($rawTitle != $row['doc_title'])
405 405   #set($discard = $row.put('doc_title_raw', $rawTitle))
406 406   #end
407 - #set ($metadataAuthor = $translatedDoc.authors.originalMetadataAuthor)
408 - #if ($metadataAuthor == $services.user.getGuestUserReference())
409 - ## Special handling for guest so that it displays unknown user.
410 - #set($discard = $row.put('doc_author', $xwiki.getPlainUserName($NULL)))
411 - #else
412 - #set($discard = $row.put('doc_author', $xwiki.getPlainUserName($metadataAuthor)))
413 - #end
414 -
415 - #set($discard = $row.put('doc_author_url', $xwiki.getURL($metadataAuthor)))
387 + #set($discard = $row.put('doc_author', $xwiki.getPlainUserName($translatedDoc.authorReference)))
416 416   #set($discard = $row.put('doc_creationDate', $xwiki.formatDate($translatedDoc.creationDate)))
417 417   #set($discard = $row.put('doc_creator', $xwiki.getPlainUserName($translatedDoc.creatorReference)))
418 418   #set($discard = $row.put('doc_hidden', $translatedDoc.isHidden()))
... ... @@ -465,12 +465,10 @@
465 465   #set($fieldProperty = $fieldObject.getProperty($colname))
466 466   #if ($fieldProperty.getPropertyClass().classType == 'Password')
467 467   #set($fieldValue = '********')
468 - #elseif ($fieldProperty.getPropertyClass().classType == 'Email' && $services.mail.general.shouldObfuscate())
469 - #set ($fieldValue = $services.mail.general.obfuscate("$!fieldProperty.getValue()"))
470 470   #else
471 471   #set($fieldValue = "$!fieldProperty.getValue()")
472 472   #end
473 - #set($fieldDisplayValue = "#unwrapXPropertyDisplay($itemDoc.display($colname, 'view'))")
443 + #set($fieldDisplayValue = "$!itemDoc.display($colname, 'view')")
474 474   #if($fieldDisplayValue == '')
475 475   #set($fieldDisplayValue = $services.localization.render("${request.transprefix}emptyvalue"))
476 476   #end
... ... @@ -482,7 +482,7 @@
482 482   #set($fieldUrl = '')
483 483   #end
484 484   #end
485 - #set($discard = $row.put($colname, $fieldDisplayValue))
455 + #set($discard = $row.put($colname, $fieldDisplayValue.replaceFirst($regextool.quote('{{html clean="false" wiki="false"}}'), '').replaceAll("$regextool.quote('{{/html}}')$", '')))
486 486   #set($discard = $row.put("${colname}_value", $fieldValue))
487 487   #set($discard = $row.put("${colname}_url", $fieldUrl))
488 488   ## Reset to the default class
... ... @@ -503,9 +503,7 @@
503 503   #set($discard = $map.put('params', $sqlParams))
504 504   #end
505 505   #set($discard = $map.put('reqNo', $numbertool.toNumber($request.reqNo).intValue()))
506 - #if("$!request.tagcloud" == 'true')
507 - #gridresult_buildTagCloudJSON($map)
508 - #end
476 + #gridresult_buildTagCloudJSON($map)
509 509   #gridresult_buildRowsJSON($map)
510 510  #end
511 511  
... ... @@ -559,10 +559,8 @@
559 559   #elseif($propType == 'TextAreaClass' || $propType == 'UsersClass' || $propType == 'GroupsClass')
560 560   #set($tableName = 'LargeStringProperty')
561 561   #elseif($propType == 'StaticListClass' || $propType == 'DBListClass' || $propType == 'DBTreeListClass' || $propType == 'PageClass')
562 - ## The following logic is mirrored from ListClass and might need to be updated when the logic in ListClass changes.
563 563   #set($multiSelect = $propClass.get($colname).getProperty('multiSelect').getValue())
564 564   #set($relationalStorage = $propClass.get($colname).getProperty('relationalStorage').getValue())
565 - #set($largeStorage = $propClass.get($colname).getProperty('largeStorage').getValue())
566 566   #if($multiSelect == 1)
567 567   #if($relationalStorage == 1)
568 568   #set($tableName = 'DBStringListProperty')
... ... @@ -569,8 +569,6 @@
569 569   #else
570 570   #set($tableName = 'StringListProperty')
571 571   #end
572 - #elseif($largeStorage == 1)
573 - #set($tableName = 'LargeStringProperty')
574 574   #else
575 575   #set($tableName = 'StringProperty')
576 576   #end