Example #1
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryId = Param::post('gallery-id')->asInteger(true, 'Недопустимое значние номера галереи.');
     $galleryItemId = Param::post('gallery-item-edit-id', false)->asInteger(false);
     $name = Param::post('gallery-item-edit-name')->noEmpty('Поле "Название" должно быть заполнено.')->asString();
     $description = Param::post('gallery-item-edit-description')->asString();
     $path = Param::post('gallery-item-edit-path')->noEmpty('Недопустимое значение пути к изображению.')->asString();
     $position = Param::post('gallery-item-edit-position')->noEmpty('Недопустимое значение позиции элемента.')->asInteger();
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     if ($oGallery->isNew()) {
         SCMSNotificationLog::instance()->pushError("Попытка добавить элемент в несуществующую галерею.");
     }
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         /** @var GalleryItem $oGalleryItem */
         $oGalleryItem = DataSource::factory(GalleryItem::cls(), $galleryItemId == 0 ? null : $galleryItemId);
         $oGalleryItem->name = $name;
         $oGalleryItem->description = $description;
         $oGalleryItem->path = $path;
         $oGalleryItem->gallery_id = $oGallery->id;
         $oGalleryItem->position = $position;
         $oGalleryItem->commit();
         SCMSNotificationLog::instance()->pushMessage("Элемент \"{$oGalleryItem->name}\" успешно " . ($galleryItemId == 0 ? "добавлен в галерею \"{$oGalleryItem->getGallery()->name}\"" : 'отредактирован') . '.');
         $redirect = '';
         if (Param::post('gallery-item-edit-accept', false)->exists()) {
             $redirect = "/admin/modules/gallery/item/?gallery_id={$oGalleryItem->gallery_id}";
         } elseif ($galleryItemId == 0) {
             $redirect = "/admin/modules/gallery/item/edit/?id={$oGalleryItem->getPrimaryKey()}";
         }
         $this->Response->send($redirect);
     } else {
         $this->Response->send();
     }
 }
Example #2
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryItemId = Param::get('id', false)->asInteger(false);
     $galleryId = Param::get('gallery_id')->asInteger(true, 'Недопустимое значение номера галереи.');
     /** @var GalleryItem $oGalleryItem */
     $oGalleryItem = DataSource::factory(GalleryItem::cls(), $galleryItemId);
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     if ($oGalleryItem->isNew() && $oGallery->isNew()) {
         SCMSNotificationLog::instance()->pushError('Недопустимое значение параметра!');
         $this->Frame->render();
         return;
     }
     $view = new ViewEditForm();
     $view->GalleryItem = $oGalleryItem;
     $view->Gallery = $oGallery;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Галереи', '/modules/gallery'), new Breadcrumb("Галерея \"{$oGallery->name}\"", "/item/?gallery_id={$oGallery->id}")];
     if ($oGalleryItem->id !== null) {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb("Редактирование \"{$oGalleryItem->name}\"", '');
     } else {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb('Добавление нового элемента галереи', '');
     }
     $view->backUrl = CoreFunctions::buildUrlByBreadcrumbs($viewBreadcrumbs->Breadcrumbs, 1);
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $view);
     $this->Frame->render();
 }
