Disposición consolidada - DOGV
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#176057880" at line 110, column 49]
----
1<#assign reserved_article_title = "${.vars['reserved-article-title'].data}"/>
2 <#assign reserved_article_id = "${.vars['reserved-article-id'].data}"/>
3 <#assign viewUrl=""/>
4 <#assign cuerpo=""/>
5 <#assign posicion=""/>
6 <#assign iframeId = "${.vars['reserved-article-id'].data}"/>
7 <#assign httpComponentsUtil = objectUtil("com.liferay.portal.kernel.util.HttpComponentsUtil")/>
8 <#assign iframeProtocol = ""/>
9 <#assign width = "100%"/>
10 <#assign height = "650"/>
11 <#assign scrolling = "auto"/>
12 <#assign src = ""/>
13 <#assign ajustar_alto = false/>
14 <#assign mostrar_atras = true/>
15 <#assign mostrar_enlazar = false/>
16 <#assign mostrar_imprimir = false/>
17
18 <div class="webContent" style="float:none;">
19 <#if reserved_article_title?? && reserved_article_title!="">
20 <p class="header10">${reserved_article_title}</p>
21 </#if>
22 </div>
23
24 <#--Dependiendo del valor de la variable posicion el Cuerpo se pinta arriba o abajo
25 por lo que primero recogemos los valores en variables -->
26
27 <#--Posición arriba/abajo-->
28 <#if Posicion?? && Posicion.getData()?? >
29 <#assign posicion=Posicion.getData()/>
30 </#if>
31
32 <#--Texto en el cuerpo caja de texto enriquecido.-->
33 <#if Cuerpo?? && Cuerpo.getData() != "" >
34 <#assign cuerpo = Cuerpo.getData()/>
35 </#if>
36
37 <div class="iframe">
38 <#--Si el valor seleccionado es arriba entonces imprimimos el contenido del cuerpo.-->
39 <#if posicion == "arriba">
40 <div class="texto_cuerpo">
41 ${cuerpo}
42 </div>
43 </#if>
44 <#--Comprobamos valores rellenados por usuario-->
45 <#if ancho.getData()?? && ancho.getData()!="">
46 <#assign width = ancho.getData()/>
47 </#if>
48
49 <#if alto.getData()?? && alto.getData()!="">
50 <#assign height = alto.getData()/>
51 </#if>
52
53 <#if barra_desplazamiento.getData()?? && barra_desplazamiento.getData()!="">
54 <#assign scrolling = barra_desplazamiento.getData()/>
55 </#if>
56
57 <#if url.getData()?? && url.getData()!="">
58 <#assign src = url.getData()/>
59 </#if>
60
61 <#if autoajustar_alto?? && autoajustar_alto.getData()=="true">
62 <#assign ajustar_alto = true/>
63 </#if>
64
65 <#if mostrar_enlace_atras?? && mostrar_enlace_atras.getData()=="false">
66 <#assign mostrar_atras = false/>
67 </#if>
68
69 <#if mostrar_enlace_enlazar?? && mostrar_enlace_enlazar.getData()=="true">
70 <#assign mostrar_enlazar = true/>
71 </#if>
72
73 <#if mostrar_boton_imprimir?? && mostrar_boton_imprimir.getData()=="true">
74 <#assign mostrar_imprimir = true/>
75 </#if>
76
77 <#--Obtengo el dominio actual-->
78 <#assign currentUrl = Request.CURRENT_COMPLETE_URL/>
79 <#assign urlParts = currentUrl?split("/")/>
80 <#assign currentDomain = ""/>
81 <#assign currentProtocol = ""/>
82 <#assign cont = 1 />
83 <#list urlParts as urlPart >
84 <#if cont == 3 >
85 <#assign currentDomain = urlPart />
86 </#if>
87 <#assign cont = cont + 1 />
88 </#list>
89 <#--Obtengo el dominio del iframe -->
90 <#assign srcParts = src?split("/")/>
91 <#assign iframeDomain = ""/>
92 <#assign iframeProtocol = "" />
93 <#assign serverUrl = ""/>
94
95 <#if srcParts[0] == "http:" || srcParts[0] == "https:">
96 <#assign iframeDomain = srcParts[2]/>
97 <#assign iframeProtocol = srcParts[0]/>
98 <#assign serverUrl = iframeProtocol + "//" + iframeDomain/>
99 </#if>
100 <#if src?? && src!="">
101 <#-- parámetros de la url del portal-->
102
103 <#assign parametrosString = httpComponentsUtil.getQueryString(currentUrl)/>
104 <#assign parameterList = parametrosString?split("&")/>
105 <#assign sufijo = ""/>
106
107 <#list parameterList as parameterKeyAndValue>
108 <#if parameterKeyAndValue?? && parameterKeyAndValue?has_content>
109 <#assign parameterKey = parameterKeyAndValue?substring(0,parameterKeyAndValue?index_of("="))/>
110 <#assign parameterValue = parameterKeyAndValue?substring(parameterKeyAndValue?index_of("=")+1)/>
111
112 <#assign anyadir = true/>
113
114 <#-- ENT-308086 : Tenemos que ver si se ha añadido algún valor en el campo ignore_parametros-->
115 <#if ignore_parametros?? && ignore_parametros?has_content>
116 <#assign ignoreParameters = ignore_parametros.getData()?split(";")/>
117 <#list ignoreParameters as ignoreParameter>
118 <#if ignoreParameter?? && ignoreParameter?has_content && ignoreParameter==parameterKey>
119 <#assign anyadir = false/>
120 </#if>
121 </#list>
122 </#if>
123 <#--FIN ENT-308086-->
124
125 <#--Buscamos si se ha definido la URL que se ha de ver en el iFrame-->
126 <#if parameterKey == "viewUrl${iframeId}">
127 <#assign viewUrl = parameterValue />
128 <#assign anyadir = false/>
129 </#if>
130
131
132 <#if anyadir >
133 <#if sufijo != "" >
134 <#assign sufijo = sufijo + "&" />
135 <#else>
136 <#assign sufijo = "?" />
137 </#if>
138 <#assign sufijo = sufijo + parameterKeyAndValue />
139 </#if>
140 </#if>
141 </#list>
142
143 <#--Establecemos la URL que se ha de ver en el iFrame, si se ha definido-->
144
145 <#if viewUrl?? && viewUrl!="">
146 <#assign src = serverUrl + viewUrl />
147 </#if>
148
149 <#-- INICIO ENT-316287
150 DIFERENCIA CON LA PLANTILLA DE IFRAME GLOBAL
151 SI NOS LLEGA UN PARÁMETRO A PARTIR DE LA URL POR LA QUE ACEDEMOS AL PORTAL
152 ELIMINAMOS EL TEXTO "?param1=" Y REEMPLAZAMOS LO QUE HACE DE SEPARADOR PARA QUE LO PINTE CORRECTAMENTE -->
153 <#assign sufijo = sufijo?replace("?param=", "")?replace("%2F", "/") />
154 <#assign sufijo = sufijo?replace("(", "%28")?replace(")", "%29") />
155 <#--FIN ENT-316287 -->
156
157 <#if sufijo?? && sufijo!="">
158
159 <#--Comprobamos si la URL ya trae parametros para concatenarlos-->
160 <#assign index = src?index_of('?')/>
161
162 <#if (index >= 0) >
163 <#assign sufijo = sufijo?replace("?", "&")/>
164 </#if>
165 <#assign src = "${src}${sufijo}"/>
166 </#if>
167
168 <div class="iframe-error-protocol iframe-error-protocol-${reserved_article_id}" style="display: none;">
169 <span>
170 <@liferay.language key="iframe.mensaje" />
171 <a href="${src}" target="_blank">
172 <b><@liferay.language key="iframe.mensaje.ventana" /></b>
173 </a>
174 </span>
175 </div>
176 <#if mostrar_enlazar || mostrar_atras || mostrar_imprimir>
177 <div class="iframe-controls iframe-controls-${reserved_article_id}">
178 <#if mostrar_atras>
179 <a class="back-link float-right" id="iframe-back-link-${reserved_article_id}" href="javascript:history.go(-1)" style="display: none;">« <@liferay.language key="back" /></a>
180 </#if>
181 <#if mostrar_enlazar>
182 <a class="iframe-show-link float-right" id="iframe-show-link-${reserved_article_id}" style="display: none;" ><i class="fas fa-link"></i><@liferay.language key="iframe.enlazar" /></a>
183 <div id="iframe-link-${reserved_article_id}" class="iframe-link">
184 <input aria-labelledby="iframe-show-link-${reserved_article_id}" id="iframe-link-input-${reserved_article_id}" class="iframe-link-input" type="text" style="display: none;" />
185 </div>
186 </#if>
187 <#if mostrar_imprimir>
188 <a class="taglib-icon float-right" id="iframe-print-${reserved_article_id}" target="_self">
189 <i class="fas fa-print"></i>
190 <span class="taglib-text"><@liferay.language key="print" /></span>
191 </a>
192 </#if>
193 </div>
194 </#if>
195
196 <div id="iframe-container-${reserved_article_id}">
197 <#--ENT-563348 - Se añade allow para poder copiar al portapapeles-->
198 <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>
199 </div>
200
201
202 <#--Si el valor seleccionado es abajo imprimimos el contenido del cuerpo.-->
203 <#if posicion == "abajo">
204 <div class="texto_cuerpo">
205 ${cuerpo}
206 </div>
207 </#if>
208
209 <script type="text/javascript">
210
211 // Script para que no cargue el src del iframe dos veces por el efecto del SPA https://help.liferay.com/hc/es/requests/41501
212 var iframe = document.getElementById('iframe-${reserved_article_id}');
213 var url = "${src}";
214 if (Liferay.SPA && iframe) {
215 iframe.src = url;
216 }
217 else {
218 Liferay.on(
219 'SPAReady',
220 function(event) {
221 if (iframe) {
222 iframe.src = url;
223 }
224 }
225 );
226 }
227
228 <#-- No es el mismo dominio, así que definimos el valor del document.domain -->
229 <#if (ajustar_alto || mostrar_enlazar) && currentDomain?has_content && iframeDomain?has_content && !currentDomain.equals(iframeDomain) >
230 document.domain = 'gva.es';
231 </#if>
232
233 <#-- ENT-337637 Cogemos protocolo por js -->
234 if( location.protocol == "https:" && "${iframeProtocol}" == "http:" )
235 $('.portlet-journal-content .iframe-error-protocol-${iframeId}').css('display','block');
236
237 <#-- Autoajustar el alto del iframe -->
238 <#if ajustar_alto >
239 <#-- Al cambiar el tamaño de la ventana
240 ##$(window).resize(function (){
241 ## var iframe = document.getElementById('iframe-${iframeId}');
242 ## iframe.style.height = (iframe.contentWindow.document.body.offsetHeight + 30 ) + 'px';
243 ##});
244
245 ## INICIO ENT-525601
246 ## DIFERENCIA CON LA PLANTILLA DE IFRAME GLOBAL
247 ## Se cambia la función para calcular el alto para que tenga en cuenta el alto de un tag del iframe
248 ## También se aprovecha para coger un id del iframe y utilizar su texto para completar el breadcrumb
249
250 ##Autoajustar alto del iframe cada X milisengundos -->
251 var milisengundosRefresco = 100;
252 //milisengundosRefresco = 2000;
253
254
255 var debug = false;
256 //debug = true;
257 setInterval(function() {
258
259 /* Recogemos los diferentes elementos del DOM */
260 const iframeContainer = document.getElementById('iframe-container-${iframeId}');
261 const iframe = document.getElementById('iframe-${iframeId}');
262 const iframeWindow = iframe.contentWindow;
263 const iframeDocument = iframeWindow.document;
264 const main = iframeDocument.querySelector("app-root main");
265 const header = iframeDocument.querySelector("app-root app-header header");
266 const legislation = iframeDocument.querySelector("app-root app-legislation-by-areas section");
267 const eli = iframeDocument.querySelector("app-root app-eli section");
268 const title = iframeDocument.querySelector("app-root app-detail main h2");
269
270 if(title){
271 document.title = title.innerText;
272 }
273
274 /* Se setablecen los valores por defecto por si el contenido de iframe todavía no está cargado */
275 let mainScrollHeight = 500;
276 let headerScrollHeight = 500;
277 let iframeScrollHeight = 0;
278
279 /*Obtenemos los alto de los elementos*/
280 if(main){
281 mainScrollHeight = main.scrollHeight;
282 }else if(legislation){
283 mainScrollHeight = legislation.scrollHeight;
284 }else if(eli){
285 mainScrollHeight = eli.scrollHeight;
286 }
287 if(header){
288 headerScrollHeight = header.scrollHeight;
289 }
290 if(iframe){
291 iframeScrollHeight = iframe.scrollHeight
292 }
293
294
295 const margenAnyadido = 100;
296
297 const alturaCalculada = mainScrollHeight + headerScrollHeight + margenAnyadido + 'px';
298
299 if (debug) console.log("--------------------------------------");
300 if (debug) console.log("BUSCAMOS EL NUEVO ALTO DEL IFRAME");
301 if (debug) console.log("iframeScrollHeight = " + iframeScrollHeight);
302 if (debug) console.log("mainScrollHeight = " + mainScrollHeight);
303 if (debug) console.log("headerScrollHeight = " + headerScrollHeight);
304 if (debug) console.log("alturaCalculada = " + alturaCalculada);
305 if (debug) console.log("FIN BUSCAMOS EL NUEVO ALTO DEL IFRAME");
306 if (debug) console.log("--------------------------------------");
307
308 if(iframeScrollHeight != mainScrollHeight){
309 iframe.style.height = alturaCalculada;
310 }
311
312
313 /* ************************************************************************************ */
314 /* Cogemos del IFRAME del DOGV la parte del camino de migas que montan en la aplicacion */
315 /* ************************************************************************************ */
316 if (debug) console.log("--------------------------------------");
317 if (debug) console.log("BUSCAMOS EL BREADCRUMB");
318
319 /* Definimos el selector del elemento dentro del iframe con el texto que se debe incluir en el iframe */
320 var bselector = 'breadcrumb-title';
321 var biframeselector = "iframe-"+bselector;
322 /* Definimos el selector del elemento del breadcrumb dentro del iframe */
323 var bselectorBreadcrumb = 'ul.breadcrumbs-horizontal';
324 var biframeDocument = iframeDocument;
325 var belement = biframeDocument.getElementById(bselector);
326 if ((typeof belement !== 'undefined') && belement ) {
327 if (debug) console.log("Se ha encontrado el elemento: " + bselector);
328 var text_to_add = belement.textContent;
329 if (debug) console.log("text_to_add: " + text_to_add);
330 if (text_to_add.length !== 0) {
331 /* Ya tenemos el texto ahora hay que buscar el elemento del breadcrumb donde incluirlo */
332 var bul = document.querySelector(bselectorBreadcrumb);
333 if ((typeof bul !== 'undefined') && bul) {
334 if (debug) console.log("Se encuentra el ul con el selector: " + bselectorBreadcrumb);
335 /* Tenemos que buscar si el elemento li ya existe o hay que crearlo */
336 var bli = bul.querySelector("#"+biframeselector);
337 if ((typeof bli !== 'undefined') && bli) {
338 if (debug) console.log("Se encuentra el li con el selector: " + biframeselector);
339 var span = bli.getElementsByTagName("span")[0];
340 if (debug) console.log("Se encuentra el span");
341 span.innerHTML = text_to_add;
342 } else {
343 if (debug) console.log("Vamos a crear el li");
344 bli = document.createElement("li");
345 bli.setAttribute('id',biframeselector);
346 var span = document.createElement("span");
347 span.appendChild(document.createTextNode(text_to_add));
348 bli.appendChild(span)
349 bul.appendChild(bli)
350 }
351 }
352 }
353 }
354 if (debug) console.log("FIN BUSCAMOS EL BREADCRUMB");
355 if (debug) console.log("--------------------------------------");
356
357 },milisengundosRefresco);
358 <#-- FIN ENT-525601 -->
359
360 </#if>
361
362
363 $(document).ready(function() {
364
365 <#-- Autoajustar alto cada vez que se cargue el contenido del iframe -->
366 <#if ajustar_alto >
367 $('#iframe-${iframeId}').load(function() {
368 this.style.height = (this.contentWindow.document.body.offsetHeight + 30 ) + 'px';
369 });
370 </#if>
371
372
373 <#-- Ocultar los enlaces de Atrás y Enlace permanente para que aparezcan sólo si se ha navegado dentro del iframe -->
374 <#if mostrar_enlazar >
375 $('#iframe-show-link-${iframeId}').hide();
376 </#if>
377 <#if mostrar_atras >
378 $('#iframe-back-link-${iframeId}').hide();
379 </#if>
380
381 var numLoads = 0;
382 document.getElementById('iframe-${iframeId}').onload = function (element) {
383 if (numLoads > 0) {
384 if ($(window).scrollTop() > $('#iframe-container-${iframeId}').offset().top) {
385 $('html, body').animate({ scrollTop: $('#iframe-container-${iframeId}').offset().top - 60 }, 'slow');
386 }
387
388 <#if mostrar_enlazar || mostrar_atras >
389 $('#iframe-link-input-${iframeId}').fadeOut();
390 </#if>
391 }
392
393
394 if (numLoads == 1) {
395 <#if mostrar_enlazar >
396 $('#iframe-show-link-${iframeId}').show();
397 </#if>
398 <#if mostrar_atras >
399 $('.portlet-journal-content .iframe-controls-${iframeId} .back-link').show();
400 </#if>
401 }
402
403 numLoads++;
404 }
405 <#-- Obtener enlace permanente del iframe -->
406 <#if mostrar_enlazar >
407 $('#iframe-show-link-${iframeId}').click(function (event) {
408 //Cuando le damos click no queremos que se quede el marco del foco
409 $('#iframe-show-link-${iframeId}').blur();
410
411 var input = $('#iframe-link-input-${iframeId}');
412
413 if (!$(input).is(':visible')) {
414 var iframeLocation = document.getElementById('iframe-${iframeId}').contentWindow.location;
415 var pageUrl = window.location.href;
416 var iframeParams = iframeLocation.href;
417
418 if (pageUrl.includes('?')) {
419 pageUrl = pageUrl.substring(0, pageUrl.indexOf('?'));
420 }
421
422 if (iframeParams.includes('?')) {
423 iframeParams = iframeParams.substring(iframeParams.indexOf('?')+1);
424 iframeParams = '&' + iframeParams.replace(/(&)?viewUrl=[^&]+/g, '');
425 } else {
426 iframeParams = '';
427 }
428
429 $(input).val(pageUrl + '?viewUrl${iframeId}=' + encodeURIComponent(iframeLocation.pathname) + iframeParams);
430 }
431 $(input).fadeToggle();
432 });
433 <#-- Para que funcione cuando le damos al enter -->
434 $('#iframe-show-link-${iframeId}').keyup(function(event){
435 if (event.keyCode == 13) {
436 event.preventDefault();
437 $('#iframe-show-link-${iframeId}').click();
438 }
439 });
440 </#if>
441
442 <#-- Imprimimos sólo el contenido del iframe -->
443 <#if mostrar_imprimir >
444 $('#iframe-print-${iframeId}').click(function (event) {
445 var ifr = document.getElementById("iframe-${iframeId}");
446 ifr.contentWindow.focus();
447 ifr.contentWindow.print();
448 //Cuando le damos click no queremos que se quede el marco del foco
449 $('#iframe-print-${iframeId}').blur();
450 });
451
452 <#-- Para que funcione cuando le damos al enter -->
453 $('#iframe-print-${iframeId}').keyup(function(event){
454 if (event.keyCode == 13) {
455 event.preventDefault();
456 $('#iframe-print-${iframeId}').click();
457 }
458 });
459 </#if>
460
461 <#-- 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 -->
462 $("span[class='header-back-to']").find("a").attr("href", "javascript:window.history.back()");
463 });
464
465 <#-- Controlamos los click en el iframe para que si está desplegado el menu del portal, se esconda -->
466 var myConfObj = {
467 iframeMouseOver : false
468 }
469 window.addEventListener('blur',function(event){
470 if(myConfObj.iframeMouseOver){
471 // Ocultar menu desplegado cuando haces click en otro sitio distinto al menu
472 var $trigger = $(".horizontal .navegacion-superior .nav-menu .level-1 li, .sede .navegacion-superior .nav-menu .level-1 li");
473 $trigger.children('ul').slideUp(300);
474 }
475 });
476 document.getElementById('iframe-container-${iframeId}').addEventListener('mouseover',function(){
477 myConfObj.iframeMouseOver = true;
478 });
479 document.getElementById('iframe-container-${iframeId}').addEventListener('mouseout',function(){
480 myConfObj.iframeMouseOver = false;
481 });
482
483 </script>
484
485 <#else>
486 No se ha introduccido una URL de iframe.
487 </#if>
488 </div>