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 80 81 82
|
<?php
function destroy_all($item) {
if (is_array($item)) {
array_walk($item, 'destroy_all');
}
else {
if (is_string($item)) {
die($item);
}
$item->destroy();
}
}
class Dojo
{
private $dir;
public $namespace;
public function __construct($namespace, $dir){
$this->setDir($dir);
$this->namespace = $namespace;
}
public function __destruct() {
unset($this->dir);
unset($this->namespace);
}
public function getPackage($file){
return new DojoPackage($file);
}
public function getDir(){
return $this->dir;
}
public function setDir($dir){
$this->dir = $dir;
}
public function getFileList($dir = false, $recurse = false){
$output = array();
if ($dir === false) {
$dir = $this->getDir();
}
if (!$recurse) {
$old_dir = getcwd();
if (!is_dir($dir)) {
return array();
}
chdir($dir);
$dir = '.';
}
$files = scandir($dir);
foreach ($files as $file) {
if ($file{0} == '.') continue;
if (is_dir($dir . '/' . $file)) {
if ($recurse) {
$file = $dir . '/' . $file;
}
$output = array_merge($output, $this->getFileList($file, true));
}else{
if (substr($file, -3) == '.js' && substr($file, -6) != '.xd.js') {
if ($recurse) {
$file = $dir . '/' . $file;
}
$output[] = $file;
}
}
}
if (!$recurse) {
chdir($old_dir);
}
return $output;
}
}
?>
|