@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("../Module/Module.php"); |
3 | 3 | class Router extends Module { |
4 | - public function __construct() { |
|
5 | - parent::__construct(); |
|
6 | - } |
|
7 | - public function getPage() { |
|
8 | - $request = $this->parameters["app"]->server["REQUEST_URI"]; |
|
9 | - $base = $this->parameters["app"]->server["RELATIVE"]; |
|
10 | - $url = str_replace($base, "", $request); |
|
11 | - $url = explode("/", $url); |
|
12 | - return $url; |
|
13 | - } |
|
4 | + public function __construct() { |
|
5 | + parent::__construct(); |
|
6 | + } |
|
7 | + public function getPage() { |
|
8 | + $request = $this->parameters["app"]->server["REQUEST_URI"]; |
|
9 | + $base = $this->parameters["app"]->server["RELATIVE"]; |
|
10 | + $url = str_replace($base, "", $request); |
|
11 | + $url = explode("/", $url); |
|
12 | + return $url; |
|
13 | + } |
|
14 | 14 | } |
15 | 15 | ?> |
@@ -1,53 +1,53 @@ |
||
1 | 1 | <?php |
2 | 2 | class JConfig { |
3 | - public $connection; |
|
4 | - public $all; |
|
5 | - public $DEBUG; |
|
6 | - public $pages; |
|
7 | - public $server; |
|
8 | - public function __construct() { |
|
9 | - $this->connection["enable"] = false; |
|
10 | - $this->connection["user"] = ""; |
|
11 | - $this->connection["password"] = ""; |
|
12 | - $this->connection["database"] = ""; |
|
13 | - $this->connection["server"] = ""; |
|
14 | - $this->all = ""; |
|
15 | - $this->DEBUG = 0; |
|
16 | - $this->pages = []; |
|
17 | - $this->server = []; |
|
18 | - $this->server["HTTP_HOST"] = $_SERVER["HTTP_HOST"]; |
|
19 | - $this->server["REQUEST_URI"] = $_SERVER["REQUEST_URI"]; |
|
20 | - $this->server["PHP_SELF"] = $_SERVER["PHP_SELF"]; |
|
21 | - $this->server["RELATIVE"] = str_replace("/index.php", "", $_SERVER["PHP_SELF"]); |
|
22 | - } |
|
23 | - public function import( $_path, $_type = "misc" ) { |
|
24 | - $data = file_get_contents($_path); |
|
25 | - $data = json_decode($data); |
|
26 | - if( $_type == "connection" ) |
|
27 | - $this->overlayConnection($data); |
|
28 | - else |
|
29 | - $this->overlayMisc($data); |
|
30 | - } |
|
31 | - protected function overlayConnection( $_data ) { |
|
32 | - $this->connection = $this->obj2array($_data); |
|
33 | - } |
|
34 | - protected function overlayMisc( $_data ) { |
|
35 | - $this->importObject($_data); |
|
36 | - } |
|
37 | - protected function obj2array ( &$_instance ) { |
|
38 | - $clone = (array) $_instance; |
|
39 | - $return = []; |
|
40 | - $return['___SOURCE_KEYS_'] = $clone; |
|
41 | - while ( list ($key, $value) = each ($clone) ) { |
|
42 | - $temp = explode ("\0", $key); |
|
43 | - $newkey = $temp[count($temp)-1]; |
|
44 | - $return[$newkey] = &$return['___SOURCE_KEYS_'][$key]; |
|
45 | - } |
|
46 | - return $return; |
|
47 | - } |
|
48 | - protected function importObject( $_object ) { |
|
49 | - foreach (get_object_vars($_object) as $key => $value) |
|
50 | - $this->$key = $value; |
|
51 | - } |
|
3 | + public $connection; |
|
4 | + public $all; |
|
5 | + public $DEBUG; |
|
6 | + public $pages; |
|
7 | + public $server; |
|
8 | + public function __construct() { |
|
9 | + $this->connection["enable"] = false; |
|
10 | + $this->connection["user"] = ""; |
|
11 | + $this->connection["password"] = ""; |
|
12 | + $this->connection["database"] = ""; |
|
13 | + $this->connection["server"] = ""; |
|
14 | + $this->all = ""; |
|
15 | + $this->DEBUG = 0; |
|
16 | + $this->pages = []; |
|
17 | + $this->server = []; |
|
18 | + $this->server["HTTP_HOST"] = $_SERVER["HTTP_HOST"]; |
|
19 | + $this->server["REQUEST_URI"] = $_SERVER["REQUEST_URI"]; |
|
20 | + $this->server["PHP_SELF"] = $_SERVER["PHP_SELF"]; |
|
21 | + $this->server["RELATIVE"] = str_replace("/index.php", "", $_SERVER["PHP_SELF"]); |
|
22 | + } |
|
23 | + public function import( $_path, $_type = "misc" ) { |
|
24 | + $data = file_get_contents($_path); |
|
25 | + $data = json_decode($data); |
|
26 | + if( $_type == "connection" ) |
|
27 | + $this->overlayConnection($data); |
|
28 | + else |
|
29 | + $this->overlayMisc($data); |
|
30 | + } |
|
31 | + protected function overlayConnection( $_data ) { |
|
32 | + $this->connection = $this->obj2array($_data); |
|
33 | + } |
|
34 | + protected function overlayMisc( $_data ) { |
|
35 | + $this->importObject($_data); |
|
36 | + } |
|
37 | + protected function obj2array ( &$_instance ) { |
|
38 | + $clone = (array) $_instance; |
|
39 | + $return = []; |
|
40 | + $return['___SOURCE_KEYS_'] = $clone; |
|
41 | + while ( list ($key, $value) = each ($clone) ) { |
|
42 | + $temp = explode ("\0", $key); |
|
43 | + $newkey = $temp[count($temp)-1]; |
|
44 | + $return[$newkey] = &$return['___SOURCE_KEYS_'][$key]; |
|
45 | + } |
|
46 | + return $return; |
|
47 | + } |
|
48 | + protected function importObject( $_object ) { |
|
49 | + foreach (get_object_vars($_object) as $key => $value) |
|
50 | + $this->$key = $value; |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | ?> |
@@ -1,49 +1,49 @@ |
||
1 | 1 | <?php |
2 | 2 | requireComponent("../Query/Query.php"); |
3 | 3 | class Html extends Query { |
4 | - public function __construct( $_parameters = [ "app" => null, "page" => null] ) { |
|
5 | - parent::__construct(); |
|
6 | - $this->data["template"] = ""; |
|
7 | - $this->tags["brand"] = ""; |
|
8 | - $this->tags["brandImg"] = ""; |
|
9 | - $this->tags["menu"] = ""; |
|
10 | - $this->tags["title"] = ""; |
|
11 | - $this->tags["subtitle"] = ""; |
|
12 | - $this->tags["content"] = ""; |
|
13 | - $this->tags["outContent"] = ""; |
|
14 | - $this->tags["footer"] = ""; |
|
15 | - $this->tags["pagePath"] = []; |
|
16 | - $this->tags["css"] = []; |
|
17 | - $this->tags["js"] = []; |
|
18 | - $this->tags["jsVariables"] = []; |
|
19 | - $this->tags["metaDescription"] = []; |
|
20 | - $this->tags["metaKeywords"] = []; |
|
21 | - $this->tags["metaAuthor"] = []; |
|
22 | - $this->parameters = $_parameters; |
|
23 | - $this->tags["base"] = $_parameters["app"]->server["RELATIVE"]."/"; |
|
24 | - } |
|
25 | - public function uniforma() { |
|
26 | - $this->addDipendences(); |
|
27 | - $this->tags["css"] = array_unique($this->tags["css"]); |
|
28 | - $this->tags["js"] = array_unique($this->tags["js"]); |
|
29 | - $this->tags["pagePath"] = json_encode($this->tags["pagePath"]); |
|
30 | - $tempStr = ""; |
|
31 | - $timeParameter = "?t=".time(); |
|
32 | - $time = ($this->parameters["app"]->cache->css == true) ? "" : $timeParameter; |
|
33 | - foreach ($this->tags["css"] as $i) |
|
34 | - $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
35 | - $this->tags["css"] = $tempStr; |
|
36 | - $tempStr = ""; |
|
37 | - $time = ($this->parameters["app"]->cache->js == true) ? "" : $timeParameter; |
|
38 | - foreach ($this->tags["js"] as $i) |
|
39 | - $tempStr .= "<script src='$i$time'></script>"; |
|
40 | - $this->tags["js"] = $tempStr; |
|
41 | - $tempStr = ""; |
|
42 | - $tempStr .= "<script type='text/javascript'>"; |
|
43 | - foreach ($this->tags["jsVariables"] as $i) |
|
44 | - $tempStr .= " $i[0] = $i[1];\n"; |
|
45 | - $tempStr .= "</script>"; |
|
46 | - $this->tags["jsVariables"] = $tempStr; |
|
47 | - } |
|
4 | + public function __construct( $_parameters = [ "app" => null, "page" => null] ) { |
|
5 | + parent::__construct(); |
|
6 | + $this->data["template"] = ""; |
|
7 | + $this->tags["brand"] = ""; |
|
8 | + $this->tags["brandImg"] = ""; |
|
9 | + $this->tags["menu"] = ""; |
|
10 | + $this->tags["title"] = ""; |
|
11 | + $this->tags["subtitle"] = ""; |
|
12 | + $this->tags["content"] = ""; |
|
13 | + $this->tags["outContent"] = ""; |
|
14 | + $this->tags["footer"] = ""; |
|
15 | + $this->tags["pagePath"] = []; |
|
16 | + $this->tags["css"] = []; |
|
17 | + $this->tags["js"] = []; |
|
18 | + $this->tags["jsVariables"] = []; |
|
19 | + $this->tags["metaDescription"] = []; |
|
20 | + $this->tags["metaKeywords"] = []; |
|
21 | + $this->tags["metaAuthor"] = []; |
|
22 | + $this->parameters = $_parameters; |
|
23 | + $this->tags["base"] = $_parameters["app"]->server["RELATIVE"]."/"; |
|
24 | + } |
|
25 | + public function uniforma() { |
|
26 | + $this->addDipendences(); |
|
27 | + $this->tags["css"] = array_unique($this->tags["css"]); |
|
28 | + $this->tags["js"] = array_unique($this->tags["js"]); |
|
29 | + $this->tags["pagePath"] = json_encode($this->tags["pagePath"]); |
|
30 | + $tempStr = ""; |
|
31 | + $timeParameter = "?t=".time(); |
|
32 | + $time = ($this->parameters["app"]->cache->css == true) ? "" : $timeParameter; |
|
33 | + foreach ($this->tags["css"] as $i) |
|
34 | + $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
35 | + $this->tags["css"] = $tempStr; |
|
36 | + $tempStr = ""; |
|
37 | + $time = ($this->parameters["app"]->cache->js == true) ? "" : $timeParameter; |
|
38 | + foreach ($this->tags["js"] as $i) |
|
39 | + $tempStr .= "<script src='$i$time'></script>"; |
|
40 | + $this->tags["js"] = $tempStr; |
|
41 | + $tempStr = ""; |
|
42 | + $tempStr .= "<script type='text/javascript'>"; |
|
43 | + foreach ($this->tags["jsVariables"] as $i) |
|
44 | + $tempStr .= " $i[0] = $i[1];\n"; |
|
45 | + $tempStr .= "</script>"; |
|
46 | + $this->tags["jsVariables"] = $tempStr; |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | ?> |
@@ -1,89 +1,89 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("../Query/Query.php"); |
3 | 3 | class Menu extends Query { |
4 | - public function __construct() { |
|
5 | - parent::__construct(); |
|
6 | - } |
|
7 | - public function init() { |
|
8 | - $menu = $this->queryFetch("SELECT * FROM menu WHERE flag_active = 1 ORDER BY `order`"); |
|
9 | - $temp = []; |
|
10 | - foreach ($menu as $i) { |
|
11 | - if($i["fk_menu"] == 0) { |
|
12 | - $pk_menu = $i["pk_menu"]; |
|
13 | - array_push($temp, array("label" => $i["label"], "link" => $i["link"], "submenu" => [], "relative" => false)); |
|
14 | - $submenu = $this->queryFetch("SELECT * FROM menu WHERE fk_menu = $pk_menu ORDER BY `order`"); |
|
15 | - if($submenu) |
|
16 | - foreach ($submenu as $j) |
|
17 | - array_push( $temp[count($temp)-1]["submenu"], array("label" => $j["label"], "link" => $j["link"], "submenu" => [], "relative" => false) ); |
|
18 | - } |
|
19 | - } |
|
20 | - $this->tags["menu"] = $temp; |
|
21 | - return $temp; |
|
22 | - } |
|
23 | - public function draw() { |
|
24 | - $temp = ""; |
|
25 | - $host = $this->parameters["app"]->server["HTTP_HOST"]; |
|
26 | - $uri = $this->parameters["app"]->server["REQUEST_URI"]; |
|
27 | - $actualLink = "http://$host$uri"; |
|
28 | - $relative = $this->parameters["app"]->server["RELATIVE"]; |
|
29 | - foreach ($this->tags["menu"] as $i) { |
|
30 | - $prePath = ""; |
|
31 | - if($i["relative"]) |
|
32 | - $prePath = $relative; |
|
33 | - $active = $this->isSubString($actualLink, array_merge(array_column($i["submenu"], 'link'), array($i["link"]))) ? "active" : ""; |
|
34 | - if( is_array($i["submenu"]) && count($i["submenu"])<1) |
|
35 | - $temp .= "<li class='$active'><a href='$prePath$i[link]'>$i[label]</a></li>"; |
|
36 | - else { |
|
37 | - $temp .= "<li class='dropdown $active'>"; |
|
38 | - $temp .= |
|
39 | - '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'. |
|
40 | - $i["label"]. |
|
41 | - '<span class="caret"></span>'. |
|
42 | - '</a>'. |
|
43 | - '<ul class="dropdown-menu">'; |
|
44 | - foreach ($i["submenu"] as $j) { |
|
45 | - $prePath = ""; |
|
46 | - if($j["relative"]) |
|
47 | - $prePath = $relative; |
|
48 | - $temp .= "<li><a href='$prePath$j[link]'>$j[label]</a></li>"; |
|
49 | - } |
|
50 | - $temp .= "</ul></li>"; |
|
51 | - } |
|
52 | - } |
|
53 | - return $temp; |
|
54 | - } |
|
55 | - protected function isSubString( $_string, $_list) { |
|
56 | - $success = false; |
|
57 | - foreach ($_list as $i) |
|
58 | - if(strpos($_string,$i) !== false) |
|
59 | - $success = true; |
|
60 | - return $success; |
|
61 | - } |
|
62 | - public function loginWithUser() { |
|
63 | - $this->init(); |
|
64 | - $temp = []; |
|
65 | - if(!isset($_SESSION["username"])) |
|
66 | - $_SESSION["username"] ="guest"; |
|
67 | - $user = $_SESSION["username"]; |
|
68 | - $blackList = $this->queryFetch( |
|
69 | - "SELECT user.*,user_section.* |
|
4 | + public function __construct() { |
|
5 | + parent::__construct(); |
|
6 | + } |
|
7 | + public function init() { |
|
8 | + $menu = $this->queryFetch("SELECT * FROM menu WHERE flag_active = 1 ORDER BY `order`"); |
|
9 | + $temp = []; |
|
10 | + foreach ($menu as $i) { |
|
11 | + if($i["fk_menu"] == 0) { |
|
12 | + $pk_menu = $i["pk_menu"]; |
|
13 | + array_push($temp, array("label" => $i["label"], "link" => $i["link"], "submenu" => [], "relative" => false)); |
|
14 | + $submenu = $this->queryFetch("SELECT * FROM menu WHERE fk_menu = $pk_menu ORDER BY `order`"); |
|
15 | + if($submenu) |
|
16 | + foreach ($submenu as $j) |
|
17 | + array_push( $temp[count($temp)-1]["submenu"], array("label" => $j["label"], "link" => $j["link"], "submenu" => [], "relative" => false) ); |
|
18 | + } |
|
19 | + } |
|
20 | + $this->tags["menu"] = $temp; |
|
21 | + return $temp; |
|
22 | + } |
|
23 | + public function draw() { |
|
24 | + $temp = ""; |
|
25 | + $host = $this->parameters["app"]->server["HTTP_HOST"]; |
|
26 | + $uri = $this->parameters["app"]->server["REQUEST_URI"]; |
|
27 | + $actualLink = "http://$host$uri"; |
|
28 | + $relative = $this->parameters["app"]->server["RELATIVE"]; |
|
29 | + foreach ($this->tags["menu"] as $i) { |
|
30 | + $prePath = ""; |
|
31 | + if($i["relative"]) |
|
32 | + $prePath = $relative; |
|
33 | + $active = $this->isSubString($actualLink, array_merge(array_column($i["submenu"], 'link'), array($i["link"]))) ? "active" : ""; |
|
34 | + if( is_array($i["submenu"]) && count($i["submenu"])<1) |
|
35 | + $temp .= "<li class='$active'><a href='$prePath$i[link]'>$i[label]</a></li>"; |
|
36 | + else { |
|
37 | + $temp .= "<li class='dropdown $active'>"; |
|
38 | + $temp .= |
|
39 | + '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'. |
|
40 | + $i["label"]. |
|
41 | + '<span class="caret"></span>'. |
|
42 | + '</a>'. |
|
43 | + '<ul class="dropdown-menu">'; |
|
44 | + foreach ($i["submenu"] as $j) { |
|
45 | + $prePath = ""; |
|
46 | + if($j["relative"]) |
|
47 | + $prePath = $relative; |
|
48 | + $temp .= "<li><a href='$prePath$j[link]'>$j[label]</a></li>"; |
|
49 | + } |
|
50 | + $temp .= "</ul></li>"; |
|
51 | + } |
|
52 | + } |
|
53 | + return $temp; |
|
54 | + } |
|
55 | + protected function isSubString( $_string, $_list) { |
|
56 | + $success = false; |
|
57 | + foreach ($_list as $i) |
|
58 | + if(strpos($_string,$i) !== false) |
|
59 | + $success = true; |
|
60 | + return $success; |
|
61 | + } |
|
62 | + public function loginWithUser() { |
|
63 | + $this->init(); |
|
64 | + $temp = []; |
|
65 | + if(!isset($_SESSION["username"])) |
|
66 | + $_SESSION["username"] ="guest"; |
|
67 | + $user = $_SESSION["username"]; |
|
68 | + $blackList = $this->queryFetch( |
|
69 | + "SELECT user.*,user_section.* |
|
70 | 70 | FROM user |
71 | 71 | INNER JOIN user_x_section |
72 | 72 | ON user.pk_user = user_x_section.fk_user |
73 | 73 | INNER JOIN user_section |
74 | 74 | ON user_section.pk_user_section = user_x_section.fk_user_section |
75 | 75 | WHERE user.username = '$user'" |
76 | - ); |
|
77 | - foreach ($this->tags["menu"] as $i) { |
|
78 | - $success = true; |
|
79 | - $k = $i["label"]; |
|
80 | - foreach ($blackList as $j) |
|
81 | - if( $j["section"] == $k) |
|
82 | - $success = false; |
|
83 | - if($success) |
|
84 | - array_push($temp,$i); |
|
85 | - } |
|
86 | - $this->tags["menu"] = $temp; |
|
87 | - } |
|
76 | + ); |
|
77 | + foreach ($this->tags["menu"] as $i) { |
|
78 | + $success = true; |
|
79 | + $k = $i["label"]; |
|
80 | + foreach ($blackList as $j) |
|
81 | + if( $j["section"] == $k) |
|
82 | + $success = false; |
|
83 | + if($success) |
|
84 | + array_push($temp,$i); |
|
85 | + } |
|
86 | + $this->tags["menu"] = $temp; |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | ?> |
@@ -2,19 +2,19 @@ |
||
2 | 2 | use Pug as Pug; |
3 | 3 | jRequire("../Module/Module.php"); |
4 | 4 | class Pug extends Module { |
5 | - public function __construct() { |
|
6 | - parent::__construct(); |
|
7 | - } |
|
8 | - public function drawFile( $_file, $_parameters = [] ) { |
|
9 | - return $this->draw($_file, $_parameters); |
|
10 | - } |
|
11 | - public function drawText( $_text, $_parameters = [] ) { |
|
12 | - return $this->draw(trim($_text), $_parameters); |
|
13 | - } |
|
14 | - public function draw( $_text, $_parameters = [] ) { |
|
15 | - $pug = new Pug\Pug(); |
|
16 | - $page = $pug->render($_text, $_parameters); |
|
17 | - return $page; |
|
18 | - } |
|
5 | + public function __construct() { |
|
6 | + parent::__construct(); |
|
7 | + } |
|
8 | + public function drawFile( $_file, $_parameters = [] ) { |
|
9 | + return $this->draw($_file, $_parameters); |
|
10 | + } |
|
11 | + public function drawText( $_text, $_parameters = [] ) { |
|
12 | + return $this->draw(trim($_text), $_parameters); |
|
13 | + } |
|
14 | + public function draw( $_text, $_parameters = [] ) { |
|
15 | + $pug = new Pug\Pug(); |
|
16 | + $page = $pug->render($_text, $_parameters); |
|
17 | + return $page; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | ?> |
@@ -1,35 +1,35 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("../Module/Module.php"); |
3 | 3 | class Query extends Module { |
4 | - public $connection; |
|
5 | - public $currentConnection; |
|
6 | - public function __construct() { |
|
7 | - parent::__construct(); |
|
8 | - $this->connection = []; |
|
9 | - $this->currentConnection = null; |
|
10 | - } |
|
11 | - public function addConnection( $_name, $_connection ) { |
|
12 | - $this->connection["$_name"] = $_connection; |
|
13 | - $this->currentConnection = $_connection; |
|
4 | + public $connection; |
|
5 | + public $currentConnection; |
|
6 | + public function __construct() { |
|
7 | + parent::__construct(); |
|
8 | + $this->connection = []; |
|
9 | + $this->currentConnection = null; |
|
10 | + } |
|
11 | + public function addConnection( $_name, $_connection ) { |
|
12 | + $this->connection["$_name"] = $_connection; |
|
13 | + $this->currentConnection = $_connection; |
|
14 | 14 | |
15 | - foreach ($this->modules as &$module) |
|
16 | - if(isset($module->currentConnection)) |
|
17 | - $module->addConnection($_name, $_connection); |
|
18 | - } |
|
19 | - public function setConnection( $_name ) { |
|
20 | - $this->currentConnection = $this->connection["$_name"]; |
|
21 | - } |
|
22 | - public function query( $_query ) { |
|
23 | - return $this->currentConnection->database->query($_query); |
|
24 | - } |
|
25 | - public function queryInsert( $_query ) { |
|
26 | - return $this->currentConnection->database->queryInsert($_query); |
|
27 | - } |
|
28 | - public function queryFetch( $_query ) { |
|
29 | - return $this->currentConnection->database->queryFetch($_query); |
|
30 | - } |
|
31 | - public function queryArray( $_query ) { |
|
32 | - return $this->currentConnection->database->queryArray($_query); |
|
33 | - } |
|
15 | + foreach ($this->modules as &$module) |
|
16 | + if(isset($module->currentConnection)) |
|
17 | + $module->addConnection($_name, $_connection); |
|
18 | + } |
|
19 | + public function setConnection( $_name ) { |
|
20 | + $this->currentConnection = $this->connection["$_name"]; |
|
21 | + } |
|
22 | + public function query( $_query ) { |
|
23 | + return $this->currentConnection->database->query($_query); |
|
24 | + } |
|
25 | + public function queryInsert( $_query ) { |
|
26 | + return $this->currentConnection->database->queryInsert($_query); |
|
27 | + } |
|
28 | + public function queryFetch( $_query ) { |
|
29 | + return $this->currentConnection->database->queryFetch($_query); |
|
30 | + } |
|
31 | + public function queryArray( $_query ) { |
|
32 | + return $this->currentConnection->database->queryArray($_query); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | ?> |
@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | 2 | function requireComponent( $_path, $_local = true ) { |
3 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
4 | - if(file_exists($path) && isPhp($path)) |
|
5 | - jRequire($path, false, 0); |
|
6 | - else |
|
7 | - requireError($_path); |
|
3 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
4 | + if(file_exists($path) && isPhp($path)) |
|
5 | + jRequire($path, false, 0); |
|
6 | + else |
|
7 | + requireError($_path); |
|
8 | 8 | } |
9 | 9 | function requireComponents( $_path, $_local = true ) { |
10 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
11 | - if(file_exists($path)) { |
|
12 | - $files = subFolderFile($path); |
|
13 | - foreach ($files as $i) { |
|
14 | - if(isPhp($path."/".$i)) |
|
15 | - requireComponent($path."/".$i, false, 0); |
|
16 | - } |
|
17 | - } else |
|
18 | - requireError($_path); |
|
10 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
11 | + if(file_exists($path)) { |
|
12 | + $files = subFolderFile($path); |
|
13 | + foreach ($files as $i) { |
|
14 | + if(isPhp($path."/".$i)) |
|
15 | + requireComponent($path."/".$i, false, 0); |
|
16 | + } |
|
17 | + } else |
|
18 | + requireError($_path); |
|
19 | 19 | } |
20 | 20 | function requireError( $_path ) { |
21 | - global $DEBUG; |
|
22 | - if( $DEBUG == 1 ) |
|
23 | - echo "Error load ($_path)<br>"; |
|
21 | + global $DEBUG; |
|
22 | + if( $DEBUG == 1 ) |
|
23 | + echo "Error load ($_path)<br>"; |
|
24 | 24 | } |
25 | 25 | function isPhp ( $_file ) { |
26 | - if(!is_file($_file)) return false; |
|
27 | - $info = pathinfo($_file); |
|
28 | - return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
|
26 | + if(!is_file($_file)) return false; |
|
27 | + $info = pathinfo($_file); |
|
28 | + return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
|
29 | 29 | } |
30 | 30 | function requireModules( $_path, $_local = true ) { |
31 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
32 | - $subFolders = subFolderDir($path); |
|
33 | - foreach ($subFolders as $i) { |
|
34 | - requireComponents($path."/".$i, false, 0); |
|
35 | - } |
|
31 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
32 | + $subFolders = subFolderDir($path); |
|
33 | + foreach ($subFolders as $i) { |
|
34 | + requireComponents($path."/".$i, false, 0); |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | function jRequire( $_path, $_local = true ) { |
38 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
39 | - require_once( $path ); |
|
38 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
39 | + require_once( $path ); |
|
40 | 40 | } |
41 | 41 | function getJFolder( $_path, $_local, $_stack ) { |
42 | - if($_local) { |
|
43 | - $stackInfo = $_stack; |
|
44 | - $folder = dirname($stackInfo[0]["file"]); |
|
45 | - $file = "$folder/$_path"; |
|
46 | - } else |
|
47 | - $file = $_path; |
|
48 | - return $file; |
|
42 | + if($_local) { |
|
43 | + $stackInfo = $_stack; |
|
44 | + $folder = dirname($stackInfo[0]["file"]); |
|
45 | + $file = "$folder/$_path"; |
|
46 | + } else |
|
47 | + $file = $_path; |
|
48 | + return $file; |
|
49 | 49 | } |
50 | 50 | ?> |
@@ -2,57 +2,57 @@ |
||
2 | 2 | jRequire("../modules/Pug/Pug.php"); |
3 | 3 | jRequire("../modules/Parsedown/Parsedown.php"); |
4 | 4 | function jBlock() { |
5 | - return ob_start(); |
|
5 | + return ob_start(); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | function jBlockClose( $_type = "html", $_parameters = [] ) { |
9 | - return jBlockEnd($_type, $_parameters); |
|
9 | + return jBlockEnd($_type, $_parameters); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | function jBlockFile( $_path, $_parameters = [] ) { |
13 | - $extension = explode(".", $_path); |
|
14 | - $extension = $extension[count($extension)-1]; |
|
15 | - $extension = strtolower($extension); |
|
16 | - return jBlockFileMan($_path, $extension, $_parameters); |
|
13 | + $extension = explode(".", $_path); |
|
14 | + $extension = $extension[count($extension)-1]; |
|
15 | + $extension = strtolower($extension); |
|
16 | + return jBlockFileMan($_path, $extension, $_parameters); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | function jBlockFileMan( $_path, $_type, $_parameters = [] ) { |
20 | - $temp = file_get_contents($_path); |
|
21 | - return jBlockParsing($_type, $temp, $_parameters); |
|
20 | + $temp = file_get_contents($_path); |
|
21 | + return jBlockParsing($_type, $temp, $_parameters); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | function jBlockEnd( $_type = "html", $_parameters = [] ) { |
25 | - $text = ob_get_clean(); |
|
26 | - return jBlockParsing($_type, $text, $_parameters); |
|
25 | + $text = ob_get_clean(); |
|
26 | + return jBlockParsing($_type, $text, $_parameters); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | function jBlockParsing( $_type = "html", $_string = "", $_parameters = [] ) { |
30 | - switch ($_type) { |
|
31 | - case "pug": |
|
32 | - case "jade": |
|
33 | - $Pug = new Pug(); |
|
34 | - $_string = $Pug->drawText($_string, $_parameters); |
|
35 | - break; |
|
36 | - case "md": |
|
37 | - case "markdown": |
|
38 | - case "parsedown": |
|
39 | - $Parsedown = new Parsedown(); |
|
40 | - $_string = $Parsedown->drawText($_string); |
|
41 | - break; |
|
42 | - case "twig": |
|
43 | - $Twig = new Twig(); |
|
44 | - $_string = $Twig->drawText($_string, $_parameters); |
|
45 | - break; |
|
46 | - default: break; |
|
47 | - } |
|
48 | - return $_string; |
|
30 | + switch ($_type) { |
|
31 | + case "pug": |
|
32 | + case "jade": |
|
33 | + $Pug = new Pug(); |
|
34 | + $_string = $Pug->drawText($_string, $_parameters); |
|
35 | + break; |
|
36 | + case "md": |
|
37 | + case "markdown": |
|
38 | + case "parsedown": |
|
39 | + $Parsedown = new Parsedown(); |
|
40 | + $_string = $Parsedown->drawText($_string); |
|
41 | + break; |
|
42 | + case "twig": |
|
43 | + $Twig = new Twig(); |
|
44 | + $_string = $Twig->drawText($_string, $_parameters); |
|
45 | + break; |
|
46 | + default: break; |
|
47 | + } |
|
48 | + return $_string; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | function minifyOutput($_buffer) { |
52 | - $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
53 | - $replace = array ( '>', '<', '\\1' ); |
|
54 | - if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
55 | - $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
|
56 | - return utf8_encode($_buffer); |
|
52 | + $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
53 | + $replace = array ( '>', '<', '\\1' ); |
|
54 | + if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
55 | + $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
|
56 | + return utf8_encode($_buffer); |
|
57 | 57 | } |
58 | 58 | ?> |
@@ -1,45 +1,45 @@ |
||
1 | 1 | <?php |
2 | 2 | function utf8ize($_array) { |
3 | - return travelStringArray($_array,"utf8_encode"); |
|
3 | + return travelStringArray($_array,"utf8_encode"); |
|
4 | 4 | } |
5 | 5 | function unutf8ize($_array) { |
6 | - return travelStringArray($_array,"utf8_decode"); |
|
6 | + return travelStringArray($_array,"utf8_decode"); |
|
7 | 7 | } |
8 | 8 | function arraySlash($_array) { |
9 | - return travelStringArray($_array,"addslashes"); |
|
9 | + return travelStringArray($_array,"addslashes"); |
|
10 | 10 | } |
11 | 11 | function arrayHtmlParser($_array) { |
12 | - return travelStringArray($_array,"htmlParser"); |
|
12 | + return travelStringArray($_array,"htmlParser"); |
|
13 | 13 | } |
14 | 14 | function travelStringArray ( $_array, $_function ) { |
15 | - if (is_array($_array)) { |
|
16 | - foreach ($_array as $k => $v) { |
|
17 | - $_array[$k] = travelStringArray($v, $_function); |
|
18 | - } |
|
19 | - } else if (is_string ($_array)) { |
|
20 | - return call_user_func($_function,$_array); |
|
21 | - } |
|
22 | - return $_array; |
|
15 | + if (is_array($_array)) { |
|
16 | + foreach ($_array as $k => $v) { |
|
17 | + $_array[$k] = travelStringArray($v, $_function); |
|
18 | + } |
|
19 | + } else if (is_string ($_array)) { |
|
20 | + return call_user_func($_function,$_array); |
|
21 | + } |
|
22 | + return $_array; |
|
23 | 23 | } |
24 | 24 | function arrayDepth( $_array ) { |
25 | - $maxDepth = 1; |
|
26 | - foreach ($_array as $value) { |
|
27 | - if (is_array($value)) { |
|
28 | - $depth = arrayDepth($value) + 1; |
|
29 | - if ($depth > $maxDepth) { |
|
30 | - $maxDepth = $depth; |
|
31 | - } |
|
32 | - } |
|
33 | - } |
|
34 | - return $maxDepth; |
|
25 | + $maxDepth = 1; |
|
26 | + foreach ($_array as $value) { |
|
27 | + if (is_array($value)) { |
|
28 | + $depth = arrayDepth($value) + 1; |
|
29 | + if ($depth > $maxDepth) { |
|
30 | + $maxDepth = $depth; |
|
31 | + } |
|
32 | + } |
|
33 | + } |
|
34 | + return $maxDepth; |
|
35 | 35 | } |
36 | 36 | function arrayDump( $_array, $_name = "Array", $_tab = " " ) { |
37 | - $position = preg_replace('/ /', '', $_tab, 1); |
|
38 | - echo "$position<span style=\"color:rgb(230,0,0)\">$_name:</span><br>"; |
|
39 | - foreach ($_array as $k => $i) |
|
40 | - if(is_array($i)) |
|
41 | - arrayDump( $i, $k, " $_tab" ); |
|
42 | - else |
|
43 | - echo "$_tab<b>$k:</b> $i<br>"; |
|
44 | - } |
|
37 | + $position = preg_replace('/ /', '', $_tab, 1); |
|
38 | + echo "$position<span style=\"color:rgb(230,0,0)\">$_name:</span><br>"; |
|
39 | + foreach ($_array as $k => $i) |
|
40 | + if(is_array($i)) |
|
41 | + arrayDump( $i, $k, " $_tab" ); |
|
42 | + else |
|
43 | + echo "$_tab<b>$k:</b> $i<br>"; |
|
44 | + } |
|
45 | 45 | ?> |