forked from contao/contao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentAccordion.php
62 lines (51 loc) · 1.44 KB
/
ContentAccordion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/
namespace Contao;
use Contao\CoreBundle\Image\Studio\LegacyFigureBuilderTrait;
/**
* Front end content element "accordion".
*
* @author Leo Feyer <https://github.com/leofeyer>
*/
class ContentAccordion extends ContentElement
{
use LegacyFigureBuilderTrait;
/**
* Template
* @var string
*/
protected $strTemplate = 'ce_accordionSingle';
/**
* Generate the content element
*/
protected function compile()
{
// Clean the RTE output
$this->text = StringUtil::toHtml5($this->text);
$this->Template->text = StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
$this->Template->addBefore = false;
// Add an image
if ($this->addImage && null !== ($figureBuilder = $this->getFigureBuilderIfResourceExists($this->singleSRC)))
{
$figureBuilder
->setSize($this->size)
->setMetadata($this->objModel->getOverwriteMetadata())
->enableLightbox((bool) $this->fullsize)
->build()
->applyLegacyTemplateData($this->Template, $this->imagemargin, $this->floating);
}
$classes = StringUtil::deserialize($this->mooClasses);
$this->Template->toggler = $classes[0] ?: 'toggler';
$this->Template->accordion = $classes[1] ?: 'accordion';
$this->Template->headlineStyle = $this->mooStyle;
$this->Template->headline = $this->mooHeadline;
}
}
class_alias(ContentAccordion::class, 'ContentAccordion');