Skip to content
Code-Schnipsel Gruppen Projekte
IntervieweeData.php 3,28 KiB
Newer Older
  • Learn to ignore specific revisions
  •  * This file contains \QUI\Interview\Controls\IntervieweeData
    
    use QUI\Exception;
    
     * Class IntervieweeData
    
     * @package quiqqer/interview
     *
    
    class IntervieweeData extends QUI\Control
    
    {
        /**
         * constructor
         *
         * @param array $attributes
         */
        public function __construct($attributes = [])
        {
    
            // default options
            $this->setAttributes([
                'class'    => 'quiqqer-interview-control-interviewee',
                'template' => 'largeImageTop' // template
            ]);
    
    
            $this->addCSSFile(dirname(__FILE__) . '/IntervieweeData.css');
    
            $this->setAttribute('cacheable', "0");
    
        public function getBody(): string
    
        {
            $Engine = QUI::getTemplateManager()->getEngine();
            $Site   = $this->getSite();
    
            if (
                $Site->getAttribute("type") !== 'quiqqer/blog:blog/entry' &&
                $Site->getAttribute("type") !== 'quiqqer/news:news/entry'
            ) {
    
            switch ($this->getAttribute('template')) {
    
                    $html = '/IntervieweeData.LargeImageLeft.html';
    
                    $html = '/IntervieweeData.SmallImageLeft.html';
    
                    $html = '/IntervieweeData.LargeImageTop.html';
    
            try {
                $intervieweeData = $this->getIntervieweeData();
            } catch (Exception $Exception) {
                QUI\System\Log::addInfo($Exception->getMessage());
    
    
                'this'           => $this,
                'name'           => $intervieweeData['name'],
                'additionalInfo' => $intervieweeData['additionalInfo'],
                'avatar'         => $intervieweeData['avatar'],
                'description'    => $intervieweeData['description']
    
            $Engine->assign('controlTemplate', $Engine->fetch(dirname(__FILE__) . $html));
    
            return $Engine->fetch(dirname(__FILE__) . '/IntervieweeData.html');
    
        /**
         * Get intrerviewee data
         *
         * @return array
         * @throws Exception
         */
    
        private function getIntervieweeData()
        {
            $Site = $this->getSite();
    
            return [
    
                'name'           => $Site->getAttribute('quiqqer.interview.settings.intervieweeData.name'),
                'additionalInfo' => $Site->getAttribute('quiqqer.interview.settings.intervieweeData.additionalInfo'),
                'avatar'         => $Site->getAttribute('quiqqer.interview.settings.intervieweeData.avatar'),
                'description'    => $Site->getAttribute('quiqqer.interview.settings.intervieweeData.description')
    
        /**
         * @return mixed|QUI\Projects\Site
         *
         * @throws QUI\Exception
         */
        protected function getSite()
        {
            if ($this->getAttribute('Site')) {
                return $this->getAttribute('Site');
            }
    
            $Site = QUI::getRewrite()->getSite();
    
            $this->setAttribute('Site', $Site);
    
            return $Site;
        }
    }