public function generate() { $this->_preloadPaths(); $this->save(AkConfig::getDir('app') . DS . $this->controller_path, $this->render('controller')); $this->save(AkConfig::getDir('helpers') . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper')); $this->save(AkConfig::getDir('test') . DS . 'functional' . DS . $this->controller_test_path, $this->render('functional_test')); $this->save(AkConfig::getDir('test') . DS . 'unit' . DS . 'helpers' . DS . $this->underscored_controller_name . "_helper_test.php", $this->render('helper_test')); @AkFileSystem::make_dir(AkConfig::getDir('views') . DS . $this->module_path . AkInflector::underscore($this->controller_name), $this->getFileOptions()); foreach ($this->actions as $action) { //$this->action = $action; $this->assignVarToTemplate('action', $action); $this->assignVarToTemplate('path', 'app' . DS . 'views' . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.html.tpl'); $this->save(AkConfig::getDir('views') . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.html.tpl', $this->render('view')); } }
function generate() { $this->_preloadPaths(); $this->class_name = AkInflector::camelize($this->class_name); $files = array('mailer' => AkInflector::toModelFilename($this->class_name), 'unit_test' => AK_TEST_DIR . DS . 'unit' . DS . 'app' . DS . 'models' . DS . $this->underscored_class_name . '.php'); foreach ($files as $template => $file_path) { $this->save($file_path, $this->render($template)); } $mailer_views_folder = AK_VIEWS_DIR . DS . AkInflector::underscore($this->class_name); @AkFileSystem::make_dir($mailer_views_folder); foreach ($this->actions as $action) { $this->assignVarToTemplate('action', $action); $path = $mailer_views_folder . DS . $action . '.tpl'; $this->assignVarToTemplate('path', $path); $this->save($path, $this->render('view')); } }
/** * Copy recursively a remote svn dir into a local path. * * Downloads recursively the contents of remote directories from a mod_svn Apache subversion interface to a local destination. * * File or directory permissions are not copied, so you will need to use installers to fix it if required. * * @param string $source An Apache mod_svn interface to subversion URL. * @param string $destination Destination directory * @return void * @access private */ private function _copyRemoteDir($source, $destination) { $dir_name = trim(substr($source, strrpos(rtrim($source, '/'), '/')), '/'); AkFileSystem::make_dir($destination . DS . $dir_name); list($directories, $files) = $this->_parseRemoteAndGetDirectoriesAndFiles($source); foreach ($files as $file) { $this->_copyRemoteFile($source . $file, $destination . DS . $dir_name . DS . $file); } foreach ($directories as $directory) { $this->_copyRemoteDir($source . $directory . '/', $destination . DS . $dir_name); } }
/** * Class constructor (ALA Akelos Framework) * * This method loads an instance of selected driver in order to * use it class wide. * * @access public * @param mixed $options You can pass a number specifying the second for * the cache to expire or an array with the * following options: * * <code> * $options = array( * //This options are valid for both cache contains (database and file based) * 'lifeTime' => cache lifetime in seconds * (int), * 'memoryCaching' => enable / disable memory caching (boolean), * 'automaticSerialization' => enable / disable automatic serialization (boolean) * * //This options are for file based cache * 'cacheDir' => directory where to put the cache files (string), * 'caching' => enable / disable caching (boolean), * 'fileLocking' => enable / disable fileLocking (boolean), * 'writeControl' => enable / disable write control (boolean), * 'readControl' => enable / disable read control (boolean), * 'readControlType' => type of read control * 'crc32', 'md5', 'strlen' (string), * 'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int), * 'onlyMemoryCaching' => enable / disable only memory caching (boolean), * 'memoryCachingLimit' => max nbr of records to store into memory caching (int), * 'fileNameProtection' => enable / disable automatic file name protection (boolean), * 'automaticCleaningFactor' => distable / tune automatic cleaning process (int) * 'hashedDirectoryLevel' => level of the hashed directory system (int) * ); * </code> * @param integer $cache_type The default value is set by defining the constant AK_CACHE_HANDLER in the following line * * <code>define ('AK_CACHE_HANDLER', 1);</code> * * in the ''config/config.php'' file * * Possible values are: * * - 0: No cache at all * - 1: File based cache using the folder defined at AK_CACHE_DIR or the system /tmp dir * - 2: Database based cache. This one has a performance penalty, but works on most servers * - 3: Memcached - The fastest option * @return void */ public function init($options = null, $cache_type = null) { $options = is_int($options) ? array('lifeTime' => $options) : (is_array($options) ? $options : array()); switch ($cache_type) { case 1: $this->cache_enabled = true; if (!class_exists('Cache_Lite')) { require_once AK_CONTRIB_DIR . '/pear/Cache_Lite/Lite.php'; } if (!isset($options['cacheDir'])) { $options['cacheDir'] = AK_CACHE_DIR . DS; } else { $options['cacheDir'] .= DS; } if (!is_dir($options['cacheDir'])) { AkFileSystem::make_dir($options['cacheDir'], array('base_path' => dirname($options['cacheDir']))); } $this->DriverInstance = new Cache_Lite($options); break; case 2: $this->DriverInstance = new AkAdodbCache(); $res = $this->DriverInstance->init($options); $this->DriverInstance->install(); $this->cache_enabled = $res; break; case 3: $this->DriverInstance = new AkMemcache(); $res = $this->DriverInstance->init($options); $this->cache_enabled = $res; break; default: $this->cache_enabled = false; break; } }
public function test_should_create_base_path_ticket_148() { $tmp_dir = AkConfig::getDir('tmp') . DS . Ak::randomString(); $base_path = AkConfig::getDir('tmp') . 'new_dir_' . time(); AkFileSystem::make_dir($base_path, array('base_path' => $base_path)); $this->assertTrue(is_dir($base_path), 'Could base_path directory ' . $base_path); clearstatcache(); }
/** * @deprecated * @uses AkFileSystem::make_dir */ static function make_dir($path, $options = array()) { Ak::deprecateMethod(__METHOD__, 'AkFileSystem::make_dir()'); return AkFileSystem::make_dir($path, $options); }
list($major, $minor, $status) = explode('.', str_replace('-', '.', $version_candidate) . '...'); if (!empty($options['status'])) { $status = is_numeric($options['status']) ? $options['status'] : array_search($options['status'], array('alpha', 'beta', 'rc', 'pr')); } if (!empty($options['minor']) && $minor != $options['minor']) { $minor = $options['minor']; } if (!empty($options['major']) && $major != $options['major']) { $major = $options['major']; } $options['version'] = (int) $major . '.' . (int) $minor . '.' . (int) $status; } $options['tag'] = empty($options['tag']) ? '' : '-' . $options['tag']; $skip_updating_version_number = !empty($options['skip_version_update']) || $options['tag'] == 'ci' || $options['tag'] == 'nighly'; $options['path'] = empty($options['path']) ? MAKELOS_BASE_DIR . DS . 'releases' : $options['path']; strstr($options['path'], MAKELOS_BASE_DIR) && AkFileSystem::make_dir($options['path'], array('base_path' => MAKELOS_BASE_DIR)); echo "Building version " . $options['version'] . $options['tag'] . "\n"; if (!$skip_updating_version_number) { file_put_contents($version_file, $options['version']); if (false && !empty($options['skip_commit_version'])) { @`git add {$version_file}`; @`git commit {$version_file} -m "Updating version"`; } } $preffix = $options['app_name'] . '-' . $options['version'] . ($options['commit'] ? '-' . $options['revision'] : '') . $options['tag']; foreach ($options['format'] as $format) { $file_path = "{$options['path']}/{$preffix}"; if ($format == 'tar' && empty($options['skip_gzip'])) { $file_name = $file_path . '.tar.gz'; $command = "git archive --format={$format} --prefix={$preffix}/ {$options['revision']} | gzip > {$file_name}"; } else {