예제 #1
0
 private static function _getFileInfo($base, $action, $format = 'html')
 {
     // go see what templates are available
     $dirPrefixPatterns = array(APP_DIR, CORE_DIR);
     $fileNamePatterns = array($action . '.' . $format, $action);
     $fileTypes = array('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 = Find::findFile($prefixedBase . TEMPLATE_DIR . $layoutDir, $filePattern)) {
                         return array('filename' => $fileMatch, 'parser' => $parserType);
                     }
                 }
                 if ($fileMatch = Find::findFile($prefixedBase . TEMPLATE_DIR, $filePattern)) {
                     return array('filename' => $fileMatch, 'parser' => $parserType);
                 }
             }
         }
     }
     return false;
 }
예제 #2
0
파일: Meta.php 프로젝트: nabble/ajde-core
 /**
  * @return Ajde_Crud_Cms_Meta_Type[]
  */
 public function getTypes()
 {
     if (!$this->_types) {
         $ds = DIRECTORY_SEPARATOR;
         $files = 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;
 }
예제 #3
0
 public function copyFiles()
 {
     // make sure we are in the current dir
     chdir(Config::get('local_root'));
     $updateDir = TMP_DIR . 'update' . DIRECTORY_SEPARATOR;
     // directories to overwrite
     $installDirs = array(CORE_DIR, DEV_DIR, LIB_DIR . 'Ajde' . DIRECTORY_SEPARATOR, PUBLIC_DIR . 'css' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR, PUBLIC_DIR . 'js' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR, PUBLIC_DIR . 'media' . DIRECTORY_SEPARATOR . '_core' . DIRECTORY_SEPARATOR, PUBLIC_DIR . 'media' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR);
     // files to overwrite
     $rootFiles = Find::findFilenames($updateDir, '*');
     // make sure we have the update dir
     if (!is_dir(TMP_DIR . 'update')) {
         throw new Exception('Update directory not found');
     }
     // make sure we have all the neccesary files
     foreach ($installDirs as $installDir) {
         if (!is_dir($updateDir . $installDir)) {
             throw new Exception('Directory ' . $installDir . ' in update package not found');
         }
     }
     // make sure we have a new index.php before deleting the old one
     if (!is_file($updateDir . 'index.php')) {
         throw new Exception('File index.php in update package not found');
     }
     // delete index.php
     $delete_tries = 0;
     do {
         $delete_tries++;
         if ($delete_tries > 20) {
             throw new Exception('Unable to remove index.php, please try again later');
         }
         if ($delete_tries > 0) {
             sleep(1);
         }
         $deleted = @unlink('index.php');
     } while ($deleted === false);
     // empty directories and copy new files
     foreach ($installDirs as $installDir) {
         if (is_dir($updateDir . $installDir)) {
             // truncate first
             Directory::truncate($installDir);
             // then copy
             Directory::copy($updateDir . $installDir, $installDir);
         } else {
             throw new Exception('This is weird, should we make updating semaphored?');
         }
     }
     // copy individual files
     foreach ($rootFiles as $rootFile) {
         if (is_file($updateDir . $rootFile)) {
             copy($updateDir . $rootFile, $rootFile);
         }
     }
     // cleaning up TMP DIR
     unlink(TMP_DIR . 'update.zip');
     Directory::delete(TMP_DIR . 'update');
     return true;
 }
예제 #4
0
파일: Db.php 프로젝트: nabble/ajde-core
 private function installFromVersion($version = 'v0')
 {
     $sqlFiles = Find::findFiles(DEV_DIR . 'db' . DIRECTORY_SEPARATOR, 'v*.sql');
     usort($sqlFiles, array($this, 'versionSort'));
     foreach ($sqlFiles as $sqlFile) {
         $sqlFileVersion = pathinfo($sqlFile, PATHINFO_FILENAME);
         if (version_compare($sqlFileVersion, $version) > 0) {
             $this->executeFile($sqlFile);
         }
     }
 }
예제 #5
0
 public function getCacheStatus()
 {
     $hash = $this->getHash();
     $fileTimePattern = $hash['fileName'] . '.' . $hash['fileTime'] . '.' . $this->getType();
     if ($fileName = Find::findFile($this->getBase(), $fileTimePattern)) {
         return array('status' => self::CACHE_STATUS_EXIST, 'fileName' => $fileName);
     }
     $fileNamePattern = $hash['fileName'] . '.*.' . $this->getType();
     if ($fileName = Find::findFile($this->getBase(), $fileNamePattern)) {
         return array('status' => self::CACHE_STATUS_UPDATE, 'fileName' => $fileName);
     }
     return array('status' => self::CACHE_STATUS_NOT_EXIST, 'fileName' => '');
 }
예제 #6
0
 public function readConfigDir()
 {
     foreach (Find::findFiles(CONFIG_DIR, '*.json') as $configFile) {
         d($configFile);
     }
 }
예제 #7
0
파일: Lang.php 프로젝트: nabble/ajde-core
 public function getAvailableNiceNames()
 {
     $langs = Find::findFiles(LANG_DIR, '*');
     $return = array();
     foreach ($langs as $lang) {
         $lang = basename($lang);
         $return[$lang] = $this->getNiceName($lang);
     }
     return $return;
 }