Exemplo n.º 1
0
function generateDocs($folder = 'creamture')
{
    if (!file_exists('docs/' . $folder)) {
        println('Docs folder doesn\'t exists');
        return;
    }
    $daux_global = array('docs_directory' => '../../../docs/' . $folder, 'valid_markdown_extensions' => array('md', 'markdown'));
    if (file_put_contents('docs/global.json', json_encode($daux_global)) === FALSE) {
        println('Error writing global conf in docs folder');
        exit;
    }
    require_once 'vendor/justinwalsh/daux.io/libs/daux.php';
    foreach (glob('docs/assets/templates/*') as $directory) {
        if (strpos('.', $directory) < 0) {
            @rmdir('vendor/justinwalsh/daux.io/templates/' . $directory);
        }
    }
    //Copy alternative imgs, js and templates
    directory_copy('docs/assets/templates', 'vendor/justinwalsh/daux.io/templates');
    if (file_exists('docs/assets/' . $folder . '_img')) {
        directory_copy('docs/assets/' . $folder . '_img', 'vendor/justinwalsh/daux.io/img');
    }
    $Daux = new \Todaymade\Daux\Daux(realpath('docs/global.json'));
    $Daux->initialize();
    if (!file_exists(PUBLICPATH . 'docs/' . $folder)) {
        mkdir(PUBLICPATH . 'docs/' . $folder, 0777, TRUE);
    }
    $Daux->generate_static(PUBLICPATH . 'docs/' . $folder);
    println('Docs generated in public folder');
}
Exemplo n.º 2
0
 public function test_directory()
 {
     $dir1 = path(self::getDir(), 'dir_1/dir1');
     $dir1_file = path($dir1, 'foo.txt');
     $dir1_file_content = 'foo bar';
     $dir2 = path(self::getDir(), 'dir_2/dir2');
     $dir2_file = path($dir2, 'foo.txt');
     $dir3 = path(self::getDir(), 'dir_3/dir3');
     $dir3_file = path($dir3, 'foo.txt');
     $dir4 = path(self::getDir(), '/dir_3/dir-3');
     $dir4_name = 'dir-3';
     $dir4_file = path($dir4, 'foo.txt');
     $this->assertFalse(directory_exists($dir1));
     directory_create($dir1);
     file_write($dir1_file, $dir1_file_content);
     $this->assertTrue(directory_exists($dir1));
     $this->assertFalse(directory_exists($dir2));
     directory_create(path($dir1, 'yolo'));
     directory_copy($dir1_file, $dir2);
     directory_delete($dir2);
     directory_copy($dir1, $dir2);
     $this->assertTrue(file_exists($dir2_file));
     $this->assertEquals(file_read($dir1_file), file_read($dir2_file));
     $this->assertFalse(directory_exists($dir3));
     directory_move($dir2, $dir3);
     $this->assertFalse(directory_exists($dir2));
     $this->assertTrue(directory_exists($dir3));
     $this->assertTrue(file_exists($dir3_file));
     $this->assertEquals(file_read($dir1_file), file_read($dir3_file));
     $this->assertFalse(directory_exists($dir4));
     directory_rename($dir3, $dir4_name);
     $this->assertTrue(directory_exists($dir4));
     $this->assertFalse(directory_exists($dir3));
     $this->assertTrue(file_exists($dir4_file));
     $this->assertEquals(file_read($dir1_file), file_read($dir4_file));
     $this->assertEquals(['foo.txt', 'yolo'], directory_list($dir1));
     $this->assertEquals([path($dir1, 'foo.txt'), path($dir1, 'yolo')], directory_list($dir1, true));
     $this->assertEquals([], directory_list('yada'));
     $this->assertEquals(['dir_1', 'dir_2', 'dir_3'], directory_list(self::getDir()));
     directory_delete(self::getDir());
     $this->assertFalse(directory_exists(self::getDir()));
     $this->assertEquals('dir1', directory_get_name($dir1));
     $this->assertEquals(self::getDir() . '/dir_1', directory_get_parent($dir1));
 }
 function directory_copy($srcdir, $dstdir)
 {
     //preparing the paths
     $srcdir = rtrim($srcdir, '/');
     $dstdir = rtrim($dstdir, '/');
     //creating the destination directory
     if (!is_dir($dstdir)) {
         mkdir($dstdir, 0777, true);
     }
     //Mapping the directory
     $dir_map = directory_map($srcdir);
     foreach ($dir_map as $object_key => $object_value) {
         if (is_numeric($object_key)) {
             copy($srcdir . '/' . $object_value, $dstdir . '/' . $object_value);
         } else {
             directory_copy($srcdir . '/' . $object_key, $dstdir . '/' . $object_key);
         }
         //this is a directory
     }
 }
 public function moveTemporaryAttachments($idContent)
 {
     $storeFolder = $this->_uploadPath . '/' . $idContent . '/';
     $tmpFolder = $this->_tmpUploadPath . '/' . $this->getTmpFolder();
     if ($tmpFolder) {
         directory_copy($tmpFolder, $storeFolder);
         $this->deleteTmpFolder();
     }
 }
Exemplo n.º 5
0
 /**
  * Copy a directory and all of its contents to the specified path
  * and create all necessary subdirectories.
  *
  * @param $oldPath
  * @param $newPath
  *
  * @return bool
  */
 function directory_copy($oldPath, $newPath)
 {
     if (directory_exists($oldPath)) {
         if (!directory_exists($newPath)) {
             directory_create($newPath);
         }
         $files = directory_list($oldPath);
         foreach ($files as $file) {
             $oldFilePath = path($oldPath, $file);
             $newFilePath = path($newPath, $file);
             if (directory_exists($oldFilePath)) {
                 directory_copy($oldFilePath, $newFilePath);
             } else {
                 file_copy($oldFilePath, $newFilePath);
             }
         }
     } else {
         return file_copy($oldPath, $newPath);
     }
 }