示例#1
0
文件: Check.php 项目: roggeo/glance
 /**
  * 
  * @param mixed $file
  * @param string $folder
  * @param string $extension Opcional
  * @param string $folder_theme Path to folder themes
  * @return string or array of files
  */
 public static function file($file, $folder, $extension = null)
 {
     $parser = new Parser();
     $folder = Filter::systemPath($folder);
     $file = Filter::systemPath($file);
     if (!$parser->file()->exists($folder)) {
         throw new Error("Directory \"{$folder}\" not found.");
     }
     if (!$file && $folder) {
         return self::fileAll($folder);
     }
     $no_extension = false;
     if (!$extension) {
         $no_extension = self::fileNoExtension($file, $folder);
     }
     if ($no_extension) {
         return $no_extension;
     }
     $parser = new Parser();
     Filter::file($file, $extension);
     if (is_string($file)) {
         $namefill = $folder . DIRECTORY_SEPARATOR . $file;
         if (!$parser->file()->exists($namefill)) {
             throw new Error("File \"{$namefill}\" not found.");
         }
         return $namefill;
     }
     if (!is_array($file)) {
         throw new Error("File invalid.");
     }
     $i = 0;
     foreach ($file as $val) {
         $namefill = $folder . DIRECTORY_SEPARATOR . $val;
         if (!$parser->file()->exists($namefill)) {
             throw new Error("File \"{$namefill}\" not found.");
         }
         $file[$i] = $namefill;
         $i++;
     }
     if ($i == count($file)) {
         return $file;
     }
 }
示例#2
0
 public function hasTreeTheme()
 {
     $folders = array($this->getCSS(), $this->getJS(), $this->getIMG());
     $files = array($this->getThemeConfig(), $this->getFileExample(), $this->getScreenshot());
     $parser = new Parser();
     foreach ($folders as $val) {
         if (!$parser->file()->exists($val)) {
             $this->error("Folder " . $val, $this->activated);
         }
     }
     foreach ($files as $val) {
         if (!$parser->file()->exists($val)) {
             $this->error("File " . $val, $this->activated);
         }
     }
 }