Пример #1
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param string $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AuthUser::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(HLib::t('messages', 'The requested page does not exist'));
     }
 }
Пример #2
0
 /**
  * @return string
  * @throws InvalidConfigException
  */
 public function run()
 {
     if (!isset($this->url)) {
         throw new InvalidConfigException(HLib::t('messages', 'The URL for the delete action is mandatory'));
     }
     $text = isset($this->text) ? $this->text : HLib::t('messages', 'Are you sure you want to delete this item?');
     if (isset($this->data)) {
         $text .= "\n" . $this->data;
     }
     return $this->render('deleteLink', ['url' => $this->url, 'text' => $text]);
 }
Пример #3
0
 /**
  * Updates an existing BaseNews model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (Yii::$app->request->isPost) {
         $post = Yii::$app->request->post();
         if (!($model->updateBaseTagsFromRequest($post) && $model->load($post) && $model->save(true, null, true))) {
             Yii::$app->session->setFlash('flash-warning', HLib::t('messages', 'There are errors in your form'));
         } else {
             return $this->redirect(Url::to(['/cms/web-news/index']));
         }
     }
     // Affichage initial ou ré-affichage en cas d'erreur
     return $this->render('update', compact('model'));
 }
Пример #4
0
 /**
  * Updates an existing BaseTag model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (Yii::$app->request->isPost) {
         if (!($model->load(Yii::$app->request->post()) && $model->save())) {
             Yii::$app->session->setFlash('flash-warning', HLib::t('messages', 'There are errors in your form'));
         } else {
             Yii::$app->session->setFlash('flash-success', HLib::t('messages', 'Update successful'));
             return $this->redirect(Url::to(['/cms/web-tags/index']));
         }
     }
     // Affichage ou ré-affichage
     return $this->render('update', compact('model'));
 }
Пример #5
0
 /**
  * Suppression d'un objet
  * Cette méthode renvoie un objet de type Response. Elle doit être appelée sur un return comme la méthode redirect() de la classe
  * Controller. Ex. : return $this->redirectAfterCreateSuccess($model)
  *
  * @param ActiveRecord $model
  * @param string|null  $redirectTo
  * @return \yii\web\Response
  */
 protected function deleteModelAndRedirect(ActiveRecord $model, $redirectTo = null)
 {
     try {
         if (!$model->delete()) {
             Yii::$app->session->setFlash('flash-danger', HLib::t('messages', 'Delete unsuccessful'));
         } else {
             Yii::$app->session->setFlash('flash-success', HLib::t('messages', 'Delete successful'));
         }
     } catch (StaleObjectException $s) {
         Yii::$app->session->setFlash('flash-warning', HLib::t('messages', 'This object is outdated. Deletion failed'));
     } catch (IntegrityException $s) {
         Yii::$app->session->setFlash('flash-warning', HLib::t('messages', 'This object is referenced by another object. Deletion failed'));
     } catch (Exception $s) {
         Yii::$app->session->setFlash('flash-danger', HLib::t('messages', 'An error occured during the process. Deletion failed'));
     }
     if (is_null($redirectTo)) {
         $redirectTo = Url::to([$this->getControllerRoute() . '/index']);
     }
     return $this->redirect($redirectTo);
 }
