Skip to content
Code-Schnipsel Gruppen Projekte
Timeline.php 1,86 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    /**
     * This file contains QUI\Timeline\Bricks\Timeline
     */
    
    namespace QUI\Timeline\Bricks;
    
    use QUI;
    
    /**
     * Class Timeline
     *
     * @package quiqqer/timeline
     */
    class Timeline extends QUI\Control
    {
    
        /**
         * constructor
         *
         * @param array $attributes
         */
        public function __construct($attributes = [])
        {
            // default options
            $this->setAttributes([
    
                'imageFillMode'     => 'cover', // cover, fill
    
                'order'     => 'c_date ASC',
                'showLinks' => true,
                'template'  => 'VerticalBothSides',
                'limit'     => 10
    
            ]);
    
            parent::__construct($attributes);
    
            $this->setAttribute('cacheable', 0);
        }
    
        /**
         * Return the inner body of the element
         * Can be overwritten
         *
         * @return String
         */
    
        public function getBody(): string
    
            $Engine  = QUI::getTemplateManager()->getEngine();
    
            $Control = new QUI\Timeline\Controls\Timeline();
    
    
            $limit = $this->getAttribute('limit');
    
            if ($limit === '') {
                $limit = 10;
            }
    
            if ($limit <= 0) {
                $limit = 1;
            }
    
    
            $Control->setAttribute('parentInputList', $this->getAttribute('site'));
    
            $Control->setAttribute('imageFillMode', $this->getAttribute('imageFillMode'));
    
            $Control->setAttribute('order', $this->getAttribute('order'));
    
            $Control->setAttribute('showLinks', $this->getAttribute('showLinks'));
    
            $Control->setAttribute('display', $this->getAttribute('template'));
            $Control->setAttribute('limit', $limit);
    
            $html = $Control->create();
    
    
            $this->addCSSFiles($Control->getCSSFiles());
    
            $options = [
    
                'this' => $this,
                'timelineHtml' => $html
    
            ];
    
            $Engine->assign($options);
    
            return $Engine->fetch(\dirname(__FILE__) . '/Timeline.html');
        }