-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADT.ftl
97 lines (70 loc) · 2.96 KB
/
ADT.ftl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<#--
Liferay 7.2
ADT example
Freemarker
ADT.ftl
-->
<#assign
dlFileEntryUtil = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")
dlAppService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLAppService")
dlUtil = serviceLocator.findService("com.liferay.document.library.kernel.util.DLUtil")
prefix = "senci"
/>
<#if entries?has_content>
<#-- Truncate Text -->
<#macro truncate_text text limit>
<#assign truncatedText = "" />
<#if text?length gt limit>
<#assign truncatedText = text?substring(0,limit)/>
<#assign truncatedText += "..."/>
${truncatedText}
<#else>
${text}
</#if>
</#macro>
<#-- Asset Entries -->
<#macro asset_entries_include assetEntryContext>
<#assign
renderer = assetEntryContext.getAssetRenderer()
journalArticle = renderer.getArticle()
document = saxReaderUtil.read(journalArticle.getContent())
rootElement = document.getRootElement()
xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='news_image']")
newsImage = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim
xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='news_content']")
newsContent = xPathSelector.selectSingleNode(rootElement).getStringValue()?trim
<#-- Get groupId and uuid -->
jsonObject = jsonFactoryUtil.createJSONObject(newsImage)
fileGroupId = getterUtil.getInteger(jsonObject.get('groupId'))
fileUuid = getterUtil.getString(jsonObject.get('uuid'))
<#-- Get fileEntryId from the document -->
fileEntry = dlFileEntryUtil.getDLFileEntryByUuidAndGroupId(fileUuid, fileGroupId)
fileEntryId = fileEntry.getFileEntryId()
/>
<#-- Create urlDocument -->
<#if fileEntryId?? && fileEntryId != 0>
<#assign
fileEntry = dlAppService.getFileEntry(fileEntryId)
fielURL = dlUtil.getDownloadURL(fileEntry, fileEntry.getFileVersion(), themeDisplay, null)
/>
<#else>
<#assign fielURL = "#">
</#if>
<#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, assetEntryContext) />
<#if assetLinkBehavior != "showFullContent">
<#assign viewURL = renderer.getURLViewInContext(renderRequest, renderResponse, viewURL) />
</#if>
</#macro>
<#assign count = 0 />
<#list entries as curEntry>
<@asset_entries_include assetEntryContext=curEntry />
<#if count == 0 >
${fielURL}
${viewURL}
${curEntry.getTitle(locale)}
<#assign publishDate = journalArticle.getModifiedDate()>
${publishDate?datetime?string("dd MMMM yyyy")}
</#if>
<#assign count = count + 1 />
</#list>
</#if>