Ejemplo n.º 1
0
 /**
  * Formularz edycji albumu
  * @param type $id
  * @return type
  * @throws \app\components\exceptions\FormException
  */
 public function actionEdit($id)
 {
     $model = new \app\modules\photo\models\Albums();
     if ($id > 0) {
         $model = $model->findOne($id);
         if (!$model) {
             throw new \app\components\exceptions\FormException('Nie znaleziono obiektu', 404);
         }
         if (!$model->canEdit()) {
             throw new \app\components\exceptions\FormException('Nie możesz dodawać zdjęć do tego albumu.', 403);
         }
     }
     $post = Yii::$app->request->post('Albums');
     if ($post) {
         $model->setAttributes($post);
         $trans = Yii::$app->db->beginTransaction();
         try {
             $model->uploadsPath = $this->module->params['uploadsPath'];
             if ($model->validate() && $model->save()) {
                 \app\helpers\Flash::setSuccess('Zapisano poprawnie.');
                 $this->redirect(['/photo/admin/album/edit', 'id' => $model->id]);
             } else {
                 throw new \app\components\exceptions\FormException('Błąd podczas zapisu.');
             }
             $trans->commit();
         } catch (\yii\base\Exception $exc) {
             $trans->rollback();
             \app\helpers\Flash::setError($exc->getMessage());
         }
     }
     return $this->render('edit', ['id' => $id, 'model' => $model]);
 }
Ejemplo n.º 2
0
 public function run()
 {
     try {
         return parent::run();
     } catch (Exception $exc) {
         Yii::error(print_r('RUN LOG:' . $exc, true));
         \app\helpers\Flash::setUndisplayError($exc->getMessage());
         header("location:/site/oooops");
     }
 }
Ejemplo n.º 3
0
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => 'Archiwum zdjęć rodzinnych', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Przeglądaj', 'url' => ['/site/index']], ['label' => 'Zarządzanie zdjęciami', 'visible' => !Yii::$app->user->isGuest, 'items' => [['label' => 'Dodaj album', 'url' => ['/photo/admin/album/create']], ['label' => 'Lista moich albumów', 'url' => ['/photo/admin/album/mylist']]]], ['label' => 'Administracja', 'visible' => Yii::$app->user->can("admin"), 'items' => [['label' => 'Lista użytkowników', 'url' => ['/user/admin']]]], Yii::$app->user->isGuest ? ['label' => 'Zaloguj się!', 'url' => ['/user/login']] : ['label' => '@' . Yii::$app->user->identity->username, 'items' => [['label' => 'Ustawienia konta', 'url' => ['/user/account']], ['label' => 'Ustawienia profilu', 'url' => ['/user/profile']], ['label' => 'Wyloguj się', 'url' => ['/user/logout'], 'linkOptions' => ['data-method' => 'post']]]]]]);
NavBar::end();
?>
	
    <div class="container">
		<div class="row flash-container">
			<?php 
\app\helpers\Flash::getAll();
?>
		</div>
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo $content;
?>
    </div>
</div>

<footer class="footer">
    <div class="container">
        <p class="pull-left">&copy; Karczmarczyk <?php 
echo date('Y');