@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | $this->connection = []; |
10 | 10 | $this->currentConnection = null; |
11 | 11 | } |
12 | - public function addConnection( $_path, $_name = "default" ) { |
|
13 | - if(!is_string($_path)) |
|
12 | + public function addConnection($_path, $_name = "default") { |
|
13 | + if (!is_string($_path)) |
|
14 | 14 | throw new JException("Parameter must be a string.", 1); |
15 | 15 | try { |
16 | 16 | $jConfig = new JConfig($_path); |
17 | - if($jConfig->enable) { |
|
17 | + if ($jConfig->enable) { |
|
18 | 18 | $connection = new Connection($jConfig); |
19 | 19 | $this->addConnectionMan($connection, $_name); |
20 | 20 | } |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | throw new JException($e->getMessage(), 1); |
23 | 23 | } |
24 | 24 | } |
25 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
25 | + public function addConnectionMan($_connection, $_name = "default") { |
|
26 | + if (!is_object($_connection) || !is_a($_connection, "Connection")) |
|
27 | 27 | throw new JException("Parameter must be a Connection object.", 1); |
28 | 28 | try { |
29 | 29 | $this->connection["$_name"] = $_connection; |
30 | 30 | $this->currentConnection = $_connection; |
31 | 31 | foreach ($this->modules as &$module) |
32 | - if(isset($this->currentConnection)) |
|
32 | + if (isset($this->currentConnection)) |
|
33 | 33 | $module->addConnectionMan($this->currentConnection, $_name); |
34 | 34 | } catch (Exception $e) { |
35 | 35 | throw new JException($e->getMessage(), 1); |
36 | 36 | } |
37 | 37 | } |
38 | - public function setConnection( $_name = "default" ) { |
|
39 | - if(!is_string($_name)) |
|
38 | + public function setConnection($_name = "default") { |
|
39 | + if (!is_string($_name)) |
|
40 | 40 | throw new JException("Parameter must be a string.", 1); |
41 | - if(!isset($this->connection["$_name"])) |
|
41 | + if (!isset($this->connection["$_name"])) |
|
42 | 42 | throw new JException("This connection name does not exist.", 1); |
43 | 43 | $this->currentConnection = $this->connection["$_name"]; |
44 | 44 | } |
45 | - public function query( $_query ) { |
|
46 | - if(!is_string($_query)) |
|
45 | + public function query($_query) { |
|
46 | + if (!is_string($_query)) |
|
47 | 47 | throw new JException("Parameter must be a string.", 1); |
48 | 48 | try { |
49 | 49 | $temp = $this->currentConnection->database->query($_query); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | } |
53 | 53 | return $temp; |
54 | 54 | } |
55 | - public function queryInsert( $_query ) { |
|
56 | - if(!is_string($_query)) |
|
55 | + public function queryInsert($_query) { |
|
56 | + if (!is_string($_query)) |
|
57 | 57 | throw new JException("Parameter must be a string.", 1); |
58 | 58 | try { |
59 | 59 | $temp = $this->currentConnection->database->queryInsert($_query); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | } |
63 | 63 | return $temp; |
64 | 64 | } |
65 | - public function queryFetch( $_query ) { |
|
66 | - if(!is_string($_query)) |
|
65 | + public function queryFetch($_query) { |
|
66 | + if (!is_string($_query)) |
|
67 | 67 | throw new JException("Parameter must be a string.", 1); |
68 | 68 | try { |
69 | 69 | $temp = $this->currentConnection->database->queryFetch($_query); |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | } |
73 | 73 | return $temp; |
74 | 74 | } |
75 | - public function queryArray( $_query ) { |
|
76 | - if(!is_string($_query)) |
|
75 | + public function queryArray($_query) { |
|
76 | + if (!is_string($_query)) |
|
77 | 77 | throw new JException("Parameter must be a string.", 1); |
78 | 78 | try { |
79 | 79 | $temp = $this->currentConnection->database->queryArray($_query); |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | protected $pages; |
6 | 6 | protected $defaultPage; |
7 | 7 | protected $urlCaseSensitive; |
8 | - public function __construct( $_path, $_urlCaseSensitive = false ) { |
|
9 | - if(!is_string($_path)) |
|
8 | + public function __construct($_path, $_urlCaseSensitive = false) { |
|
9 | + if (!is_string($_path)) |
|
10 | 10 | throw new JException("Parameter must be a string."); |
11 | 11 | $jConfig = new JConfig($_path); |
12 | 12 | $server = new ServerVars(); |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | $pageSelected = null; |
24 | 24 | foreach ($this->pages as $page) { |
25 | 25 | $urlParameters = $this->pathSeeker(explode("/", $page[0]), $this->url); |
26 | - if(is_array($urlParameters)) { |
|
27 | - if(isset($page[2]) && is_array($page[2])) |
|
26 | + if (is_array($urlParameters)) { |
|
27 | + if (isset($page[2]) && is_array($page[2])) |
|
28 | 28 | $urlParameters = array_merge($urlParameters, $page[2]); |
29 | 29 | $pageSelected = [ |
30 | 30 | $page[1], |
@@ -33,28 +33,28 @@ discard block |
||
33 | 33 | break; |
34 | 34 | } |
35 | 35 | } |
36 | - if( $pageSelected !== null ) |
|
36 | + if ($pageSelected !== null) |
|
37 | 37 | return $pageSelected; |
38 | 38 | else |
39 | 39 | return $this->defaultPage; |
40 | 40 | } |
41 | - protected function pathSeeker( $_path, $_url ) { |
|
41 | + protected function pathSeeker($_path, $_url) { |
|
42 | 42 | $urlLength = count($_url); |
43 | 43 | $cont = 0; |
44 | 44 | $variables = []; |
45 | 45 | $pathLength = count($_path); |
46 | - if($urlLength == $pathLength) { |
|
47 | - while($cont < $urlLength) { |
|
48 | - if( |
|
46 | + if ($urlLength == $pathLength) { |
|
47 | + while ($cont < $urlLength) { |
|
48 | + if ( |
|
49 | 49 | ($this->urlCaseSensitive && $_path[$cont] == $_url[$cont]) || |
50 | 50 | (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) |
51 | 51 | $cont++; |
52 | - else if( strpos($_path[$cont], "\$") !== false ) { |
|
52 | + else if (strpos($_path[$cont], "\$") !== false) { |
|
53 | 53 | $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont]; |
54 | 54 | $cont++; |
55 | 55 | } else break; |
56 | 56 | } |
57 | - if($cont == $urlLength) |
|
57 | + if ($cont == $urlLength) |
|
58 | 58 | return $variables; |
59 | 59 | } |
60 | 60 | return null; |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | "base" => "" |
22 | 22 | ]; |
23 | 23 | } |
24 | - public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { |
|
24 | + public function setParameters($_parameters = ["app" => null, "page" => null]) { |
|
25 | 25 | $this->app = $_parameters["app"]; |
26 | 26 | $this->page = $_parameters["page"]; |
27 | 27 | } |
28 | 28 | abstract public function init(); |
29 | 29 | public function draw() { |
30 | - if($this->template == "") |
|
30 | + if ($this->template == "") |
|
31 | 31 | throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
32 | 32 | $server = new ServerVars(); |
33 | 33 | $this->addDipendences(); |
@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | return jBlockFile($this->template, $this->tags); |
39 | 39 | } |
40 | 40 | public function getCss() { |
41 | - return $this->getRequire("getCss",".css"); |
|
41 | + return $this->getRequire("getCss", ".css"); |
|
42 | 42 | } |
43 | 43 | public function getJs() { |
44 | - return $this->getRequire("getJs",".js"); |
|
44 | + return $this->getRequire("getJs", ".js"); |
|
45 | 45 | } |
46 | 46 | public function getJsVars() { |
47 | 47 | return $this->jsVars; |
48 | 48 | } |
49 | - public function addJsVar( $_name, $_value ) { |
|
50 | - if(!is_string($_name)) |
|
49 | + public function addJsVar($_name, $_value) { |
|
50 | + if (!is_string($_name)) |
|
51 | 51 | throw new InvalidArgumentException("Parameter name must be a string."); |
52 | - if(!is_string($_value)) |
|
52 | + if (!is_string($_value)) |
|
53 | 53 | throw new InvalidArgumentException("Parameter value must be a string."); |
54 | 54 | $this->jsVars[] = [$_name, $_value]; |
55 | 55 | } |
56 | - public function addJsVars( $_array ) { |
|
57 | - if(!is_array($_array)) |
|
56 | + public function addJsVars($_array) { |
|
57 | + if (!is_array($_array)) |
|
58 | 58 | throw new InvalidArgumentException("Parameter must be an array."); |
59 | 59 | foreach ($_array as $value) |
60 | 60 | $this->addJsVar($value[0], $value[1]); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->tags["js"] = $this->getJs(); |
84 | 84 | $this->tags["jsVar"] = $this->getJsVars(); |
85 | 85 | } |
86 | - protected function getRequire( $_function, $_extenction) { |
|
86 | + protected function getRequire($_function, $_extenction) { |
|
87 | 87 | $temp = []; |
88 | 88 | $filesRequired = $this->getFilesRequired(); |
89 | 89 | $files = $this->getFiles(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
92 | 92 | $temp[] = $i; |
93 | 93 | foreach ($this->modules as $i) |
94 | - $temp = array_merge( $temp, $i->$_function() ); |
|
94 | + $temp = array_merge($temp, $i->$_function()); |
|
95 | 95 | foreach ($files as $i) |
96 | 96 | if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
97 | 97 | $temp[] = $i; |
@@ -16,19 +16,19 @@ |
||
16 | 16 | $this->__queryConstruct(); |
17 | 17 | $this->__fileConstruct(); |
18 | 18 | } |
19 | - public function addModules( $_modules ) { |
|
20 | - if(!is_array($_modules)) |
|
19 | + public function addModules($_modules) { |
|
20 | + if (!is_array($_modules)) |
|
21 | 21 | throw new JException("Parameter must be an array."); |
22 | 22 | foreach ($_modules as $value) |
23 | 23 | $this->addModule($value); |
24 | 24 | } |
25 | - public function addModule( $_module ) { |
|
26 | - if(!is_object($_module)) |
|
25 | + public function addModule($_module) { |
|
26 | + if (!is_object($_module)) |
|
27 | 27 | throw new JException("Parameter must be a object."); |
28 | - if(! is_subclass_of ($_module, "Module")) |
|
28 | + if (!is_subclass_of($_module, "Module")) |
|
29 | 29 | throw new JException("Parameter must be a object inherited from Module object."); |
30 | 30 | $this->modules[$_module->name] = $_module; |
31 | - if($this->currentConnection) |
|
31 | + if ($this->currentConnection) |
|
32 | 32 | $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
33 | 33 | } |
34 | 34 | } |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | class JConfig { |
3 | - public function __construct( $_path ) { |
|
4 | - if(!is_string($_path)) |
|
3 | + public function __construct($_path) { |
|
4 | + if (!is_string($_path)) |
|
5 | 5 | throw new JException("Path must be a string."); |
6 | - if(!file_exists($_path)) |
|
6 | + if (!file_exists($_path)) |
|
7 | 7 | throw new JException("File [$_path] not found."); |
8 | 8 | $data = file_get_contents($_path); |
9 | 9 | $data = json_decode($data); |
10 | - if($data === NULL) |
|
10 | + if ($data === NULL) |
|
11 | 11 | throw new JException("Invalid file data. [$_path]"); |
12 | - if(is_object($data)) |
|
12 | + if (is_object($data)) |
|
13 | 13 | foreach (get_object_vars($data) as $key => $value) |
14 | 14 | $this->$key = $value; |
15 | - if(is_array($data)) |
|
15 | + if (is_array($data)) |
|
16 | 16 | $this->data = $data; |
17 | 17 | } |
18 | 18 | } |