private static function _getFileInfo($base, $action, $format = 'html') { // go see what templates are available $dirPrefixPatterns = [APP_DIR, CORE_DIR]; $fileNamePatterns = [$action . '.' . $format, $action]; $fileTypes = ['phtml' => 'Phtml', 'xhtml' => 'Xhtml']; foreach ($dirPrefixPatterns as $dirPrefixPattern) { $prefixedBase = $dirPrefixPattern . $base; foreach ($fileNamePatterns as $fileNamePattern) { foreach ($fileTypes as $fileType => $parserType) { $filePattern = $fileNamePattern . '.' . $fileType; if (!substr_count($prefixedBase, DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR)) { $layoutDir = 'layout.' . Ajde::app()->getDocument()->getLayout()->getName() . DIRECTORY_SEPARATOR; if ($fileMatch = Ajde_Fs_Find::findFile($prefixedBase . TEMPLATE_DIR . $layoutDir, $filePattern)) { return ['filename' => $fileMatch, 'parser' => $parserType]; } } if ($fileMatch = Ajde_Fs_Find::findFile($prefixedBase . TEMPLATE_DIR, $filePattern)) { return ['filename' => $fileMatch, 'parser' => $parserType]; } } } } return false; }
/** * TODO. * * @param string $directory * * @throws Exception */ public function readConfigDir($directory) { $environment = Ajde_Environment::current(); $searchDirs = [CORE_DIR . $directory, CORE_DIR . $directory . $environment . DS, APP_DIR . $directory, APP_DIR . $directory . $environment . DS]; foreach ($searchDirs as $searchDir) { foreach (Ajde_Fs_Find::findFiles($searchDir, '*.json') as $configFile) { if (!($configData = json_decode(file_get_contents($configFile), true))) { throw new Exception('Config file ' . $configFile . ' contains invalid JSON'); } $this->merge(pathinfo($configFile, PATHINFO_FILENAME), $configData); } } }
/** * @return Ajde_Crud_Cms_Meta_Type[] */ public function getTypes() { if (!$this->_types) { $ds = DIRECTORY_SEPARATOR; $files = Ajde_Fs_Find::findFiles(LIB_DIR . 'Ajde' . $ds . 'Crud' . $ds . 'Cms' . $ds . 'Meta' . $ds . 'Type' . $ds, '*.php'); foreach ($files as $file) { $filename = pathinfo($file, PATHINFO_FILENAME); $className = 'Ajde_Crud_Cms_Meta_Type_' . ucfirst($filename); $this->_types[strtolower($filename)] = new $className(); } ksort($this->_types); } return $this->_types; }
public function afterDelete() { // Delete main file $clean = Ajde_Fs_Find::findFiles($this->uploadDirectory, $this->pointer); // Delete thumbnail file $clean = array_merge($clean, Ajde_Fs_Find::findFiles($this->uploadDirectory, $this->thumbnail)); // Delete thumbs of main file $clean = array_merge($clean, Ajde_Fs_Find::findFiles($this->uploadDirectory . Ajde_Resource_Image::$_thumbDir . DS, pathinfo($this->pointer, PATHINFO_FILENAME) . '_*x*.' . pathinfo($this->pointer, PATHINFO_EXTENSION))); // Delete thumbs of thumbnail file $clean = array_merge($clean, Ajde_Fs_Find::findFiles($this->uploadDirectory . Ajde_Resource_Image::$_thumbDir . DS, pathinfo($this->thumbnail, PATHINFO_FILENAME) . '_*x*.' . pathinfo($this->thumbnail, PATHINFO_EXTENSION))); foreach (array_unique($clean) as $path) { unlink($path); } }
public function getCacheStatus() { $hash = $this->getHash(); $fileTimePattern = $hash['fileName'] . '.' . $hash['fileTime'] . '.' . $this->getType(); if ($fileName = Ajde_Fs_Find::findFile($this->getBase(), $fileTimePattern)) { return ['status' => self::CACHE_STATUS_EXIST, 'fileName' => $fileName]; } $fileNamePattern = $hash['fileName'] . '.*.' . $this->getType(); if ($fileName = Ajde_Fs_Find::findFile($this->getBase(), $fileNamePattern)) { return ['status' => self::CACHE_STATUS_UPDATE, 'fileName' => $fileName]; } return ['status' => self::CACHE_STATUS_NOT_EXIST, 'fileName' => '']; }
private function installFromVersion($version = 'v0') { $sqlFiles = Ajde_Fs_Find::findFiles(DEV_DIR . 'db' . DIRECTORY_SEPARATOR, 'v*.sql'); usort($sqlFiles, [$this, 'versionSort']); foreach ($sqlFiles as $sqlFile) { $sqlFileVersion = pathinfo($sqlFile, PATHINFO_FILENAME); if (version_compare($sqlFileVersion, $version) > 0) { $this->executeFile($sqlFile); } } }
public function getAvailableNiceNames() { $langs = Ajde_Fs_Find::findFiles(LANG_DIR, '*'); $return = []; foreach ($langs as $lang) { $lang = basename($lang); $return[$lang] = $this->getNiceName($lang); } return $return; }
public function doCleanthumbs() { $toBeCleaned = Ajde_Fs_Find::findFilenames(UPLOAD_DIR . Ajde_Resource_Image::$_thumbDir . DIRECTORY_SEPARATOR, '*.*'); foreach ($toBeCleaned as $file) { unlink(LOCAL_ROOT . UPLOAD_DIR . Ajde_Resource_Image::$_thumbDir . DIRECTORY_SEPARATOR . $file); } Ajde_Session_Flash::alert('Thumbnails will be refreshed next time they are loaded'); return $this->redirect(Ajde_Http_Response::REDIRECT_REFFERER); }