<?php
class ReviewsController extends NodeSiteController
{
    public function actionIndex()
    {
        /** @var $reviewsRoot ReviewsRoot */
        $reviewsRoot = ReviewsRoot::model()->with('i18n')->findByPk($this->getNode()->data_id);
        
        $this->pageName = $reviewsRoot->i18n->page_name;
        $this->setSEOParams($reviewsRoot->i18n->title, $reviewsRoot->i18n->keywords, $reviewsRoot->i18n->description);

        
        $this->setContacts(explode(',', $reviewsRoot->contacts_data));

        
        $reviews = Review::model()->with('i18n')->findAll(array(
            'order' => 'date desc',
            'condition' => 'reviews_root_id = ' . $this->getNode()->data_id
        ));
        $this->headerGalleryId = $reviewsRoot->header_gallery_id;
        $this->render('index', array(
            'sidebar' => $reviewsRoot->i18n->sidebar_content,
            'reviews' => $reviews,
        ));
    }
}
