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
 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 #6
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 #7
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 #8
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();
 }