Begins search for directories matching mask.
public static findDirectories ( $masks ) : self | ||
Результат | self |
public function beforeRender() { $albumsPaths = null; $path = 'gallery/'; $a = 0; $albumsNames = null; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { DIRECTORY_SEPARATOR == '/'; } else { DIRECTORY_SEPARATOR == '\\'; } foreach (Finder::findDirectories('*')->exclude('[0-9][0-9][0-9]', '_big')->in($path) as $key => $file) { $albumsNames[] = str_replace("gallery" . DIRECTORY_SEPARATOR, "", $key); $albumsPaths[] = $key; $i = 0; $nImg = 0; if (($files = @scandir($key)) && count($files) <= 2) { $albumImgs[$a] = null; $this->template->thumbs = null; } else { foreach (Finder::findFiles('*.jpg', '*.png', '*.jpeg', '*.JPG', '*.PNG', '*.JPEG')->in($key) as $key2 => $file) { $albumImgs[$a] = $file->getFilename(); $i++; } $this->template->thumbs = $albumImgs; } $a++; } $this->template->albumsNames = $albumsNames; }
/** * Generate dir structure tree * * @param string $dir Path to root dir * @param boolean $showFiles Show files * * @return \Nette\Utils\Html */ private function generateTree($dir, $showFiles = true) { if (!is_dir($dir)) { throw new \Exception("Directory '{$dir}' does not exist!"); } if ($showFiles) { $files = Finder::find("*")->in($dir); } else { $files = Finder::findDirectories("*")->in($dir); } $list = Html::el("ul"); foreach ($files as $file) { // Create file link $link = Html::el("a")->href($file->getRealPath())->title($file->getRealPath()); if ($file->isDir()) { $link[0] = Html::el("i")->class("icon-folder-open"); } else { $link[0] = Html::el("i")->class("icon-file"); } $link[1] = Html::el("span", Strings::truncate($file->getFileName(), 30)); // Create item in list $item = Html::el("li"); $item[0] = $link; if ($file->isDir()) { $item[1] = $this->generateTree($file->getPathName(), $showFiles); } $list->add($item); } return $list; }
public function getAvailableThemes() { $directories = array_keys(iterator_to_array(Finder::findDirectories('*')->in($this->getThemesDir()))); array_walk($directories, function (&$item) { $item = basename($item); }); return $directories; }
private function getUnimportedTasks($folder) { $importedExperiments = \Nette\Utils\Finder::findDirectories('*')->in($folder)->imported(TRUE)->toArray(); if (count($importedExperiments) == 0) { return array(); } return \Nette\Utils\Finder::findDirectories('*')->in($importedExperiments)->imported(FALSE)->aborted(FALSE); }
/** * Returns all declared namespaces * * @return array */ public function getDeclaredNamespaces() { $namespaces = array(); /** @var $file \SplFileInfo */ foreach (Finder::findDirectories("*")->in($this->assetsDir)->exclude($this->generatedDirs) as $file) { $namespaces[] = $file->getFilename(); } return $namespaces; }
public function findPackages() { $packages = []; foreach (Finder::findDirectories('*')->in($this->packagesDir) as $package) { $package = $this->register($package); $packages[$package['name']] = $package; } return $packages; }
/** * @param $module * @return array */ public function getLayoutsByModule($module) { $data = array(); $path = $this->modules[$module]['path'] . '/Resources/layouts'; if (file_exists($path)) { foreach (Finder::findDirectories("*")->in($path) as $file) { if (file_exists($file->getPathname() . '/@layout.latte')) { $data[$file->getBasename()] = "@{$module}Module/{$file->getBasename()}/@layout.latte"; } } } return $data; }
/** * @param string $keyIdentifier * @return Article * @throws ArticleKeyIdentifierNotValidException * @throws ArticleNotFoundException */ public function getArticle($keyIdentifier) : Article { $articleFullPath = $this->getArticleFullPath(); $this->validateKeyIdentifier($keyIdentifier); $mask = sprintf('*/*/%s', $keyIdentifier); $result = Finder::findDirectories($mask)->from($articleFullPath); $iterator = $result->getIterator(); $iterator->rewind(); if (($articleDirectory = $iterator->current()) === null) { throw new ArticleNotFoundException(sprintf("Article identified by: '%s' NOT found.", $keyIdentifier)); } $relativePath = $this->parseRelativePath($articleDirectory); return $this->articleBuilder->getArticle($articleDirectory, $relativePath); }
/** * @param string $dir */ public static function cleanAll($dir) { foreach (\Nette\Utils\Finder::findFiles('*')->from($dir) as $file) { unlink($file); } $array = iterator_to_array(\Nette\Utils\Finder::findDirectories('*')->from($dir)); usort($array, function ($a, $b) { $aC = substr_count($a, '/') + substr_count($a, '\\'); $bC = substr_count($b, '/') + substr_count($b, '\\'); return $aC === $bC ? 0 : ($aC < $bC ? 1 : -1); }); foreach ($array as $file) { rmdir($file); } }
/** * @return Form */ public function create() { $form = $this->factory->create(); $pages = $this->pagesRepository->getAll()->fetchPairs('id', 'name'); $themes = []; foreach (Finder::findDirectories('*')->in(__DIR__ . '/../../../themes') as $dir) { /** @var \SplFileInfo $dir */ $filename = $dir->getFilename(); $themes[$filename] = $filename; } $form->addText('siteName', "messages.settings.siteName")->setAttribute('placeholder', "messages.settings.siteName")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsSiteName"); $form->addText('adminMail', "messages.settings.adminMail")->setAttribute('placeholder', "messages.settings.adminMail")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsAdminMail"); $form->addText('companyMail', "messages.settings.companyMail")->setAttribute('placeholder', "messages.settings.companyMail")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsCompanyMail"); $form->addText('companyPhone', "messages.settings.companyPhone")->setAttribute('placeholder', "messages.settings.companyPhone")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsCompanyPhone"); $form->addText('companyAddress', "messages.settings.companyAddress")->setAttribute('placeholder', "messages.settings.companyAddress")->setAttribute('class', 'form-control input-sm')->setRequired("messages.settings.plsCompanyAddress"); $form->addText('noreplyMail', "messages.settings.noreplyMail")->setAttribute('placeholder', "messages.settings.noreplyMail")->setAttribute('class', 'form-control input-sm'); $form->addText('motto1', "messages.settings.motto1")->setAttribute('placeholder', "messages.settings.motto1")->setAttribute('class', 'form-control input-sm'); $form->addText('motto2', "messages.settings.motto2")->setAttribute('placeholder', "messages.settings.motto2")->setAttribute('class', 'form-control input-sm'); $form->addSelect('theme', "messages.settings.template", $themes)->setAttribute('class', 'form-control input-sm'); $form->addText('smtpHost', "messages.settings.smtpServer")->setAttribute('placeholder', "messages.settings.smtpServer")->setAttribute('class', 'form-control input-sm'); $form->addText('smtpUsername', "messages.settings.smtpUsername")->setAttribute('placeholder', "messages.settings.smtpUsername")->setAttribute('class', 'form-control input-sm'); $form->addText('smtpPassword', "messages.settings.smtpPassword")->setAttribute('placeholder', "messages.settings.smtpPassword")->setAttribute('class', 'form-control input-sm'); $form->addText('smtpSecure', "messages.settings.smtpSecure")->setAttribute('placeholder', "messages.settings.smtpSecure")->setAttribute('class', 'form-control input-sm'); $form->addCheckbox('useMail', "messages.settings.useMail")->setAttribute('placeholder', "messages.settings.useMail")->setAttribute('class', 'bootstrap'); $form->addTextArea('ownScript', "messages.settings.footerScript")->setAttribute('placeholder', "messages.settings.footerScript")->setAttribute('class', 'form-control input-sm')->setAttribute('rows', '20'); $form->addSelect('thanksPage', "messages.settings.thanksPage", $pages)->setAttribute('class', 'form-control input-sm select2'); $form->addCheckbox('showAsBlog', "messages.settings.showAsBlog")->setAttribute('class', 'bootstrap'); $form->addText('pagesPerPage', "messages.settings.pagesPerPage")->setAttribute('placeholder', "messages.settings.pagesPerPage")->setAttribute('class', 'form-control input-sm'); $form->addText('rowInRss', "messages.settings.rowInRss")->setAttribute('placeholder', "messages.settings.rowInRss")->setAttribute('class', 'form-control input-sm'); $form->addText('logo', "messages.settings.logo")->setAttribute('placeholder', "messages.settings.logo")->setAttribute('onclick', 'openKCFinder(this)')->setAttribute('class', 'form-control input-sm'); $form->addText('sliderInterval', "messages.settings.interval")->setAttribute('placeholder', "messages.settings.interval")->setAttribute('class', 'form-control input-sm'); $form->addSubmit('process', "messages.settings.btnSubmit")->setAttribute('class', 'btn btn-primary'); $form->setRenderer(new BootstrapRenderer()); $form->onSuccess[] = function (Form $form) { $this->formSucceeded($form); }; return $form; }
<?php /** * Created by PhpStorm. * User: Azathoth * Date: 10. 1. 2016 * Time: 15:29 */ require_once 'vendor/autoload.php'; use Nette\Utils\Finder; use Nette\Utils\Strings; $directions = ['nahoru' => true, 'dolù' => false, 'doleva' => true, 'doprava' => false]; //true øíká, zda je cílová buòka sudá /** @var \SplFileInfo $colorDirectory */ foreach (Finder::findDirectories('*')->from(__DIR__ . '/imagesOld') as $colorDirectory) { \Nette\Utils\FileSystem::createDir(__DIR__ . '/imagesNew/' . $colorDirectory->getBasename()); $directionImages = []; $directionImages['startCell'] = []; $startCellImages = []; $directionImages['targetCell'] = []; $targetCellImages = []; foreach (array_keys($directions) as $direction) { $directionImages['startCell'][$direction] = []; $directionImages['targetCell'][$direction] = []; } /** @var \SplFileInfo $image */ foreach (Finder::find('*')->from($colorDirectory->getPathname()) as $image) { // echo $image->getPathname() . PHP_EOL; foreach ($directions as $direction => $isTargetEven) { //rozlišení smìru if (Strings::contains($image->getBasename(), $direction)) {
/** * Determines Bower components directory. * @return string */ private function getBowerDir() { // Load from configuration if (isset($this->config['directory'])) { return $this->config['directory']; } // Find .bowerrc $bowerrcs = Finder::findFiles('.bowerrc')->in(array($this->containerBuilder->parameters['wwwDir'], $this->containerBuilder->parameters['wwwDir'] . '/..')); foreach ($bowerrcs as $rc => $spl) { try { $bowerrc = Json::decode(@file_get_contents($rc)); if (isset($bowerrc->directory)) { return dirname($rc) . '/' . $bowerrc->directory; } } catch (JsonException $e) { throw new BowerLoaderException("Error while loading '{$rc}'", NULL, $e); } } // Find bower_components $directories = Finder::findDirectories('bower_components')->in(array($this->containerBuilder->parameters['wwwDir'], $this->containerBuilder->parameters['wwwDir'] . '/..')); foreach ($directories as $directory => $spl) { return $directory; } }
/** * @return Nette\Utils\Finder */ public function getSubdirectories() { if ($this->subdirs === NULL) { $this->subdirs = Nette\Utils\Finder::findDirectories('*')->from($this->getRoot()); } return $this->subdirs; }
/** * Find all modules in filesystem. * * @return IModule[] */ public function findModules() { if ($this->_findModules === NULL) { $this->_findModules = array(); foreach (Finder::findDirectories('*')->in($this->libsDir) as $dir) { foreach (Finder::findDirectories('*')->in($dir) as $dir2) { foreach (self::$moduleFiles as $moduleFile) { foreach (Finder::findFiles($moduleFile)->in($dir2) as $file) { $this->findModulesClosure($file); } } } } foreach (Finder::findDirectories('*')->in($this->modulesDir) as $dir2) { foreach (self::$moduleFiles as $moduleFile) { foreach (Finder::findFiles($moduleFile)->in($dir2) as $file) { $this->findModulesClosure($file); } } } } return $this->_findModules; }
<?php /** * Created by PhpStorm. * User: Azathoth * Date: 11. 1. 2016 * Time: 15:30 */ require_once 'vendor/autoload.php'; use Nette\Utils\Finder; use Nette\Utils\Strings; /** @var \SplFileInfo $file */ foreach (Finder::findFiles('dolù*')->from(__DIR__ . '/imagesNew') as $file) { echo $file->getBasename() . PHP_EOL; \Nette\Utils\FileSystem::rename($file->getPathname(), Strings::replace($file->getPathname(), '~ù~', 'u')); } $translateColors = ['FIALOVÝ' => 'violet', 'ZELENEJ' => 'green', 'MODREJ' => 'blue', 'ÈERVENÝ' => 'red', 'ÈERNEJ' => 'black']; foreach ($translateColors as $czech => $english) { /** @var \SplFileInfo $file */ foreach (Finder::findDirectories("{$czech}*")->from(__DIR__ . '/imagesNew') as $file) { echo $file->getBasename() . PHP_EOL; \Nette\Utils\FileSystem::rename($file->getPathname(), Strings::replace($file->getPathname(), "~{$czech}~", $english)); } }
public function resetDiskPermisions($dest) { foreach (\Nette\Utils\Finder::findDirectories('*')->from($dest) as $dir) { @chmod($dir, 0777); } }
require __DIR__ . '/../vendor/autoload.php'; use Nette\Utils\Finder; $dir = "./blog"; if (strpos(dirname(__FILE__), '/', 0) !== false) { define('WINDOWS_SERVER', false); } else { define('WINDOWS_SERVER', true); } echo "--- Setting up PHP..." . PHP_EOL; set_time_limit(0); date_default_timezone_set('Europe/Prague'); echo "--- Installing blog via Composer... [can take a while]" . PHP_EOL; echo exec("composer create-project --no-interaction mrtnzlml/zeminem.cz blog dev-develop"); echo "--- Cleaning project..." . PHP_EOL; $working_dir = realpath($dir); foreach (Finder::findDirectories(".git")->from($working_dir)->childFirst() as $file) { delete($file); } foreach (Finder::findFiles(".git*")->from($working_dir) as $file) { delete($file); } delete($working_dir . DIRECTORY_SEPARATOR . '.travis.yml'); delete($working_dir . DIRECTORY_SEPARATOR . 'composer.json'); delete($working_dir . DIRECTORY_SEPARATOR . 'composer.lock'); delete($working_dir . DIRECTORY_SEPARATOR . '.git'); delete($working_dir . DIRECTORY_SEPARATOR . 'tests'); delete($working_dir . DIRECTORY_SEPARATOR . 'build'); delete($working_dir . DIRECTORY_SEPARATOR . 'temp/cache'); echo "--- Creating ZIP archive..." . PHP_EOL; $source = './blog/'; $destination = './blog.zip';
$genresManager = $container->getByType(\App\Model\GenresManager::class); if ($argc < 2) { echo 'Adds all songs in chosen directory to jukebox. ' . PHP_EOL . 'Good for batch processing and large amount of songs.' . PHP_EOL . 'Usage: php add-songs.php <songsDirectory>'; exit(0); } $relativePath = $argv[1]; $path = getcwd() . DIRECTORY_SEPARATOR . $relativePath; echo $path . PHP_EOL; $songs = \Nette\Utils\Finder::findFiles('*.*')->from($path); // zobrazování procent $count = $songs->count(); $i = 0; $previous = 0; //zobrazování procent /** @var \SplFileInfo $genreDirectory */ foreach (\Nette\Utils\Finder::findDirectories('*')->from($path) as $genreDirectory) { $genre = $genreDirectory->getBasename(); $genresManager->addGenre($genre); /** @var \SplFileInfo $file */ foreach (\Nette\Utils\Finder::findFiles('*.*')->from($genreDirectory->getRealPath()) as $file) { $time_pre = microtime(true); $songsManager->addSongFromCLI($file, $genre); $time_post = microtime(true); $exec_time = $time_post - $time_pre; echo $exec_time . PHP_EOL; $i++; $percentage = (int) ($i * 100 / $count); if ($percentage > $previous) { echo "{$percentage}% done" . PHP_EOL; } $previous = $percentage;