Example #3
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryId = Param::get('gallery_id')->asInteger(true, 'Недопустимое значение номера галереи.');
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     if (!$oGallery) {
         SCMSNotificationLog::instance()->pushError("Запрошенная галерея с номером \"{$galleryId}\" не существует.");
         $this->Frame->render();
         return;
     }
     $pageNumber = Param::get('gallery-item-page', false)->asInteger(false);
     $itemsPerPage = Param::get('gallery-item-items-per-page', false)->asInteger(false);
     $manifest = $this->ModuleInstaller->getManifest($this->ModuleDirectory);
     $dataGridView = new ViewDataGrid();
     $retriever = new GalleryRetriever();
     $dataGrid = new DataGrid('item', '', 'id', $manifest['meta']['alias'], $pageNumber, $itemsPerPage, $manifest['meta']['description']);
     $dataGrid->getMenu()->addElement(new Item('Добавить элемент', "/admin/modules/gallery/item/edit/?gallery_id={$oGallery->id}"));
     $dataGrid->addAction(new Action('id', "/admin/modules/gallery/item/edit/?gallery_id={$oGallery->id}", 'edit', '', [], ['class' => 'glyphicon glyphicon-pencil'], 'Редактировать'))->addAction(new Action('id', '/admin/modules/gallery/item/delete/', 'delete', '', [], ['class' => 'glyphicon glyphicon-trash'], 'Удалить', true));
     $dataGrid->addHeader(new Header('id', '№', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('item-filter-id', false)->asString(false)))->addHeader(new Header('name', 'Название', null, ['class' => 'text-center', 'style' => 'width: 250px;'], [], true, Param::get('item-filter-name', false)->asString(false)))->addHeader(new Header('description', 'Описание', new ViewCutString(20, true, ['class' => 'content-to-modal', 'style' => 'cursor: pointer;'], ['style' => 'display: none;']), ['class' => 'text-center'], ['class' => 'modal-display-field'], true, Param::get('item-filter-description', false)->asString(false)))->addHeader(new Header('path', 'Миниатюра', new ViewCondition(new ViewImageLink(true, ['class' => 'fancybox'], ['class' => 'img-rounded', 'style' => 'height: 20px;']), [['field' => 'path', 'value' => '/public/assets/images/system/no-image.svg', 'view' => new ViewStub('<span class="glyphicon glyphicon-picture"></span>')]]), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center']))->addHeader(new Header('position', 'Позиция', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('item-filter-position', false)->asString(false)));
     $galleries = $retriever->getGalleryItems($oGallery, $dataGrid->getFilterConditions(), $dataGrid->Pagination->getLimit(), $dataGrid->Pagination->getOffset());
     $dataSet = new ArrayDataSet($galleries);
     $dataGrid->addDataSet($dataSet);
     $dataGridView->dataGrid = $dataGrid;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Галереи', '/modules/gallery'), new Breadcrumb("Элементы галереи \"{$oGallery->name}\"", '')];
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $dataGridView);
     $this->Frame->render();
 }
Example #4
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryId = Param::post('gallery-edit-id', false)->asInteger(false);
     $name = Param::post('gallery-edit-name')->noEmpty('Поле "Название" должно быть заполнено.')->asString();
     $description = Param::post('gallery-edit-description')->asString();
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         /** @var Gallery $oGallery */
         $oGallery = DataSource::factory(Gallery::cls(), $galleryId == 0 ? null : $galleryId);
         $oGallery->name = $name;
         $oGallery->description = $description;
         $oGallery->deleted = false;
         $oGallery->commit();
         SCMSNotificationLog::instance()->pushMessage("Галерея \"{$oGallery->name}\" успешно " . ($galleryId == 0 ? 'добавлена' : 'отредактирована') . '.');
         $redirect = '';
         if (Param::post('gallery-edit-accept', false)->exists()) {
             $redirect = '/admin/modules/gallery/';
         } elseif ($galleryId == 0) {
             $redirect = "/admin/modules/gallery/edit/?id={$oGallery->getPrimaryKey()}";
         }
         $this->Response->send($redirect);
     } else {
         $this->Response->send();
     }
 }
