コード例 #1
0
ファイル: Page.php プロジェクト: rogyar/Balcon
 /**
  * Collects and returns all navigation links
  *
  * @return array
  */
 public function getNavigationItems()
 {
     if (0 == count($this->navigationItems)) {
         /** @var Block $block */
         foreach ($this->blocksCollection->getBlocks() as $block) {
             if ($block->includeInNavigation()) {
                 $this->navigationItems[$block->getSortOrderValue()] = ['name' => isset($block->getParams()['navigation_title']) ? $block->getParams()['navigation_title'] : '', 'route' => $block->getRoute()];
             }
         }
     }
     ksort($this->navigationItems);
     return $this->navigationItems;
 }
コード例 #2
0
ファイル: Page.php プロジェクト: Zifius/Balcon
 /**
  * Searches for a page that matches current route
  * Returns true if the page has been found
  *
  * @return bool
  */
 public function process()
 {
     $route = "/{$this->getRoute()}";
     if ($route) {
         /** @var  $block */
         foreach ($this->blocksCollection->getBlocks() as $block) {
             if ($block->getRoute() == $route) {
                 // TODO: check if block is routable
                 $this->setDispatchedBlock($block);
                 $this->isProcessed = true;
                 return true;
             }
         }
     } else {
         throw new Exception('No route has been set for CMS Page entity');
     }
     return false;
 }
コード例 #3
0
ファイル: Renderer.php プロジェクト: rogyar/Balcon
 /**
  * Sort posts by 'post_date' parameter provided in
  * the .md file headers. If 'post_date' parameter is not provided
  * the file last modification time will be used for sorting
  *
  * @param BlocksCollection $postsCollection
  * @return BlocksCollection $postsCollection
  */
 protected function sortPosts(BlocksCollection $postsCollection)
 {
     $sortedBlocks = [];
     /** @var Block $block */
     foreach ($postsCollection->getBlocks() as $block) {
         $customBlockParams = $block->getParams();
         if (isset($customBlockParams['post_date'])) {
             $postTimestamp = strtotime($customBlockParams['post_date']);
             $sortedBlocks[(int) $postTimestamp] = $block;
         } else {
             $postDate = $block->getFileAttrs()['updated_at'];
             $sortedBlocks[strtotime($postDate)] = $block;
         }
     }
     if (count($sortedBlocks) > 0) {
         ksort($sortedBlocks);
         $postsCollection->setBlocks($sortedBlocks);
     }
     return $postsCollection;
 }