Ejemplo n.º 1
0
    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);
        @Ak::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'));
        }
    }
Ejemplo n.º 2
0
 function generate()
 {
     $this->_preloadPaths();
     $this->save(AK_APP_DIR . DS . $this->controller_path, $this->render('controller'));
     $this->save(AK_HELPERS_DIR . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper'));
     $this->save(AK_TEST_DIR . DS . 'functional' . DS . $this->controller_path, $this->render('functional_test'));
     $this->save(AK_TEST_DIR . DS . 'fixtures' . DS . 'app' . DS . $this->controller_path, $this->render('fixture'));
     $this->save(AK_TEST_DIR . DS . 'fixtures' . DS . 'app' . DS . 'helpers' . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper_fixture'));
     @Ak::make_dir(AK_VIEWS_DIR . DS . $this->module_path . AkInflector::underscore($this->controller_name));
     foreach ($this->actions as $action) {
         //$this->action = $action;
         $this->assignVarToTemplate('action', $action);
         $this->assignVarToTemplate('path', 'AK_VIEWS_DIR.DS.\'' . $this->module_path . AkInflector::underscore($this->controller_name) . '/' . $action . '.tpl\'');
         $this->save(AK_VIEWS_DIR . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.tpl', $this->render('view'));
     }
 }
Ejemplo n.º 3
0
Archivo: Ak.php Proyecto: joeymetal/v1
 /**
  * This static method will copy recursively all the files or directories from one
  * path within an Akelos application to another.
  * 
  * It uses current installation settings, so it can perform copies via the filesystem or via FTP
  */
 function copy($origin, $target, $options = array())
 {
     $default_options = array('ftp' => defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP, 'base_path' => AK_BASE_DIR);
     $options = array_merge($default_options, $options);
     $sucess = true;
     $origin = Ak::_getRestrictedPath($origin, $options);
     $target = Ak::_getRestrictedPath($target, $options);
     if (empty($origin) || empty($target)) {
         return false;
     }
     if ($options['ftp']) {
         require_once AK_LIB_DIR . DS . 'AkFtp.php';
     }
     $destination = str_replace($origin, $target, $origin);
     if (is_file($options['base_path'] . DS . $origin)) {
         return Ak::file_put_contents($options['base_path'] . DS . $destination, Ak::file_get_contents($options['base_path'] . DS . $origin, $options), $options);
     }
     Ak::make_dir($options['base_path'] . DS . $destination);
     if ($fs_items = glob($options['base_path'] . DS . $origin . "/*")) {
         $items_to_copy = array('directories' => array(), 'files' => array());
         foreach ($fs_items as $fs_item) {
             $items_to_copy[is_dir($fs_item) ? 'directories' : 'files'][] = $fs_item;
         }
         foreach ($items_to_copy['files'] as $file) {
             $destination = str_replace($origin, $target, $file);
             $sucess = $sucess ? Ak::file_put_contents($destination, Ak::file_get_contents($file, $options), $options) : $sucess;
         }
         foreach ($items_to_copy['directories'] as $directory) {
             $destination = str_replace($origin, $target, $directory);
             $sucess = $sucess ? Ak::copy($directory, $destination, $options) : $sucess;
         }
     }
     return $sucess;
 }
Ejemplo n.º 4
0
Archivo: Ak.php Proyecto: joeymetal/v1
 function make_dir($path, $options = array())
 {
     $default_options = array('ftp' => defined('AK_READ_FILES_USING_FTP') && AK_READ_FILES_USING_FTP, 'base_path' => AK_BASE_DIR);
     $options = array_merge($default_options, $options);
     $path = trim(str_replace($options['base_path'], '', $path), DS);
     if ($options['ftp']) {
         require_once AK_LIB_DIR . DS . 'AkFtp.php';
         $path = trim(str_replace(array(DS, '//'), array('/', '/'), $path), '/');
         return AkFtp::make_dir($path);
     } else {
         $path = $options['base_path'] . DS . $path;
         if (!file_exists($path)) {
             Ak::make_dir(dirname($path), $options);
             return mkdir($path);
         }
     }
     return false;
 }
Ejemplo n.º 5
0
 public function test_should_delete_nested_directories_when_include_hidden_files()
 {
     $tmp_dir = AK_TMP_DIR . DS . Ak::randomString();
     $hidden_tmp_dir = $tmp_dir . DS . '.hidden';
     Ak::make_dir($tmp_dir, array('base_path' => AK_TMP_DIR));
     Ak::make_dir($tmp_dir . DS . '.hidden', array('base_path' => AK_TMP_DIR));
     $this->assertTrue(is_dir($hidden_tmp_dir), 'Could not create test directory ' . $hidden_tmp_dir);
     $this->assertTrue(Ak::directory_delete($tmp_dir, array('base_path' => AK_TMP_DIR)));
     clearstatcache();
     $this->assertFalse(is_dir($tmp_dir));
 }
Ejemplo n.º 6
0
 /**
  * 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
  */
 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'])) {
                 Ak::make_dir($options['cacheDir'], array('base_path' => dirname($options['cacheDir'])));
             }
             $this->_driverInstance =& new Cache_Lite($options);
             break;
         case 2:
             require_once AK_LIB_DIR . '/AkCache/AkAdodbCache.php';
             $this->_driverInstance =& new AkAdodbCache();
             $res = $this->_driverInstance->init($options);
             $this->cache_enabled = $res;
             break;
         case 3:
             require_once AK_LIB_DIR . '/AkCache/AkMemcache.php';
             $this->_driverInstance =& new AkMemcache();
             $res = $this->_driverInstance->init($options);
             $this->cache_enabled = $res;
             break;
         default:
             $this->cache_enabled = false;
             break;
     }
 }
Ejemplo n.º 7
0
    /**
     * 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
     */
    function _copyRemoteDir($source, $destination)
    {
        $dir_name = trim(substr($source, strrpos(rtrim($source, '/'), '/')),'/');
        Ak::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);
        }
    }
Ejemplo n.º 8
0
 function test_should_delete_nested_directories_when_include_hidden_files()
 {
     $dir_name = AK_TMP_DIR . Ak::randomString();
     Ak::make_dir($dir_name);
     Ak::make_dir($dir_name . DS . '.hidden');
     $this->assertTrue(is_dir($dir_name), 'Could not create test directory ' . $dir_name);
     $this->assertTrue(Ak::directory_delete($dir_name));
     clearstatcache();
     $this->assertFalse(is_dir($dir_name));
 }