public function initialize(IPage $page, $baker)
 {
     $this->path = $page->getPath();
     $this->pageType = $page->getPageType();
     $this->blogKey = $page->getBlogKey();
     $this->pageKey = $page->getPageKey();
     $this->taxonomy = array();
     $this->usedTaxonomyCombinations = array();
     $this->usedPages = false;
     $this->usedPosts = array();
     $this->outputs = array();
     if ($baker) {
         $tags = $page->getConfig()->getValue('tags');
         if ($tags) {
             $this->taxonomy['tags'] = $tags;
         }
         $category = $page->getConfig()->getValue('category');
         if ($category) {
             $this->taxonomy['category'] = $category;
         }
         $collector = $page->getApp()->getEnvironment()->getLinkCollector();
         if ($collector) {
             $tagCombinations = $collector->getAllTagCombinations();
             if ($tagCombinations) {
                 $this->usedTaxonomyCombinations['tags'] = $tagCombinations;
             }
             $collector->clearAllTagCombinations();
         }
         // TODO: remember posts used by blog.
         $this->usedPosts = $baker->wasPaginationDataAccessed();
         $this->outputs = $baker->getBakedFiles();
     }
 }
Example #2
0
 public function addPageClauses(IPage $page, array $userFilterInfo = null)
 {
     // If the current page is a tag/category page, add filtering
     // for that.
     $pageClause = null;
     $pieCrust = $page->getApp();
     $flags = $pieCrust->getConfig()->getValue('site/slugify_flags');
     switch ($page->getPageType()) {
         case IPage::TYPE_TAG:
             $pageKey = $page->getPageKey();
             if (is_array($pageKey)) {
                 $pageClause = new AndBooleanClause();
                 foreach ($pageKey as $k) {
                     $pageClause->addClause(new HasFilterClause('tags', $k, function ($t) use($flags) {
                         return UriBuilder::slugify($t, $flags);
                     }));
                 }
             } else {
                 $pageClause = new HasFilterClause('tags', $pageKey, function ($t) use($flags) {
                     return UriBuilder::slugify($t, $flags);
                 });
             }
             break;
         case IPage::TYPE_CATEGORY:
             $pageClause = new IsFilterClause('category', $page->getPageKey(), function ($c) use($flags) {
                 return UriBuilder::slugify($c, $flags);
             });
             break;
     }
     if ($pageClause != null) {
         // Combine the default page filters with some user filters,
         // if any.
         if ($userFilterInfo != null) {
             $combinedClause = new AndBooleanClause();
             $combinedClause->addClause($pageClause);
             $this->addClausesRecursive($userFilterInfo, $combinedClause);
             $this->addClause($combinedClause);
         } else {
             $this->addClause($pageClause);
         }
     }
 }
 public function addPageClauses(IPage $page)
 {
     // If the current page is a tag/category page, add filtering
     // for that.
     switch ($page->getPageType()) {
         case IPage::TYPE_TAG:
             $pageKey = $page->getPageKey();
             if (is_array($pageKey)) {
                 $wrapper = new AndBooleanClause();
                 foreach ($pageKey as $k) {
                     $wrapper->addClause(new HasFilterClause('tags', $k));
                 }
                 $this->addClause($wrapper);
             } else {
                 $this->addClause(new HasFilterClause('tags', $pageKey));
             }
             break;
         case IPage::TYPE_CATEGORY:
             $this->addClause(new IsFilterClause('category', $page->getPageKey()));
             break;
     }
 }
Example #4
0
 /**
  * Gets whether the given page is a category listing.
  */
 public static function isCategory(IPage $page)
 {
     return $page->getPageType() == IPage::TYPE_CATEGORY;
 }