1<#attempt>
2<#assign templateUtilService = serviceLocator.findService('it.gov.aifa.template.util.service.TemplateUtilService') />
3
4<#assign splitter = themeDisplay.getURLCurrent()?split("/-/")>
5<#assign titleJournalDirty = (splitter?last)>
6<#assign titleJournal = titleJournalDirty>
7
8<#if titleJournal?contains("/-/")>
9 <#assign titleJournal = titleJournalDirty?substring(0,titleJournalDirty?index_of("/-/"))>
10</#if>
11
12 <#assign article = templateUtilService.fetchArticleByUrlTitle(groupId,titleJournal)>
13
14 <#if article?has_content>
15
16 <#assign docXml = saxReaderUtil.read(article.getContentByLocale(locale)) />
17 <#assign rootElement = docXml.document.getRootElement() >
18 <#assign listadocumenti = docXml.getRootElement().selectNodes("//dynamic-element[@name='TitoloDocumentoCorrelato']") />
19 <#assign articleId = article.getArticleId() >
20
21 <#assign count = 0 />
22 <#list listadocumenti as doc>
23 <#assign docItem = doc.valueOf("dynamic-content/text()")!""/>
24 <#assign docItem = docItem?trim/>
25
26 <#if docItem?has_content && docItem?length gt 0>
27 <#assign count = count + 1 />
28 </#if>
29 </#list>
30
31 <#if count gt 0>
32 <div class="underline_title istituzionale">
33 <h2 class="portlet-content portlet-title-text-model portlet-title-text"><@liferay_ui['message'] key='label.templates.documenti.correlati' /></h2>
34
35 <div class="it-list-wrapper">
36 <ul class="it-list">
37
38 <#list listadocumenti as doc>
39
40 <li>
41 <#assign docTitle = doc.valueOf("dynamic-content/text()") />
42 <#assign docItem = doc.valueOf("dynamic-element[@name='DocumentiCorrelati']/dynamic-content/text()") />
43
44 <#assign jsonDocument=jsonFactoryUtil.createJSONObject(docItem)>
45
46
47 <#if docItem?has_content && docItem?length gt 0>
48 <#assign groupId=jsonDocument.getLong("groupId")>
49 <#assign uuId=jsonDocument.getString("uuid")>
50 <#assign docName=jsonDocument.getString("title")>
51 <#assign docItem = "/documents/"+groupId+"/"+0+"/"+docName+"/"+uuId />
52 <#assign jsonFile=templateUtilService.buildFileEntryByUrlDocument(themeDisplay.getScopeGroupId(),docItem) />
53
54
55 <#if ((jsonFile.length())>0)>
56
57 <#assign tipoDocumento = jsonFile.extension?upper_case/>
58
59 <#if (tipoDocumento == "PDF")>
60
61 <div class="it-right-zone">
62 <a title="${docTitle}" aria-label="<@liferay_ui['message'] key='aria.label.templates.download.file' /> ${docTitle} " href="${jsonFile.url}">
63 <span class="text">${docTitle} [${(jsonFile.size?number/(1024*1024))?string["0.##"]} Mb] [${jsonFile.extension}] ></span>
64 </a>
65 <span class="it-multiple">
66 <a title="<@liferay_ui['message'] key='title.label.preview' />" aria-label="<@liferay_ui['message'] key='aria.label.templates.view.file' /> ${docTitle}" onclick="buildModale('${docItem}');" >
67 <i class="u-color-blu fas fa-search"></i>
68 </a>
69 <a title="<@liferay_ui['message'] key='title.label.download' />" aria-label="<@liferay_ui['message'] key='aria.label.templates.download.file' /> ${docTitle} " href="${jsonFile.url}">
70 <i class="fas fa-download"></i>
71 </a>
72 </span>
73 </div>
74
75 <#else>
76
77 <a class="active" title="<@liferay_ui['message'] key='title.label.download' />" aria-label="<@liferay_ui['message'] key='aria.label.templates.download.file' /> ${docTitle} " href="${jsonFile.url}">
78 <div class="it-right-zone">
79 <span class="text">${docTitle} [${(jsonFile.size?number/(1024*1024))?string["0.##"]} Mb] [${jsonFile.extension}] ></span>
80 <i class="fas fa-download"></i>
81 </div>
82 </a>
83
84 </#if>
85 </#if>
86 </#if>
87 </li>
88 </#list>
89 <div class="yui3-skin-sam" data-toggle="modal">
90
91 <div id="modal-${articleId}" class="container preview-document">
92 </div>
93 </div>
94 </ul>
95 </div>
96 </div>
97 </#if>
98 </#if>
99
100<#recover>
101</#attempt>
102
103<script>
104
105function buildModale(urlDocument){
106 var modal;
107
108 YUI().use('aui-modal', function(Y) {
109 var StdMod = Y.WidgetStdMod;
110
111 modal = new Y.Modal({
112 bodyContent : '<object style="width:33rem; height:25rem;" data="'+urlDocument+'" type="application/pdf"></object>',
113 centered : true,
114 draggable: false,
115 resizeble: false,
116 visible : true,
117 destroyOnHide : true,
118 headerContent : 'Dettaglio documento',
119 modal : true,
120 focused:true,
121 render : '#modal-${articleId}'
122 });
123 });
124
125
126}
127</script>