Fehler bei der Verarbeitung der Vorlage.
Can't convert this string to number: "2,1" The blamed expression: ==> paragraphImagePosition?number [in template "20155#20195#STANDARD-ARTICLE" at line 136, column 71] ---- FTL stack trace ("~" means nesting-related): - Failed at: #if paragraphImagePosition != "null" ... [in template "20155#20195#STANDARD-ARTICLE" at line 136, column 29] ----
1<#--
2 Name: Standard article NewWeb.
3 Author: Author: Silvio Meier, Patrik Burkhalter
4 Date: 10.11.2016
5 Version: 1.3.3.3
6-->
7
8
9<#assign logFactory = staticUtil["com.liferay.portal.kernel.log.LogFactoryUtil"] />
10<#assign log = logFactory.getLog('StandardArticle') />
11
12<#-- common definitions -->
13<#assign namespace = randomNamespace/>
14
15<#-- ${log.info("-------------" + namespace)} -->
16
17
18<#-- prepare layouting of right-hand side articles and right-hand side html boxes -->
19<#assign rhsArticles = retrieveRightHandSideArticles() />
20<#assign rhsArtAvailable = hasRightHandSideArticles(rhsArticles) />
21<#assign rhsBoxAvailable = hasRightHandSideBoxes() />
22
23<#-- styles -->
24<@javaScriptOfStandardArticle/>
25
26
27<#if rhsArtAvailable || rhsBoxAvailable>
28<div class="row">
29 <div class="col-12 col-md-9 std-art-output-wrapper">
30 </#if>
31 <div class="std-art-output-wrapper">
32 <#-- code for rendering main content -->
33 <div class="std-art-output">
34
35 <#if !(hideTitle?? && isNotTrue(hideTitle)) >
36 <h2><@selectTitle pTitle=(.vars['reserved-article-title'].data) pPrintTitle=printTitle /></h2>
37 </#if>
38 <#if abstract.getData()?? >
39 <div class="std-art-abstract">${abstract.getData()}</div>
40 </#if>
41 <#-- representative image -->
42 <#--<#assign repImgCaption="" />
43 <#list repImage.getChildren() as child>
44 <#if child.getName()?contains("repImageCaption") && child.getData()??>
45 <#assign repImgCaption=child.getData() />
46 </#if>
47 </#list> -->
48 <@renderFreestandingImage
49 imageAlignment="repImage"
50 checkImageAlignment="repImage"
51 marginDefault="0px,0px,0px,0px"
52 margin=""
53 image=repImage.getData()
54 imageCaption=repImageCaption.getData()
55 imageLink=repImageLink.getData()
56 />
57
58 <#if paragraph.getSiblings()?has_content>
59 <#-- prepare content of the paragraph for further processing -->
60
61 <#list paragraph.getSiblings() as curParagraph>
62 <#assign paragraphTitleSize = "h5"/>
63 <#assign paragraphImage = "" />
64 <#assign paragraphText = "" />
65 <#assign paragraphImageAlignment= "topLeft" />
66 <#assign paragraphImageCaption = "" />
67 <#assign paragraphImageLink = "" />
68 <#assign paragraphImagePosition = 0.0 />
69 <#assign paragraphImageMarginValues = "" />
70 <#assign paragraphSlideshow = "" />
71 <#assign paragraphYoutubeVideo = "" />
72
73 <#list curParagraph.getChildren() as pchild>
74 <#if (pchild.getName()) == "paragraphTitle" && pchild.getData()??>
75 <#assign paragraphTitle = pchild.getData()/>
76 </#if>
77 <#if (pchild.getName()) == "paragraphTitleSize" && pchild.getData()?has_content>
78 <#assign paragraphTitleSize = pchild.getData()/>
79 </#if>
80 <#if (pchild.getName()) == "paragraphText" && pchild.getData()??>
81 <#assign paragraphText = pchild.getData() />
82 </#if>
83 <#if (pchild.getName()) == "paragraphImage" && pchild.getData()??>
84 <#assign paragraphImage = pchild.getData() />
85 </#if>
86 <#if (pchild.getName()) == "paragraphImageCaption" && pchild.getData()??>
87 <#assign paragraphImageCaption = pchild.getData() />
88 </#if>
89 <#if (pchild.getName()) == "paragraphImageLink" && pchild.getData()??>
90 <#assign paragraphImageLink = pchild.getData() />
91 </#if>
92 <#if (pchild.getName()) == "paragraphImageAlignment" && pchild.getData()??>
93 <#assign paragraphImageAlignment = pchild.getData() />
94 </#if>
95 <#if (pchild.getName()) == "paragraphImagePosition" && pchild.getData()??>
96 <#assign paragraphImagePosition = pchild.getData() />
97 </#if>
98 <#if (pchild.getName()) == "paragraphImageMarginValues" && pchild.getData()??>
99 <#assign paragraphImageMarginValues = pchild.getData() />
100 </#if>
101 <#if (pchild.getName()) == "paragraphSlideshow" && pchild.getData()??>
102 <#assign paragraphSlideshow = pchild />
103 </#if>
104 <#if (pchild.getName()) == "paragraphYoutubeVideo" && pchild.getData()??>
105 <#assign paragraphYoutubeVideo = pchild />
106 </#if>
107 </#list>
108
109
110
111 <#-- default margins for images in the paragraph -->
112 <#assign leftFreeMarginDef = "0px,5px,10px,0px" />
113 <#assign rightFreeMarginDef = "10px,5px,0px,0px" />
114 <#assign topLeftMarginDef = "0px,5px,10px,0px" />
115 <#assign topRightMarginDef = "10px,5px,0px,0px" />
116 <#assign bottomLeftMarginDef = "0px,10px,10px,10px" />
117 <#assign bottomrightMarginDef = "10px,10px,0px,10px" />
118 <#assign beforeParagpraphMarginDef = "0px,0px,0px,0px" />
119 <#assign afterAlignmentMarginDef = "0px,0px,0px,0px" />
120
121 <#-- render paragraph content -->
122 <div class="std-paragraph-block">
123
124 <#if paragraphText?? && paragraphText?has_content>
125 <#-- prepare paragraph image position for free floating image -->
126 <#if paragraphImage?? && paragraphImage?has_content &&
127 (paragraphImageAlignment="leftFree" || paragraphImageAlignment="rightFree")>
128
129 <#-- if the image is freely floating on the left or the right-hand side
130 of the paragraph, caluclate the position in the text which is the next
131 to the position specified by the percentage of the text and which is
132 a space character. -->
133
134 <#assign imgPosPercentage = 0.0 />
135 <#if paragraphImagePosition?? && paragraphImagePosition?has_content >
136 <#if paragraphImagePosition != "null" && (paragraphImagePosition?number > -1.0) >
137 <#assign imgPosPercentage = paragraphImagePosition?number />
138 </#if>
139 </#if>
140
141 <#assign charPos = (paragraphText?length / 100.0) * imgPosPercentage />
142 <#if (charPos?number > paragraphText?length - 1) >
143 <#assign charPos = paragraphText?length - 1 />
144 </#if>
145
146 <#if (paragraphText[charPos] != "\t" && paragraphText[charPos] != "\t" &&
147 paragraphText[charPos] != "\n" && paragraphText[charPos] != "\r" &&
148 paragraphText[charPos] != "\n\r" && paragraphText[charPos] != "\n\r") >
149 <#assign charPos = paragraphText?index_of(" ", charPos) />
150 <#if charPos == -1 >
151 <#assign charPos = paragraphText?length -1 />
152 </#if>
153 </#if>
154
155 <#-- do not split any html tags! -->
156 <#assign gtNextPos = paragraphText?index_of(">", charPos) />
157 <#assign ltNextPos = paragraphText?index_of("<", charPos) />
158 <#assign insertPosition = charPos />
159
160 <#if (gtNextPos > -1) && (ltNextPos > gtNextPos) >
161 <#assign insertPosition = gtNextPos + 1 />
162 </#if>
163 <#if (charPos?number == paragraphText?length - 1) >
164 <#assign insertPosition = paragraphText?length />
165 </#if>
166 </#if>
167
168 <@renderFreestandingImage
169 imageAlignment=paragraphImageAlignment
170 checkImageAlignment="beforeParagraph"
171 marginDefault="0px,0px,0px,0px"
172 margin=paragraphImageMarginValues
173 image=paragraphImage
174 imageCaption=paragraphImageCaption
175 imageLink=paragraphImageLink
176 />
177
178 <#if paragraphTitle??>
179 <${paragraphTitleSize}>${paragraphTitle}</${paragraphTitleSize}>
180 </#if>
181
182 <div class="std-art-paragraph">
183 <#-- render top left or top right paragraph images -->
184 <@renderEmbeddedImage
185 imageAlignment=paragraphImageAlignment
186 altImageAlignment1="topLeft"
187 altImageAlignment2="topRight"
188 alignImg1="left"
189 alignImg2="right"
190 marginDefault1=topLeftMarginDef
191 marginDefault2=topRightMarginDef
192 margin=paragraphImageMarginValues
193 image=paragraphImage
194 imageCaption=paragraphImageCaption
195 imageLink=paragraphImageLink
196 />
197
198 <#-- render free left or free right paragraph image -->
199 <#if paragraphImage?? && paragraphImage?has_content && paragraphText?? &&
200 (paragraphImageAlignment="leftFree" || paragraphImageAlignment="rightFree")>
201 ${paragraphText?substring(0,insertPosition)}
202 <#-- render embedded image -->
203 <@renderEmbeddedImage
204 imageAlignment=paragraphImageAlignment
205 altImageAlignment1="leftFree"
206 altImageAlignment2="rightFree"
207 alignImg1="left"
208 alignImg2="right"
209 marginDefault1=leftFreeMarginDef
210 marginDefault2=rightFreeMarginDef
211 margin=paragraphImageMarginValues
212 image=paragraphImage
213 imageCaption=paragraphImageCaption
214 imageLink=paragraphImageLink
215 />
216 ${paragraphText?substring(insertPosition,paragraphText?length)}
217 <#else>
218 ${paragraphText}
219 </#if>
220
221 <#-- render bottom left or bottom right paragraph images -->
222 <#if (paragraphImageAlignment="bottomLeft" || paragraphImageAlignment == "bottomRight") && paragraphImage != "">
223 <@renderEmbeddedImage
224 imageAlignment=paragraphImageAlignment
225 altImageAlignment1="bottomLeft"
226 altImageAlignment2="bottomRight"
227 alignImg1="left"
228 alignImg2="right"
229 marginDefault1=bottomLeftMarginDef
230 marginDefault2=bottomrightMarginDef
231 margin=paragraphImageMarginValues
232 image=paragraphImage
233 imageCaption=paragraphImageCaption
234 imageLink=paragraphImageLink
235 />
236 </#if>
237 </div>
238 <#-- render image which follows the paragraph -->
239 <@renderFreestandingImage
240 imageAlignment=paragraphImageAlignment
241 checkImageAlignment="afterParagraph"
242 marginDefault="0px,0px,0px,0px"
243 margin=paragraphImageMarginValues
244 image=paragraphImage
245 imageCaption=paragraphImageCaption
246 imageLink=paragraphImageLink
247 />
248 <#else> <#-- paragraphText?has_content -->
249 <#if paragraphTitle?? && paragraphTitle?has_content>
250 <${paragraphTitleSize}>${paragraphTitle}</${paragraphTitleSize}>
251 </#if>
252 <#if paragraphImage?? && paragraphImage?has_content>
253 <@renderFreestandingImage
254 imageAlignment="repImage"
255 checkImageAlignment="repImage"
256 marginDefault="0px,0px,0px,0px"
257 margin=""
258 image=paragraphImage
259 imageCaption=paragraphImageCaption
260 imageLink=paragraphImageLink
261 />
262 </#if>
263 </#if> <#-- paragraphText?has_content -->
264
265 <#-- render the slideshow -->
266 <#if paragraphSlideshow?? && paragraphSlideshow?has_content>
267 <@renderSlideshow paragraphSlideshow namespace+curParagraph?counter />
268 </#if>
269
270 <#-- render the youtube video -->
271 <#if paragraphYoutubeVideo?? && paragraphYoutubeVideo?has_content>
272 <@renderYoutubeVideo paragraphYoutubeVideo />
273 </#if>
274
275 </div>
276 </#list>
277 </#if>
278
279
280 </div> <#-- std-art-output -->
281</div> <#-- std-art-output-wrapper -->
282
283<#-- right-hand column -->
284<#if rhsArtAvailable || rhsBoxAvailable>
285 </div>
286 <div class="col-12 col-md-3 std-art-right-hand-column">
287 <div class="std-art-right-hand-column" >
288 <#-- global counter for the right hand side boxes and realted assets -->
289 <#assign rcount = 0 />
290 <#if rightHandBoxesOnTop.getData()?string == "true"> <#-- ?boolean not available? -->
291 <@renderRightHandSideBoxes />
292 <@renderRightHandSideArticles articleList=rhsArticles />
293 <#else>
294 <@renderRightHandSideArticles articleList=rhsArticles />
295 <@renderRightHandSideBoxes />
296 </#if>
297
298 </div>
299 </div>
300 </div>
301</#if>
302
303<#-- Returns the id of the global group/site -->
304<#function getGlobalGroupId>
305 <#local retVal = "0" />
306 <#local journalService = serviceLocator.findService("com.liferay.portal.service.GroupLocalService") />
307 <#if journalService?? >
308 <#local retVal = journalService.getCompanyGroup(portalUtil.getDefaultCompanyId()).getGroupId() />
309 </#if>
310 <#return retVal />
311</#function>
312
313<#-- GroupLocalServiceUtil.getCompanyGroup(PortalUtil.getDefaultCompanyId()).getGroupId(); -->
314
315<#-- Renders the print title -->
316<#-- pTitle: The default document title -->
317<#-- pPrintTitle: The print title of the document -->
318<#macro selectTitle pTitle pPrintTitle>
319 <#if pPrintTitle?? && pPrintTitle.getData()?has_content && pPrintTitle.getData() != "">
320 ${pPrintTitle.getData()}
321 <#else>
322 ${pTitle}
323 </#if>
324</#macro>
325
326<#-- Renders a freestanding image -->
327<#-- paragraphImageAlignment: The alignment of the image in the paragraph that is set -->
328<#-- checkImageAlignment: Is the alignment constant that must be set in order to render the image in the following set -->
329<#-- paragraphImage: Image URL of the image to render -->
330<#-- paragraphImageCaption: The image caption of the image -->
331<#macro renderFreestandingImage
332imageAlignment
333checkImageAlignment
334marginDefault
335margin
336image
337imageCaption
338imageLink >
339
340
341 <#if (imageAlignment=checkImageAlignment) && image != "">
342 <#assign left = imageMargin(marginDefault, 1) />
343 <#assign top = imageMargin(marginDefault, 2) />
344 <#assign right = imageMargin(marginDefault, 3) />
345 <#assign bottom = imageMargin(marginDefault, 4) />
346
347 <#if imageMargin(margin, 1)?has_content >
348 <#assign left = imageMargin(margin, 1) />
349 </#if>
350 <#if imageMargin(margin, 2)?has_content >
351 <#assign top = imageMargin(margin, 2) />
352 </#if>
353 <#if imageMargin(margin, 3)?has_content >
354 <#assign right = imageMargin(margin, 3) />
355 </#if>
356 <#if imageMargin(margin, 4)?has_content >
357 <#assign bottom = imageMargin(margin, 4) />
358 </#if>
359 <#assign marginImg = "margin-left:" + left + "; margin-top: " + top + "; margin-right: " + right + "; margin-bottom: " + bottom + ";"/>
360
361 <#-- if the image has a link, then define the link string for the cell div -->
362 <#assign imglink="">
363 <#assign imglinkstyle="">
364 <#if imageLink?? && imageLink?has_content>
365 <#assign imglink="onclick=\"window.location='" + imageLink + "';\"">
366 <#assign imglinkstyle="cursor: pointer;">
367 </#if>
368
369 <div class="std-art-freestanding-image" style="${marginImg} ${imglinkstyle}" ${imglink}>
370
371 <#-- If the element has a link, then print a different string -->
372 <#-- Note: This link is redundant, but it could be needed for search machines (the cell link on the div is a javascript link)-->
373 <#if imageLink?? && imageLink?has_content>
374 <a href="${imageLink}"><img alt="${image}" src="${image}" /></a>
375 <#else>
376 <img alt="${image}" src="${image}" />
377 </#if>
378
379 <#if imageCaption?? && imageCaption?has_content>
380 <div class="std-art-img-caption-freestanding">${imageCaption}</div>
381 </#if>
382 </div>
383 </#if>
384</#macro>
385
386<#-- renderEmbeddedImage Renders an embedded image of a paragraph for opposite alignment alternatives -->
387<#-- paragraphImageAlignment: The image alignment that is set for the paragraph -->
388<#-- altImageAlignment1: The id of the first alternative for the image alignment that is handled by this macro -->
389<#-- altImageAlignment2: The id of the second alternative for the image alignment that is handled by this macro -->
390<#-- alignImg1: The actual css alignment for the first alternative alignment -->
391<#-- alignImg2: The actual css alignment for the second alternative alignment -->
392<#-- marginDefault1: The default margin settings for the first alternative image alignement -->
393<#-- marginDefault2: The default margin settings for the second alternative image alignement -->
394<#-- margin: The actually set margin settings for the set image aligments -->
395<#-- paragraphImage: The image url of the image -->
396<#-- paragraphImageCaption: The caption of the image -->
397<#macro renderEmbeddedImage
398imageAlignment
399altImageAlignment1
400altImageAlignment2
401alignImg1
402alignImg2
403marginDefault1
404marginDefault2
405margin
406image
407imageCaption
408imageLink
409>
410 <#if (imageAlignment = altImageAlignment1 || imageAlignment = altImageAlignment2) && image != "">
411 <#if imageAlignment=altImageAlignment1>
412 <#assign marginDefault = marginDefault1 />
413 <#assign alignImg = alignImg1 />
414 <#else>
415 <#assign marginDefault = marginDefault2 />
416 <#assign alignImg = alignImg2 />
417 </#if>
418
419 <#assign left = imageMargin(marginDefault, 1) />
420 <#assign top = imageMargin(marginDefault, 2) />
421 <#assign right = imageMargin(marginDefault, 3) />
422 <#assign bottom = imageMargin(marginDefault, 4) />
423
424 <#if imageMargin(margin, 1)?has_content >
425 <#assign left = imageMargin(margin, 1) />
426 </#if>
427 <#if imageMargin(margin, 2)?has_content >
428 <#assign top = imageMargin(margin, 2) />
429 </#if>
430 <#if imageMargin(margin, 3)?has_content >
431 <#assign right = imageMargin(margin, 3) />
432 </#if>
433 <#if imageMargin(margin, 4)?has_content >
434 <#assign bottom = imageMargin(margin, 4) />
435 </#if>
436
437 <#assign marginImg = "margin-left:" + left + "; margin-top: " + top + "; margin-right: " + right + "; margin-bottom: " + bottom + ";"/>
438 <#assign border="" />
439 <#assign innermargin="" />
440 <#-- only set a border and a second margin inside the border, if there is a caption -->
441
442 <#-- if the image has a link, then define the link string for the cell div -->
443 <#assign imglink="">
444 <#assign imglinkstyle="">
445 <#if imageLink?? && imageLink?has_content>
446 <#assign imglink="onclick=\"window.location='" + imageLink + "';\"">
447 <#assign imglinkstyle="cursor: pointer;">
448 </#if>
449
450 <div style="float: ${alignImg}; ${marginImg} ${imglinkstyle}" ${imglink}>
451 <div class="std-art-embedded-image" >
452 <div class="std-art-img-row">
453 <div class="std-art-img-cell">
454 <#-- If the element has a link, then print a different string -->
455 <#-- Note: This link is redundant, but it could be needed for search machines (the cell link on the div is a javascript link)-->
456 <#--<div class="magnify-img-link">-->
457 <#if imageLink?? && imageLink?has_content>
458 <a href="${imageLink}"><img alt="${image}" src="${image}" /></a>
459 <#else>
460 <img alt="${image}" src="${image}" />
461 </#if>
462 <#--</div>-->
463 </div>
464 </div>
465 <#if imageCaption?? && imageCaption?has_content>
466 <div class="std-art-img-caption-embedded">${imageCaption}</div>
467 </#if>
468
469 </div>
470 </div>
471 </#if>
472</#macro>
473
474<#-- This macro renders the slideshow -->
475<#macro renderSlideshow paragraphSlideshow slideshowNamespace>
476
477 <#assign hasImages = false >
478 <#if paragraphSlideshow?? && paragraphSlideshow?has_content>
479 <#list paragraphSlideshow.getChildren() as images>
480 <#list images.getSiblings() as image>
481 <#if image.getData()?? && image.getData()?has_content>
482 <#assign hasImages = true >
483 </#if>
484 </#list>
485 </#list>
486 </#if>
487
488 <#if hasImages>
489 <!-- Slideshow container -->
490 <div class="${slideshowNamespace}slideshow-container slideshow-container">
491 <#list paragraphSlideshow.getChildren() as images>
492 <#assign size = images.getSiblings()?size />
493 <#assign index = 0>
494 <#list images.getSiblings() as image>
495 <div class="${slideshowNamespace}mySlides mySlides">
496 <#assign index = index + 1/>
497 <div class="${slideshowNamespace}numbertext numbertext">${index} / ${size}</div>
498
499 <div style="height: 490px; width: 100%; background-repeat: no-repeat; background-size: contain; background-position: center center; background-color: #222222; background-image: url('${image.getData()}')" onClick="toggleCaptions('${slideshowNamespace}')"></div>
500
501 <#list image.getChildren() as child>
502 <#if child.getName()?contains("slideshowImageCaption") && child.getData()??>
503 <#if child.getData()?has_content>
504 <div class="${slideshowNamespace}text text" onClick="toggleCaptions('${slideshowNamespace}')">${child.getData()}</div>
505 </#if>
506 </#if>
507 </#list>
508
509 </div>
510 </#list>
511 </#list>
512 <!-- Next and previous buttons -->
513 <a class="${slideshowNamespace}prev prev" onclick="plusSlides('${slideshowNamespace}',-1)">❮</a>
514 <a class="${slideshowNamespace}next next" onclick="plusSlides('${slideshowNamespace}',1)">❯</a>
515 <script>
516 captionsStatus['${slideshowNamespace}'] = 1;
517 slideIndex['${slideshowNamespace}'] = 1;
518 </script>
519 </div>
520 </#if>
521
522</#macro>
523
524<#-- This macro renders the youtube video -->
525<#macro renderYoutubeVideo paragraphYoutubeVideo>
526 <#if paragraphYoutubeVideo?? && paragraphYoutubeVideo?has_content>
527 <#assign url = paragraphYoutubeVideo.getData() />
528 <#if url?? && url?has_content && url?contains("v=") >
529 <#assign videoId = url?split("v=")[1]?split("&")[0] />
530 <#if videoId?? && videoId?has_content>
531 <div class="videoWrapper">
532 <iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
533 allowfullscreen="" frameborder="0"
534 src="https://www.youtube.com/embed/${videoId}">
535 </iframe>
536 </div>
537 </#if>
538 </#if>
539 </#if>
540</#macro>
541
542<#-- extracts the margin values for embedded images -->
543<#function imageMargin marginString index>
544 <#assign leftM = "" />
545 <#assign topM = "" />
546 <#assign rightM = "" />
547 <#assign bottomM = "" />
548 <#if marginString?? && marginString?has_content && marginString?is_string>
549 <#assign commaPos1 = -1 />
550 <#assign commaPos2 = -1 />
551 <#assign commaPos3 = -1 />
552 <#assign commaPos1 = marginString?index_of(",", 0) />
553 <#if commaPos1 gt -1 >
554 <#assign commaPos2 = marginString?index_of(",", commaPos1 + 1) />
555 <#assign leftM = marginString?substring(0, commaPos1) />
556 </#if>
557 <#if commaPos2 gt -1 >
558 <#assign topM = marginString?substring(commaPos1+1, commaPos2) />
559 <#assign commaPos3 = marginString?index_of(",", commaPos2 + 1) />
560 </#if>
561 <#if commaPos3 gt -1 >
562 <#assign rightM = marginString?substring(commaPos2+1, commaPos3) />
563 <#assign bottomM = marginString?substring(commaPos3+1, marginString?length) />
564 </#if>
565 </#if>
566 <#if index == 1>
567 <#return leftM >
568 <#elseif index == 2>
569 <#return topM >
570 <#elseif index == 3>
571 <#return rightM >
572 <#elseif index == 4>
573 <#return bottomM >
574 </#if>
575 <#return "" >
576</#function>
577
578<#function hasRightHandSideArticles articleList>
579 <#assign retVal = false />
580 <#if articleList?? && (articleList?size > 0) >
581 <#assign retVal = true />
582 </#if>
583 <#return retVal />
584</#function>
585
586<#function hasRightHandSideBoxes>
587 <#assign retVal = false />
588 <#if rightHandBox?? && (rightHandBox?size > 0) >
589 <#list rightHandBox.getSiblings() as curRightHandBox>
590 <#assign rightHandBoxTitle = "" />
591 <#assign rightHandBoxContent = "" />
592 <#list curRightHandBox.getChildren() as bchild>
593 <#if (bchild.getName()) == "rightHandBoxTitle" && bchild.getData()??>
594 <#assign rightHandBoxTitle = bchild.getData()/>
595 </#if>
596 <#if (bchild.getName()) == "rightHandBoxContent" && bchild.getData()??>
597 <#assign rightHandBoxContent = bchild.getData()/>
598 </#if>
599 </#list>
600 <#if rightHandBoxTitle != "" || rightHandBoxContent != "">
601 <#assign retVal = true />
602 </#if>
603 </#list>
604 </#if>
605 <#return retVal />
606</#function>
607
608<#function retrieveCurrentArticleAssetEntryId>
609<#--${log.info("-------------")}-->
610
611 <#assign JournalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService")>[$CURSOR$]${JournalArticleLocalService}
612
613 <#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService" ) />
614 <#assign assetLinkLocalService = serviceLocator.findService("com.liferay.asset.link.service.AssetLinkLocalService" ) />
615 <#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService" ) />
616 <#assign currentArticle = journalArticleLocalService.getArticle(getterUtil.getLong(groupId),.vars['reserved-article-id'].getData()) />
617 <#assign currentArticleResourcePrimKey = currentArticle.getResourcePrimKey() />
618 <#assign currentArticleAssetEntry = assetEntryLocalService.getEntry("com.liferay.journal.model.JournalArticle", currentArticleResourcePrimKey) />
619 <#assign currentArticleAssetEntryEntryId = currentArticleAssetEntry.getEntryId() />
620<#--${log.info("currentArticleAssetEntryEntryId:\t" + currentArticleAssetEntryEntryId)}-->
621 <#return currentArticleAssetEntryEntryId />
622</#function>
623
624<#function retrieveRightHandSideArticles>
625 <#assign currentArticleAssetEntryEntryId = retrieveCurrentArticleAssetEntryId() />
626 <#assign currentArticleRelatedLinks = assetLinkLocalService.getDirectLinks(currentArticleAssetEntryEntryId) />
627 <#assign currentArticleRelatedLinksSorted = currentArticleRelatedLinks?sort_by("linkId") />
628 <#return currentArticleRelatedLinksSorted />
629</#function>
630
631<#macro renderRightHandSideArticles articleList>
632 <#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService" ) />
633
634<#-- article is of type AssetLink -->
635 <#list articleList as article>
636
637 <#assign currentArticleAssetEntryId = retrieveCurrentArticleAssetEntryId() />
638 ${log.debug("Resolving asset links for article: " + currentArticleAssetEntryId)}
639
640 <#-- An asset Link has 2 ID's, source (id1) and destination (id2) -->
641 <#assign linkedAssetEntryId = article.getEntryId2() />
642 ${log.debug("Resolving asset link: " + article.getEntryId1() + " -> " + article.getEntryId2())}
643
644 <#-- or in other words, if id1 == id2 -->
645 <#if linkedAssetEntryId == currentArticleAssetEntryId>
646 <h1>Prevented a recursion, please use another right hand side article </h1>
647 ${log.error("Article with ID " + currentArticleAssetEntryId + " tried to include Article with ID " + linkedAssetEntryId)}
648 <#break />
649 </#if>
650
651 <#-- if the linked asset entry is not the same type as the current asset entry, then complain and goto next -->
652 <#if assetEntryLocalService.getEntry(linkedAssetEntryId).getClassNameId() != assetEntryLocalService.getEntry(currentArticleAssetEntryId).getClassNameId()>
653 <h1>Can only have right hand side articles of type ${assetEntryLocalService.getEntry(currentArticleAssetEntryId).getClassName()} </h1>
654 ${log.error("Invalid right hand side article type " + assetEntryLocalService.getEntry(linkedAssetEntryId).getClassNameId() + ", ignoring")}
655 <#break />
656 </#if>
657
658 <#-- get the linked asset entry -->
659 <#assign linkedAssetEntry = assetEntryLocalService.getEntry(linkedAssetEntryId) />
660 <#assign linkedAssetEntryPrimaryKey = linkedAssetEntry.getClassPK() />
661 <#assign linkedArticle = journalArticleLocalService.getLatestArticle(linkedAssetEntryPrimaryKey) />
662
663 <#-- check if the linked article is of type STANDARD-ARTICLE or NEWS-ARTICLE to prevent recursion -->
664 <#assign linkedArticleStructureKey = linkedArticle.getDDMStructureKey() />
665 ${log.debug("Found RHS article with template id " + linkedArticleStructureKey)}
666 <#if linkedArticleStructureKey?contains("STANDARD-ARTICLE") || linkedArticleStructureKey?contains("NEWS-ARTICLE") >
667 <h1>RHS article type ${linkedArticleStructureKey} not allowed</h1>
668 ${log.error("Invalid RHS article " + linkedArticleStructureKey + ", ignoring")}
669 <#break />
670 </#if>
671
672 <#-- global counter for the right hand side boxes and realted assets -->
673 <#if rcount != 0>
674 <hr/>
675 </#if>
676
677 <#assign groupId = linkedArticle.getGroupId() />
678 <#assign articleId = linkedArticle.getArticleId() />
679
680 <div class="std-art-rhs-article">
681 ${journalArticleLocalService.getArticleDisplay(groupId, articleId, "", locale, themeDisplay).getContent()}
682 </div>
683 <#-- global counter for the right hand side boxes and realted assets -->
684 <#assign rcount = rcount + 1 />
685 </#list>
686</#macro>
687
688<#macro renderRightHandSideBoxes>
689 <#if rightHandBox.getSiblings()?has_content>
690 <#list rightHandBox.getSiblings() as curRightHandBox>
691 <#assign rightHandBoxTitle = "" />
692 <#assign rightHandBoxContent = "" />
693
694 <#list curRightHandBox.getChildren() as bchild>
695 <#if (bchild.getName()) == "rightHandBoxTitle" && bchild.getData()??>
696 <#assign rightHandBoxTitle = bchild.getData()/>
697 </#if>
698 <#if (bchild.getName()) == "rightHandBoxContent" && bchild.getData()??>
699 <#assign rightHandBoxContent = bchild.getData()/>
700 </#if>
701 </#list>
702
703 <#if rightHandBoxTitle != "" || rightHandBoxContent != "">
704 <#-- global counter for the right hand side boxes and realted assets -->
705 <#if rcount != 0>
706 <hr/>
707 </#if>
708 <div class="std-art-rhs-box">
709 <#if rightHandBoxTitle?? && rightHandBoxTitle != "">
710 <div class="std-art-rhs-box-title">
711 ${rightHandBoxTitle}
712 </div>
713 </#if>
714 <#if rightHandBoxContent?? && rightHandBoxContent != "">
715 <div class="std-art-rhs-box-content">
716 ${rightHandBoxContent}
717 </div>
718 </#if>
719 </div>
720 <#-- global counter for the right hand side boxes and realted assets -->
721 <#assign rcount = rcount + 1 />
722 </#if>
723
724 </#list>
725 </#if>
726</#macro>
727
728<#-- returns true only if the value is declared and defined true -->
729<#function isNotTrue value >
730 <#assign retVal = false />
731 <#if value??>
732 <#if value?has_content>
733 <#if value?is_hash>
734 <#if getterUtil.getBoolean(value.getData()) >
735 <#assign retVal = true />
736 </#if>
737 </#if>
738 </#if>
739 </#if>
740 <#return retVal />
741</#function>
742
743<#-- java script of the article -->
744<#macro javaScriptOfStandardArticle>
745
746 <script>
747
748 var slideIndex = {};
749 var captionsStatus = {};
750
751 function initSlides() {
752 let namespaces = Object.keys(slideIndex);
753 for(let i = 0; i < namespaces.length;i++) {
754 showSlides(namespaces[i],slideIndex[namespaces[i]]);
755 }
756 }
757
758 // Next previous controls
759 function plusSlides(namespace,n) {
760 showSlides(namespace,slideIndex[namespace] += n);
761 }
762
763 // Thumbnail image controls
764 function currentSlide(n) {
765 showSlides(namespace,slideIndex[namespace] = n);
766 }
767
768 function toggleCaptions(namespace) {
769 if(captionsStatus[namespace] == 1) {
770 console.log("Captions off");
771 captionsStatus[namespace] = 0;
772 } else {
773 console.log("Captions on");
774 captionsStatus[namespace] = 1;
775 }
776 updateCaptions(namespace);
777 }
778
779 function captionsOn(namespace) {
780 captionsStatus[namespace] = 1;
781 updateCaptions(namespace);
782 }
783
784 function captionsOff(namespace) {
785 captionsStatus[namespace] = 1;
786 updateCaptions(namespace);
787 }
788
789 function updateCaptions(namespace) {
790 var captions = document.getElementsByClassName(namespace+"text");
791 for (i = 0; i < captions.length; i++) {
792 if(captionsStatus[namespace] == 1) {
793 captions[i].style.display = "block";
794 } else {
795 captions[i].style.display = "none";
796 }
797 }
798 }
799
800 function showSlides(namespace,n) {
801 var i;
802 var slides = document.getElementsByClassName(namespace+"mySlides");
803 if(slides.length == 0) {
804 return;
805 }
806
807 if (n > slides.length) {
808 slideIndex[namespace] = 1;
809 }
810
811 if (n < 1) {
812 slideIndex[namespace] = slides.length;
813 }
814
815 for (i = 0; i < slides.length; i++) {
816 slides[i].style.display = "none";
817 }
818 slides[slideIndex[namespace]-1].style.display = "block";
819 captionsOn(namespace);
820
821 }
822
823 AUI().ready(function(A) {
824 initSlides();
825 });
826
827 </script>
828</#macro>