public function loadModel($id)
 {
     if (($model = MainPageBlock::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
Ejemplo n.º 2
0
 public function run()
 {
     $block = MainPageBlock::model()->with('children')->find('t.code = :code', array(':code' => $this->code));
     if (null === $block && $this->silent === false) {
         throw new CException(Yii::t('BlockModule.block', 'Блок "{code}" не найден!', array('{code}' => $this->code)));
     }
     $this->view = empty($block->template) ? $this->view : $block->template;
     $this->render($this->view, array('model' => $block));
 }
Ejemplo n.º 3
0
 /**
  * Отображение главной страницы
  *
  * @return void
  */
 public function actionIndex()
 {
     // Загружаем главную страницу
     Yii::import("application.modules.page.models.Page");
     $page = Page::model()->findByPath("index");
     // Страница не найдена
     if ($page === null) {
         throw new CHttpException('404', Yii::t('PageModule.page', 'Страница не найдена'));
     }
     // Список блоков
     Yii::import("application.modules.block.models.MainPageBlock");
     $blocks = MainPageBlock::model()->published()->root()->findAll();
     // Список программ
     Yii::import("application.modules.classroom.models.*");
     $programs = Course::model()->published()->subscribeEnabled()->with(array('images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->findAll(array('order' => 't.sort ASC'));
     $this->render('index', array('page' => $page, 'blocks' => $blocks, 'programs' => $programs));
 }
Ejemplo n.º 4
0
<?php

if (!$model->disable_banner_course) {
    ?>

<?php 
    $topBanner = '';
    if ($model->use_main_page_banner) {
        Yii::import("application.modules.block.models.MainPageBlock");
        $topBannerBlock = MainPageBlock::model()->find('t.code = :code', array(':code' => 'top-banner'));
        if ($topBannerBlock) {
            $topBanner = $topBannerBlock->imageUrl;
        }
    } elseif ($model->banner_course != '') {
        $topBanner = $model->bannerCourseUpload->imageUrl;
    }
    ?>

<?php 
    if ($topBanner != '') {
        ?>
<div class="top-banner" style="background-image: url(<?php 
        echo $topBanner;
        ?>
);"></div>
<?php 
    }
    ?>

<?php 
}
Ejemplo n.º 5
0
echo $model->hasErrors('parent_id') ? 'error' : '';
?>
">
        <div class="span3">
        <?php 
if (!$model->isNewRecord) {
    ?>
        <?php 
    echo $form->dropDownListRow($model, 'parent_id', array_diff_key(MainPageBlock::model()->root()->getTabList(), $model->root()->getAssocList()), array('class' => 'span7 popover-help', 'empty' => 'Выберите', 'encode' => false));
    ?>
  
        <?php 
} else {
    ?>
        <?php 
    echo $form->dropDownListRow($model, 'parent_id', MainPageBlock::model()->root()->getTabList(), array('class' => 'span7 popover-help', 'empty' => 'Выберите', 'encode' => false));
    ?>
          
        <?php 
}
?>
        </div>     
    </div>

    <div class="row-fluid control-group <?php 
echo $model->hasErrors('title') ? 'error' : '';
?>
">
        <?php 
echo $form->textFieldRow($model, 'title', array('size' => 60, 'maxlength' => 150, 'class' => 'span7 popover-help', 'data-original-title' => $model->getAttributeLabel('title'), 'data-content' => $model->getAttributeDescription('title')));
?>