Example #1
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $pageId = Param::post('page-edit-id', false)->asInteger(false);
     $name = Param::post('page-edit-name')->noEmpty('Поле "Наименование" должно быть заполнено.')->asString();
     $description = Param::post('page-edit-description')->asString();
     $content = Param::post('page-edit-content')->asString();
     $active = (bool) Param::post('page-edit-active')->exists();
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         /** @var Page $oPage */
         $oPage = DataSource::factory(Page::cls(), $pageId == 0 ? null : $pageId);
         $oPage->name = $name;
         $oPage->description = $description;
         $oPage->content = $content;
         $oPage->active = $active;
         if (!$oPage->getPrimaryKey()) {
             $oPage->deleted = false;
         }
         $oPage->commit();
         SCMSNotificationLog::instance()->pushMessage("Страница \"{$oPage->name}\" успешно " . ($pageId == 0 ? 'добавлена' : 'отредактирована') . '.');
         $redirect = '';
         if (Param::post('page-edit-accept', false)->exists()) {
             $redirect = '/admin/modules/pages/';
         } elseif ($pageId == 1) {
             $redirect = "/admin/modules/pages/edit/?id={$oPage->getPrimaryKey()}";
         }
         $this->Response->send($redirect);
     } else {
         $this->Response->send();
     }
 }
Example #2
0
 public function actionIndex()
 {
     $view = new ViewPage();
     if ($this->page_id != 0) {
         /** @var Page $oPage */
         $oPage = DataSource::factory(Page::cls(), $this->page_id);
         $view->page = $oPage;
         $view->render();
     } else {
         echo 'Страница не назначена.';
     }
 }
Example #3
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $pageId = Param::get('id')->noEmpty('Не задан обязательный параметр.')->asInteger(true, 'Параметр должен быть числом.');
     /** @var Page $oPage */
     $oPage = DataSource::factory(Page::cls(), $pageId);
     if (is_null($oPage) || !$oPage->getPrimaryKey()) {
         SCMSNotificationLog::instance()->pushError('Статическая страница не найдена.');
     } else {
         SCMSNotificationLog::instance()->pushMessage("Страница \"{$oPage->name}\" успешно удалена.");
         $oPage->deleted = true;
         $oPage->commit();
     }
     $this->Response->send();
 }
Example #4
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $pageId = Param::get('id', false)->asInteger(false);
     /** @var Page $oPage */
     $oPage = is_null($pageId) ? null : DataSource::factory(Page::cls(), $pageId);
     $view = new ViewEditForm();
     $view->page = $oPage;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Статичные страницы', '/modules/pages')];
     if ($oPage !== null) {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb("Редактирование \"{$oPage->name}\"", '');
     } else {
         $viewBreadcrumbs->Breadcrumbs[] = new Breadcrumb('Добавление новой статичной страницы', '');
     }
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $view);
     $this->Frame->render();
 }