コード例 #1
0
 /**
  * Locate the file paths of the template, CSS and JS files
  * based on the supplied array of file names. The file name
  * array should be in order of highest priority first, lowest
  * priority last.
  *
  * @access public
  * @since  0.8
  * @static
  * @uses   filePaths()
  *
  * @param  array $files An indexed array of file names to search for.
  * @param  string $return
  *
  * @return mixed bool|string The absolute file system path to the located file. False is file not found.
  */
 public static function file($files, $return = 'path')
 {
     $path = FALSE;
     $files = array_filter((array) $files);
     // Try locating this template file by looping through the template paths.
     foreach (self::filePaths() as $filePath) {
         // Try to find a template file.
         foreach ($files as $fileName) {
             // var_dump( $filePath . $fileName );
             if (file_exists($filePath . $fileName)) {
                 // var_dump( $filePath . $fileName );
                 $path = $filePath . $fileName;
                 break 2;
             }
         }
     }
     switch ($return) {
         case 'url':
             $result = $path ? cnURL::fromPath($path) : $path;
             break;
         default:
             $result = $path;
             break;
     }
     return $result;
 }
コード例 #2
0
 /**
  * Get the template base URL.
  *
  * @access public
  * @since  0.7.6
  * @uses   cnURL::fromPath()
  * @uses   getPath()
  *
  * @return string
  */
 public function getURL()
 {
     /*
      * The template URL is required when registering a template, but is not enforced.
      * So, there is a possibility that this value is empty.
      *
      * Let get the URL from the $this->getPath().
      */
     if (empty($this->url)) {
         $this->url = cnURL::fromPath($this->getPath());
     }
     return $this->url;
 }