Esempio n. 1
0
 public function getIcons($folderName, $path)
 {
     unset($this->icons);
     $filesPathes = Finder::findFiles('*')->from($folderName);
     $files = $this->isolateNames($path, $filesPathes);
     foreach ($files as $file) {
         foreach ($this->supportedTypes as $type) {
             if ($this->isolateType($file) == $type) {
                 $this->icons[] = $file;
             }
         }
     }
     $this->iconNames = $this->isolateNames($path, $this->icons);
     return $this->iconNames;
 }
Esempio n. 2
0
 /**
  * Scan a directory for PHP files, subdirectories and 'netterobots.txt' file.
  * @param  string
  * @return void
  */
 private function scanDirectory($dir)
 {
     if (is_dir($dir)) {
         $disallow = array();
         $iterator = Nette\Finder::findFiles(String::split($this->acceptFiles, '#[,\\s]+#'))->filter(function ($file) use(&$disallow) {
             return !isset($disallow[$file->getPathname()]);
         })->from($dir)->exclude(String::split($this->ignoreDirs, '#[,\\s]+#'))->filter($filter = function ($dir) use(&$disallow) {
             $path = $dir->getPathname();
             if (is_file("{$path}/netterobots.txt")) {
                 foreach (file("{$path}/netterobots.txt") as $s) {
                     if ($matches = String::match($s, '#^disallow\\s*:\\s*(\\S+)#i')) {
                         $disallow[$path . str_replace('/', DIRECTORY_SEPARATOR, rtrim('/' . ltrim($matches[1], '/'), '/'))] = TRUE;
                     }
                 }
             }
             return !isset($disallow[$path]);
         });
         $filter(new \SplFileInfo($dir));
     } else {
         $iterator = new \ArrayIterator(array(new \SplFileInfo($dir)));
     }
     foreach ($iterator as $entry) {
         $path = $entry->getPathname();
         if (!isset($this->files[$path]) || $this->files[$path] !== $entry->getMTime()) {
             $this->scanScript($path);
         }
     }
 }
Esempio n. 3
0
	/**
	 * Returns list of available languages.
	 *
	 * @author   Jan Tvrdík
	 * @param    string
	 * @return   array             # => langCode
	 */
	public function getAvailableLanguages($page)
	{
		$langs = array();
		$templates = Nette\Finder::findFiles("$page.*.latte")->in(TEMPLATES_DIR);
		foreach ($templates as $template) {
			$langs[] = substr($template, -8, 2);
		}
		return $langs;
	}
Esempio n. 4
0
	protected function analyse() {
		$this->isSource = TRUE;
		// collect informations from all classes
		foreach(array_merge(array($this->sourceDir), $this->libDirs) as $dir) {
			foreach(Finder::findFiles("*.php")->from($dir)->exclude($this->ignoredDirs) as $fileInfo) {
				debug::timer($fileInfo->getFilename());
				$this->parseFile($fileInfo->getPath() . "/" . $fileInfo->getFilename());
				$this->onOutput(self::OI_FILE_ANALYSED, array(
					self::FILE => $fileInfo->getFilename(),
					self::TIME => debug::timer($fileInfo->getFilename()),
				));
			}

			$this->isSource = FALSE;
		}
	}