Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Faq::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['faq_id' => $this->faq_id, 'faq_show_on_main' => $this->faq_show_on_main]);
     $query->andFilterWhere(['like', 'faq_title', $this->faq_title])->andFilterWhere(['like', 'faq_text', $this->faq_text])->andFilterWhere(['like', 'faq_language', $this->faq_language]);
     return $dataProvider;
 }
Example #2
0
use vladkukushkin\faq\models\Faq;
use vladkukushkin\faq\Module;
/* @var $this yii\web\View */
/* @var $searchModel vladkukushkin\faq\models\search\FaqSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('faq', 'FREQUENTLY_ASKED_QUESTIONS');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="faq-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Module::t('faq', 'Create'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'faq_id', 'faq_title', ['attribute' => 'faq_text', 'format' => 'raw'], ['attribute' => 'faq_show_on_main', 'value' => function ($model) {
    return Faq::getVisibleOnMain()[$model->faq_show_on_main];
}, 'filter' => Faq::getVisibleOnMain()], ['attribute' => 'faq_language', 'filter' => Faq::getLanguageFilter()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Example #3
0
 public function run()
 {
     $models = Faq::find()->where(['faq_language' => \Yii::$app->language])->asArray()->all();
     return $this->render($this->viewPath, ['models' => $models, 'id' => $this->id, 'title' => $this->title, 'breadcrumbs' => $this->breadcrumbs]);
 }
Example #4
0
<div class="faq-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'faq_title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'faq_text')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['lang' => Yii::$app->controller->module->imperaviLanguage, 'minHeight' => 200, 'paragraphize' => false, 'cleanOnPaste' => false, 'replaceDivs' => false, 'linebreaks' => false, 'plugins' => ['fullscreen', 'imagemanager'], 'imageUpload' => Url::to(['/faq/default/image-upload']), 'imageManagerJson' => Url::to(['/faq/default/images-get'])]]);
?>

    <?php 
echo $form->field($model, 'faq_show_on_main')->dropDownList(Faq::getVisibleOnMain());
?>
    <?php 
echo $form->field($model, 'faq_language')->dropDownList([Yii::$app->language => Yii::$app->language]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('faq', 'Create') : Module::t('faq', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #5
0
use yii\widgets\DetailView;
use vladkukushkin\faq\models\Faq;
use vladkukushkin\faq\Module;
/* @var $this yii\web\View */
/* @var $model vladkukushkin\faq\models\Faq */
$this->title = $model->faq_title;
$this->params['breadcrumbs'][] = ['label' => Module::t('faq', 'FREQUENTLY_ASKED_QUESTIONS'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="faq-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Module::t('faq', 'Update'), ['update', 'id' => $model->faq_id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Module::t('faq', 'Delete'), ['delete', 'id' => $model->faq_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['faq_id', 'faq_title', ['attribute' => 'faq_text', 'format' => 'raw'], ['attribute' => 'faq_show_on_main', 'value' => Faq::getVisibleOnMain()[$model->faq_show_on_main]], 'faq_language']]);
?>

</div>
 /**
  * Finds the Faq model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Faq the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Faq::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }