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 <#if paragraphImage?has_content>
183 <#assign clearfix="clearfix" />
184 <#else>
185 <#assign clearfix="" />
186 </#if>
187 <div class="std-art-paragraph ${clearfix}">
188 <#-- render top left or top right paragraph images -->
189 <@renderEmbeddedImage
190 imageAlignment=paragraphImageAlignment
191 altImageAlignment1="topLeft"
192 altImageAlignment2="topRight"
193 alignImg1="left"
194 alignImg2="right"
195 marginDefault1=topLeftMarginDef
196 marginDefault2=topRightMarginDef
197 margin=paragraphImageMarginValues
198 image=paragraphImage
199 imageCaption=paragraphImageCaption
200 imageLink=paragraphImageLink
201 />
202
203 <#-- render free left or free right paragraph image -->
204 <#if paragraphImage?? && paragraphImage?has_content && paragraphText?? &&
205 (paragraphImageAlignment="leftFree" || paragraphImageAlignment="rightFree")>
206 ${paragraphText?substring(0,insertPosition)}
207 <#-- render embedded image -->
208 <@renderEmbeddedImage
209 imageAlignment=paragraphImageAlignment
210 altImageAlignment1="leftFree"
211 altImageAlignment2="rightFree"
212 alignImg1="left"
213 alignImg2="right"
214 marginDefault1=leftFreeMarginDef
215 marginDefault2=rightFreeMarginDef
216 margin=paragraphImageMarginValues
217 image=paragraphImage
218 imageCaption=paragraphImageCaption
219 imageLink=paragraphImageLink
220 />
221 ${paragraphText?substring(insertPosition,paragraphText?length)}
222 <#else>
223 ${paragraphText}
224 </#if>
225
226 <#-- render bottom left or bottom right paragraph images -->
227 <#if (paragraphImageAlignment="bottomLeft" || paragraphImageAlignment == "bottomRight") && paragraphImage != "">
228 <@renderEmbeddedImage
229 imageAlignment=paragraphImageAlignment
230 altImageAlignment1="bottomLeft"
231 altImageAlignment2="bottomRight"
232 alignImg1="left"
233 alignImg2="right"
234 marginDefault1=bottomLeftMarginDef
235 marginDefault2=bottomrightMarginDef
236 margin=paragraphImageMarginValues
237 image=paragraphImage
238 imageCaption=paragraphImageCaption
239 imageLink=paragraphImageLink
240 />
241 </#if>
242 </div>
243 <#-- render image which follows the paragraph -->
244 <@renderFreestandingImage
245 imageAlignment=paragraphImageAlignment
246 checkImageAlignment="afterParagraph"
247 marginDefault="0px,0px,0px,0px"
248 margin=paragraphImageMarginValues
249 image=paragraphImage
250 imageCaption=paragraphImageCaption
251 imageLink=paragraphImageLink
252 />
253 <#else> <#-- paragraphText?has_content -->
254 <#if paragraphTitle?? && paragraphTitle?has_content>
255 <${paragraphTitleSize}>${paragraphTitle}</${paragraphTitleSize}>
256 </#if>
257 <#if paragraphImage?? && paragraphImage?has_content>
258 <@renderFreestandingImage
259 imageAlignment="repImage"
260 checkImageAlignment="repImage"
261 marginDefault="0px,0px,0px,0px"
262 margin=""
263 image=paragraphImage
264 imageCaption=paragraphImageCaption
265 imageLink=paragraphImageLink
266 />
267 </#if>
268 </#if> <#-- paragraphText?has_content -->
269
270 <#-- render the slideshow -->
271 <#if paragraphSlideshow?? && paragraphSlideshow?has_content>
272 <@renderSlideshow paragraphSlideshow namespace+curParagraph?counter />
273 </#if>
274
275 <#-- render the youtube video -->
276 <#if paragraphYoutubeVideo?? && paragraphYoutubeVideo?has_content>
277 <@renderYoutubeVideo paragraphYoutubeVideo />
278 </#if>
279
280 </div>
281 </#list>
282 </#if>
283
284
285 </div> <#-- std-art-output -->
286</div> <#-- std-art-output-wrapper -->
287
288<#-- right-hand column -->
289<#if rhsArtAvailable || rhsBoxAvailable>
290 </div>
291 <div class="col-12 col-md-3 std-art-right-hand-column">
292 <div class="std-art-right-hand-column" >
293 <#-- global counter for the right hand side boxes and realted assets -->
294 <#assign rcount = 0 />
295 <#if rightHandBoxesOnTop.getData()?string == "true"> <#-- ?boolean not available? -->
296 <@renderRightHandSideBoxes />
297 <@renderRightHandSideArticles articleList=rhsArticles />
298 <#else>
299 <@renderRightHandSideArticles articleList=rhsArticles />
300 <@renderRightHandSideBoxes />
301 </#if>
302
303 </div>
304 </div>
305 </div>
306</#if>
307
308<#-- Returns the id of the global group/site -->
309<#function getGlobalGroupId>
310 <#local retVal = "0" />
311 <#local journalService = serviceLocator.findService("com.liferay.portal.service.GroupLocalService") />
312 <#if journalService?? >
313 <#local retVal = journalService.getCompanyGroup(portalUtil.getDefaultCompanyId()).getGroupId() />
314 </#if>
315 <#return retVal />
316</#function>
317
318<#-- GroupLocalServiceUtil.getCompanyGroup(PortalUtil.getDefaultCompanyId()).getGroupId(); -->
319
320<#-- Renders the print title -->
321<#-- pTitle: The default document title -->
322<#-- pPrintTitle: The print title of the document -->
323<#macro selectTitle pTitle pPrintTitle>
324 <#if pPrintTitle?? && pPrintTitle.getData()?has_content && pPrintTitle.getData() != "">
325 ${pPrintTitle.getData()}
326 <#else>
327 ${pTitle}
328 </#if>
329</#macro>
330
331<#-- Renders a freestanding image -->
332<#-- paragraphImageAlignment: The alignment of the image in the paragraph that is set -->
333<#-- checkImageAlignment: Is the alignment constant that must be set in order to render the image in the following set -->
334<#-- paragraphImage: Image URL of the image to render -->
335<#-- paragraphImageCaption: The image caption of the image -->
336<#macro renderFreestandingImage
337imageAlignment
338checkImageAlignment
339marginDefault
340margin
341image
342imageCaption
343imageLink >
344
345
346 <#if (imageAlignment=checkImageAlignment) && image != "">
347 <#assign left = imageMargin(marginDefault, 1) />
348 <#assign top = imageMargin(marginDefault, 2) />
349 <#assign right = imageMargin(marginDefault, 3) />
350 <#assign bottom = imageMargin(marginDefault, 4) />
351
352 <#if imageMargin(margin, 1)?has_content >
353 <#assign left = imageMargin(margin, 1) />
354 </#if>
355 <#if imageMargin(margin, 2)?has_content >
356 <#assign top = imageMargin(margin, 2) />
357 </#if>
358 <#if imageMargin(margin, 3)?has_content >
359 <#assign right = imageMargin(margin, 3) />
360 </#if>
361 <#if imageMargin(margin, 4)?has_content >
362 <#assign bottom = imageMargin(margin, 4) />
363 </#if>
364 <#assign marginImg = "margin-left:" + left + "; margin-top: " + top + "; margin-right: " + right + "; margin-bottom: " + bottom + ";"/>
365
366 <#-- if the image has a link, then define the link string for the cell div -->
367 <#assign imglink="">
368 <#assign imglinkstyle="">
369 <#if imageLink?? && imageLink?has_content>
370 <#assign imglink="onclick=\"window.location='" + imageLink + "';\"">
371 <#assign imglinkstyle="cursor: pointer;">
372 </#if>
373
374 <div class="std-art-freestanding-image" style="${marginImg} ${imglinkstyle}" ${imglink}>
375
376 <#-- If the element has a link, then print a different string -->
377 <#-- Note: This link is redundant, but it could be needed for search machines (the cell link on the div is a javascript link)-->
378 <#if imageLink?? && imageLink?has_content>
379 <a href="${imageLink}"><img alt="${image}" src="${image}" /></a>
380 <#else>
381 <img alt="${image}" src="${image}" />
382 </#if>
383
384 <#if imageCaption?? && imageCaption?has_content>
385 <div class="std-art-img-caption-freestanding">${imageCaption}</div>
386 </#if>
387 </div>
388 </#if>
389</#macro>
390
391<#-- renderEmbeddedImage Renders an embedded image of a paragraph for opposite alignment alternatives -->
392<#-- paragraphImageAlignment: The image alignment that is set for the paragraph -->
393<#-- altImageAlignment1: The id of the first alternative for the image alignment that is handled by this macro -->
394<#-- altImageAlignment2: The id of the second alternative for the image alignment that is handled by this macro -->
395<#-- alignImg1: The actual css alignment for the first alternative alignment -->
396<#-- alignImg2: The actual css alignment for the second alternative alignment -->
397<#-- marginDefault1: The default margin settings for the first alternative image alignement -->
398<#-- marginDefault2: The default margin settings for the second alternative image alignement -->
399<#-- margin: The actually set margin settings for the set image aligments -->
400<#-- paragraphImage: The image url of the image -->
401<#-- paragraphImageCaption: The caption of the image -->
402<#macro renderEmbeddedImage
403imageAlignment
404altImageAlignment1
405altImageAlignment2
406alignImg1
407alignImg2
408marginDefault1
409marginDefault2
410margin
411image
412imageCaption
413imageLink
414>
415 <#if (imageAlignment = altImageAlignment1 || imageAlignment = altImageAlignment2) && image != "">
416 <#if imageAlignment=altImageAlignment1>
417 <#assign marginDefault = marginDefault1 />
418 <#assign alignImg = alignImg1 />
419 <#else>
420 <#assign marginDefault = marginDefault2 />
421 <#assign alignImg = alignImg2 />
422 </#if>
423
424 <#assign left = imageMargin(marginDefault, 1) />
425 <#assign top = imageMargin(marginDefault, 2) />
426 <#assign right = imageMargin(marginDefault, 3) />
427 <#assign bottom = imageMargin(marginDefault, 4) />
428
429 <#if imageMargin(margin, 1)?has_content >
430 <#assign left = imageMargin(margin, 1) />
431 </#if>
432 <#if imageMargin(margin, 2)?has_content >
433 <#assign top = imageMargin(margin, 2) />
434 </#if>
435 <#if imageMargin(margin, 3)?has_content >
436 <#assign right = imageMargin(margin, 3) />
437 </#if>
438 <#if imageMargin(margin, 4)?has_content >
439 <#assign bottom = imageMargin(margin, 4) />
440 </#if>
441
442 <#assign marginImg = "margin-left:" + left + "; margin-top: " + top + "; margin-right: " + right + "; margin-bottom: " + bottom + ";"/>
443 <#assign border="" />
444 <#assign innermargin="" />
445 <#-- only set a border and a second margin inside the border, if there is a caption -->
446
447 <#-- if the image has a link, then define the link string for the cell div -->
448 <#assign imglink="">
449 <#assign imglinkstyle="">
450 <#if imageLink?? && imageLink?has_content>
451 <#assign imglink="onclick=\"window.location='" + imageLink + "';\"">
452 <#assign imglinkstyle="cursor: pointer;">
453 </#if>
454
455 <div style="float: ${alignImg}; ${marginImg} ${imglinkstyle}" ${imglink}>
456 <div class="std-art-embedded-image" >
457 <div class="std-art-img-row">
458 <div class="std-art-img-cell">
459 <#-- If the element has a link, then print a different string -->
460 <#-- Note: This link is redundant, but it could be needed for search machines (the cell link on the div is a javascript link)-->
461 <#--<div class="magnify-img-link">-->
462 <#if imageLink?? && imageLink?has_content>
463 <a href="${imageLink}"><img alt="${image}" src="${image}" /></a>
464 <#else>
465 <img alt="${image}" src="${image}" />
466 </#if>
467 <#--</div>-->
468 </div>
469 </div>
470 <#if imageCaption?? && imageCaption?has_content>
471 <div class="std-art-img-caption-embedded">${imageCaption}</div>
472 </#if>
473
474 </div>
475 </div>
476 </#if>
477</#macro>
478
479<#-- This macro renders the slideshow -->
480<#macro renderSlideshow paragraphSlideshow slideshowNamespace>
481
482 <#assign hasImages = false >
483 <#if paragraphSlideshow?? && paragraphSlideshow?has_content>
484 <#list paragraphSlideshow.getChildren() as images>
485 <#list images.getSiblings() as image>
486 <#if image.getData()?? && image.getData()?has_content>
487 <#assign hasImages = true >
488 </#if>
489 </#list>
490 </#list>
491 </#if>
492
493 <#if hasImages>
494 <!-- Slideshow container -->
495 <div class="${slideshowNamespace}slideshow-container slideshow-container">
496 <#list paragraphSlideshow.getChildren() as images>
497 <#assign size = images.getSiblings()?size />
498 <#assign index = 0>
499 <#list images.getSiblings() as image>
500 <div class="${slideshowNamespace}mySlides mySlides">
501 <#assign index = index + 1/>
502 <div class="${slideshowNamespace}numbertext numbertext">${index} / ${size}</div>
503
504 <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>
505
506 <#list image.getChildren() as child>
507 <#if child.getName()?contains("slideshowImageCaption") && child.getData()??>
508 <#if child.getData()?has_content>
509 <div class="${slideshowNamespace}text text" onClick="toggleCaptions('${slideshowNamespace}')">${child.getData()}</div>
510 </#if>
511 </#if>
512 </#list>
513
514 </div>
515 </#list>
516 </#list>
517 <!-- Next and previous buttons -->
518 <a class="${slideshowNamespace}prev prev" onclick="plusSlides('${slideshowNamespace}',-1)">❮</a>
519 <a class="${slideshowNamespace}next next" onclick="plusSlides('${slideshowNamespace}',1)">❯</a>
520 <script>
521 captionsStatus['${slideshowNamespace}'] = 1;
522 slideIndex['${slideshowNamespace}'] = 1;
523 </script>
524 </div>
525 </#if>
526
527</#macro>
528
529<#-- This macro renders the youtube video -->
530<#macro renderYoutubeVideo paragraphYoutubeVideo>
531 <#if paragraphYoutubeVideo?? && paragraphYoutubeVideo?has_content>
532 <#assign url = paragraphYoutubeVideo.getData() />
533 <#if url?? && url?has_content && url?contains("v=") >
534 <#assign videoId = url?split("v=")[1]?split("&")[0] />
535 <#if videoId?? && videoId?has_content>
536 <div class="videoWrapper">
537 <iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
538 allowfullscreen="" frameborder="0"
539 src="https://www.youtube.com/embed/${videoId}">
540 </iframe>
541 </div>
542 </#if>
543 </#if>
544 </#if>
545</#macro>
546
547<#-- extracts the margin values for embedded images -->
548<#function imageMargin marginString index>
549 <#assign leftM = "" />
550 <#assign topM = "" />
551 <#assign rightM = "" />
552 <#assign bottomM = "" />
553 <#if marginString?? && marginString?has_content && marginString?is_string>
554 <#assign commaPos1 = -1 />
555 <#assign commaPos2 = -1 />
556 <#assign commaPos3 = -1 />
557 <#assign commaPos1 = marginString?index_of(",", 0) />
558 <#if commaPos1 gt -1 >
559 <#assign commaPos2 = marginString?index_of(",", commaPos1 + 1) />
560 <#assign leftM = marginString?substring(0, commaPos1) />
561 </#if>
562 <#if commaPos2 gt -1 >
563 <#assign topM = marginString?substring(commaPos1+1, commaPos2) />
564 <#assign commaPos3 = marginString?index_of(",", commaPos2 + 1) />
565 </#if>
566 <#if commaPos3 gt -1 >
567 <#assign rightM = marginString?substring(commaPos2+1, commaPos3) />
568 <#assign bottomM = marginString?substring(commaPos3+1, marginString?length) />
569 </#if>
570 </#if>
571 <#if index == 1>
572 <#return leftM >
573 <#elseif index == 2>
574 <#return topM >
575 <#elseif index == 3>
576 <#return rightM >
577 <#elseif index == 4>
578 <#return bottomM >
579 </#if>
580 <#return "" >
581</#function>
582
583<#function hasRightHandSideArticles articleList>
584 <#assign retVal = false />
585 <#if articleList?? && (articleList?size > 0) >
586 <#assign retVal = true />
587 </#if>
588 <#return retVal />
589</#function>
590
591<#function hasRightHandSideBoxes>
592 <#assign retVal = false />
593 <#if rightHandBox?? && (rightHandBox?size > 0) >
594 <#list rightHandBox.getSiblings() as curRightHandBox>
595 <#assign rightHandBoxTitle = "" />
596 <#assign rightHandBoxContent = "" />
597 <#list curRightHandBox.getChildren() as bchild>
598 <#if (bchild.getName()) == "rightHandBoxTitle" && bchild.getData()??>
599 <#assign rightHandBoxTitle = bchild.getData()/>
600 </#if>
601 <#if (bchild.getName()) == "rightHandBoxContent" && bchild.getData()??>
602 <#assign rightHandBoxContent = bchild.getData()/>
603 </#if>
604 </#list>
605 <#if rightHandBoxTitle != "" || rightHandBoxContent != "">
606 <#assign retVal = true />
607 </#if>
608 </#list>
609 </#if>
610 <#return retVal />
611</#function>
612
613<#function retrieveCurrentArticleAssetEntryId>
614<#--${log.info("-------------")}-->
615
616 <#assign JournalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService")>[$CURSOR$]${JournalArticleLocalService}
617
618 <#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService" ) />
619 <#assign assetLinkLocalService = serviceLocator.findService("com.liferay.asset.link.service.AssetLinkLocalService" ) />
620 <#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService" ) />
621 <#assign currentArticle = journalArticleLocalService.getArticle(getterUtil.getLong(groupId),.vars['reserved-article-id'].getData()) />
622 <#assign currentArticleResourcePrimKey = currentArticle.getResourcePrimKey() />
623 <#assign currentArticleAssetEntry = assetEntryLocalService.getEntry("com.liferay.journal.model.JournalArticle", currentArticleResourcePrimKey) />
624 <#assign currentArticleAssetEntryEntryId = currentArticleAssetEntry.getEntryId() />
625<#--${log.info("currentArticleAssetEntryEntryId:\t" + currentArticleAssetEntryEntryId)}-->
626 <#return currentArticleAssetEntryEntryId />
627</#function>
628
629<#function retrieveRightHandSideArticles>
630 <#assign currentArticleAssetEntryEntryId = retrieveCurrentArticleAssetEntryId() />
631 <#assign currentArticleRelatedLinks = assetLinkLocalService.getDirectLinks(currentArticleAssetEntryEntryId) />
632 <#assign currentArticleRelatedLinksSorted = currentArticleRelatedLinks?sort_by("linkId") />
633 <#return currentArticleRelatedLinksSorted />
634</#function>
635
636<#macro renderRightHandSideArticles articleList>
637 <#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService" ) />
638
639<#-- article is of type AssetLink -->
640 <#list articleList as article>
641
642 <#assign currentArticleAssetEntryId = retrieveCurrentArticleAssetEntryId() />
643 ${log.debug("Resolving asset links for article: " + currentArticleAssetEntryId)}
644
645 <#-- An asset Link has 2 ID's, source (id1) and destination (id2) -->
646 <#assign linkedAssetEntryId = article.getEntryId2() />
647 ${log.debug("Resolving asset link: " + article.getEntryId1() + " -> " + article.getEntryId2())}
648
649 <#-- or in other words, if id1 == id2 -->
650 <#if linkedAssetEntryId == currentArticleAssetEntryId>
651 <h1>Prevented a recursion, please use another right hand side article </h1>
652 ${log.error("Article with ID " + currentArticleAssetEntryId + " tried to include Article with ID " + linkedAssetEntryId)}
653 <#break />
654 </#if>
655
656 <#-- if the linked asset entry is not the same type as the current asset entry, then complain and goto next -->
657 <#if assetEntryLocalService.getEntry(linkedAssetEntryId).getClassNameId() != assetEntryLocalService.getEntry(currentArticleAssetEntryId).getClassNameId()>
658 <h1>Can only have right hand side articles of type ${assetEntryLocalService.getEntry(currentArticleAssetEntryId).getClassName()} </h1>
659 ${log.error("Invalid right hand side article type " + assetEntryLocalService.getEntry(linkedAssetEntryId).getClassNameId() + ", ignoring")}
660 <#break />
661 </#if>
662
663 <#-- get the linked asset entry -->
664 <#assign linkedAssetEntry = assetEntryLocalService.getEntry(linkedAssetEntryId) />
665 <#assign linkedAssetEntryPrimaryKey = linkedAssetEntry.getClassPK() />
666 <#assign linkedArticle = journalArticleLocalService.getLatestArticle(linkedAssetEntryPrimaryKey) />
667
668 <#-- check if the linked article is of type STANDARD-ARTICLE or NEWS-ARTICLE to prevent recursion -->
669 <#assign linkedArticleStructureKey = linkedArticle.getDDMStructureKey() />
670 ${log.debug("Found RHS article with template id " + linkedArticleStructureKey)}
671 <#if linkedArticleStructureKey?contains("STANDARD-ARTICLE") || linkedArticleStructureKey?contains("NEWS-ARTICLE") >
672 <h1>RHS article type ${linkedArticleStructureKey} not allowed</h1>
673 ${log.error("Invalid RHS article " + linkedArticleStructureKey + ", ignoring")}
674 <#break />
675 </#if>
676
677 <#-- global counter for the right hand side boxes and realted assets -->
678 <#if rcount != 0>
679 <hr/>
680 </#if>
681
682 <#assign groupId = linkedArticle.getGroupId() />
683 <#assign articleId = linkedArticle.getArticleId() />
684
685 <div class="std-art-rhs-article">
686 ${journalArticleLocalService.getArticleDisplay(groupId, articleId, "", locale, themeDisplay).getContent()}
687 </div>
688 <#-- global counter for the right hand side boxes and realted assets -->
689 <#assign rcount = rcount + 1 />
690 </#list>
691</#macro>
692
693<#macro renderRightHandSideBoxes>
694 <#if rightHandBox.getSiblings()?has_content>
695 <#list rightHandBox.getSiblings() as curRightHandBox>
696 <#assign rightHandBoxTitle = "" />
697 <#assign rightHandBoxContent = "" />
698
699 <#list curRightHandBox.getChildren() as bchild>
700 <#if (bchild.getName()) == "rightHandBoxTitle" && bchild.getData()??>
701 <#assign rightHandBoxTitle = bchild.getData()/>
702 </#if>
703 <#if (bchild.getName()) == "rightHandBoxContent" && bchild.getData()??>
704 <#assign rightHandBoxContent = bchild.getData()/>
705 </#if>
706 </#list>
707
708 <#if rightHandBoxTitle != "" || rightHandBoxContent != "">
709 <#-- global counter for the right hand side boxes and realted assets -->
710 <#if rcount != 0>
711 <hr/>
712 </#if>
713 <div class="std-art-rhs-box">
714 <#if rightHandBoxTitle?? && rightHandBoxTitle != "">
715 <div class="std-art-rhs-box-title">
716 ${rightHandBoxTitle}
717 </div>
718 </#if>
719 <#if rightHandBoxContent?? && rightHandBoxContent != "">
720 <div class="std-art-rhs-box-content">
721 ${rightHandBoxContent}
722 </div>
723 </#if>
724 </div>
725 <#-- global counter for the right hand side boxes and realted assets -->
726 <#assign rcount = rcount + 1 />
727 </#if>
728
729 </#list>
730 </#if>
731</#macro>
732
733<#-- returns true only if the value is declared and defined true -->
734<#function isNotTrue value >
735 <#assign retVal = false />
736 <#if value??>
737 <#if value?has_content>
738 <#if value?is_hash>
739 <#if getterUtil.getBoolean(value.getData()) >
740 <#assign retVal = true />
741 </#if>
742 </#if>
743 </#if>
744 </#if>
745 <#return retVal />
746</#function>
747
748<#-- java script of the article -->
749<#macro javaScriptOfStandardArticle>
750
751 <script>
752
753 var slideIndex = {};
754 var captionsStatus = {};
755
756 function initSlides() {
757 let namespaces = Object.keys(slideIndex);
758 for(let i = 0; i < namespaces.length;i++) {
759 showSlides(namespaces[i],slideIndex[namespaces[i]]);
760 }
761 }
762
763 // Next previous controls
764 function plusSlides(namespace,n) {
765 showSlides(namespace,slideIndex[namespace] += n);
766 }
767
768 // Thumbnail image controls
769 function currentSlide(n) {
770 showSlides(namespace,slideIndex[namespace] = n);
771 }
772
773 function toggleCaptions(namespace) {
774 if(captionsStatus[namespace] == 1) {
775 console.log("Captions off");
776 captionsStatus[namespace] = 0;
777 } else {
778 console.log("Captions on");
779 captionsStatus[namespace] = 1;
780 }
781 updateCaptions(namespace);
782 }
783
784 function captionsOn(namespace) {
785 captionsStatus[namespace] = 1;
786 updateCaptions(namespace);
787 }
788
789 function captionsOff(namespace) {
790 captionsStatus[namespace] = 1;
791 updateCaptions(namespace);
792 }
793
794 function updateCaptions(namespace) {
795 var captions = document.getElementsByClassName(namespace+"text");
796 for (i = 0; i < captions.length; i++) {
797 if(captionsStatus[namespace] == 1) {
798 captions[i].style.display = "block";
799 } else {
800 captions[i].style.display = "none";
801 }
802 }
803 }
804
805 function showSlides(namespace,n) {
806 var i;
807 var slides = document.getElementsByClassName(namespace+"mySlides");
808 if(slides.length == 0) {
809 return;
810 }
811
812 if (n > slides.length) {
813 slideIndex[namespace] = 1;
814 }
815
816 if (n < 1) {
817 slideIndex[namespace] = slides.length;
818 }
819
820 for (i = 0; i < slides.length; i++) {
821 slides[i].style.display = "none";
822 }
823 slides[slideIndex[namespace]-1].style.display = "block";
824 captionsOn(namespace);
825
826 }
827
828 AUI().ready(function(A) {
829 initSlides();
830 });
831
832 </script>
833</#macro>
-
Teilen