コード例 #1
0
 public function loadModel($id)
 {
     if (($model = FaqGroup::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
コード例 #2
0
 /**
  * FAQ
  */
 public function actionFaq()
 {
     // Загружаем страницу "FAQ"
     Yii::import("application.modules.page.models.Page");
     $page = Page::model()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC')))->findByPath("faq");
     // Список групп
     $groups = FaqGroup::model()->published()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC'), 'questions' => array('scopes' => array('answered', 'faq'), 'order' => 'questions.sort ASC')))->findAll(array('order' => 't.sort ASC'));
     /*
             $dataProvider = new CActiveDataProvider('Feedback', array('criteria'  => array(
        'condition' => 'type_id = :type_id AND (status = :sended OR status = :finished)',
        'params'    => array(
            ':type_id'  => $type->id,
            ':sended'   => Feedback::STATUS_ANSWER_SENDED,
            ':finished' => Feedback::STATUS_FINISHED,
        ),
        'order'     => 't.sort ASC',
             )));
     * 
     */
     $type = DictionaryData::model()->findByCode('feedback-faq');
     if (!$type) {
         throw new CHttpException(404);
     }
     $form = $this->_processForm($type);
     $this->render('faq', array('model' => $form, 'page' => $page, 'groups' => $groups));
 }
コード例 #3
0
 public function actionCopy()
 {
     exit;
     Yii::import('feedback.models.*');
     $faqGroups = FaqGroup::model()->findAll(array('order' => 't.id ASC'));
     foreach ($faqGroups as $key => $group) {
         $category = new FaqCategory();
         $category->id = $group->id;
         $category->title = $group->title;
         $category->sort = $group->sort * 10;
         $category->status = $group->status;
         $category->parent_id = 0;
         if ($category->save()) {
             echo $category->title . ' - success<br />';
         } else {
             echo $category->title . ' - error<br />';
             var_dump($category->getErrors());
         }
         echo '<hr>';
     }
 }
コード例 #4
0
 /**
  * Список групп:
  * 
  * @return array
  */
 public function getFaqGroupList()
 {
     return CHtml::listData(FaqGroup::model()->findAll(array('select' => 'id, title')), 'id', 'title');
 }