Пример #6
0
 /**
  * Runs the action
  *
  * @return string result content
  */
 public function run()
 {
     if (($exception = Yii::$app->getErrorHandler()->exception) === null) {
         // action has been invoked not from error handler, but by direct route, so we display '404 Not Found'
         $exception = new HttpException(404, Yii::t('yii', 'Page not found.'));
     }
     if ($exception instanceof HttpException) {
         $code = $exception->statusCode;
     } else {
         $code = $exception->getCode();
     }
     if ($exception instanceof Exception) {
         $name = $exception->getName();
     } else {
         $name = $this->defaultName ?: Yii::t('yii', 'Error');
     }
     if ($code) {
         $name .= " (#{$code})";
     }
     if ($exception instanceof UserException) {
         $message = $exception->getMessage();
     } else {
         $message = $this->defaultMessage ?: HLib::t('messages', 'An error occurred during the process');
     }
     if (Yii::$app->getRequest()->getIsAjax()) {
         // Requête AJAX : on renvoie juste de quoi identifier l'erreur
         return "{$name}: {$message}";
     }
     // Le modèle de page utilisé dépend du code de l'erreur. Par défaut, c'est 'error.php'
     switch ($code) {
         case '404':
             $this->view = 'error404';
             break;
         default:
             break;
     }
     return $this->controller->render($this->view ?: $this->id, compact('name', 'message', 'exception'));
 }
Пример #7
0
                                <?php 
        echo GridListActionButtons::widget(['controllerRoute' => '/cms/web-tags', 'modelId' => $model->id, 'deleteMessageData' => $model->label]);
        ?>
                            </div>
                        </div>
                    </li>
                <?php 
    }
    ?>
            </ul>

            <?php 
    echo LinkPager::widget(['pagination' => $dataProvider->getPagination()]);
    ?>
        <?php 
}
?>

    </div>

    <div class="panel-footer">
        <!--suppress HtmlUnknownTag -->
        <info>
            <?php 
echo HLib::t('messages', 'There {n, plural, =0{are no results} =1{is one results} other{are # results} fitting your search criteria}', ['n' => $count]);
?>
        </info>
    </div>

