public function contextBackend() { $datasourcePage = \Navigation::addPage(['id' => 'datasource', 'title' => 'datasource::core.title.section', 'priority' => 500, 'icon' => 'tasks']); $sections = app('datasource.manager')->getRootSections(); foreach ($sections as $dsSection) { $page = new Section($dsSection); if ($dsSection->getSetting('show_in_root_menu')) { \Navigation::addPage($page); } else { $datasourcePage->addPage($page); } } $folders = SectionFolder::with('sections')->get(); foreach ($folders as $folder) { if (count($folder->sections) > 0) { $folderPage = $datasourcePage->addPage(new Folder($folder)); foreach ($folder->sections as $dsSection) { $folderPage->addPage(new Section($dsSection)); } } } if (count($types = app('datasource.manager')->getAvailableTypes()) > 0) { $create = $datasourcePage->addPage(['title' => 'datasource::core.button.create', 'icon' => 'plus', 'id' => 'datasource-create']); foreach ($types as $type => $object) { $create->addPage(new SectionType($object)); } } }
/** * @param SectionRepository $repository * @param int $sectionId */ public function getIndex(SectionRepository $repository, $sectionId = null) { if (is_null($sectionId)) { $sectionId = $this->request->cookie(static::DS_COOKIE_NAME); } /** @var SectionInterface $section */ if (is_null($sectionId)) { $section = $repository->query()->first(); } else { $section = $repository->query()->findOrFail($sectionId); } if (!is_null($section)) { $headline = $section->getHeadline()->render(); $toolbar = $section->getToolbar()->render(); $this->setTitle($section->getName()); $this->response->withCookie(cookie()->forever(static::DS_COOKIE_NAME, $section->getId())); } else { $section = $headline = $toolbar = null; } Assets::loadPackage('jquery-ui'); $this->setContent('content', ['navigation' => view('datasource::navigation', ['types' => DatasourceManager::getAvailableTypes(), 'folders' => SectionFolder::with('sections')->get(), 'sections' => DatasourceManager::getRootSections()]), 'section' => view('datasource::section', ['headline' => $headline, 'toolbar' => $toolbar, 'section' => $section])]); view()->share('currentSection', $section); $this->templateScripts['SECTION'] = $section; }
/** * @param SectionRepository $repository */ public function getMenu(SectionRepository $repository) { $sectionId = $this->getRequiredParameter('section_id'); $this->setContent(view('datasource::sections-list', ['sections' => DatasourceManager::getSections(), 'folders' => SectionFolder::with('sections')->get(), 'currentSection' => $repository->findOrFail($sectionId)])); }