コード例 #1
0
ファイル: Linker.php プロジェクト: omnicolor/bulletphp-site
 /**
  * Creates a new instance of Linker.
  */
 public function __construct(IPage $page, $dir = null)
 {
     $this->page = $page;
     if ($dir != null) {
         $this->baseDir = $dir;
         $this->selfName = null;
     } else {
         $this->baseDir = dirname($page->getPath()) . '/';
         $this->selfName = basename($page->getPath());
     }
     $this->sortByName = null;
     $this->sortByReverse = false;
 }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
ファイル: Linker.php プロジェクト: giftnuss/PieCrust
 /**
  * Creates a new instance of Linker.
  */
 public function __construct(IPage $page, $dir = null)
 {
     $this->page = $page;
     $this->baseDir = $dir != null ? $dir : dirname($page->getPath());
     $this->baseDir = rtrim($this->baseDir, '/\\') . '/';
     $this->sortByName = null;
     $this->sortByReverse = false;
 }
コード例 #4
0
 /**
  * Gets the relative path of a page.
  */
 public static function getRelativePath(IPage $page, $stripExtension = false)
 {
     $basePath = null;
     $themeDir = $page->getApp()->getThemeDir();
     if ($themeDir and strncmp($page->getPath(), $themeDir, strlen($themeDir))) {
         // This is a theme page.
         switch ($page->getPageType()) {
             case IPage::TYPE_REGULAR:
             case IPage::TYPE_CATEGORY:
             case IPage::TYPE_TAG:
                 $basePath = $themeDir . PieCrustDefaults::CONTENT_PAGES_DIR;
                 break;
             case IPage::TYPE_POST:
                 $basePath = $themeDir . PieCrustDefaults::CONTENT_POSTS_DIR;
                 break;
             default:
                 throw new InvalidArgumentException("Unknown page type given: " . $page->getPageType());
         }
     } else {
         // This is a website page.
         switch ($page->getPageType()) {
             case IPage::TYPE_REGULAR:
             case IPage::TYPE_CATEGORY:
             case IPage::TYPE_TAG:
                 $basePath = $page->getApp()->getPagesDir();
                 break;
             case IPage::TYPE_POST:
                 $basePath = $page->getApp()->getPostsDir();
                 break;
             default:
                 throw new InvalidArgumentException("Unknown page type given: " . $page->getPageType());
         }
     }
     if (!$basePath) {
         throw new PieCrustException("Can't get a relative page path if no pages or posts directory exsists in the website.");
     }
     $relativePath = substr($page->getPath(), strlen($basePath));
     if ($stripExtension) {
         $relativePath = preg_replace('/\\.[a-zA-Z0-9]+$/', '', $relativePath);
     }
     return $relativePath;
 }
コード例 #5
0
ファイル: Assetor.php プロジェクト: giftnuss/PieCrust
 protected static function buildUrlBase(IPage $page, $assetUrlBaseRemap)
 {
     $siteRoot = $page->getApp()->getConfig()->getValueUnchecked('site/root');
     $relativePath = str_replace('\\', '/', PieCrustHelper::getRelativePath($page->getApp(), $page->getPath(), true));
     $uri = $page->getUri();
     $prettyUrls = PageHelper::getConfigValue($page, 'pretty_urls', 'site');
     if (!$prettyUrls) {
         // Remove the extension from the URI (if any), because without 'pretty URLs',
         // we want to copy assets to a directory named after the page's filename
         // (without the extension). See `PageBaker` for more information.
         $uriInfo = pathinfo($uri);
         $uri = $uriInfo['dirname'];
         if ($uri == '.') {
             $uri = '';
         } else {
             $uri .= '/';
         }
         $uri .= $uriInfo['filename'];
     }
     $replacements = array('%site_root%' => $siteRoot, '%path%' => $relativePath, '%uri%' => $uri);
     return str_replace(array_keys($replacements), array_values($replacements), $assetUrlBaseRemap);
 }