public function reorder() { if (!acl_check('parts.reorder')) { return; } $ids = $this->getParameter('ids', []); $part = new PagePart(); $part->reorder($ids); }
public function boot() { app('view')->addNamespace('layouts', layouts_path()); Page::observe(new PageObserver()); PagePartModel::observe(new PagePartObserver()); $this->registerWidgets(); }
/** * Run the database seeds. * * @return void */ public function run() { Page::truncate(); PagePart::truncate(); $rootPage = Page::create(['title' => 'Home', 'breadcrumb' => 'Home', 'slug' => '', 'layout_file' => 'normal.blade', 'published_at' => new Carbon()]); $page = new Page(['title' => 'Page not found', 'breadcrumb' => 'Page not found', 'slug' => 'page-not-found', 'behavior' => 'page.not.found', 'status' => FrontendPage::STATUS_HIDDEN, 'published_at' => new Carbon()]); $rootPage->children()->save($page); $page->parts()->save(new PagePart(['name' => 'content', 'content' => '<h1>Page not found</h1>', 'wysiwyg' => 'ace'])); }
/** * @param integer $pageId * @return array|null */ private static final function loadPartsbyPageId($pageId) { if (!array_key_exists($pageId, static::$cached)) { self::$cached[$pageId] = Cache::tags(PagePartModel::table())->remember("pageParts::{$pageId}", Carbon::now()->addHour(1), function () use($pageId) { return PagePartModel::select('name', 'content', 'content_html')->where('page_id', $pageId)->get(); }); } return self::$cached[$pageId]; }
/** * TODO: добавить кеширование на основе тегов. * * @param int $pageId * * @return array|null */ private static final function loadPartsByPageId($pageId) { if (!array_key_exists($pageId, static::$cached)) { self::$cached[$pageId] = Cache::remember("pageParts::{$pageId}", Carbon::now()->addHour(1), function () use($pageId) { $parts = PagePartModel::select('id', 'name', 'content', 'content_html')->where('page_id', $pageId)->get(); $return = []; foreach ($parts as $part) { $return[$pageId][$part->name] = $part->toArray(); } return $return; }); } return self::$cached[$pageId]; }
/** * @param \KodiCMS\Pages\Model\Page $page * @return bool */ public function updateParts($page) { $partContent = Request::input('part_content', []); foreach ($partContent as $id => $content) { $part = PagePart::find($id); if (is_null($part)) { continue; } if ($content == $part->content) { continue; } $part->update(['content' => $content]); } return TRUE; }
public function register() { Page::observe(new PageObserver()); PagePart::observe(new PagePartObserver()); BehaviorManager::init(); }