</div>
Пример #8
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => HLib::t('labels', 'ID'), 'name' => HLib::t('labels', 'Name'), 'description' => HLib::t('labels', 'Description'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #9
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => HLib::t('labels', 'ID'), 'title' => HLib::t('labels', 'Title'), 'menu_title' => HCms::t('labels', 'Menu title'), 'meta_description' => HCms::t('labels', 'Meta Description'), 'meta_keywords' => HCms::t('labels', 'Meta Keywords'), 'base_id' => HCms::t('labels', 'Base page'), 'language_id' => HCms::t('labels', 'Language'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #10
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => HLib::t('labels', 'ID'), 'email' => HUsers::t('labels', 'Email'), 'name' => HUsers::t('labels', 'Name'), 'password' => HUsers::t('labels', 'Password'), 'password_repeat' => HUsers::t('labels', 'Repeat Password'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #11
0
 * @var string $viewUrl
 * @var string $deleteUrl
 * @var string $deleteMessageData
 */
?>

<a href="<?php 
echo $updateUrl;
?>
" class="btn btn-success btn-xs" title="<?php 
echo HLib::t('labels', 'Edit');
?>
">
    <span class="glyphicon glyphicon-pencil"></span>
</a>

<a href="<?php 
echo $viewUrl;
?>
" class="btn btn-info btn-xs" title="<?php 
echo HLib::t('labels', 'View');
?>
">
    <span class="glyphicon glyphicon-eye-open"></span>
</a>

<?php 
echo DeleteLink::widget(['url' => $deleteUrl, 'data' => $deleteMessageData]);
?>

Пример #12
0
<?php

/**
 * Accès au lien vers la page de visualisation du modèle
 *
 * @var $url string
 * @deprecated
 */
use app\modules\hlib\HLib;
?>
<a href="<?php 
echo $url;
?>
" class="btn btn-info btn-xs" title="<?php 
echo HLib::t('labels', 'Show');
?>
">
    <span class="glyphicon glyphicon-eye-open"></span>
</a>

Пример #13
0
 /**
  * Met à jour la liste des index de menus. Ceux-ci sont dédoublonnés et réalignés à partir de l'index 1. l'ordre initial des pages est
  * conservé. Si deux pages avaient le même index de menu, elles sont reclassées par #id
  */
 private function resetMenuIndexes()
 {
     try {
         Yii::$app->db->transaction(function () {
             $idx = 0;
             /** @var array $row ['id' => id, 'menu_index' => val] */
             foreach (BasePagesQuery::getMenuIndexesMap() as $row) {
                 if (BasePagesQuery::updateMenuIndexes($row['id'], ++$idx) != 1) {
                     throw new Exception("Erreur sur BasePagesQuery::updateMenuIndexes({$row['id']}, {$idx})");
                 }
             }
         });
     } catch (\Exception $x) {
         Yii::$app->session->addFlash('warning', HLib::t('messages', 'An error has occurred'));
         Yii::error(h::_($x), __METHOD__);
     }
 }
Пример #14
0
<?php

use app\modules\hlib\HLib;
use app\modules\hlib\widgets\ViewModelsList;
use yii\db\ActiveRecord;
use yii\helpers\Html;
use yii\helpers\Url;
/** @var ViewModelsList $widget */
$widget = $this->context;
/** @var $model ActiveRecord */
?>

<ul>
    <?php 
foreach ($widget->models as $model) {
    ?>
        <li>
            <?php 
    /** @noinspection PhpUndefinedFieldInspection */
    echo Html::a($widget->retrieveLabel($model), Url::to([$widget->controllerRoute . '/view', 'id' => $model->id]));
    /** @noinspection PhpUndefinedFieldInspection */
    if ($widget->checkEnabled && !$model->enabled) {
        echo "&nbsp;<i>(" . mb_strtolower(HLib::t('labels', 'Disabled')) . ")</i>";
    }
    ?>
        </li>
    <?php 
}
?>
</ul>
Пример #15
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['base_id' => HCms::t('labels', 'Base text'), 'language_id' => HCms::t('labels', 'Language'), 'title' => HLib::t('labels', 'Title'), 'subtitle' => HLib::t('labels', 'Subtitle'), 'description' => HLib::t('labels', 'Description'), 'body' => HLib::t('labels', 'Body'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #16
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['base_id' => HCms::t('labels', 'Base tag'), 'language_id' => HCms::t('labels', 'Language'), 'label' => HLib::t('labels', 'Label'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #17
0
<div class="row news-navigation-links">
    <div class="col-sm-4">
        <?php 
if ($previous = $model->getPrevious()) {
    ?>
            <?php 
    echo Html::a('<span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>&nbsp' . HCms::t('labels', 'Previous news'), Url::to(['/cms/web-news/show', 'id' => $previous->id, 'slug' => $previous->getSlug()]));
    ?>
        <?php 
}
?>
    </div>

    <div class="col-sm-4 text-center">
        <?php 
echo Html::a('<span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp' . HLib::t('labels', 'Home'), Url::to(['/site/index']));
?>
    </div>

    <div class="col-sm-4 text-right">
        <?php 
if ($next = $model->getNext()) {
    ?>
            <?php 
    echo Html::a(HCms::t('labels', 'Next news') . '&nbsp<span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>', Url::to(['/cms/web-news/show', 'id' => $next->id, 'slug' => $next->getSlug()]));
    ?>
        <?php 
}
?>
    </div>
</div>
Пример #18
0
$this->title = HCms::t('labels', 'View news');
?>
<div class="row panel panel-default">
    <div class="panel-heading">
        <h1><?php 
echo Html::encode($model->title);
?>
</h1>
    </div>

    <div class="panel-body">

        <?php 
echo ViewButtons::widget(['modelId' => $model->id, 'controllerPath' => '/cms/web-news']);
?>

        <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['title', 'description', ['label' => HCms::t('label', 'Body'), 'value' => $model->body, 'format' => 'html']]]);
?>

        <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['label' => HLib::t('labels', 'Enabled'), 'value' => \app\modules\hlib\helpers\hAssets::getImageTagForBoolean($model->isEnabled()), 'format' => 'html'], ['label' => HCms::t('labels', 'Base news'), 'value' => ViewModelsList::widget(['models' => $model->base, 'labelField' => 'event_date', 'controllerRoute' => '/cms/base-news', 'listType' => 'div']), 'format' => 'html'], ['label' => HCms::t('labels', 'Language'), 'value' => $model->language->iso_639_code]]]);
?>

        <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['created_at', 'updated_at']]);
