Code source wiki de Macros de résultats Livetable
Modifié par Admin le 24/03/2023 - 15:51
Masquer les derniers auteurs
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{include reference="XWiki.LiveTableResultsMacros" /}} |
2 | |||
3 | {{velocity output="false"}} | ||
4 | #* | ||
5 | * We override the following macro from XWiki.LiveTableResultsMacros to: | ||
6 | * - disable the filter on XWikiServerTemplate (revert when https://jira.xwiki.org/browse/XWIKI-10010 is fixed) | ||
7 | * - put order by value in MAX() function and GROUP BY (revert when https://jira.xwiki.org/browse/XWIKI-15595 is fixed) | ||
8 | *# | ||
9 | #macro(gridresultwithfilter_buildQuery $className $collist $filterfrom $filterwhere $filterParams) | ||
10 | ## Additional columns, should *not* contain parameters, all added column names must be filtered | ||
11 | #set($fromSql = '') | ||
12 | ## parametrized filter part of the query | ||
13 | #set($whereSql = '') | ||
14 | ## list of parameters to use with $whereSql | ||
15 | #set($whereParams = {}) | ||
16 | #set($class = $xwiki.getDocument($className).getxWikiClass()) | ||
17 | ## | ||
18 | ## Add the columns needed for the actual data | ||
19 | ## | ||
20 | #set($tablelist = []) | ||
21 | #foreach($colname in $collist) | ||
22 | ## If a classname is defined and the class field corresponding to the column name, | ||
23 | ## we check the type of the field and skip it if it's Password. | ||
24 | #if ($className != '' && $class.get($colname)) | ||
25 | #if ($class.get($colname).classType != 'Password') | ||
26 | #livetable_addColumnToQuery($colname) | ||
27 | #end | ||
28 | #else | ||
29 | #livetable_addColumnToQuery($colname) | ||
30 | #end | ||
31 | #end | ||
32 | ## | ||
33 | ## Tag filtering | ||
34 | ## | ||
35 | #if($request.tag) | ||
36 | #set($fromSql = "${fromSql} , BaseObject as tobject, DBStringListProperty as tagprop") | ||
37 | #set($whereSql = "${whereSql} and tobject.className='XWiki.TagClass' and tobject.name=doc.fullName and tobject.id=tagprop.id.id and tagprop.id.name='tags' and (") | ||
38 | #foreach($tag in $request.getParameterValues('tag')) | ||
39 | #if($foreach.count > 1) #set($whereSql = "${whereSql} and ") #end | ||
40 | ## Tags are case insensitive but they are stored unchanged which means we have to normalize them when performing | ||
41 | ## a query. Unfortunately there's no simple way to match multiple tags (AND operator). If we join the list of | ||
42 | ## tags in the FROM clause then we match at least one of the tags (OR operator). The only remaining option is to | ||
43 | ## check that the list of tags contains each of the desired tags. HQL doesn't help us to lower-case the entire | ||
44 | ## list of tags so we use an inner select for this. | ||
45 | #set($whereSql = "${whereSql} lower(:wikitag${foreach.count}) in (select lower(tag) from tagprop.list tag)") | ||
46 | #set($discard = $whereParams.put("wikitag$foreach.count", "${tag}")) | ||
47 | #end | ||
48 | #set($whereSql = "${whereSql})") | ||
49 | #end | ||
50 | ## | ||
51 | ## | ||
52 | ## Order | ||
53 | ## | ||
54 | #set($order = "$!request.sort") | ||
55 | #if($order != '') | ||
56 | #set($orderDirection = "$!{request.get('dir').toLowerCase()}") | ||
57 | #if("$!orderDirection" != '' && "$!orderDirection" != 'asc') | ||
58 | #set($orderDirection = 'desc') | ||
59 | #end | ||
60 | #if($order == 'description') | ||
61 | #set($tableAlias = 'dtable') | ||
62 | #else | ||
63 | #set($tableAlias = $order) | ||
64 | #end | ||
65 | ## only safe version should be used in SQL queries | ||
66 | #livetable_getTableAlias($tableAlias) | ||
67 | ## | ||
68 | #if($order.startsWith('doc.')) | ||
69 | #if ($order == "doc.fullName") | ||
70 | #set($orderSql = " order by ${safe_tableAlias.replace('_','.')} ${orderDirection}") | ||
71 | #else | ||
72 | #set($orderSql = " order by MAX(${safe_tableAlias.replace('_','.')}) ${orderDirection}") | ||
73 | #end | ||
74 | #elseif($tablelist.contains($tableAlias)) | ||
75 | #set ($multiselect = "$!{class.get($order).getProperty('multiSelect').getValue()}") | ||
76 | #if ($multiselect != '1') | ||
77 | #set ($orderSql = " order by MAX(${safe_tableAlias}.value) ${orderDirection}") | ||
78 | #end | ||
79 | #elseif($order == 'averagevote') | ||
80 | #livetable_getTableName($order) | ||
81 | #set($fromSql = "${fromSql}, BaseObject as objratings, ${tableName} ${safe_tableAlias}") | ||
82 | #set($whereSql = "${whereSql} and doc.fullName=objratings.name and objratings.className='XWiki.AverageRatingsClass' and objratings.id=${safe_tableAlias}.id.id and ${safe_tableAlias}.name = :wikiorder") | ||
83 | #set($discard = $whereParams.put('wikorder', "${order}")) | ||
84 | #set($orderSql = " order by MAX(${safe_tableAlias}.value) ${orderDirection}") | ||
85 | #else | ||
86 | #set($multiselect = $class.get($order).getProperty('multiSelect').getValue()) | ||
87 | #if("$multiselect" != '1') | ||
88 | #livetable_getTableName($order) | ||
89 | #set($fromSql = "${fromSql}, ${tableName} ${safe_tableAlias}") | ||
90 | #set($whereSql = "${whereSql} and obj.id=${safe_tableAlias}.id.id and ${safe_tableAlias}.name = :wikiorder") | ||
91 | #set($discard = $whereParams.put('wikiorder', "${order}")) | ||
92 | #set($orderSql = " order by MAX(${safe_tableAlias}.value) ${orderDirection}") | ||
93 | #end | ||
94 | #end | ||
95 | #end | ||
96 | ## | ||
97 | ## | ||
98 | ## Compute the final queries | ||
99 | ## | ||
100 | #set($sqlParams = {}) | ||
101 | #set($tagsMatchingParams = {}) | ||
102 | #set($allMatchingParams = {}) | ||
103 | #if("$!className" != '') | ||
104 | ## Class query | ||
105 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
106 | #set($countSql = ", BaseObject as obj $!fromSql $!filterfrom where obj.name=doc.fullName and obj.className = :className and doc.fullName <> :classTemplate $!whereSql $!filterwhere") | ||
107 | #set($discard = $sqlParams.put('className', "${className}")) | ||
108 | #set($discard = $sqlParams.put('classTemplate', "${className}Template")) | ||
109 | #set($discard = $sqlParams.putAll($whereParams)) | ||
110 | ## | ||
111 | #set($tagsMatchingFiltersFrom = ", BaseObject as obj $!fromSql $!filterfrom") | ||
112 | #set($tagsMatchingFiltersWhere = "obj.name=doc.fullName and obj.className = :tagsClassName and doc.fullName <> :tagsClassTemplate $!whereSql $!filterwhere") | ||
113 | #set($discard = $tagsMatchingParams.put('tagsClassName', "${className}")) | ||
114 | #set($discard = $tagsMatchingParams.put('tagsClassTemplate', "${className}Template")) | ||
115 | #set($discard = $tagsMatchingParams.putAll($whereParams)) | ||
116 | ## | ||
117 | #set($allMatchingTagsFrom = ", BaseObject as obj $!filterfrom") | ||
118 | #set($allMatchingTagsWhere = "obj.name=doc.fullName and obj.className = :allClassName and doc.fullName <> :allClassTemplate $!filterwhere") | ||
119 | #set($discard = $allMatchingParams.put('allClassName', "${className}")) | ||
120 | #set($discard = $allMatchingParams.put('allClassTemplate', "${className}Template")) | ||
121 | ################################################# | ||
122 | ## | ||
123 | #if($filterParams) | ||
124 | #set($discard = $sqlParams.putAll($filterParams)) | ||
125 | #set($discard = $tagsMatchingParams.putAll($filterParams)) | ||
126 | #set($discard = $allMatchingParams.putAll($filterParams)) | ||
127 | #end | ||
128 | #else | ||
129 | ## Document query | ||
130 | #set($countSql = "$!fromSql $!filterfrom where 1=1 $!whereSql $!filterwhere") | ||
131 | #set($discard = $sqlParams.putAll($whereParams)) | ||
132 | ## | ||
133 | #set($tagsMatchingFiltersFrom = "$!fromSql $!filterfrom") | ||
134 | #set($tagsMatchingFiltersWhere = "1=1 $!whereSql $!filterwhere") | ||
135 | #set($discard = $tagsMatchingParams.putAll($whereParams)) | ||
136 | ## | ||
137 | #set($allMatchingTagsFrom = "$!filterfrom") | ||
138 | #set($allMatchingTagsWhere = "1=1 $!filterwhere") | ||
139 | ## | ||
140 | #if($filterParams) | ||
141 | #set($discard = $sqlParams.putAll($filterParams)) | ||
142 | #set($discard = $tagsMatchingParams.putAll($filterParams)) | ||
143 | #set($discard = $allMatchingParams.putAll($filterParams)) | ||
144 | #end | ||
145 | #end | ||
146 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
147 | ## Group by doc.fullName if needed | ||
148 | #if ($orderSql && $orderSql.contains('order by MAX(')) | ||
149 | #set($orderSql = "GROUP BY doc.fullName $orderSql") | ||
150 | #end | ||
151 | ################################################# | ||
152 | #set($sql = "$countSql $!{orderSql}") | ||
153 | #end | ||
154 | #* | ||
155 | * We override the following macro from XWiki.LiveTableResultsMacros to disable the filter on hidden documents and to display wiki ui properties with a custom code | ||
156 | *# | ||
157 | #macro(gridresult_buildRowsJSON $map) | ||
158 | #set($offset = $numbertool.toNumber($request.get('offset')).intValue()) | ||
159 | ## offset starts from 0 in velocity and 1 in javascript | ||
160 | #set($offset = $offset - 1) | ||
161 | #if (!$offset || $offset < 0) | ||
162 | #set($offset = 0) | ||
163 | #end | ||
164 | #set($limit = $numbertool.toNumber($request.get('limit')).intValue()) | ||
165 | #if (!$limit) | ||
166 | #set ($limit = 15) | ||
167 | #end | ||
168 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
169 | ## The descriptors are always hidden, so we don't filter on the hidden column. | ||
170 | #set($query = $services.query.hql($sql).addFilter('currentlanguage').setLimit($limit).setOffset($offset).bindValues($sqlParams)) | ||
171 | #set($items = $query.execute()) | ||
172 | #if ($sql.contains('GROUP BY doc.fullName')) | ||
173 | ## The group by we have to use to make sure we get unique documents break $query.count so we remove it | ||
174 | #set($countQuery = $services.query.hql($sql.replace('GROUP BY doc.fullName', '')).addFilter('unique')) | ||
175 | #set($void = $countQuery.setWiki($query.wiki)) | ||
176 | #set($void = $countQuery.bindValues($query.namedParameters)) | ||
177 | #else | ||
178 | $countQuery = $query | ||
179 | #end | ||
180 | #set($discard = $map.put('totalrows', $countQuery.count())) | ||
181 | ################################################# | ||
182 | #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit))) | ||
183 | #set($discard = $map.put('offset', $mathtool.add($offset, 1))) | ||
184 | #set($rows = []) | ||
185 | #foreach($item in $items) | ||
186 | #gridresult_buildRowJSON($item $rows) | ||
187 | #end | ||
188 | #set($discard = $map.put('rows', $rows)) | ||
189 | #end | ||
190 | #* | ||
191 | * We override the following macro from XWiki.LiveTableResultsMacros to add custom actions (join, leave, etc...) | ||
192 | * and to display the membershipType. | ||
193 | *# | ||
194 | #macro(gridresult_buildRowJSON $item $rows) | ||
195 | ## Handle both the case where the "language" filter is used and thus languages are returned too and the case where | ||
196 | ## only the document name is returned. When more than the document name is returned the $item variable is a list. | ||
197 | #if ($item.size()) | ||
198 | ## Extract doc name and doc language from $item | ||
199 | #set($docName = $item[0]) | ||
200 | #set($docLanguage = $item[1]) | ||
201 | #else | ||
202 | #set($docName = $item) | ||
203 | #set($docLanguage = '') | ||
204 | #end | ||
205 | #set($viewable = $xwiki.hasAccessLevel('view', $xcontext.user, "${xcontext.database}:${docName}")) | ||
206 | #set($row = {'doc_viewable': $viewable}) | ||
207 | #if(!$viewable) | ||
208 | #set($discard = $row.put('doc_fullName', "${xcontext.database}:${item}")) | ||
209 | #else | ||
210 | #set($itemDoc = $xwiki.getDocument($docName)) | ||
211 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
212 | ## Some constants which are usefull while processing each item. | ||
213 | #set ($currentUser = $services.model.serialize($xcontext.userReference, 'default')) | ||
214 | #set ($deleteWikiDocumentReference = $services.model.createDocumentReference('', 'WikiManager', 'DeleteWiki')) | ||
215 | #set ($joinWikiDocumentReference = $services.model.createDocumentReference('', 'WikiManager', 'JoinWiki')) | ||
216 | #set ($leaveWikiDocumentReference = $services.model.createDocumentReference('', 'WikiManager', 'LeaveWiki')) | ||
217 | #set ($wikiId = $docName.toLowerCase().replaceAll("xwiki.xwikiserver", "")) | ||
218 | #set ($wiki = $services.wiki.getById($wikiId)) | ||
219 | ## Init membership actions as denied. | ||
220 | #set ($itemMembershipType = $services.wiki.user.getMembershipType($wiki.id)) | ||
221 | #set ($itemUserScope = $services.wiki.user.getUserScope($wiki.id)) | ||
222 | #set ($itemHasJoin = false) | ||
223 | #set ($itemHasRequestJoin = false) | ||
224 | #set ($itemHasCancelJoinRequest = false) | ||
225 | #set ($itemHasViewInvitation = false) | ||
226 | #set ($itemHasLeave = false) | ||
227 | ## Determine if current user is already a member. | ||
228 | #set ($currentUserIsMember = ($services.wiki.user.isMember($currentUser, $wiki.id) || $currentUser == $wiki.ownerId)) | ||
229 | ## Determine available membership action and action URL. | ||
230 | #if ($currentUserIsMember) | ||
231 | ## Don't allow the owner to leave the workspace. | ||
232 | #if ($wiki.ownerId != $currentUser) | ||
233 | #set ($itemHasLeave = true) | ||
234 | #set ($leaveUrl = $xwiki.getURL($leaveWikiDocumentReference, 'view', "wikiId=${wikiId}")) | ||
235 | #end | ||
236 | #elseif($itemUserScope != 'LOCAL_ONLY') | ||
237 | ## | ||
238 | ## Determine if, regardless of membership type, an existing invitation exists for the | ||
239 | #set ($invitations = $services.wiki.user.getAllInvitations($wikiId)) | ||
240 | #set ($existingInvitation = false) | ||
241 | #if ($invitations && !$invitations.isEmpty()) | ||
242 | #foreach($invitation in $invitations) | ||
243 | #if ($invitation.userId == $currentUser && $invitation.status == 'PENDING') | ||
244 | #set ($existingInvitation = $invitation) | ||
245 | #end | ||
246 | #end | ||
247 | #end | ||
248 | #if ($existingInvitation) | ||
249 | #set ($itemHasViewInvitation = true) | ||
250 | #set ($viewInvitationUrl = $xwiki.getURL($joinWikiDocumentReference, 'view', "wikiId=${wikiId}")) | ||
251 | #elseif ($itemMembershipType == 'OPEN') | ||
252 | #set ($itemHasJoin = true) | ||
253 | #set ($joinUrl = $xwiki.getURL($joinWikiDocumentReference, 'view', "wikiId=${wikiId}")) | ||
254 | #elseif ($itemMembershipType == 'REQUEST') | ||
255 | ## Determine if a request was already sent. | ||
256 | #set ($pendingRequest = false) | ||
257 | #set ($existingRequests = $services.wiki.user.getAllRequests($wikiId)) | ||
258 | #foreach ($existingRequest in $existingRequests) | ||
259 | #if ($existingRequest.userId == $currentUser && $existingRequest.status == 'PENDING') | ||
260 | #set ($pendingRequest = true) | ||
261 | #end | ||
262 | #end | ||
263 | #if ($pendingRequest) | ||
264 | #set ($itemHasCancelJoinRequest = true) | ||
265 | #set ($cancelJoinRequestUrl = $xwiki.getURL($joinWikiDocumentReference, 'view', "wikiId=${wikiId}&cancelJoinRequest=1")) | ||
266 | #else | ||
267 | #set ($itemHasRequestJoin = true) | ||
268 | #set ($requestJoinUrl = $xwiki.getURL($joinWikiDocumentReference, 'view', "wikiId=${wikiId}&requestJoin=1")) | ||
269 | #end | ||
270 | #end | ||
271 | #end | ||
272 | ################################################# | ||
273 | ## Handle translations. We need to make sure we display the data associated to the correct document if the returned | ||
274 | ## result is a translation. | ||
275 | #if ("$!docLanguage" != "" && $xwiki.getLanguagePreference() != $docLanguage) | ||
276 | #set($translatedDoc = $itemDoc.getTranslatedDocument($docLanguage)) | ||
277 | #set($isTranslation = true) | ||
278 | #else | ||
279 | #set($translatedDoc = $itemDoc) | ||
280 | #set($isTranslation = false) | ||
281 | #end | ||
282 | #set($fullname = $services.model.serialize($itemDoc.documentReference, 'default')) | ||
283 | #set($discard = $itemDoc.use($className)) | ||
284 | #if ($isTranslation) | ||
285 | ## Display the language after the document name so that not all translated documents have the same name displayed | ||
286 | #set($discard = $row.put('doc_name', "$itemDoc.documentReference.name ($docLanguage)")) | ||
287 | #else | ||
288 | #set($discard = $row.put('doc_name', $itemDoc.documentReference.name)) | ||
289 | #end | ||
290 | #set($discard = $row.put('doc_fullName', $fullname)) | ||
291 | #set($discard = $row.put('doc_space', $itemDoc.space)) | ||
292 | #set($discard = $row.put('doc_url', $xwiki.getURL($docName))) | ||
293 | #set($discard = $row.put('doc_space_url', $xwiki.getURL($services.model.createDocumentReference($!itemDoc.wiki, $!itemDoc.space, 'WebHome')))) | ||
294 | #set($discard = $row.put('doc_wiki', $itemDoc.wiki)) | ||
295 | #set($discard = $row.put('doc_wiki_url', $xwiki.getURL($services.model.resolveDocument('', 'default', $itemDoc.documentReference.extractReference('WIKI'))))) | ||
296 | #set($discard = $row.put('doc_hasadmin', $xwiki.hasAdminRights())) | ||
297 | #set($discard = $row.put('doc_hasedit', $xwiki.hasAccessLevel('edit', $xcontext.user, $fullname))) | ||
298 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
299 | #set($discard = $row.put('doc_hasdelete', $services.wiki.canDeleteWiki($currentUser, $wikiId))) | ||
300 | ################################################# | ||
301 | #set($discard = $row.put('doc_copy_url', $itemDoc.getURL('view', 'xpage=copy'))) | ||
302 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
303 | #set($deleteUrl = $xwiki.getURL($deleteWikiDocumentReference, 'view', "wikiId=${wikiId}")) | ||
304 | #set($discard = $row.put('doc_delete_url', $deleteUrl)) | ||
305 | #set($discard = $row.put('doc_edit_url', $itemDoc.getURL('view'))) | ||
306 | ################################################# | ||
307 | #set($discard = $row.put('doc_rename_url', $itemDoc.getURL('view', 'xpage=rename&step=1'))) | ||
308 | #set($discard = $row.put('doc_rights_url', $itemDoc.getURL('edit', 'editor=rights'))) | ||
309 | #set($discard = $row.put('doc_author_url', $xwiki.getURL($translatedDoc.author))) | ||
310 | #set($discard = $row.put('doc_date', $xwiki.formatDate($translatedDoc.date))) | ||
311 | #set($discard = $row.put('doc_title', $translatedDoc.plainTitle)) | ||
312 | #set($discard = $row.put('doc_author', $xwiki.getLocalUserName($translatedDoc.author, false))) | ||
313 | #set($discard = $row.put('doc_creationDate', $xwiki.formatDate($translatedDoc.creationDate))) | ||
314 | #set($discard = $row.put('doc_creator', $xwiki.getLocalUserName($translatedDoc.creator, false))) | ||
315 | #foreach($colname in $collist) | ||
316 | #gridresult_buildColumnJSON($colname $row) | ||
317 | #end | ||
318 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
319 | #if($itemUserScope == 'LOCAL_ONLY' || $wikiId == $services.wiki.mainWikiId) | ||
320 | #set($discard = $row.put('membershipType', $services.localization.render("platform.wiki.browse.emptyvalue"))) | ||
321 | #else | ||
322 | #set($discard = $row.put('membershipType', $services.localization.render("WikiManager.WikiUserClass_membershipType_${itemMembershipType.name().toLowerCase()}"))) | ||
323 | #end | ||
324 | #set($discard = $row.put('doc_hasjoin', $itemHasJoin)) | ||
325 | #set($discard = $row.put('doc_hasrequestJoin', $itemHasRequestJoin)) | ||
326 | #set($discard = $row.put('doc_hasviewInvitation', $itemHasViewInvitation)) | ||
327 | #set($discard = $row.put('doc_hascancelJoinRequest', $itemHasCancelJoinRequest)) | ||
328 | #set($discard = $row.put('doc_hasleave', $itemHasLeave)) | ||
329 | #if ($itemHasJoin) | ||
330 | #set($discard = $row.put('doc_join_url', $joinUrl)) | ||
331 | #elseif ($itemHasLeave) | ||
332 | #set($discard = $row.put('doc_leave_url', $leaveUrl)) | ||
333 | #elseif ($itemHasRequestJoin) | ||
334 | #set($discard = $row.put('doc_requestJoin_url', $requestJoinUrl)) | ||
335 | #elseif ($itemHasViewInvitation) | ||
336 | #set($discard = $row.put('doc_viewInvitation_url', $viewInvitationUrl)) | ||
337 | #elseif ($itemHasCancelJoinRequest) | ||
338 | #set($discard = $row.put('doc_cancelJoinRequest_url', $cancelJoinRequestUrl)) | ||
339 | #end | ||
340 | ################################################# | ||
341 | #end | ||
342 | #set($discard = $rows.add($row)) | ||
343 | #end | ||
344 | |||
345 | |||
346 | #** | ||
347 | * Adds information about the given column to the JSON returned by a live table data call. | ||
348 | * NOTE: This macro uses Velocity variables available in gridresult_buildRowJSON. | ||
349 | * | ||
350 | * @param $colname the name of the live table column for which to retrieve information | ||
351 | * @param $row stores the JSON in memory so that it can be adjusted before serialization | ||
352 | *# | ||
353 | #macro(gridresult_buildColumnJSON $colname $row) | ||
354 | #if($colname.startsWith('doc.')) | ||
355 | #elseif($colname == '_action') | ||
356 | #set($discard = $row.put($colname, $services.localization.render("${request.transprefix}actiontext"))) | ||
357 | #elseif($colname == '_attachments') | ||
358 | #livetable_getAttachmentsList($translatedDoc) | ||
359 | #set($discard = $row.put($colname, $attachlist)) | ||
360 | #elseif($colname == '_avatar') | ||
361 | #livetable_getAvatar($itemDoc) | ||
362 | #set($discard = $row.put($colname, $avatar)) | ||
363 | #elseif($colname == '_images') | ||
364 | #livetable_getImagesList($itemDoc) | ||
365 | #set($discard = $row.put($colname, $imagesList)) | ||
366 | #else | ||
367 | #set($propClassName = "$!request.get($colname.concat('_class'))") | ||
368 | #if($propClassName != '') | ||
369 | #set($propClass = $xwiki.getDocument($propClassName).getxWikiClass()) | ||
370 | #set($discard = $itemDoc.use($propClassName)) | ||
371 | #else | ||
372 | #set($propClass = $class) | ||
373 | #end | ||
374 | ## Retrieve the property type as it might be usefull | ||
375 | #set($propType = '') | ||
376 | #if($propClass.getPropertyNames().contains($colname)) | ||
377 | #set($propType = "$!propClass.get($colname).type") | ||
378 | #end | ||
379 | #set($fieldValue = "$!itemDoc.getValue($colname)") | ||
380 | #set($fieldDisplayValue = "#unwrapXPropertyDisplay($itemDoc.display($colname, 'view'))") | ||
381 | #if($fieldDisplayValue == '') | ||
382 | #set($fieldDisplayValue = $services.localization.render("${request.transprefix}emptyvalue")) | ||
383 | #end | ||
384 | #set($fieldUrl = '') | ||
385 | ## only retrieve an URL for a DBListClass item | ||
386 | #if($propType == 'DBListClass' && $propClass.get($colname).getProperty('multiSelect').value != 1) | ||
387 | #set($fieldUrl = $xwiki.getURL($fieldValue)) | ||
388 | #if($fieldUrl == $xwiki.getURL($services.model.resolveDocument('', 'default', $doc.documentReference.extractReference('WIKI')))) | ||
389 | #set($fieldUrl = '') | ||
390 | #end | ||
391 | #end | ||
392 | #set($discard = $row.put($colname, $fieldDisplayValue)) | ||
393 | #set($discard = $row.put("${colname}_value", $fieldValue)) | ||
394 | ######## WIKI UI MAINWIKI CUSTOMIZATION ######### | ||
395 | #if($colname == 'wikiprettyname') | ||
396 | #set($fieldUrl = $xwiki.getURL("$wiki.mainPageReference")) | ||
397 | #end | ||
398 | ################################################# | ||
399 | #set($discard = $row.put("${colname}_url", $fieldUrl)) | ||
400 | ## reset to the default class | ||
401 | #set($discard = $itemDoc.use($className)) | ||
402 | #end | ||
403 | #end | ||
404 | {{/velocity}} |