예제 #1
0
 /**
  * @param string $uri
  * @param bool $includeHidden
  * @param FrontendPage $parentPage
  * @return stdClass
  */
 public static function findByUri($uri, $includeHidden = true, FrontendPage $parentPage = null)
 {
     $uri = trim($uri, '/');
     $urls = preg_split('/\\//', $uri, -1, PREG_SPLIT_NO_EMPTY);
     if ($parentPage === null) {
         $urls = array_merge([''], $urls);
     }
     $url = '';
     $pageObject = new \stdClass();
     $pageObject->id = 0;
     foreach ($urls as $pageSlug) {
         $url = ltrim($url . '/' . $pageSlug, '/');
         if ($pageObject = self::findBySlug($pageSlug, $parentPage, $includeHidden)) {
             if (!is_null($pageObject->getBehavior()) and $behavior = BehaviorManager::load($pageObject->getBehavior(), $pageObject)) {
                 $behavior->executeRoute($pageObject->getUri());
                 $pageObject->behaviorObject = $behavior;
                 return $pageObject;
             }
         } else {
             break;
         }
         $parentPage = $pageObject;
     }
     return $pageObject;
 }
예제 #2
0
 public function getCreate($parent_id = NULL)
 {
     $page = new Page(['parent_id' => $parent_id, 'published_at' => new Carbon()]);
     $this->setTitle(trans('pages::core.title.pages.create'));
     $pagesMap = $page->getSitemap();
     $behaviorList = BehaviorManager::formChoices();
     $this->setContent('pages.create', compact('page', 'pagesMap', 'behaviorList'));
 }
 /**
  * @param PageRepository $pageRepository
  *
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getSettings(PageRepository $pageRepository)
 {
     $pageId = $this->getParameter('pid');
     $behavior = $this->getRequiredParameter('behavior');
     if (!is_null($behavior = BehaviorManager::load($behavior))) {
         $page = $pageRepository->findOrFail($pageId);
         if ($page->hasBehavior()) {
             $behavior->setPage($page);
         }
     }
     return $this->setContent($behavior->getSettings()->render());
 }
 /**
  * Register any other events for your application.
  *
  * @param  DispatcherContract $events
  *
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     foreach ($this->listens() as $event => $listeners) {
         foreach ($listeners as $priority => $listener) {
             $events->listen($event, $listener, $priority);
         }
     }
     $events->listen('config.loaded', function () {
         BehaviorManager::init();
     });
     app('view')->addNamespace('layouts', layouts_path());
     $events->listen('view.page.edit', function ($page) {
         WYSIWYG::loadAllEditors();
         echo view('pages::parts.list')->with('page', $page);
     }, 999);
 }
 public function register()
 {
     Page::observe(new PageObserver());
     PagePart::observe(new PagePartObserver());
     BehaviorManager::init();
 }
예제 #6
0
 /**
  * @return \KodiCMS\Pages\Contracts\Behavior\BehaviorInterface|void
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getBehaviorObject()
 {
     if (!$this->hasBehavior()) {
         return;
     }
     return BehaviorManager::load($this->getBehavior());
 }
예제 #7
0
 /**
  * @return null|\KodiCMS\Pages\Behavior\Decorator
  * @throws \KodiCMS\Pages\Exceptions\BehaviorException
  */
 public function getBehaviorObject()
 {
     if (is_null($this->behavior)) {
         return null;
     }
     return BehaviorManager::load($this->behavior);
 }