Ejemplo n.º 1
0
 /**
  * @param bool $bool
  * @param bool $showFalse
  * @return string
  */
 public static function getImageTagForBoolean($bool, $showFalse = true)
 {
     $out = "";
     if ($bool) {
         $out = Html::img(Yii::$app->homeUrl . 'images/ok-16.png', ['alt' => hLib::t('labels', 'yes')]);
     } else {
         if ($showFalse) {
             $out = Html::img(Yii::$app->homeUrl . 'images/ko-16.png', ['alt' => hLib::t('labels', 'no')]);
         }
     }
     return $out;
 }
Ejemplo n.º 2
0
 /**
  * @return array
  */
 public function attributeLabels()
 {
     return ['title' => hLib::t('labels', 'Title'), 'body' => hLib::t('labels', 'Text'), 'tagId' => HCms::t('labels', 'Tag')];
 }
Ejemplo n.º 3
0
    </div>

    <div class="col-sm-3">
        <?php 
echo Html::activeLabel($model, 'body', ['class' => 'control-label']);
?>
        <?php 
echo Html::activeTextInput($model, 'body', ['class' => 'form-control']);
?>
    </div>

    <div class="col-sm-3">
        <?php 
echo Html::activeLabel($model, 'tagId', ['class' => 'control-label']);
?>
        <?php 
echo Html::activeDropDownList($model, 'tagId', $tags, ['class' => 'form-control', 'prompt' => '']);
?>
    </div>

    <div class="col-sm-3">
        <?php 
echo Html::submitButton(hLib::t('labels', 'All'), ['class' => 'btn btn-default search-button', 'name' => 'action[clear]']);
?>
        <?php 
echo Html::submitButton(hLib::t('labels', 'Search'), ['class' => 'btn btn-primary search-button', 'name' => 'action[submit]']);
?>
    </div>
</div>
<?php 
ActiveForm::end();
Ejemplo n.º 4
0
 /**
  * Traitement d'une recherche en frontend et affichage des résultats
  *
  * @return mixed
  */
 public function actionPostSearch()
 {
     $model = new WebNewsSearch();
     /** @var array $request [WebNewsSearch[...], action[submit|clear]] */
     $request = Yii::$app->request->isPost ? Yii::$app->request->post() : Yii::$app->request->get();
     if (isset($request['action']['clear'])) {
         // Suppression des filtres
         $model->deleteFiltersInSession();
         $request = [];
     }
     // Activation des filtres
     $request['status'] = 1;
     if ($model->load($request) && $model->validate()) {
         ArrayHelper::remove($request, '_csrf');
         ArrayHelper::remove($request, 'action');
         $model->storeFiltersInSession($request);
     } else {
         Yii::$app->session->setFlash('flash-warning', hLib::t('messages', 'There are errors in your form'));
     }
     return $this->redirect(Url::to(['/cms/web-news/display-search-results', 'page' => 1]));
 }