Exemple #1
0
 public function Test_copy_directories()
 {
     $original_path = 'ak_test_folder';
     $copy_path = $original_path . '_copy';
     $this->assertTrue(Ak::copy($original_path, $copy_path));
     $file_name = $copy_path . '/new_folder/test_file.txt';
     $content = "\rThis is the content of the test file";
     $this->assertTrue(Ak::file_get_contents($file_name) === $content);
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
 function __construct()
 {
     empty($this->avoid_copying_views) && Ak::copy(AK_BASE_DIR.DS.'app'.DS.'views',AK_VIEWS_DIR);
 }
 function manifest()
 {
     Ak::copy($this->_generator_base_path.DS.'templates', AK_PUBLIC_DIR.DS.'stylesheets'.DS.'calendar');
 }