?>

    </div>
</div>
Пример #19
0
 * @var array        $parameters
 * @var array        $baseTexts [BaseText]
 * @var array        $languages [Language]
 */
// Quand le texte/racine sélectionné est modifié, on recharge le sous-formulaire associé
$this->registerJs("\n    \$('#webtext-base_id').change(function() {\n        var url = '/cms/base-texts/get-form/' + \$(this).val();\n        \$('#base-model-display').load(url);\n    });\n");
?>

<div class="backend-form">

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

    <?php 
echo $form->field($model, 'base_id')->dropDownList(ArrayHelper::map($baseTexts, 'id', 'code'), ['prompt' => HLib::t('messages', 'Select a value in the list')]);
?>

    <fieldset id="base-model-display">
        <?php 
echo BaseTextForm::widget(['model' => $baseModel, 'asNestedForm' => true]);
?>
    </fieldset>

    <fieldset>

        <div class="row">
            <div class="col-sm-4">
                <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
Пример #20
0
 /**
  * Affichage du formulaire de modification
  *
  * @param int $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $request = Yii::$app->request;
     $ok = true;
     $baseModel = null;
     if ($request->isPost) {
         // Mise à jour de la WebPage et de la BasePage associée
         /** @var BasePage $baseModel */
         if (!($baseModel = BasePage::findOne($request->post()['WebPage']['base_id']))) {
             $baseModel = new BasePage();
         }
         $ok &= $baseModel && $baseModel->load($request->post()) && $baseModel->save();
         $ok &= $model->load($request->post()) && $model->save();
         if (!$ok) {
             Yii::$app->session->setFlash('flash-warning', HLib::t('messages', 'There are errors in your form'));
         } else {
             Yii::$app->session->setFlash('flash-success', HLib::t('messages', 'Update successful'));
             if ($request->getBodyParam('action') == 'saveAndBackToList') {
                 return $this->redirect(Url::to([$this->getControllerRoute() . '/index', 'page' => 1]));
             }
         }
     } else {
         $baseModel = $model->base;
     }
     // Affichage ou ré-affichage
     $basePages = BasePage::find()->orderBy('code ASC')->all();
     $languages = Language::find()->orderBy('name')->all();
     return $this->render('update', compact('model', 'basePages', 'languages', 'baseModel'));
 }
Пример #21
0
 * @var string $indexUrl
 * @var string $updateUrl
 * @var string $deleteUrl
 * @var array  $additionalButtons
 */
use app\modules\hlib\HLib;
use yii\helpers\Html;
if (!isset($additionalButtons)) {
    $additionalButtons = [];
}
?>
<div class="view-buttons">
    <?php 
echo Html::a(HLib::t('labels', 'Back to List'), $indexUrl, ['class' => 'btn btn-primary']);
?>

    <?php 
echo Html::a(HLib::t('labels', 'Update'), $updateUrl, ['class' => 'btn btn-success']);
?>

    <?php 
echo Html::a(HLib::t('labels', 'Delete'), $deleteUrl, ['class' => 'btn btn-danger', 'data' => ['confirm' => HLib::t('messages', 'Are you sure you want to delete this item?'), 'method' => 'delete']]);
?>

    <?php 
foreach ($additionalButtons as $btn) {
    echo Html::a(HLib::t('labels', $btn['label']), $btn['url'], ['class' => 'btn ' . $btn['class']]);
}
?>
</div>
Пример #22
0
 */
$this->title = HLib::t('labels', 'Site information');
?>
<div class="row panel panel-default">

    <div class="panel-heading">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>

    <div class="panel-body">
        <ul class="list-group">
            <?php 
