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