Example #1
0
 /**
  * Similar to the path() method, but uses the $themePath as the path from
  * which the user-specified path is relative.
  *
  * @param string $path Relative path from themePath.
  * @access public
  */
 public function themePath($path, $included = false)
 {
     if (is_array($path)) {
         $path = implode('/', $path);
     }
     // Remove frag for file checking.
     $frag = "";
     preg_match("/(\\?|\\#).*/", $path, $matches);
     if (count($matches)) {
         $frag = $matches[0];
         $path = substr($path, 0, -strlen($frag));
     }
     $uri = $this->path("{$this->themePath}/{$this->themeName}/{$path}", $included);
     // normalized basePath.
     $base = preg_replace('/(\\/+)$/', '', $this->basePath) . '/';
     $base = preg_quote($base, '/');
     $chk = FLUX_ROOT . '/' . preg_replace('/^(' . $base . ')/', '', $uri);
     // If file not found, search in parent's template.
     if (!file_exists($chk) && !empty($this->parentTemplate)) {
         $path = $this->parentTemplate->themePath($path, $included);
         $chk = FLUX_ROOT . '/' . preg_replace('/^(' . $base . ')/', '', $path);
         if (file_exists($chk)) {
             $uri = $path;
         }
     }
     return $uri . $frag;
 }