Example #5
0
 /**
  * Finds the Gallery model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * 
  * @param integer  $id
  * @return Gallery The loaded model.
  * 
  * @throws NotFoundHttpException if the model cannot be found.
  */
 public function findModel($id)
 {
     if (($model = Gallery::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
 public function actionIndex()
 {
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $this->gallery_id);
     $view = new MainView();
     $view->displayType = $this->gallery_display_type;
     $view->oGallery = $oGallery;
     $view->oStructure = $this->oStructure;
     $view->render();
 }
Example #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array   $params
  * @param integer $pageSize  The number of results to be displayed per page.
  *
  * @return ActiveDataProvider
  */
 public function search($params, $pageSize = 3)
 {
     $query = Gallery::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => $pageSize]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #8
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryId = Param::get('id')->noEmpty('Не задан обязательный параметр.')->asInteger(true, 'Параметр должен быть числом.');
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     if (is_null($oGallery) || !$oGallery->getPrimaryKey()) {
         SCMSNotificationLog::instance()->pushError('Галерея не найдена.');
     } else {
         SCMSNotificationLog::instance()->pushMessage("Галерея \"{$oGallery->name}\" успешно удалена.");
         $oGallery->delete();
     }
     $this->Response->send();
 }
Example #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Gallery::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(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #10
0
 public function getGallery()
 {
     /** @var Gallery[] $aGalleries */
     $aGalleries = $this->findRelationCache('gallery_id', Gallery::cls());
     if (empty($aGalleries)) {
         /** @var Gallery $oGalleries */
         $oGalleries = DataSource::factory(Gallery::cls());
         $oGalleries->builder()->where("{$oGalleries->getPrimaryKeyName()}={$this->gallery_id}");
         $aGalleries = $oGalleries->findAll();
         foreach ($aGalleries as $oGallery) {
             $this->addRelationCache('gallery_id', $oGallery);
             $oGallery->addRelationCache($oGallery->getPrimaryKeyName(), $this);
         }
     }
     return isset($aGalleries[0]) ? $aGalleries[0] : null;
 }
Example #11
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $galleryId = Param::get('id', false)->asInteger(false);
     /** @var Gallery $oGallery */
     $oGallery = DataSource::factory(Gallery::cls(), $galleryId);
     $view = new ViewEditForm();
     $view->gallery = $oGallery;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Галереи', '/modules/gallery')];
     if ($oGallery->id !== null) {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb("Редактирование \"{$oGallery->name}\"", '');
     } else {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb('Добавление новой галереи', '');
     }
     $view->backUrl = CoreFunctions::buildUrlByBreadcrumbs($viewBreadcrumbs->Breadcrumbs, 1);
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $view);
     $this->Frame->render();
 }
Example #12
0
    public function currentRender()
    {
        $isNew = is_null($this->gallery->id);
        if (!$isNew) {
            $id = $this->gallery->id;
            $name = $this->gallery->name;
            $description = $this->gallery->description;
            $aGalleryItems = $this->gallery->getGalleryItems('position');
        } else {
            $id = $name = $description = '';
            $aGalleryItems = [];
        }
        ?>
        <form id="gallery-edit-form" action="/admin/modules/gallery/save/" method="post">
            <fieldset>
                <legend><?php 
        echo $isNew ? 'Добавление новой галереи' : "Редактирование галереи (<a target=\"_blank\" href=\"/admin/modules/gallery/item/?gallery_id={$id}\">перейти к редактированию элементов</a>)";
        ?>
</legend>
                <input type="hidden" name="gallery-edit-id" value="<?php 
        echo $id;
        ?>
" />

                <div class="row">
                    <div class="col-sm-6">
                        <div class="row">
                            <div class="col-lg-1">
                                <div class="form-group">
                                    <label for="gallery-edit-number">№</label>
                                    <input class="form-control input-sm" id="gallery-edit-number" name="gallery-edit-number" disabled="disabled" type="number" placeholder="№" value="<?php 
        echo $id;
        ?>
">
                                    <span class="help-block">Номер</span>
                                </div>
                            </div>
                            <div class="col-lg-11">
                                <div class="form-group">
                                    <label for="gallery-edit-name">Наименование</label>
                                    <input class="form-control input-sm" id="gallery-edit-name" name="gallery-edit-name" type="text" placeholder="Наименование" value="<?php 
        echo $name;
        ?>
">
                                    <span class="help-block">Название галереи</span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="gallery-edit-description">Описание</label>
                            <textarea class="form-control input-sm" id="gallery-edit-description" name="gallery-edit-description" placeholder="Описание" style="width: 100%; height: 100px;"><?php 
        echo $description;
        ?>
</textarea>
                            <span class="help-block">Служебная информация, к заполнению не обязательна.</span>
                        </div>
                    </div>

                    <?php 
        if (!empty($aGalleryItems)) {
            ?>
                    <div class="col-sm-6">
                        <h4>Режим галереи с прокруткой</h4>
                        <div class="galleria">
                            <?php 
            foreach ($aGalleryItems as $oGalleryItem) {
                ?>
                                <a href="<?php 
                echo $oGalleryItem->path;
                ?>
">
                                    <img src="<?php 
                echo $oGalleryItem->path;
                ?>
" data-big="<?php 
                echo $oGalleryItem->path;
                ?>
" data-title="<?php 
                echo $oGalleryItem->name;
                ?>
" data-description="<?php 
                echo $oGalleryItem->description;
                ?>
" />
                                </a>
                            <?php 
            }
            ?>
                        </div>
                    </div>
                    <?php 
        }
        ?>
                </div>
                <?php 
        if (!empty($aGalleryItems)) {
            ?>
                <hr/>
                <div class="row">
                    <h4 class="text-center">Режим галереи с плитками</h4>

                    <div class="col-xs-12">
                        <div class="container">
                            <div class="row eq-height">
                                <?php 
            foreach ($aGalleryItems as $oGalleryItem) {
                ?>
                                    <div class="col-md-3 col-sm-4 col-xs-6 thumb">
                                        <a class="fancyimage" rel="group" href="<?php 
                echo $oGalleryItem->path;
                ?>
">
                                            <img class="img-responsive" src="<?php 
                echo $oGalleryItem->path;
                ?>
" />
                                        </a>
                                    </div>
                                <?php 
            }
            ?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php 
        }
        ?>

                <hr/>
                <a href="<?php 
        echo $this->backUrl;
        ?>
" class="btn btn-warning">Отмена</a>
                <button id="gallery-edit-save" name="gallery-edit-save" type="submit" class="btn btn-primary">Сохранить</button>
                <button id="gallery-edit-accept" name="gallery-edit-accept" type="submit" class="btn btn-success">Применить</button>
            </fieldset>
        </form>
        <?php 
    }
