public function onSave() { $this->validateRequestTheme(); $type = Request::input('objectType'); $object = $this->fillObjectFromPost($type); $object->save(); $result = ['objectPath' => $type != 'content' ? $object->getBaseFileName() : $object->fileName, 'objectMtime' => $object->mtime, 'tabTitle' => $this->getTabTitle($type, $object)]; if ($type == 'page') { $result['pageUrl'] = URL::to($object->getViewBag()->property('url')); PagesPlugin::clearCache(); } $successMessages = ['page' => 'rainlab.pages::lang.page.saved', 'menu' => 'rainlab.pages::lang.menu.saved']; $successMessage = isset($successMessages[$type]) ? $successMessages[$type] : $successMessages['page']; Flash::success(Lang::get($successMessage)); return $result; }
public function boot() { Event::listen('cms.router.beforeRoute', function ($url) { return Controller::instance()->initCmsPage($url); }); Event::listen('cms.page.beforeRenderPage', function ($controller, $page) { /* * Before twig renders */ $twig = $controller->getTwig(); $loader = $controller->getLoader(); Controller::instance()->injectPageTwig($page, $loader, $twig); /* * Get rendered content */ $contents = Controller::instance()->getPageContents($page); if (strlen($contents)) { return $contents; } }); Event::listen('cms.page.initComponents', function ($controller, $page) { Controller::instance()->initPageComponents($controller, $page); }); Event::listen('cms.block.render', function ($blockName, $blockContents) { $page = CmsController::getController()->getPage(); if (!isset($page->apiBag['staticPage'])) { return; } $contents = Controller::instance()->getPlaceholderContents($page, $blockName, $blockContents); if (strlen($contents)) { return $contents; } }); Event::listen('pages.menuitem.listTypes', function () { return ['static-page' => 'rainlab.pages::lang.menuitem.static_page', 'all-static-pages' => 'rainlab.pages::lang.menuitem.all_static_pages']; }); Event::listen('pages.menuitem.getTypeInfo', function ($type) { if ($type == 'url') { return []; } if ($type == 'static-page' || $type == 'all-static-pages') { return StaticPage::getMenuTypeInfo($type); } }); Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) { if ($type == 'static-page' || $type == 'all-static-pages') { return StaticPage::resolveMenuItem($item, $url, $theme); } }); Event::listen('backend.form.extendFieldsBefore', function ($formWidget) { if ($formWidget->model instanceof \Cms\Classes\Partial) { Snippet::extendPartialForm($formWidget); } }); Event::listen('cms.template.save', function ($controller, $template, $type) { Plugin::clearCache(); }); Event::listen('cms.template.processSettingsBeforeSave', function ($controller, $dataHolder) { $dataHolder->settings = Snippet::processTemplateSettingsArray($dataHolder->settings); }); Event::listen('cms.template.processSettingsAfterLoad', function ($controller, $template) { Snippet::processTemplateSettings($template); }); Event::listen('cms.template.processTwigContent', function ($template, $dataHolder) { if ($template instanceof \Cms\Classes\Layout) { $dataHolder->content = Controller::instance()->parseSyntaxFields($dataHolder->content); } }); Event::listen('backend.richeditor.listTypes', function () { return ['static-page' => 'rainlab.pages::lang.menuitem.static_page']; }); Event::listen('backend.richeditor.getTypeInfo', function ($type) { if ($type === 'static-page') { return StaticPage::getRichEditorTypeInfo($type); } }); }