-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.php
More file actions
79 lines (70 loc) · 2.03 KB
/
Copy pathexport.php
File metadata and controls
79 lines (70 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require 'bootstrap.php';
$exportDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . date('YmdHis') . '_export';
$buildDir = dirname(__FILE__);
echo "BUILD DIR:\n$buildDir\n\n";
echo "EXPORT DIR:\n$exportDir\n\n";
if (!is_dir($exportDir)){
mkdir($exportDir, 0755, true);
}
$buildDirs = array(
'js' => $buildDir . DIRECTORY_SEPARATOR . 'js',
'css' => $buildDir . DIRECTORY_SEPARATOR . 'css',
'scss' => $buildDir . DIRECTORY_SEPARATOR . 'scss',
'images' => $buildDir . DIRECTORY_SEPARATOR . 'images',
);
$exportDirs = array(
'html' => $exportDir,
'js' => $exportDir . DIRECTORY_SEPARATOR . 'js',
'css' => $exportDir . DIRECTORY_SEPARATOR . 'css',
'scss' => $exportDir . DIRECTORY_SEPARATOR . 'scss',
'images' => $exportDir . DIRECTORY_SEPARATOR . 'images',
);
$front = FrontController::getInstance();
foreach($front->getViewNames() as $view){
ob_start();
$front->renderPage($view);
$html = ob_get_clean();
$filename = "$view.html";
file_put_contents($exportDirs['html'] . DIRECTORY_SEPARATOR . $filename, $html);
echo "Wrote $filename\n";
}
foreach($buildDirs as $type=>$dir){
copy_r($dir, $exportDirs[$type]);
echo "Copied $type directory\n";
}
function copy_r( $path, $dest )
{
if( is_dir($path) )
{
@mkdir( $dest );
$objects = scandir($path);
if( sizeof($objects) > 0 )
{
foreach( $objects as $file )
{
if( $file == "." || $file == ".." )
continue;
// go on
if( is_dir( $path . DIRECTORY_SEPARATOR . $file ) )
{
copy_r( $path . DIRECTORY_SEPARATOR . $file, $dest . DIRECTORY_SEPARATOR . $file );
}
else
{
copy( $path . DIRECTORY_SEPARATOR . $file, $dest . DIRECTORY_SEPARATOR . $file );
}
}
}
return true;
}
elseif( is_file($path) )
{
return copy($path, $dest);
}
else
{
return false;
}
}
?>