112 Comunitat Valenciana - 112CV
Se ha producido un error al procesar la plantilla.
?substring(...) argument #2 had invalid value: The index must be at least 0, but was -1.
----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign parameterKey = parameterKeyAn... [in template "10155#10193#161981574" at line 115, column 49]
----
1<#ftl output_format="HTML">
2<#--
3 * Autor: Andrea Olivero
4 * Fecha Inicio: 22/06/2020
5 * Formato migracion: json
6 * Fecha Finalizacion: 30/06/2020
7 -->
8
9 <#assign reserved_article_title = "${.vars['reserved-article-title'].data}"/>
10 <#assign reserved_article_id = "${.vars['reserved-article-id'].data}"/>
11 <#assign viewUrl=""/>
12 <#assign cuerpo=""/>
13 <#assign posicion=""/>
14 <#assign iframeId = "${.vars['reserved-article-id'].data}"/>
15 <#assign iframeProtocol = ""/>
16 <#assign width = "100%"/>
17 <#assign height = "650"/>
18 <#assign scrolling = "auto"/>
19 <#assign src = ""/>
20 <#assign velocityCount = ""/>
21 <#assign ajustar_alto = false/>
22 <#assign mostrar_atras = false/>
23 <#assign mostrar_enlazar = false/>
24 <#assign mostrar_imprimir = false/>
25
26 <div class="webContent" style="float:none;">
27 <#if reserved_article_title?? && reserved_article_title!="">
28 <p class="header10">${reserved_article_title}</p>
29 </#if>
30 </div>
31
32 <#--Dependiendo del valor de la variable posicion el Cuerpo se pinta arriba o abajo
33 por lo que primero recogemos los valores en variables -->
34
35 <#--Posición arriba/abajo-->
36 <#if Posicion??>
37 <#assign posicion=Posicion.getData()/>
38 </#if>
39
40 <#--Texto en el cuerpo caja de texto enriquecido.-->
41 <#if Cuerpo??>
42 <#assign cuerpo = Cuerpo.getData()/>
43 </#if>
44
45 <div class="iframe">
46 <#--Si el valor seleccionado es arriba entonces imprimimos el contenido del cuerpo.-->
47 <#if posicion == "arriba">
48 <div class="texto_cuerpo">
49 ${cuerpo?no_esc}
50 </div>
51 </#if>
52 <#--Comprobamos valores rellenados por usuario-->
53 <#if ancho.getData()?? && ancho.getData()!="">
54 <#assign width = ancho.getData()/>
55 </#if>
56
57 <#if alto.getData()?? && alto.getData()!="">
58 <#assign height = alto.getData()/>
59 </#if>
60
61 <#if barra_desplazamiento.getData()?? && barra_desplazamiento.getData()!="">
62 <#assign scrolling = barra_desplazamiento.getData()/>
63 </#if>
64
65 <#if url.getData()?? && url.getData()!="">
66 <#assign src = url.getData()/>
67 </#if>
68
69 <#if autoajustar_alto?? && autoajustar_alto.getData()=="true">
70 <#assign ajustar_alto = true/>
71 </#if>
72
73 <#if mostrar_enlace_atras?? && mostrar_enlace_atras.getData()=="true">
74 <#assign mostrar_atras = true/>
75 </#if>
76
77 <#if mostrar_enlace_enlazar?? && mostrar_enlace_enlazar.getData()=="true">
78 <#assign mostrar_enlazar = true/>
79 </#if>
80
81 <#if mostrar_boton_imprimir?? && mostrar_boton_imprimir.getData()=="true">
82 <#assign mostrar_imprimir = true/>
83 </#if>
84
85 <#--Obtengo el dominio actual-->
86 <#assign currentUrl = Request.CURRENT_COMPLETE_URL/>
87 <#assign urlParts = currentUrl?split("/")/>
88 <#assign currentDomain = ""/>
89 <#assign currentProtocol = ""/>
90 <#list urlParts as urlPart>
91 <#if velocityCount == "3">
92 <#assign currentDomain = urlPart/>
93 </#if>
94 </#list>
95 <#--Obtengo el dominio del iframe -->
96 <#assign srcParts = src?split("/")/>
97 <#assign iframeDomain = ""/>
98 <#assign serverUrl = ""/>
99
100 <#if srcParts[0] == "http:" || srcParts[0] == "https:">
101 <#assign iframeDomain = srcParts[2]/>
102 <#assign iframeProtocol = srcParts[0]/>
103 <#assign serverUrl = iframeProtocol + "//" + iframeDomain/>
104 </#if>
105
106 <#if src?? && src!="">
107 <#-- parámetros de la url del portal-->
108
109 <#assign parametrosString = httpUtil.getQueryString(currentUrl)/>
110 <#assign parameterList = parametrosString?split("&")/>
111 <#assign sufijo = ""/>
112
113 <#list parameterList as parameterKeyAndValue>
114 <#if parameterKeyAndValue?? && parameterKeyAndValue?has_content>
115 <#assign parameterKey = parameterKeyAndValue?substring(0,parameterKeyAndValue?index_of("="))/>
116 <#assign parameterValue = parameterKeyAndValue?substring(parameterKeyAndValue?index_of("=")+1)/>
117
118 <#assign anyadir = true/>
119
120 <#-- ENT-308086 : Tenemos que ver si se ha añadido algún valor en el campo ignore_parametros-->
121 <#if ignore_parametros?? && ignore_parametros?has_content>
122 <#assign ignoreParameters = ignore_parametros.getData()?split(";")/>
123 <#list ignoreParameters as ignoreParameter>
124 <#if ignoreParameter?? && ignoreParameter?has_content && ignoreParameter==parameterKey>
125 <#assign anyadir = false/>
126 </#if>
127 </#list>
128 </#if>
129 <#--FIN ENT-308086-->
130
131 <#--Buscamos si se ha definido la URL que se ha de ver en el iFrame-->
132 <#if parameterKey == "viewUrl${iframeId}">
133 <#assign viewUrl = parameterValue />
134 <#assign anyadir = false/>
135 </#if>
136
137
138 <#if anyadir >
139 <#if sufijo != "" >
140 <#assign sufijo = sufijo + "&" />
141 <#else>
142 <#assign sufijo = "?" />
143 </#if>
144 <#assign sufijo = sufijo + parameterKeyAndValue />
145 </#if>
146 </#if>
147 </#list>
148
149 <#--Establecemos la URL que se ha de ver en el iFrame, si se ha definido-->
150
151 <#if viewUrl?? && viewUrl!="">
152 <#assign src = serverUrl + viewUrl />
153 </#if>
154
155 <#if sufijo?? && sufijo!="">
156
157 <#--Comprobamos si la URL ya trae parametros para concatenarlos-->
158 <#assign index = src?index_of('?')/>
159
160 <#if (index >= 0) >
161 <#assign sufijo = sufijo?replace("?", "&")/>
162 </#if>
163 <#assign src = "${src}${sufijo}"/>
164 </#if>
165
166 <div class="iframe-error-protocol" style="display: none;"><span><@liferay.language key="iframe.mensaje" /><a href="${src?no_esc}" target="_blank"><b><@liferay.language key="iframe.mensaje.ventana" /></b></a></span></div>
167 <#if mostrar_enlazar || mostrar_atras || mostrar_imprimir>
168 <div class="iframe-controls iframe-controls-${reserved_article_id} gva-btn-group gva-btn-group-end">
169 <#if mostrar_imprimir>
170 <a class="taglib-icon pull-right gva-btn gva-btn-outline-primary" id="iframe-print-${reserved_article_id}" target="_self">
171 <i class="fas fa-print"></i>
172 <span class="taglib-text"><@liferay.language key="print" /></span>
173 </a>
174 </#if>
175 <#if mostrar_enlazar>
176 <a class="iframe-show-link pull-right gva-btn gva-btn-outline-primary" id="iframe-show-link-${reserved_article_id}" style="display: none;" ><i class="fas fa-link"></i><@liferay.language key="iframe.enlazar" /></a>
177 </#if>
178 <#if mostrar_atras>
179 <a class="back-link pull-right gva-btn gva-btn-ghost-primary bold" id="iframe-back-link-${reserved_article_id}" href="javascript:history.go(-1)" style="display: none;"><i class="fa-solid fa-arrow-left"></i><@liferay.language key="back" /></a>
180 </#if>
181 </div>
182 <#if mostrar_enlazar>
183 <div id="toasts-${reserved_article_id}" tabindex="-1"></div>
184 </#if>
185
186 </#if>
187
188 <div id="iframe-container-${reserved_article_id}">
189 <iframe allow="clipboard-write" src="" width="${width}" height="${height}" scrolling="${scrolling}" title="${reserved_article_title}" id="iframe-${reserved_article_id}" name="iframe-${reserved_article_id}"></iframe>
190 </div>
191
192
193 <#--Si el valor seleccionado es abajo imprimimos el contenido del cuerpo.-->
194 <#if posicion == "abajo">
195 <div class="texto_cuerpo">
196 ${cuerpo?no_esc}
197 </div>
198 </#if>
199
200 <script type="text/javascript">
201
202
203 // Script para que no cargue el src del iframe dos veces por el efecto del SPA https://help.liferay.com/hc/es/requests/41501
204 var iframe = document.getElementById('iframe-${reserved_article_id}');
205 var url = "${src?no_esc}";
206 if (Liferay.SPA && iframe) {
207 iframe.src = url;
208 }
209 else {
210 Liferay.on(
211 'SPAReady',
212 function(event) {
213 if (iframe) {
214 iframe.src = url;
215 }
216 }
217 );
218 }
219
220 // No es el mismo dominio, así que definimos el valor del document.domain
221 <#if (ajustar_alto || mostrar_atras) && currentDomain?has_content && iframeDomain?has_content && !currentDomain.equals(iframeDomain) >
222 document.domain = 'gva.es';
223 </#if>
224
225 // ENT-337637 Cogemos protocolo por js
226 if( location.protocol == "https:" && "${iframeProtocol}" == "http:" )
227 $('.iframe-error-protocol').css('display','block');
228
229
230 // Controlar la visualizacion de los botones de Atras y Enlazar en las sucesivas cargas del iframe
231 <#if mostrar_enlazar || mostrar_atras >
232 var numLoads=0;
233 document.getElementById('iframe-${reserved_article_id}').onload = function () {
234 if (numLoads > 0) {
235 if ($(window).scrollTop() > $('#iframe-container-${reserved_article_id}').offset().top) {
236 $('html, body').animate({ scrollTop: $('#iframe-container-${reserved_article_id}').offset().top - 60 }, 'slow');
237 }
238 }
239 if (numLoads == 1) {
240 $('#iframe-show-link-${reserved_article_id}').show();
241 $('#iframe-back-link-${reserved_article_id}').show();
242 }
243 numLoads++;
244 }
245 </#if>
246
247 function getIframePermanentUrl() {
248 var iframeLocation = document.getElementById('iframe-${reserved_article_id}').contentWindow.location;
249 var pageUrl = window.location.href;
250 var iframeParams = iframeLocation.href;
251
252 if (pageUrl.includes('?')) {
253 pageUrl = pageUrl.substring(0, pageUrl.indexOf('?'));
254 }
255
256 if (iframeParams.includes('?')) {
257 iframeParams = iframeParams.substring(iframeParams.indexOf('?')+1);
258 iframeParams = '&' + iframeParams.replace(/(&)?viewUrl=[^&]+/g, '');
259 } else {
260 iframeParams = '';
261 }
262
263 return pageUrl + '?viewUrl${iframeId}=' + iframeLocation.pathname + iframeParams;
264 }
265
266 function showCopiedUrlToast(copiedUrl) {
267 var toast = document.getElementById('toasts-${reserved_article_id}');
268
269 if (!toast) {
270 return;
271 }
272
273 const notif = document.createElement('div');
274 const div = document.createElement('div');
275 const notifLabelTitle = document.createElement('span');
276 const notifButtonClose = document.createElement('span');
277 const iconClose = document.createElement('i');
278 const notifLabelMessage = document.createElement('span');
279
280 notif.classList.add('toast');
281 notif.classList.add('success');
282 div.classList.add('header');
283
284 notifLabelTitle.classList.add('title-message');
285 notifButtonClose.classList.add('close-message');
286 iconClose.classList.add('fas');
287 iconClose.classList.add('fa-times');
288 notifLabelMessage.classList.add('body-message');
289
290 var idioma = 1;
291 if (copiedUrl.includes('/es/')) idioma = 0;
292 else if (copiedUrl.includes('/en/')) idioma = 2;
293 else if (copiedUrl.includes('/fr/')) idioma = 3;
294
295 const messagesTitle = ['URL copiada', 'URL copiada', 'Copied URL', 'URL copiée'];
296 const messagesBody = ['Se ha copiado la dirección web', 'S\'ha copiat l\'adreça web', 'The web address has been copied', 'L\'adresse Web a été copiée'];
297
298 notifLabelTitle.innerText = messagesTitle[idioma];
299 notifLabelMessage.innerText = messagesBody[idioma];
300
301 toast.appendChild(notif);
302 div.append(notifLabelTitle);
303 notifButtonClose.append(iconClose);
304 div.append(notifButtonClose);
305 notif.append(div);
306 notif.append(notifLabelMessage);
307
308 notifButtonClose.addEventListener('click', function() {
309 notif.remove();
310 });
311
312 setTimeout(function() {
313 notif.remove();
314 }, 3000);
315 }
316
317
318 //Obtener enlace permanente del iframe
319 $('#iframe-show-link-${reserved_article_id}').click(function (event) {
320
321 //Cuando le damos click no queremos que se quede el marco del foco
322 $('#iframe-show-link-${reserved_article_id}').blur();
323
324 var iframePermanentUrl = getIframePermanentUrl();
325
326 navigator.clipboard.writeText(iframePermanentUrl).then(function() {
327 showCopiedUrlToast(iframePermanentUrl);
328 });
329 });
330
331 $('#iframe-show-link-${reserved_article_id}').keyup(function(event){
332 if (event.keyCode == 13) {
333 event.preventDefault();
334 $('#iframe-show-link-${reserved_article_id}').click();
335 }
336 });
337
338 //Imprimimos sólo el contenido del iframe
339 $('#iframe-print-${reserved_article_id}').click(function (event) {
340 var ifr = document.getElementById("iframe-${reserved_article_id}");
341 ifr.contentWindow.focus();
342 ifr.contentWindow.print();
343 console.log("Click")
344 });
345 $('#iframe-print-${reserved_article_id}').keyup(function(event){
346 if (event.keyCode == 13) {
347 event.preventDefault();
348 $('#iframe-print-${reserved_article_id}').click();
349 }
350 });
351
352 //El enlace « Atrás de los publicadores para los contenidos de tipo IFRAME, vuelve atrás en el historial para que deshaga una posible navegación realizada en la página incrustada
353 $("span[class='header-back-to']").find("a").attr("href", "javascript:window.history.back()");
354
355 //Autoajustar alto cada vez que se cargue el contenido del iframe
356 <#if ajustar_alto >
357
358 // Autoajustar el alto del iframe cada segundo
359 setInterval(function() {
360 var iframe = document.getElementById('iframe-${reserved_article_id}');
361 var style = 0;
362 if (iframe && iframe !== 'null' && iframe !== 'undefined') {
363 style = iframe.style.height.replace('px', '');
364 if (iframe.contentWindow.document.body && iframe.contentWindow.document.body !== 'null' && iframe.contentWindow.document.body !== 'undefined') {
365 var offset = iframe.contentWindow.document.body.offsetHeight + 30;
366
367 if(style>=offset+31 || style<=offset-31){
368 iframe.style.height = offset + 'px';
369 }
370 }
371 }
372 },1);
373 </#if>
374 </script>
375
376 <#else>
377 No se ha introduccido una URL de iframe.
378 </#if>
379 </div>
Bon Nadal
Ver todas las notas de prensa






