Wiki broncode van GetAnnouncements

Laatst gewijzigd door Mark van den Broek (Admin) op 03-04-2017 01:41:55

Show last authors
1 {{velocity wiki="false"}}
2 #if("$!{request.xpage}" == 'plain')
3 $response.setContentType('application/json')
4 #end
5 ## Initialize
6 #set($annClass = "360AnnouncementCode.AnnouncementClass")
7 #set($now = $datetool.toDate('yyyyMMddHHmmssSSS', $datetool.getDate()))
8 #set($language = "nl")
9 #set($wikiid = "%")
10 ## Get the appropriate announcements
11 #if("$!{request.wikiId}" != "")
12 #set($wikiid = "%${request.wikiId}%")
13 #end
14 #if("$!{request.language}" != "")
15 #set($language = ${request.language})
16 #end
17 #set($announcementMessage = {})
18 #set($xwq = "from doc.object('${annClass}') as announcement where (announcement.publishOnWikis LIKE :wikis or announcement.publishOnWikis = '') and announcement.language = :lang and announcement.startDate <= :startdate and announcement.endDate > :enddate order by doc.date desc")
19 #set($annDocResults = $services.query.xwql($xwq).bindValue("wikis", $wikiid).bindValue("lang", ${language}).bindValue("startdate", $datetool.toDate('yyyy-MM-dd HH:mm:ss:SSS', $now)).bindValue("enddate", $datetool.toDate('yyyy-MM-dd HH:mm:ss:SSS', $now)).execute())
20 #set($discard = $announcementMessage.put('numberOfAnnouncements', $annDocResults.size()))
21 #if($annDocResults.size())
22 #set($announcements = [])
23 #foreach($annResult in $annDocResults)
24 #set($announcement = {})
25 #set($annDoc = $xwiki.getDocument($annResult))
26 #set($annObj = $annDoc.getObject($annClass, 'language', $language))
27 #set($discard = $announcement.put('shortHeader', $annObj.shortHeader))
28 #set($discard = $announcement.put('icon', $annObj.icon))
29 #set($discard = $announcement.put('fullAnnouncement', $annObj.getProperty('fullAnnouncement').value))
30 #set($discard = $announcement.put('publicallyVisible', $annObj.getProperty('publicallyVisible').value))
31 #set($discard = $announcements.add($announcement))
32 #end
33 #set($discard = $announcementMessage.put('announcements', $announcements))
34 #end
35 $jsontool.serialize(${announcementMessage})
36 {{/velocity}}
Deze 360º Overheid-site is ontwikkeld door VirtualConsult m.b.v. open-source-software XWiki 12.5.1