Wiki broncode van GetAnnouncements

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

Hide last authors
Mark van den Broek (Admin) 1.1 1 {{velocity wiki="false"}}
2 #if("$!{request.xpage}" == 'plain')
3 $response.setContentType('application/json')
4 #end
Mark van den Broek (Admin) 36.1 5 ## Initialize
6 #set($annClass = "360AnnouncementCode.AnnouncementClass")
Mark van den Broek (Admin) 34.1 7 #set($now = $datetool.toDate('yyyyMMddHHmmssSSS', $datetool.getDate()))
Mark van den Broek (Admin) 36.1 8 #set($language = "nl")
9 #set($wikiid = "%")
Mark van den Broek (Admin) 1.2 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
Mark van den Broek (Admin) 2.1 17 #set($announcementMessage = {})
Mark van den Broek (Admin) 52.1 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")
Mark van den Broek (Admin) 47.1 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())
Mark van den Broek (Admin) 2.1 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))
Mark van den Broek (Admin) 35.1 26 #set($annObj = $annDoc.getObject($annClass, 'language', $language))
Mark van den Broek (Admin) 36.1 27 #set($discard = $announcement.put('shortHeader', $annObj.shortHeader))
Mark van den Broek (Admin) 41.1 28 #set($discard = $announcement.put('icon', $annObj.icon))
Mark van den Broek (Admin) 36.1 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))
Mark van den Broek (Admin) 2.1 32 #end
Mark van den Broek (Admin) 18.1 33 #set($discard = $announcementMessage.put('announcements', $announcements))
Mark van den Broek (Admin) 1.2 34 #end
Mark van den Broek (Admin) 19.1 35 $jsontool.serialize(${announcementMessage})
Mark van den Broek (Admin) 1.1 36 {{/velocity}}
Deze 360º Overheid-site is ontwikkeld door VirtualConsult m.b.v. open-source-software XWiki 12.5.1