@@ -2,13 +2,13 @@ |
||
2 | 2 | // use Twig as Twig; |
3 | 3 | jRequire("ParserAbstract.php"); |
4 | 4 | class TwigAdapter extends ParserAbstract { |
5 | - public function draw( $_text, $_parameters = [] ) { |
|
6 | - $loader = new Twig_Loader_Array([ |
|
7 | - 'index' => $_text |
|
8 | - ]); |
|
9 | - $twig = new Twig_Environment($loader); |
|
10 | - $page = $twig->render('index', $_parameters); |
|
11 | - return $page; |
|
12 | - } |
|
5 | + public function draw( $_text, $_parameters = [] ) { |
|
6 | + $loader = new Twig_Loader_Array([ |
|
7 | + 'index' => $_text |
|
8 | + ]); |
|
9 | + $twig = new Twig_Environment($loader); |
|
10 | + $page = $twig->render('index', $_parameters); |
|
11 | + return $page; |
|
12 | + } |
|
13 | 13 | } |
14 | 14 | ?> |
@@ -2,7 +2,7 @@ |
||
2 | 2 | // use Twig as Twig; |
3 | 3 | jRequire("ParserAbstract.php"); |
4 | 4 | class TwigAdapter extends ParserAbstract { |
5 | - public function draw( $_text, $_parameters = [] ) { |
|
5 | + public function draw($_text, $_parameters = []) { |
|
6 | 6 | $loader = new Twig_Loader_Array([ |
7 | 7 | 'index' => $_text |
8 | 8 | ]); |
@@ -3,11 +3,11 @@ |
||
3 | 3 | jRequire("../../ExternalModules/Parsedown/Parsedown.php"); |
4 | 4 | use Parsedown as Parsedown; |
5 | 5 | class ParsedownAdapter extends ParserAbstract { |
6 | - public function draw( $_text, $_parameters = [] ) { |
|
7 | - $Parsedown = new Parsedown\Parsedown(); |
|
8 | - $page = $Parsedown->text($_text); |
|
9 | - $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', " ", $page); |
|
10 | - return $page; |
|
11 | - } |
|
6 | + public function draw( $_text, $_parameters = [] ) { |
|
7 | + $Parsedown = new Parsedown\Parsedown(); |
|
8 | + $page = $Parsedown->text($_text); |
|
9 | + $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', " ", $page); |
|
10 | + return $page; |
|
11 | + } |
|
12 | 12 | } |
13 | 13 | ?> |
@@ -3,7 +3,7 @@ |
||
3 | 3 | jRequire("../../ExternalModules/Parsedown/Parsedown.php"); |
4 | 4 | use Parsedown as Parsedown; |
5 | 5 | class ParsedownAdapter extends ParserAbstract { |
6 | - public function draw( $_text, $_parameters = [] ) { |
|
6 | + public function draw($_text, $_parameters = []) { |
|
7 | 7 | $Parsedown = new Parsedown\Parsedown(); |
8 | 8 | $page = $Parsedown->text($_text); |
9 | 9 | $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', " ", $page); |
@@ -1,31 +1,31 @@ |
||
1 | 1 | <?php |
2 | 2 | class JException extends Exception { |
3 | - static protected $escapeString = "|jate|"; |
|
4 | - public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
|
5 | - parent::__construct($_message, $_code, $_previous); |
|
6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
7 | - $this->file = debug_backtrace()[$_level]["file"]; |
|
8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
9 | - $this->line = debug_backtrace()[$_level]["line"]; |
|
10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
11 | - $this->function = debug_backtrace()[$_level]["function"]; |
|
12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
13 | - $this->class = debug_backtrace()[$_level]["class"]; |
|
14 | - } |
|
15 | - public function __toString() { |
|
16 | - return JException::encode(JException::decode($this->message)); |
|
17 | - } |
|
18 | - static public function decode( $_message ) { |
|
19 | - $messageSplitted = explode(JException::$escapeString, $_message); |
|
20 | - if(count($messageSplitted) == 3) |
|
21 | - return $messageSplitted[1]; |
|
22 | - else |
|
23 | - return $_message; |
|
24 | - } |
|
25 | - static public function encode( $_message ) { |
|
26 | - $escape = JException::$escapeString; |
|
27 | - return "$escape$_message$escape"; |
|
3 | + static protected $escapeString = "|jate|"; |
|
4 | + public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
|
5 | + parent::__construct($_message, $_code, $_previous); |
|
6 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
7 | + $this->file = debug_backtrace()[$_level]["file"]; |
|
8 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
9 | + $this->line = debug_backtrace()[$_level]["line"]; |
|
10 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
11 | + $this->function = debug_backtrace()[$_level]["function"]; |
|
12 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
13 | + $this->class = debug_backtrace()[$_level]["class"]; |
|
14 | + } |
|
15 | + public function __toString() { |
|
16 | + return JException::encode(JException::decode($this->message)); |
|
17 | + } |
|
18 | + static public function decode( $_message ) { |
|
19 | + $messageSplitted = explode(JException::$escapeString, $_message); |
|
20 | + if(count($messageSplitted) == 3) |
|
21 | + return $messageSplitted[1]; |
|
22 | + else |
|
23 | + return $_message; |
|
24 | + } |
|
25 | + static public function encode( $_message ) { |
|
26 | + $escape = JException::$escapeString; |
|
27 | + return "$escape$_message$escape"; |
|
28 | 28 | |
29 | - } |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | ?> |
@@ -3,26 +3,26 @@ |
||
3 | 3 | static protected $escapeString = "|jate|"; |
4 | 4 | public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
5 | 5 | parent::__construct($_message, $_code, $_previous); |
6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
6 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
7 | 7 | $this->file = debug_backtrace()[$_level]["file"]; |
8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
8 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
9 | 9 | $this->line = debug_backtrace()[$_level]["line"]; |
10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
10 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
11 | 11 | $this->function = debug_backtrace()[$_level]["function"]; |
12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
12 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
13 | 13 | $this->class = debug_backtrace()[$_level]["class"]; |
14 | 14 | } |
15 | 15 | public function __toString() { |
16 | 16 | return JException::encode(JException::decode($this->message)); |
17 | 17 | } |
18 | - static public function decode( $_message ) { |
|
18 | + static public function decode($_message) { |
|
19 | 19 | $messageSplitted = explode(JException::$escapeString, $_message); |
20 | - if(count($messageSplitted) == 3) |
|
20 | + if (count($messageSplitted) == 3) |
|
21 | 21 | return $messageSplitted[1]; |
22 | 22 | else |
23 | 23 | return $_message; |
24 | 24 | } |
25 | - static public function encode( $_message ) { |
|
25 | + static public function encode($_message) { |
|
26 | 26 | $escape = JException::$escapeString; |
27 | 27 | return "$escape$_message$escape"; |
28 | 28 |
@@ -3,24 +3,29 @@ |
||
3 | 3 | static protected $escapeString = "|jate|"; |
4 | 4 | public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
5 | 5 | parent::__construct($_message, $_code, $_previous); |
6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
7 | - $this->file = debug_backtrace()[$_level]["file"]; |
|
8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
9 | - $this->line = debug_backtrace()[$_level]["line"]; |
|
10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
11 | - $this->function = debug_backtrace()[$_level]["function"]; |
|
12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
13 | - $this->class = debug_backtrace()[$_level]["class"]; |
|
6 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) { |
|
7 | + $this->file = debug_backtrace()[$_level]["file"]; |
|
8 | + } |
|
9 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) { |
|
10 | + $this->line = debug_backtrace()[$_level]["line"]; |
|
11 | + } |
|
12 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) { |
|
13 | + $this->function = debug_backtrace()[$_level]["function"]; |
|
14 | + } |
|
15 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) { |
|
16 | + $this->class = debug_backtrace()[$_level]["class"]; |
|
17 | + } |
|
14 | 18 | } |
15 | 19 | public function __toString() { |
16 | 20 | return JException::encode(JException::decode($this->message)); |
17 | 21 | } |
18 | 22 | static public function decode( $_message ) { |
19 | 23 | $messageSplitted = explode(JException::$escapeString, $_message); |
20 | - if(count($messageSplitted) == 3) |
|
21 | - return $messageSplitted[1]; |
|
22 | - else |
|
23 | - return $_message; |
|
24 | + if(count($messageSplitted) == 3) { |
|
25 | + return $messageSplitted[1]; |
|
26 | + } else { |
|
27 | + return $_message; |
|
28 | + } |
|
24 | 29 | } |
25 | 30 | static public function encode( $_message ) { |
26 | 31 | $escape = JException::$escapeString; |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | class ServerVars { |
3 | - public $server; |
|
4 | - public function __construct() { |
|
5 | - $this->server = []; |
|
6 | - $this->server["HTTP_HOST"] = $_SERVER["HTTP_HOST"]; |
|
7 | - $this->server["REQUEST_URI"] = $_SERVER["REQUEST_URI"]; |
|
8 | - $this->server["PHP_SELF"] = $_SERVER["PHP_SELF"]; |
|
9 | - $this->server["RELATIVE"] = str_replace("/index.php", "", $_SERVER["PHP_SELF"]); |
|
10 | - } |
|
3 | + public $server; |
|
4 | + public function __construct() { |
|
5 | + $this->server = []; |
|
6 | + $this->server["HTTP_HOST"] = $_SERVER["HTTP_HOST"]; |
|
7 | + $this->server["REQUEST_URI"] = $_SERVER["REQUEST_URI"]; |
|
8 | + $this->server["PHP_SELF"] = $_SERVER["PHP_SELF"]; |
|
9 | + $this->server["RELATIVE"] = str_replace("/index.php", "", $_SERVER["PHP_SELF"]); |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | ?> |
@@ -2,19 +2,19 @@ |
||
2 | 2 | jRequire("../Router/Router.php"); |
3 | 3 | jRequire("../JConfig/JConfig.php"); |
4 | 4 | class WebApp { |
5 | - private $router; |
|
6 | - private $misc; |
|
7 | - public function __construct() { |
|
8 | - $configPath = "config"; |
|
9 | - $this->misc = new JConfig("$configPath/app.json"); |
|
10 | - $this->router = new Router("$configPath/router.json", $this->misc->urlCaseSensitive); |
|
11 | - } |
|
12 | - public function draw() { |
|
13 | - $pageSelected = $this->router->getPage(); |
|
14 | - $currentPage = new $pageSelected[0](); |
|
15 | - $currentPage->setParameters(["app" => $this->misc, "page" => $pageSelected[1]]); |
|
16 | - $currentPage->init(); |
|
17 | - echo minifyOutput($currentPage->draw()); |
|
18 | - } |
|
5 | + private $router; |
|
6 | + private $misc; |
|
7 | + public function __construct() { |
|
8 | + $configPath = "config"; |
|
9 | + $this->misc = new JConfig("$configPath/app.json"); |
|
10 | + $this->router = new Router("$configPath/router.json", $this->misc->urlCaseSensitive); |
|
11 | + } |
|
12 | + public function draw() { |
|
13 | + $pageSelected = $this->router->getPage(); |
|
14 | + $currentPage = new $pageSelected[0](); |
|
15 | + $currentPage->setParameters(["app" => $this->misc, "page" => $pageSelected[1]]); |
|
16 | + $currentPage->init(); |
|
17 | + echo minifyOutput($currentPage->draw()); |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | ?> |
@@ -1,63 +1,63 @@ |
||
1 | 1 | <?php |
2 | 2 | requireComponent("../ServerVars/ServerVars.php"); |
3 | 3 | class Router { |
4 | - protected $url; |
|
5 | - protected $pages; |
|
6 | - protected $defaultPage; |
|
7 | - protected $urlCaseSensitive; |
|
8 | - public function __construct( $_path, $_urlCaseSensitive = false ) { |
|
9 | - if(!is_string($_path)) |
|
10 | - throw new JException("Parameter must be a string."); |
|
11 | - $jConfig = new JConfig($_path); |
|
12 | - $server = new ServerVars(); |
|
13 | - $request = $server->server["REQUEST_URI"]; |
|
14 | - $base = $server->server["RELATIVE"]; |
|
15 | - $url = str_replace($base, "", $request); |
|
16 | - $this->url = explode("/", $url); |
|
17 | - $this->pages = $jConfig->pages; |
|
18 | - $this->defaultPage = $jConfig->defaultPage; |
|
19 | - $this->urlCaseSensitive = $_urlCaseSensitive; |
|
20 | - } |
|
21 | - public function getPage() { |
|
22 | - $parameters = []; |
|
23 | - $pageSelected = null; |
|
24 | - foreach ($this->pages as $page) { |
|
25 | - $urlParameters = $this->pathSeeker(explode("/", $page[0]), $this->url); |
|
26 | - if(is_array($urlParameters)) { |
|
27 | - if(isset($page[2]) && is_array($page[2])) |
|
28 | - $urlParameters = array_merge($urlParameters, $page[2]); |
|
29 | - $pageSelected = [ |
|
30 | - $page[1], |
|
31 | - $urlParameters |
|
32 | - ]; |
|
33 | - break; |
|
34 | - } |
|
35 | - } |
|
36 | - if( $pageSelected !== null ) |
|
37 | - return $pageSelected; |
|
38 | - else |
|
39 | - return $this->defaultPage; |
|
40 | - } |
|
41 | - protected function pathSeeker( $_path, $_url ) { |
|
42 | - $urlLength = count($_url); |
|
43 | - $cont = 0; |
|
44 | - $variables = []; |
|
45 | - $pathLength = count($_path); |
|
46 | - if($urlLength == $pathLength) { |
|
47 | - while($cont < $urlLength) { |
|
48 | - if( |
|
49 | - ($this->urlCaseSensitive && $_path[$cont] == $_url[$cont]) || |
|
50 | - (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) |
|
51 | - $cont++; |
|
52 | - else if( strpos($_path[$cont], "\$") !== false ) { |
|
53 | - $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont]; |
|
54 | - $cont++; |
|
55 | - } else break; |
|
56 | - } |
|
57 | - if($cont == $urlLength) |
|
58 | - return $variables; |
|
59 | - } |
|
60 | - return null; |
|
61 | - } |
|
4 | + protected $url; |
|
5 | + protected $pages; |
|
6 | + protected $defaultPage; |
|
7 | + protected $urlCaseSensitive; |
|
8 | + public function __construct( $_path, $_urlCaseSensitive = false ) { |
|
9 | + if(!is_string($_path)) |
|
10 | + throw new JException("Parameter must be a string."); |
|
11 | + $jConfig = new JConfig($_path); |
|
12 | + $server = new ServerVars(); |
|
13 | + $request = $server->server["REQUEST_URI"]; |
|
14 | + $base = $server->server["RELATIVE"]; |
|
15 | + $url = str_replace($base, "", $request); |
|
16 | + $this->url = explode("/", $url); |
|
17 | + $this->pages = $jConfig->pages; |
|
18 | + $this->defaultPage = $jConfig->defaultPage; |
|
19 | + $this->urlCaseSensitive = $_urlCaseSensitive; |
|
20 | + } |
|
21 | + public function getPage() { |
|
22 | + $parameters = []; |
|
23 | + $pageSelected = null; |
|
24 | + foreach ($this->pages as $page) { |
|
25 | + $urlParameters = $this->pathSeeker(explode("/", $page[0]), $this->url); |
|
26 | + if(is_array($urlParameters)) { |
|
27 | + if(isset($page[2]) && is_array($page[2])) |
|
28 | + $urlParameters = array_merge($urlParameters, $page[2]); |
|
29 | + $pageSelected = [ |
|
30 | + $page[1], |
|
31 | + $urlParameters |
|
32 | + ]; |
|
33 | + break; |
|
34 | + } |
|
35 | + } |
|
36 | + if( $pageSelected !== null ) |
|
37 | + return $pageSelected; |
|
38 | + else |
|
39 | + return $this->defaultPage; |
|
40 | + } |
|
41 | + protected function pathSeeker( $_path, $_url ) { |
|
42 | + $urlLength = count($_url); |
|
43 | + $cont = 0; |
|
44 | + $variables = []; |
|
45 | + $pathLength = count($_path); |
|
46 | + if($urlLength == $pathLength) { |
|
47 | + while($cont < $urlLength) { |
|
48 | + if( |
|
49 | + ($this->urlCaseSensitive && $_path[$cont] == $_url[$cont]) || |
|
50 | + (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) |
|
51 | + $cont++; |
|
52 | + else if( strpos($_path[$cont], "\$") !== false ) { |
|
53 | + $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont]; |
|
54 | + $cont++; |
|
55 | + } else break; |
|
56 | + } |
|
57 | + if($cont == $urlLength) |
|
58 | + return $variables; |
|
59 | + } |
|
60 | + return null; |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | ?> |
@@ -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; |
@@ -6,8 +6,9 @@ discard block |
||
6 | 6 | protected $defaultPage; |
7 | 7 | protected $urlCaseSensitive; |
8 | 8 | public function __construct( $_path, $_urlCaseSensitive = false ) { |
9 | - if(!is_string($_path)) |
|
10 | - throw new JException("Parameter must be a string."); |
|
9 | + if(!is_string($_path)) { |
|
10 | + throw new JException("Parameter must be a string."); |
|
11 | + } |
|
11 | 12 | $jConfig = new JConfig($_path); |
12 | 13 | $server = new ServerVars(); |
13 | 14 | $request = $server->server["REQUEST_URI"]; |
@@ -24,8 +25,9 @@ discard block |
||
24 | 25 | foreach ($this->pages as $page) { |
25 | 26 | $urlParameters = $this->pathSeeker(explode("/", $page[0]), $this->url); |
26 | 27 | if(is_array($urlParameters)) { |
27 | - if(isset($page[2]) && is_array($page[2])) |
|
28 | - $urlParameters = array_merge($urlParameters, $page[2]); |
|
28 | + if(isset($page[2]) && is_array($page[2])) { |
|
29 | + $urlParameters = array_merge($urlParameters, $page[2]); |
|
30 | + } |
|
29 | 31 | $pageSelected = [ |
30 | 32 | $page[1], |
31 | 33 | $urlParameters |
@@ -33,10 +35,11 @@ discard block |
||
33 | 35 | break; |
34 | 36 | } |
35 | 37 | } |
36 | - if( $pageSelected !== null ) |
|
37 | - return $pageSelected; |
|
38 | - else |
|
39 | - return $this->defaultPage; |
|
38 | + if( $pageSelected !== null ) { |
|
39 | + return $pageSelected; |
|
40 | + } else { |
|
41 | + return $this->defaultPage; |
|
42 | + } |
|
40 | 43 | } |
41 | 44 | protected function pathSeeker( $_path, $_url ) { |
42 | 45 | $urlLength = count($_url); |
@@ -47,15 +50,18 @@ discard block |
||
47 | 50 | while($cont < $urlLength) { |
48 | 51 | if( |
49 | 52 | ($this->urlCaseSensitive && $_path[$cont] == $_url[$cont]) || |
50 | - (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) |
|
51 | - $cont++; |
|
52 | - else if( strpos($_path[$cont], "\$") !== false ) { |
|
53 | + (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) { |
|
54 | + $cont++; |
|
55 | + } else if( strpos($_path[$cont], "\$") !== false ) { |
|
53 | 56 | $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont]; |
54 | 57 | $cont++; |
55 | - } else break; |
|
58 | + } else { |
|
59 | + break; |
|
60 | + } |
|
61 | + } |
|
62 | + if($cont == $urlLength) { |
|
63 | + return $variables; |
|
56 | 64 | } |
57 | - if($cont == $urlLength) |
|
58 | - return $variables; |
|
59 | 65 | } |
60 | 66 | return null; |
61 | 67 | } |
@@ -2,34 +2,34 @@ |
||
2 | 2 | jRequire("../Query/Query.php"); |
3 | 3 | jRequire("../File/File.php"); |
4 | 4 | class Module { |
5 | - use Query { |
|
6 | - Query::__construct as private __queryConstruct; |
|
7 | - } |
|
8 | - use File { |
|
9 | - File::__construct as private __fileConstruct; |
|
10 | - } |
|
11 | - public $name; |
|
12 | - public $modules; |
|
13 | - public function __construct() { |
|
14 | - $this->name = get_class($this); |
|
15 | - $this->modules = []; |
|
16 | - $this->__queryConstruct(); |
|
17 | - $this->__fileConstruct(); |
|
18 | - } |
|
19 | - public function addModules( $_modules ) { |
|
20 | - if(!is_array($_modules)) |
|
21 | - throw new JException("Parameter must be an array."); |
|
22 | - foreach ($_modules as $value) |
|
23 | - $this->addModule($value); |
|
24 | - } |
|
25 | - public function addModule( $_module ) { |
|
26 | - if(!is_object($_module)) |
|
27 | - throw new JException("Parameter must be a object."); |
|
28 | - if(! is_subclass_of ($_module, "Module")) |
|
29 | - throw new JException("Parameter must be a object inherited from Module object."); |
|
30 | - $this->modules[$_module->name] = $_module; |
|
31 | - if($this->currentConnection) |
|
32 | - $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
33 | - } |
|
5 | + use Query { |
|
6 | + Query::__construct as private __queryConstruct; |
|
7 | + } |
|
8 | + use File { |
|
9 | + File::__construct as private __fileConstruct; |
|
10 | + } |
|
11 | + public $name; |
|
12 | + public $modules; |
|
13 | + public function __construct() { |
|
14 | + $this->name = get_class($this); |
|
15 | + $this->modules = []; |
|
16 | + $this->__queryConstruct(); |
|
17 | + $this->__fileConstruct(); |
|
18 | + } |
|
19 | + public function addModules( $_modules ) { |
|
20 | + if(!is_array($_modules)) |
|
21 | + throw new JException("Parameter must be an array."); |
|
22 | + foreach ($_modules as $value) |
|
23 | + $this->addModule($value); |
|
24 | + } |
|
25 | + public function addModule( $_module ) { |
|
26 | + if(!is_object($_module)) |
|
27 | + throw new JException("Parameter must be a object."); |
|
28 | + if(! is_subclass_of ($_module, "Module")) |
|
29 | + throw new JException("Parameter must be a object inherited from Module object."); |
|
30 | + $this->modules[$_module->name] = $_module; |
|
31 | + if($this->currentConnection) |
|
32 | + $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | ?> |
@@ -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 | } |
@@ -17,19 +17,24 @@ |
||
17 | 17 | $this->__fileConstruct(); |
18 | 18 | } |
19 | 19 | public function addModules( $_modules ) { |
20 | - if(!is_array($_modules)) |
|
21 | - throw new JException("Parameter must be an array."); |
|
22 | - foreach ($_modules as $value) |
|
23 | - $this->addModule($value); |
|
20 | + if(!is_array($_modules)) { |
|
21 | + throw new JException("Parameter must be an array."); |
|
22 | + } |
|
23 | + foreach ($_modules as $value) { |
|
24 | + $this->addModule($value); |
|
25 | + } |
|
24 | 26 | } |
25 | 27 | public function addModule( $_module ) { |
26 | - if(!is_object($_module)) |
|
27 | - throw new JException("Parameter must be a object."); |
|
28 | - if(! is_subclass_of ($_module, "Module")) |
|
29 | - throw new JException("Parameter must be a object inherited from Module object."); |
|
28 | + if(!is_object($_module)) { |
|
29 | + throw new JException("Parameter must be a object."); |
|
30 | + } |
|
31 | + if(! is_subclass_of ($_module, "Module")) { |
|
32 | + throw new JException("Parameter must be a object inherited from Module object."); |
|
33 | + } |
|
30 | 34 | $this->modules[$_module->name] = $_module; |
31 | - if($this->currentConnection) |
|
32 | - $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
35 | + if($this->currentConnection) { |
|
36 | + $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
37 | + } |
|
33 | 38 | } |
34 | 39 | } |
35 | 40 | ?> |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | class JConfig { |
3 | - public function __construct( $_path ) { |
|
4 | - if(!is_string($_path)) |
|
5 | - throw new JException("Path must be a string."); |
|
6 | - if(!file_exists($_path)) |
|
7 | - throw new JException("File [$_path] not found."); |
|
8 | - $data = file_get_contents($_path); |
|
9 | - $data = json_decode($data); |
|
10 | - if($data === NULL) |
|
11 | - throw new JException("Invalid file data. [$_path]"); |
|
12 | - if(is_object($data)) |
|
13 | - foreach (get_object_vars($data) as $key => $value) |
|
14 | - $this->$key = $value; |
|
15 | - if(is_array($data)) |
|
16 | - $this->data = $data; |
|
17 | - } |
|
3 | + public function __construct( $_path ) { |
|
4 | + if(!is_string($_path)) |
|
5 | + throw new JException("Path must be a string."); |
|
6 | + if(!file_exists($_path)) |
|
7 | + throw new JException("File [$_path] not found."); |
|
8 | + $data = file_get_contents($_path); |
|
9 | + $data = json_decode($data); |
|
10 | + if($data === NULL) |
|
11 | + throw new JException("Invalid file data. [$_path]"); |
|
12 | + if(is_object($data)) |
|
13 | + foreach (get_object_vars($data) as $key => $value) |
|
14 | + $this->$key = $value; |
|
15 | + if(is_array($data)) |
|
16 | + $this->data = $data; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | ?> |
@@ -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 | } |
@@ -1,19 +1,24 @@ |
||
1 | 1 | <?php |
2 | 2 | class JConfig { |
3 | 3 | public function __construct( $_path ) { |
4 | - if(!is_string($_path)) |
|
5 | - throw new JException("Path must be a string."); |
|
6 | - if(!file_exists($_path)) |
|
7 | - throw new JException("File [$_path] not found."); |
|
4 | + if(!is_string($_path)) { |
|
5 | + throw new JException("Path must be a string."); |
|
6 | + } |
|
7 | + if(!file_exists($_path)) { |
|
8 | + throw new JException("File [$_path] not found."); |
|
9 | + } |
|
8 | 10 | $data = file_get_contents($_path); |
9 | 11 | $data = json_decode($data); |
10 | - if($data === NULL) |
|
11 | - throw new JException("Invalid file data. [$_path]"); |
|
12 | - if(is_object($data)) |
|
13 | - foreach (get_object_vars($data) as $key => $value) |
|
12 | + if($data === NULL) { |
|
13 | + throw new JException("Invalid file data. [$_path]"); |
|
14 | + } |
|
15 | + if(is_object($data)) { |
|
16 | + foreach (get_object_vars($data) as $key => $value) |
|
14 | 17 | $this->$key = $value; |
15 | - if(is_array($data)) |
|
16 | - $this->data = $data; |
|
18 | + } |
|
19 | + if(is_array($data)) { |
|
20 | + $this->data = $data; |
|
21 | + } |
|
17 | 22 | } |
18 | 23 | } |
19 | 24 | ?> |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | requireComponent("../Html/Html.php"); |
3 | 3 | class Angular extends Html { |
4 | - public function init() { |
|
5 | - header("Access-Control-Allow-Origin: *"); |
|
6 | - header("Content-Type: application/json; charset=UTF-8"); |
|
7 | - } |
|
8 | - public function draw() {} |
|
4 | + public function init() { |
|
5 | + header("Access-Control-Allow-Origin: *"); |
|
6 | + header("Content-Type: application/json; charset=UTF-8"); |
|
7 | + } |
|
8 | + public function draw() {} |
|
9 | 9 | } |
10 | 10 | ?> |