public function loadModel($id)
 {
     if (($model = FaqCategory::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
Ejemplo n.º 2
0
 /**
  * Запускаем отрисовку виджета
  *
  * @return void
  */
 public function run()
 {
     $categories = FaqCategory::model()->published()->with(array('questions' => array('scopes' => 'published')))->findAll(array('order' => 't.sort ASC'));
     if (empty($categories)) {
         return;
     }
     $this->render($this->view, array('categories' => $categories));
 }
Ejemplo n.º 3
0
 public function actionIndex()
 {
     $categoryId = $this->iGet('category_id', 1);
     $model = new Faq();
     $model->unsetAttributes();
     $model->category_id = $categoryId;
     $model->status = Faq::STATUS_SHOW;
     $categories = FaqCategory::getCategoryMenu();
     $this->title = Yii::t('common', 'Frequently Asked Questions');
     $this->pageTitle = array($this->title);
     if ($model->category) {
         $this->pageTitle = array($this->title, $model->category->getAttributeValue('name'));
     }
     $this->breadcrumbs = array('FAQ');
     $this->render('index', array('model' => $model, 'categories' => $categories));
 }
Ejemplo n.º 4
0
 public function actionIndex($path = '', $tag = null)
 {
     // Загружаем список категорий верхнего уровня
     $categories = FaqCategory::model()->root()->published()->findAll(array('order' => 't.sort ASC'));
     // Категория FAQ
     if ($path == '') {
         $category = !empty($categories) ? $categories[0] : null;
     } else {
         $category = FaqCategory::model()->published()->findByPath($path);
     }
     if (is_null($category)) {
         throw new CHttpException(404);
     }
     // Если выбран тег
     if ($tag !== null) {
         $questions = FaqQuestion::model()->withTag($tag)->published()->findAll(array('order' => 't.sort ASC'));
         $this->render('list', array('categories' => $categories, 'category' => $category, 'questions' => $questions, 'tag' => $tag));
     } else {
         $this->render('index', array('categories' => $categories, 'category' => $category));
     }
 }
Ejemplo n.º 5
0
 public function actionHideCategory()
 {
     $id = $this->iGet('id');
     $model = FaqCategory::model()->findByPk($id);
     if ($model === null) {
         $this->redirect(Yii::app()->request->urlReferrer);
     }
     $model->status = FaqCategory::STATUS_HIDE;
     $model->save();
     Yii::app()->user->setFlash('success', '隐藏FAQ分类成功');
     $this->redirect(Yii::app()->request->urlReferrer);
 }
Ejemplo n.º 6
0
 public function getCategoryList()
 {
     return CHtml::listData(FaqCategory::model()->findAll(array('select' => 'id, title')), 'id', 'title');
 }
Ejemplo n.º 7
0
        <span class="required">*</span>
        <?php 
echo Yii::t('FaqModule.faq', ' are required');
?>
    </div>

    <?php 
echo $form->errorSummary($model);
?>

    <div class='control-group <?php 
echo $model->hasErrors("parent_id") ? "error" : "";
?>
'>
        <?php 
$categories = !$model->isNewRecord ? array_diff_key(FaqCategory::model()->getTabList(), $model->getAssocList()) : FaqCategory::model()->getTabList();
?>
  
        <?php 
echo $form->dropDownListRow($model, 'parent_id', $categories, array('class' => 'span6', 'empty' => 'Корневая категория'));
?>
    </div>

    <div class='control-group <?php 
echo $model->hasErrors("title") ? "error" : "";
?>
'>
        <?php 
echo $form->textFieldRow($model, 'title', array('class' => 'span7', 'maxlength' => 250), array('label' => $model->getAttributeLabel('title')));
?>
    </div>
Ejemplo n.º 8
0
          <div class="portlet-body">
            <?php 
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('class' => 'clearfix row'), 'enableClientValidation' => true));
?>
            <?php 
echo Html::formGroup($model, 'title_zh', array('class' => 'col-lg-6'), $form->labelEx($model, 'title_zh', array('label' => '中文标题')), Html::activeTextField($model, 'title_zh'), $form->error($model, 'title_zh', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'title', array('class' => 'col-lg-6'), $form->labelEx($model, 'title', array('label' => '英文标题')), Html::activeTextField($model, 'title'), $form->error($model, 'title', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'date', array('class' => 'col-lg-6'), $form->labelEx($model, 'date', array('label' => '时间')), Html::activeTextField($model, 'date', array('class' => 'datetime-picker', 'data-date-format' => 'yyyy-mm-dd hh:ii:ss')), $form->error($model, 'date', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'category_id', array('class' => 'col-lg-6'), $form->labelEx($model, 'category_id', array('label' => '分类')), $form->dropDownList($model, 'category_id', FaqCategory::getCategories(), array('class' => 'form-control', 'prompt' => '')), $form->error($model, 'category_id', array('class' => 'text-danger')));
?>
            <div class="clearfix"></div>
            <?php 
echo Html::formGroup($model, 'content_zh', array('class' => 'col-lg-6'), $form->labelEx($model, 'content_zh', array('label' => '中文正文')), $form->textArea($model, 'content_zh', array('class' => 'editor form-control')), $form->error($model, 'content_zh', array('class' => 'text-danger')));
?>
            <?php 
echo Html::formGroup($model, 'content', array('class' => 'col-lg-6'), $form->labelEx($model, 'content', array('label' => '英文正文')), $form->textArea($model, 'content', array('class' => 'editor form-control')), $form->error($model, 'content', array('class' => 'text-danger')));
?>
            <div class="col-lg-12">
              <button type="submit" class="btn btn-default btn-square"><?php 
echo Yii::t('common', 'Submit');
?>
</button>
            </div>
            <?php 
Ejemplo n.º 9
0
 public function getList()
 {
     return CHtml::listData(FaqCategory::model()->findAll(), 'id', 'title');
 }
Ejemplo n.º 10
0
<?php

$this->widget('yupe\\widgets\\OGridView', array('id' => 'question-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('style' => 'width:20px')), array('name' => 'question', 'type' => 'raw', 'value' => '$data->question'), array('name' => 'answer', 'type' => 'raw', 'value' => '$data->answer'), array('name' => 'category_id', 'type' => 'raw', 'value' => '$data->categoryTitle', 'filter' => FaqCategory::model()->getTabList()), array('name' => 'sort', 'class' => 'yupe.widgets.CustomEditableColumn', 'htmlOptions' => array('style' => 'width:200px'), 'editable' => array('placement' => 'right', 'success' => 'js: function(response, newValue) {
                    $.fn.yiiGridView.update("question-grid"); 
                }'), 'htmlOptions' => array('style' => 'width:130px; text-align: center')), array('name' => 'status', 'type' => 'raw', 'value' => '$this->grid->returnBootstrapStatusHtml($data, "status", "Status", array("pencil", "ok-sign"))', 'filter' => $model->getStatusList(), 'htmlOptions' => array('style' => 'width:80px')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}{delete}', 'htmlOptions' => array('style' => 'width:110px')))));
Ejemplo n.º 11
0
        <?php 
echo Yii::t('FaqModule.faq', ' are required');
?>
    </div>

    <?php 
echo $form->errorSummary($model);
?>

    <div class="row-fluid control-group">
        <div class="span3 <?php 
echo $model->hasErrors('category_id') ? 'error' : '';
?>
">
            <?php 
$categoryList = FaqCategory::model()->getTabList();
echo $form->dropDownListRow($model, 'category_id', $categoryList, array('empty' => 'Выберите категорию'));
?>
        </div>
        <div class="span3 <?php 
echo $model->hasErrors('status') ? 'error' : '';
?>
">
            <?php 
echo $form->dropDownListRow($model, 'status', $model->statusList);
?>
        </div>
    </div>

    <div class="row-fluid control-group <?php 
echo $model->hasErrors('question') ? 'error' : '';
Ejemplo n.º 12
0
<div class="row">
  <div class="col-lg-12">
    <div class="portlet portlet-default">
      <div class="portlet-heading">
          <div class="portlet-title">
              <h4>FAQ列表</h4>
          </div>
          <div class="clearfix"></div>
      </div>
      <div class="panel-collapse collapse in">
        <div class="portlet-body">
          <?php 
$this->widget('GridView', array('dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('header' => '操作', 'type' => 'raw', 'value' => '$data->operationButton'), 'id', array('name' => 'user_id', 'value' => '$data->user->name_zh', 'filter' => false), array('name' => 'category_id', 'filter' => FaqCategory::getCategories(), 'value' => '$data->category->name_zh'), 'title_zh', array('name' => 'date', 'type' => 'raw', 'value' => 'date("Y-m-d H:i:s", $data->date)', 'filter' => false), array('name' => 'status', 'type' => 'raw', 'value' => '$data->getStatusText()', 'filter' => Faq::getAllStatus()))));
?>
        </div>
      </div>
    </div>
  </div>
</div>