/**
  * Returns a path relative to a site's root directory.
  */
 public static function getRelativePath(IPieCrust $pieCrust, $path, $stripExtension = false)
 {
     $relativePath = PathHelper::getRelativePath($pieCrust->getRootDir(), $path);
     if ($stripExtension) {
         $relativePath = preg_replace('/\\.[a-zA-Z0-9]+$/', '', $relativePath);
     }
     return $relativePath;
 }
示例#2
0
 /**
  * Returns a path relative to a site's root directory.
  */
 public static function getRelativePath(IPieCrust $pieCrust, $path, $stripExtension = false)
 {
     $basePath = null;
     $themeDir = $pieCrust->getThemeDir();
     if ($themeDir and strncmp($path, $themeDir, strlen($themeDir)) == 0) {
         // Theme path.
         $basePath = $themeDir;
     } else {
         // Normal website path.
         $basePath = $pieCrust->getRootDir();
     }
     if (!$basePath) {
         throw new PieCrustException("Can't get a relative path for '{$path}': it doesn't seem to be either a website, theme or resource path.");
     }
     $relativePath = PathHelper::getRelativePath($basePath, $path);
     if ($stripExtension) {
         $relativePath = preg_replace('/\\.[a-zA-Z0-9]+$/', '', $relativePath);
     }
     return $relativePath;
 }
示例#3
0
 public function initialize(IPieCrust $pieCrust, $logger = null)
 {
     $this->rootDirLength = strlen($pieCrust->getRootDir());
 }