@@ -11,6 +11,10 @@ |
||
11 | 11 | function arrayHtmlParser($_array) { |
12 | 12 | return travelStringArray($_array,"htmlParser"); |
13 | 13 | } |
14 | + |
|
15 | + /** |
|
16 | + * @param string $_function |
|
17 | + */ |
|
14 | 18 | function travelStringArray ( $_array, $_function ) { |
15 | 19 | if (is_array($_array)) { |
16 | 20 | foreach ($_array as $k => $v) { |
@@ -36,10 +36,12 @@ |
||
36 | 36 | function arrayDump( $_array, $_name = "Array", $_tab = " " ) { |
37 | 37 | $position = preg_replace('/ /', '', $_tab, 1); |
38 | 38 | echo "$position<span style=\"color:rgb(230,0,0)\">$_name:</span><br>"; |
39 | - foreach ($_array as $k => $i) |
|
40 | - if(is_array($i)) |
|
39 | + foreach ($_array as $k => $i) { |
|
40 | + if(is_array($i)) |
|
41 | 41 | arrayDump( $i, $k, " $_tab" ); |
42 | - else |
|
43 | - echo "$_tab<b>$k:</b> $i<br>"; |
|
42 | + } |
|
43 | + else { |
|
44 | + echo "$_tab<b>$k:</b> $i<br>"; |
|
45 | + } |
|
44 | 46 | } |
45 | 47 | ?> |
@@ -17,6 +17,10 @@ |
||
17 | 17 | }); |
18 | 18 | return $temp; |
19 | 19 | } |
20 | + |
|
21 | + /** |
|
22 | + * @param Closure $_function |
|
23 | + */ |
|
20 | 24 | function fetchInSubFolder( $_dir = "./", $_function) { |
21 | 25 | $temp = []; |
22 | 26 | if (is_dir($_dir)) { |
@@ -21,10 +21,11 @@ discard block |
||
21 | 21 | $temp = []; |
22 | 22 | if (is_dir($_dir)) { |
23 | 23 | if ($dirOpened = opendir($_dir)) { |
24 | - while (($file = readdir($dirOpened)) !== false) |
|
25 | - if( ($file !='.')&&($file !='..') ) |
|
24 | + while (($file = readdir($dirOpened)) !== false) { |
|
25 | + if( ($file !='.')&&($file !='..') ) |
|
26 | 26 | if($_function($file)) |
27 | 27 | array_push($temp,$file); |
28 | + } |
|
28 | 29 | closedir($dirOpened); |
29 | 30 | } |
30 | 31 | } |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | } |
33 | 34 | function requireSubfolder( $_dir = "./" ) { |
34 | 35 | $temp = subFolderFile($_dir); |
35 | - foreach ($temp as $i) |
|
36 | - jRequire($_dir."/".$i); |
|
36 | + foreach ($temp as $i) { |
|
37 | + jRequire($_dir."/".$i); |
|
38 | + } |
|
37 | 39 | } |
38 | 40 | function require_js( $_dir = "./" ) { |
39 | 41 | $tempArray = []; |
40 | 42 | $temp = subFolderFile($_dir); |
41 | - foreach ($temp as $i) |
|
42 | - array_push($tempArray, $_dir."/".$i); |
|
43 | + foreach ($temp as $i) { |
|
44 | + array_push($tempArray, $_dir."/".$i); |
|
45 | + } |
|
43 | 46 | return $tempArray; |
44 | 47 | } |
45 | 48 | ?> |
@@ -1,4 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | + /** |
|
3 | + * @param string $_path |
|
4 | + */ |
|
2 | 5 | function requireComponent( $_path, $_local = true ) { |
3 | 6 | $path = getJFolder($_path, $_local, debug_backtrace()); |
4 | 7 | if(file_exists($path) && isPhp($path)) |
@@ -6,6 +9,10 @@ discard block |
||
6 | 9 | else |
7 | 10 | requireError($_path); |
8 | 11 | } |
12 | + |
|
13 | + /** |
|
14 | + * @param string $_path |
|
15 | + */ |
|
9 | 16 | function requireComponents( $_path, $_local = true ) { |
10 | 17 | $path = getJFolder($_path, $_local, debug_backtrace()); |
11 | 18 | if(file_exists($path)) { |
@@ -38,6 +45,10 @@ discard block |
||
38 | 45 | $path = getJFolder($_path, $_local, debug_backtrace()); |
39 | 46 | require_once( $path ); |
40 | 47 | } |
48 | + |
|
49 | + /** |
|
50 | + * @param boolean $_local |
|
51 | + */ |
|
41 | 52 | function getJFolder( $_path, $_local, $_stack ) { |
42 | 53 | if($_local) { |
43 | 54 | $stackInfo = $_stack; |
@@ -1,29 +1,35 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function requireComponent( $_path, $_local = true ) { |
3 | 3 | $path = getJFolder($_path, $_local, debug_backtrace()); |
4 | - if(file_exists($path) && isPhp($path)) |
|
5 | - jRequire($path, false, 0); |
|
6 | - else |
|
7 | - requireError($_path); |
|
4 | + if(file_exists($path) && isPhp($path)) { |
|
5 | + jRequire($path, false, 0); |
|
6 | + } else { |
|
7 | + requireError($_path); |
|
8 | + } |
|
8 | 9 | } |
9 | 10 | function requireComponents( $_path, $_local = true ) { |
10 | 11 | $path = getJFolder($_path, $_local, debug_backtrace()); |
11 | 12 | if(file_exists($path)) { |
12 | 13 | $files = subFolderFile($path); |
13 | 14 | foreach ($files as $i) { |
14 | - if(isPhp($path."/".$i)) |
|
15 | - requireComponent($path."/".$i, false, 0); |
|
15 | + if(isPhp($path."/".$i)) { |
|
16 | + requireComponent($path."/".$i, false, 0); |
|
17 | + } |
|
16 | 18 | } |
17 | - } else |
|
18 | - requireError($_path); |
|
19 | + } else { |
|
20 | + requireError($_path); |
|
21 | + } |
|
19 | 22 | } |
20 | 23 | function requireError( $_path ) { |
21 | 24 | global $DEBUG; |
22 | - if( $DEBUG == 1 ) |
|
23 | - echo "Error load ($_path)<br>"; |
|
25 | + if( $DEBUG == 1 ) { |
|
26 | + echo "Error load ($_path)<br>"; |
|
27 | + } |
|
24 | 28 | } |
25 | 29 | function isPhp ( $_file ) { |
26 | - if(!is_file($_file)) return false; |
|
30 | + if(!is_file($_file)) { |
|
31 | + return false; |
|
32 | + } |
|
27 | 33 | $info = pathinfo($_file); |
28 | 34 | return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
29 | 35 | } |
@@ -43,8 +49,9 @@ discard block |
||
43 | 49 | $stackInfo = $_stack; |
44 | 50 | $folder = dirname($stackInfo[0]["file"]); |
45 | 51 | $file = "$folder/$_path"; |
46 | - } else |
|
47 | - $file = $_path; |
|
52 | + } else { |
|
53 | + $file = $_path; |
|
54 | + } |
|
48 | 55 | return $file; |
49 | 56 | } |
50 | 57 | ?> |
@@ -1,6 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | interface ConnectionAdapterInterface { |
3 | + |
|
4 | + /** |
|
5 | + * @return void |
|
6 | + */ |
|
3 | 7 | public function __construct( $_srv, $_db, $_usr, $_pass); |
8 | + |
|
9 | + /** |
|
10 | + * @return boolean |
|
11 | + */ |
|
4 | 12 | public function query( $_query ); |
5 | 13 | public function queryFetch( $_query ); |
6 | 14 | public function queryArray( $_query ); |
@@ -39,6 +39,10 @@ discard block |
||
39 | 39 | array_push($temp,$i); |
40 | 40 | return $temp; |
41 | 41 | } |
42 | + |
|
43 | + /** |
|
44 | + * @param string $_mods |
|
45 | + */ |
|
42 | 46 | public function addModules( $_mods ) { |
43 | 47 | if(!is_array($_mods)) |
44 | 48 | throw new InvalidArgumentException("Parameter must be an array."); |
@@ -64,6 +68,10 @@ discard block |
||
64 | 68 | throw new InvalidArgumentException("Parameter must be a string or an array."); |
65 | 69 | array_push($this->files, $_file); |
66 | 70 | } |
71 | + |
|
72 | + /** |
|
73 | + * @param string $_files |
|
74 | + */ |
|
67 | 75 | public function addFilesRequired( $_files ) { |
68 | 76 | if(!is_array($_files)) |
69 | 77 | throw new InvalidArgumentException("Parameter must be an array."); |
@@ -80,6 +88,11 @@ discard block |
||
80 | 88 | $this->tags["js"] = $this->getJs(); |
81 | 89 | $this->tags["jsVariables"] = $this->getJsVariables(); |
82 | 90 | } |
91 | + |
|
92 | + /** |
|
93 | + * @param string $_function |
|
94 | + * @param string $_extenction |
|
95 | + */ |
|
83 | 96 | protected function getRequire( $_function, $_extenction) { |
84 | 97 | $temp = []; |
85 | 98 | foreach ($this->required as $i) |
@@ -29,50 +29,63 @@ discard block |
||
29 | 29 | } |
30 | 30 | public function getJsVariables() { |
31 | 31 | $temp = []; |
32 | - foreach ($this->required as $i) |
|
33 | - if (is_array($i)) |
|
32 | + foreach ($this->required as $i) { |
|
33 | + if (is_array($i)) |
|
34 | 34 | array_push($temp,$i); |
35 | - foreach ($this->modules as $i) |
|
36 | - $temp = array_merge( $temp, $i->getJsVariables() ); |
|
37 | - foreach ($this->files as $i) |
|
38 | - if (is_array($i)) |
|
35 | + } |
|
36 | + foreach ($this->modules as $i) { |
|
37 | + $temp = array_merge( $temp, $i->getJsVariables() ); |
|
38 | + } |
|
39 | + foreach ($this->files as $i) { |
|
40 | + if (is_array($i)) |
|
39 | 41 | array_push($temp,$i); |
42 | + } |
|
40 | 43 | return $temp; |
41 | 44 | } |
42 | 45 | public function addModules( $_mods ) { |
43 | - if(!is_array($_mods)) |
|
44 | - throw new InvalidArgumentException("Parameter must be an array."); |
|
45 | - foreach ($_mods as $value) |
|
46 | - $this->addModule($value); |
|
46 | + if(!is_array($_mods)) { |
|
47 | + throw new InvalidArgumentException("Parameter must be an array."); |
|
48 | + } |
|
49 | + foreach ($_mods as $value) { |
|
50 | + $this->addModule($value); |
|
51 | + } |
|
47 | 52 | } |
48 | 53 | public function addModule( $_mod ) { |
49 | - if(!is_object($_mod)) |
|
50 | - throw new InvalidArgumentException("Parameter must be a class."); |
|
51 | - if(! is_subclass_of ($_mod, "Module")) |
|
52 | - throw new InvalidArgumentException("Parameter must be a class."); |
|
54 | + if(!is_object($_mod)) { |
|
55 | + throw new InvalidArgumentException("Parameter must be a class."); |
|
56 | + } |
|
57 | + if(! is_subclass_of ($_mod, "Module")) { |
|
58 | + throw new InvalidArgumentException("Parameter must be a class."); |
|
59 | + } |
|
53 | 60 | $this->modules[$_mod->name] = $_mod; |
54 | 61 | $this->modules[$_mod->name]->parameters = &$this->parameters; |
55 | 62 | } |
56 | 63 | public function addFiles( $_files ) { |
57 | - if(!is_array($_files)) |
|
58 | - throw new InvalidArgumentException("Parameter must be an array."); |
|
59 | - foreach ($_files as $value) |
|
60 | - $this->addFile($value); |
|
64 | + if(!is_array($_files)) { |
|
65 | + throw new InvalidArgumentException("Parameter must be an array."); |
|
66 | + } |
|
67 | + foreach ($_files as $value) { |
|
68 | + $this->addFile($value); |
|
69 | + } |
|
61 | 70 | } |
62 | 71 | public function addFile( $_file ) { |
63 | - if(!(is_string($_file) || is_array($_file))) |
|
64 | - throw new InvalidArgumentException("Parameter must be a string or an array."); |
|
72 | + if(!(is_string($_file) || is_array($_file))) { |
|
73 | + throw new InvalidArgumentException("Parameter must be a string or an array."); |
|
74 | + } |
|
65 | 75 | array_push($this->files, $_file); |
66 | 76 | } |
67 | 77 | public function addFilesRequired( $_files ) { |
68 | - if(!is_array($_files)) |
|
69 | - throw new InvalidArgumentException("Parameter must be an array."); |
|
70 | - foreach ($_files as $value) |
|
71 | - $this->addFileRequired($value); |
|
78 | + if(!is_array($_files)) { |
|
79 | + throw new InvalidArgumentException("Parameter must be an array."); |
|
80 | + } |
|
81 | + foreach ($_files as $value) { |
|
82 | + $this->addFileRequired($value); |
|
83 | + } |
|
72 | 84 | } |
73 | 85 | public function addFileRequired( $_file ) { |
74 | - if(!is_string($_file)) |
|
75 | - throw new InvalidArgumentException("Parameter must be a string."); |
|
86 | + if(!is_string($_file)) { |
|
87 | + throw new InvalidArgumentException("Parameter must be a string."); |
|
88 | + } |
|
76 | 89 | array_push($this->required, $_file); |
77 | 90 | } |
78 | 91 | protected function addDipendences() { |
@@ -82,14 +95,17 @@ discard block |
||
82 | 95 | } |
83 | 96 | protected function getRequire( $_function, $_extenction) { |
84 | 97 | $temp = []; |
85 | - foreach ($this->required as $i) |
|
86 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
98 | + foreach ($this->required as $i) { |
|
99 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
87 | 100 | array_push($temp,$i); |
88 | - foreach ($this->modules as $i) |
|
89 | - $temp = array_merge( $temp, $i->$_function() ); |
|
90 | - foreach ($this->files as $i) |
|
91 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
101 | + } |
|
102 | + foreach ($this->modules as $i) { |
|
103 | + $temp = array_merge( $temp, $i->$_function() ); |
|
104 | + } |
|
105 | + foreach ($this->files as $i) { |
|
106 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
92 | 107 | array_push($temp,$i); |
108 | + } |
|
93 | 109 | return $temp; |
94 | 110 | } |
95 | 111 | } |
@@ -9,6 +9,10 @@ |
||
9 | 9 | public function drawFile( $_template ) { |
10 | 10 | return $this->draw($_template); |
11 | 11 | } |
12 | + |
|
13 | + /** |
|
14 | + * @param string $_template |
|
15 | + */ |
|
12 | 16 | public function drawText( $_template ) { |
13 | 17 | return $this->draw(trim($_template)); |
14 | 18 | } |
@@ -8,6 +8,10 @@ |
||
8 | 8 | public function drawFile( $_file, $_parameters = [] ) { |
9 | 9 | return $this->draw($_file, $_parameters); |
10 | 10 | } |
11 | + |
|
12 | + /** |
|
13 | + * @param string $_text |
|
14 | + */ |
|
11 | 15 | public function drawText( $_text, $_parameters = [] ) { |
12 | 16 | return $this->draw(trim($_text), $_parameters); |
13 | 17 | } |
@@ -14,6 +14,10 @@ |
||
14 | 14 | $page = $template->render($_parameters); |
15 | 15 | return $page; |
16 | 16 | } |
17 | + |
|
18 | + /** |
|
19 | + * @param string $_text |
|
20 | + */ |
|
17 | 21 | public function drawText( $_text, $_parameters = [] ) { |
18 | 22 | $loader = new Twig_Loader_Array([ |
19 | 23 | 'index' => $_text |
@@ -19,15 +19,17 @@ discard block |
||
19 | 19 | if(is_array($_page)) { |
20 | 20 | $path = $_page[0]; |
21 | 21 | $class = $_page[1]; |
22 | - if(isset($_page[2])) |
|
23 | - $param = $_page[2]; |
|
22 | + if(isset($_page[2])) { |
|
23 | + $param = $_page[2]; |
|
24 | + } |
|
24 | 25 | } |
25 | 26 | $this->pages[$path] = [$class, $param]; |
26 | 27 | return $this->pages[$path]; |
27 | 28 | } |
28 | 29 | public function addPages( $_pages ) { |
29 | - foreach ($_pages as $i) |
|
30 | - $this->addPage($i); |
|
30 | + foreach ($_pages as $i) { |
|
31 | + $this->addPage($i); |
|
32 | + } |
|
31 | 33 | } |
32 | 34 | public function fetchPage() { |
33 | 35 | $router = new Router(); |
@@ -43,10 +45,11 @@ discard block |
||
43 | 45 | break; |
44 | 46 | } |
45 | 47 | } |
46 | - if( isset($temp[1]) && is_array($temp[1]) ) |
|
47 | - $temp[1] = array_merge($temp[1], $parameters); |
|
48 | - else |
|
49 | - $temp[1] = $parameters; |
|
48 | + if( isset($temp[1]) && is_array($temp[1]) ) { |
|
49 | + $temp[1] = array_merge($temp[1], $parameters); |
|
50 | + } else { |
|
51 | + $temp[1] = $parameters; |
|
52 | + } |
|
50 | 53 | $this->currentPage = new $temp[0](["app" => $this->jConfig, "page" => $temp[1]]); |
51 | 54 | return $this->currentPage; |
52 | 55 | } |
@@ -68,15 +71,18 @@ discard block |
||
68 | 71 | while($cont < $urlLength) { |
69 | 72 | if( |
70 | 73 | ($this->jConfig->urlCaseSensitive && $_path[$cont] == $_url[$cont]) || |
71 | - (!$this->jConfig->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) |
|
72 | - $cont++; |
|
73 | - else if( strpos($_path[$cont], "\$") !== false ) { |
|
74 | + (!$this->jConfig->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) { |
|
75 | + $cont++; |
|
76 | + } else if( strpos($_path[$cont], "\$") !== false ) { |
|
74 | 77 | $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont]; |
75 | 78 | $cont++; |
76 | - } else break; |
|
79 | + } else { |
|
80 | + break; |
|
81 | + } |
|
82 | + } |
|
83 | + if($cont == $urlLength) { |
|
84 | + return $variables; |
|
77 | 85 | } |
78 | - if($cont == $urlLength) |
|
79 | - return $variables; |
|
80 | 86 | } |
81 | 87 | return null; |
82 | 88 | } |