<?php

class TextPageController extends NodePageController
{
    public function actionIndex()
    {

        /** @var $textSection TextPage */
        $textPage = TextPage::model()->with('i18n')->findByPk($this->getNode()->data_id);

        /** @var $textSection TextPage */
        $textSection = TextPage::model()->with('i18n')->findByPk($this->getSectionNode()->data_id);

        /** @var $textRoot TextPage */
        $textRoot = TextPage::model()->with('i18n')->findByPk($this->getRootNode()->data_id);
        $this->pageName = $textPage->i18n->page_name;
        $this->setSEOParams($textPage->i18n->title, $textPage->i18n->keywords, $textPage->i18n->description);
        $this->setContacts(explode(',', $textPage->contacts_data));
        $this->setContacts(explode(',', $textSection->contacts_data));
        $this->setContacts(explode(',', $textRoot->contacts_data));

        if ($textSection->galleryBehavior->getGalleryPhotoCount() == 0)
            $this->headerGalleryId = $textRoot->header_gallery_id;
        else
            $this->headerGalleryId = $textSection->header_gallery_id;

        $this->sectionGalleryId = $textPage->header_gallery_id;

        $this->render('index', array(
            'content' => $textSection->i18n->content,
        ));
    }
}