Example #13
0
 /**
  * Deletes an existing Gallery model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * 
  * @param  integer $id
  * @return mixed
  *
  * @throws NotFoundHttpException
  */
 public function actionDelete($id)
 {
     $gallery = new Gallery();
     $gallery->findModel($id)->delete();
     return $this->redirect('admin');
 }
Example #14
0
    public function currentRender()
    {
        $aGalleryItems = $this->oGallery->getGalleryItems('position');
        ?>
        <div class="container">
            <h4><?php 
        echo $this->oStructure->name;
        ?>
</h4>
            <hr/>

            <?php 
        if ($this->displayType == Gallery::DISPLAY_TYPE_FANCY) {
            ?>
            <div class="row eq-height">
                <?php 
            foreach ($aGalleryItems as $oGalleryItem) {
                ?>
                    <div class="col-md-3 col-sm-3 col-xs-4">
                        <a class="fancyimage thumbnail" rel="group" href="<?php 
                echo $oGalleryItem->path;
                ?>
">
                            <img class="img-responsive" src="<?php 
                echo $oGalleryItem->getPathToThumbnail();
                ?>
" />
                        </a>
                    </div>
                <?php 
            }
            ?>
            </div>
            <?php 
        }
        ?>

            <?php 
        if ($this->displayType == Gallery::DISPLAY_TYPE_GALLERIA) {
            ?>
                <blockquote>
                    <p>Для перехода в полноэкранный режим сделайте двойное нажатие по галерее.</p>
                </blockquote>
                <div class="galleria">
                    <?php 
            foreach ($aGalleryItems as $oGalleryItem) {
                ?>
                        <a href="<?php 
                echo $oGalleryItem->path;
                ?>
">
                            <img src="<?php 
                echo $oGalleryItem->getPathToThumbnail();
                ?>
" data-big="<?php 
                echo $oGalleryItem->path;
                ?>
" data-title="<?php 
                echo $oGalleryItem->name;
                ?>
" data-description="<?php 
                echo $oGalleryItem->description;
                ?>
" />
                        </a>
                    <?php 
            }
            ?>
                </div>
            <?php 
        }
        ?>
        </div>
        <?php 
    }