echo GridListHeader::widget(['columns' => [["width" => 6, "label" => HLib::t('labels', 'Name')], ["width" => 6, "label" => HLib::t('labels', 'Value')]]]);
?>

            <li class="list-group-item">
                <div class="row">
                    <div class="col-sm-6">INTL_ICU_VERSION</div>
                    <div class="col-sm-6"><?php 
echo INTL_ICU_VERSION;
?>
 </div>
                </div>
            </li>

            <li class="list-group-item">
                <div class="row">
                    <div class="col-sm-6">PHP_VERSION</div>
Пример #23
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['code' => HLib::t('labels', 'Code'), 'base_page_id' => HCms::t('labels', 'Base page'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #24
0
?>

    <?php 
echo $form->field($model, 'base_id')->dropDownList(ArrayHelper::map($baseTags, 'id', 'code'), ['prompt' => HLib::t('messages', 'Select a value in the list')]);
?>

    <fieldset id="base-model-display">
        <?php 
echo BaseTagForm::widget(['model' => $baseModel, 'asNestedForm' => true]);
?>
    </fieldset>

    <div class="row">
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'language_id')->dropDownList(ArrayHelper::map($languages, 'id', 'iso_639_code'), ['prompt' => HLib::t('messages', 'Select a value in the list')]);
?>
        </div>

        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'label')->textInput(['maxlength' => true]);
?>
        </div>
    </div>

    <?php 
echo SubmitButtons::widget(['indexUrl' => Url::to(['/cms/web-tags/index'], true)]);
?>

    <?php 
Пример #25
0
        </div>
    </div>

    <?php 
echo $form->field($model, 'baseTags')->listBox(ArrayHelper::map($baseTags, 'id', 'code'), ['id' => 'base_tags_ids', 'multiple' => true]);
?>

    <?php 
if (!$asNestedForm) {
    ?>
        <div class="form-group">
            <?php 
    echo Html::submitButton(HLib::t('labels', 'Save'), ['class' => 'btn btn-success', 'name' => 'action', 'value' => 'save']);
    ?>

            <?php 
    echo Html::a(HLib::t('labels', 'Cancel'), Url::to(['/cms/web-news/index']), ['class' => 'btn btn-warning', 'name' => 'action', 'value' => 'cancel']);
    ?>
        </div>
    <?php 
}
?>

    <?php 
if (!$asNestedForm) {
    ActiveForm::end();
}
?>

</div>
Пример #26
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['event_date' => HCms::t('labels', 'Event Date'), 'enabled' => HLib::t('labels', 'Enabled'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At'), 'baseTags' => HCms::t('labels', 'Base tags')];
 }
Пример #27
0
 /**
  * Deletes an existing User model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  *
  * @param int $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     try {
         $this->findModel($id)->delete();
         Yii::$app->session->setFlash('flash-success', HLib::t('messages', 'Delete successful'));
     } catch (IntegrityException $s) {
         Yii::$app->session->setFlash('flash-warning', HLib::t('messages', 'This object is referenced by another object. Deletion failed'));
     }
     return $this->redirect(Url::toRoute('/users/users/index'));
 }
Пример #28
0
<?php

/**
 * Accès au lien vers la page de mise à jour du modèle
 *
 * @var $url string
 * @deprecated
 */
use app\modules\hlib\HLib;
?>
<a href="<?php 
echo $url;
?>
" class="btn btn-success btn-xs" title="<?php 
echo HLib::t('labels', 'Edit');
?>
">
    <span class="glyphicon glyphicon-pencil"></span>
</a>

Пример #29
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }
Пример #30
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => HLib::t('labels', 'ID'), 'name' => HLib::t('labels', 'Name'), 'iso_639_code' => HCms::t('labels', 'Code'), 'created_at' => HLib::t('labels', 'Created At'), 'updated_at' => HLib::t('labels', 'Updated At')];
 }