public function show()
 {
     $page = Router::getActivePage();
     $format = $this->request->format();
     if ($this->request->route()->getParameter('format')) {
         $format = $this->request->route()->getParameter('format');
     }
     $method = 'as' . ucfirst($format);
     if (method_exists($this, $method)) {
         return $this->{$method}($page);
     }
     abort(406);
 }
Example #2
0
 /**
  * Returns a chunk object of the required type.
  *
  * @param string $type     Chunk type, e.g. text, feature, etc.
  * @param string $slotname The name of the slot to retrieve a chunk from.
  * @param mixed  $page     The page the chunk belongs to. If not given then the page from the current request will be used.
  *
  * @return BaseChunk
  */
 public function edit($type, $slotname, $page = null)
 {
     $className = 'BoomCMS\\Chunk\\' . ucfirst($type);
     if ($page === null) {
         $page = Router::getActivePage();
     } elseif ($page === 0) {
         // 0 was given as the page - this signifies a 'global' chunk not assigned to any page.
         $page = new Page();
     }
     $chunk = $this->find($type, $slotname, $page->getCurrentVersion());
     $attrs = $chunk ? $chunk->toArray() : [];
     return new $className($page, $attrs, $slotname, $this->allowedToEdit($page));
 }
Example #3
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $activePage = Router::getActivePage();
     if ($activePage === null || Gate::denies('toolbar', $activePage)) {
         return $next($request);
     }
     $response = $next($request);
     $originalHtml = $response instanceof Response ? $response->getOriginalContent() : (string) $response;
     preg_match('|(.*)(</head>)(.*<body[^>]*>)|imsU', $originalHtml, $matches);
     if (!empty($matches)) {
         $head = view('boomcms::editor.iframe', ['before_closing_head' => $matches[1], 'body_tag' => $matches[3], 'editor' => $this->editor, 'page_id' => $activePage->getId()]);
         $newHtml = str_replace($matches[0], (string) $head, $originalHtml);
         if ($response instanceof Response) {
             $response->setContent($newHtml);
         } else {
             return $newHtml;
         }
     }
     return $response;
 }
Example #4
0
 /**
  * Get the pages applied to the children of a page.
  *
  * @param Page\Page $page
  * @param string    $group
  *
  * @return array
  */
 public static function getTagsInSection(PageInterface $page = null, $group = null)
 {
     $page = $page ?: Router::getActivePage();
     $finder = new Tag\Finder\Finder();
     $finder->addFilter(new Tag\Finder\AppliedToPageDescendants($page));
     $finder->addFilter(new Tag\Finder\Group($group));
     return $finder->setOrderBy('name', 'asc')->findAll();
 }
Example #5
0
 /**
  * Insert a chunk into a page.
  *
  * @param string    $type
  * @param string    $slotname
  * @param null|Page $page
  *
  * @return mixed
  */
 public function insert($type, $slotname, $page = null)
 {
     if ($page === null || $page === Router::getActivePage()) {
         return $this->edit($type, $slotname, $page);
     }
     return $this->get($type, $slotname, $page);
 }
Example #6
0
 function h1(Page $page = null)
 {
     $page = $page ?: Router::getActivePage();
     return "<h1 id='b-page-title'>{$page->getTitle()}</h1>";
 }