Debian Codegraph @

util/docscripts/lib/parser/Dojo.php

raw symbols SCIP
1 <?php
2
3 function destroy_all($item) {
4 if (is_array($item)) {
5 array_walk($item, 'destroy_all');
6 }
7 else {
8 if (is_string($item)) {
9 die($item);
10 }
11 $item->destroy();
12 }
13 }
14
15 class Dojo
16 {
17 private $dir;
18 public $namespace;
19
20 public function __construct($namespace, $dir){
21 $this->setDir($dir);
22 $this->namespace = $namespace;
23 }
24
25 public function __destruct() {
26 unset($this->dir);
27 unset($this->namespace);
28 }
29
30 public function getPackage($file){
31 return new DojoPackage($file);
32 }
33
34 public function getDir(){
35 return $this->dir;
36 }
37
38 public function setDir($dir){
39 $this->dir = $dir;
40 }
41
42 public function getFileList($dir = false, $recurse = false){
43 $output = array();
44 if ($dir === false) {
45 $dir = $this->getDir();
46 }
47
48 if (!$recurse) {
49 $old_dir = getcwd();
50 if (!is_dir($dir)) {
51 return array();
52 }
53 chdir($dir);
54 $dir = '.';
55 }
56 $files = scandir($dir);
57
58 foreach ($files as $file) {
59 if ($file{0} == '.') continue;
60 if (is_dir($dir . '/' . $file)) {
61 if ($recurse) {
62 $file = $dir . '/' . $file;
63 }
64 $output = array_merge($output, $this->getFileList($file, true));
65 }else{
66 if (substr($file, -3) == '.js' && substr($file, -6) != '.xd.js') {
67 if ($recurse) {
68 $file = $dir . '/' . $file;
69 }
70 $output[] = $file;
71 }
72 }
73 }
74
75 if (!$recurse) {
76 chdir($old_dir);
77 }
78 return $output;
79 }
80 }
81
82 ?>