示例#1
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->page->aclEnabled()) {
         if (!$this->guard->check()) {
             return new RedirectResponse(route('login'));
         }
         if ($this->gate->denies('view', $this->page)) {
             abort(403);
         }
     }
     return $next($request);
 }
示例#2
0
 public function __construct()
 {
     $this->query = Model::currentVersion()->withUrl();
     if (Editor::isDisabled()) {
         $this->query = $this->query->isVisible();
     }
 }
示例#3
0
 public function getPageTitles()
 {
     $results = [];
     $pages = Page::autocompleteTitle($this->request->input('text'), $this->count)->get();
     foreach ($pages as $p) {
         $primaryUri = substr($p->primary_uri, 0, 1) === '/' ? $p->primary_uri : '/' . $p->primary_uri;
         $results[] = ['label' => $p->title . ' (' . $primaryUri . ')', 'value' => $primaryUri];
     }
     return $results;
 }
示例#4
0
 public function handle()
 {
     $attrs = [];
     if ($this->parent) {
         $attrs += ['parent_id' => $this->parent->getId(), 'visible_in_nav' => $this->parent->childrenAreVisibleInNav(), 'visible_in_nav_cms' => $this->parent->childrenAreVisibleInCmsNav(), 'children_visible_in_nav' => $this->parent->childrenAreVisibleInNav(), 'children_visible_in_nav_cms' => $this->parent->childrenAreVisibleInCmsNav(), 'enable_acl' => $this->parent->aclEnabled()];
     }
     $page = PageFacade::create($attrs);
     $page->addVersion(['template_id' => $this->parent ? $this->parent->getDefaultChildTemplateId() : null, 'title' => $this->title, 'embargoed_until' => time()]);
     if ($this->parent) {
         $groupIds = $this->parent->getAclGroupIds();
         foreach ($groupIds as $groupId) {
             $page->addAclGroupId($groupId);
         }
     }
     Event::fire(new PageWasCreated($page, $this->parent));
     return $page;
 }
 public function boot()
 {
     parent::boot();
     Models\Asset::observe(CreationLogObserver::class);
     Models\AssetVersion::observe(CreationLogObserver::class);
     Models\Page::observe(CreationLogObserver::class);
     Models\PageVersion::observe(CreationLogObserver::class);
     Models\Asset::observe(SetSiteObserver::class);
     Models\Group::observe(SetSiteObserver::class);
     Models\Page::observe(SetSiteObserver::class);
     Models\Tag::observe(SetSiteObserver::class);
     Models\URL::observe(SetSiteObserver::class);
     Models\Page::observe(DeletionLogObserver::class);
 }
示例#6
0
 /**
  * Returns whether a given page internal name is already in use.
  *
  * @param string $name
  *
  * @return bool
  */
 public function internalNameExists($name)
 {
     return $this->model->withTrashed()->where(Model::ATTR_INTERNAL_NAME, $name)->exists();
 }
示例#7
0
 public function testIsVisibleAtAnyTime()
 {
     $yes = [1, true];
     $no = [0, false, null];
     foreach ($yes as $y) {
         $page = new Page([Page::ATTR_VISIBLE => $y]);
         $this->assertTrue($page->isVisibleAtAnyTime(), $y);
     }
     foreach ($no as $n) {
         $page = new Page([Page::ATTR_VISIBLE => $n]);
         $this->assertFalse($page->isVisibleAtAnyTime(), $n);
     }
 }
示例#8
0
 public function __construct()
 {
     $this->query = Model::currentVersion();
 }
示例#9
0
 /**
  * Save the page navigation settings.
  *
  * @param Request $request
  * @param Page    $page
  */
 public function postNavigation(Request $request, Page $page)
 {
     $this->authorize('editNavBasic', $page);
     if (Gate::allows('editNavAdvanced', $page)) {
         $parent = Page::find($request->input('parent_id'));
         if ($parent) {
             $page->setParent($parent);
         }
     }
     $page->setVisibleInNav($request->has('visible_in_nav'))->setVisibleInCmsNav($request->has('visible_in_nav_cms'));
     PageFacade::save($page);
 }
示例#10
0
 public function save(Model $page)
 {
     $page->save();
     return $page;
 }
示例#11
0
 public function testUrlReturnsUrlObject()
 {
     $page = new Page([Page::ATTR_PRIMARY_URI => 'test']);
     $url = $page->url();
     $this->assertInstanceOf(URL::class, $url);
     $this->assertEquals('test', $url->getLocation());
 }