Esempio n. 1
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\\Core\\Chunk\\' . ucfirst($type);
     if ($page === null) {
         $page = Editor::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));
 }
Esempio n. 2
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 ?: Editor::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();
 }