@@ -2,6 +2,10 @@ discard block |
||
2 | 2 | requireComponents("Adapters"); |
3 | 3 | jRequire("../JException/JException.php"); |
4 | 4 | class Parser { |
5 | + |
|
6 | + /** |
|
7 | + * @param string $_type |
|
8 | + */ |
|
5 | 9 | private static function setParser ( $_type ) { |
6 | 10 | $parser = null; |
7 | 11 | $_type = strtolower($_type); |
@@ -27,6 +31,10 @@ discard block |
||
27 | 31 | } |
28 | 32 | return $parser; |
29 | 33 | } |
34 | + |
|
35 | + /** |
|
36 | + * @param string $_text |
|
37 | + */ |
|
30 | 38 | public static function parseText( $_text, $_parameters = [], $_type = "html" ) { |
31 | 39 | if(!is_string($_text) || !is_string($_type)) |
32 | 40 | throw new JException("Parameter must be a string."); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | requireComponents("Adapters"); |
3 | 3 | jRequire("../JException/JException.php"); |
4 | 4 | class Parser { |
5 | - private static function setParser ( $_type ) { |
|
5 | + private static function setParser($_type) { |
|
6 | 6 | $parser = null; |
7 | 7 | $_type = strtolower($_type); |
8 | 8 | switch ($_type) { |
@@ -27,20 +27,20 @@ discard block |
||
27 | 27 | } |
28 | 28 | return $parser; |
29 | 29 | } |
30 | - public static function parseText( $_text, $_parameters = [], $_type = "html" ) { |
|
31 | - if(!is_string($_text) || !is_string($_type)) |
|
30 | + public static function parseText($_text, $_parameters = [], $_type = "html") { |
|
31 | + if (!is_string($_text) || !is_string($_type)) |
|
32 | 32 | throw new JException("Parameter must be a string."); |
33 | - if(!is_array($_parameters)) |
|
33 | + if (!is_array($_parameters)) |
|
34 | 34 | throw new JException("Parameter must be an array."); |
35 | 35 | $parser = self::setParser($_type); |
36 | - if($parser === -1) |
|
36 | + if ($parser === -1) |
|
37 | 37 | return $_text; |
38 | 38 | return $parser->drawText($_text, $_parameters); |
39 | 39 | } |
40 | - public static function parseFileMan( $_path, $_parameters = [], $_type = "html" ) { |
|
41 | - if(!is_string($_path)) |
|
40 | + public static function parseFileMan($_path, $_parameters = [], $_type = "html") { |
|
41 | + if (!is_string($_path)) |
|
42 | 42 | throw new JException("Parameter must be a string."); |
43 | - if(!file_exists($_path)) |
|
43 | + if (!file_exists($_path)) |
|
44 | 44 | throw new JException("File [$_path] not found."); |
45 | 45 | $string = file_get_contents($_path); |
46 | 46 | try { |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | } |
51 | 51 | return $text; |
52 | 52 | } |
53 | - public static function parseFile( $_path, $_parameters = [] ) { |
|
54 | - if(!is_string($_path)) |
|
53 | + public static function parseFile($_path, $_parameters = []) { |
|
54 | + if (!is_string($_path)) |
|
55 | 55 | throw new JException("Parameter must be a string."); |
56 | 56 | $extension = explode(".", $_path); |
57 | - $extension = $extension[count($extension)-1]; |
|
57 | + $extension = $extension[count($extension) - 1]; |
|
58 | 58 | $extension = strtolower($extension); |
59 | 59 | try { |
60 | 60 | $text = self::parseFileMan($_path, $_parameters, $extension); |
@@ -28,20 +28,25 @@ discard block |
||
28 | 28 | return $parser; |
29 | 29 | } |
30 | 30 | public static function parseText( $_text, $_parameters = [], $_type = "html" ) { |
31 | - if(!is_string($_text) || !is_string($_type)) |
|
32 | - throw new JException("Parameter must be a string."); |
|
33 | - if(!is_array($_parameters)) |
|
34 | - throw new JException("Parameter must be an array."); |
|
31 | + if(!is_string($_text) || !is_string($_type)) { |
|
32 | + throw new JException("Parameter must be a string."); |
|
33 | + } |
|
34 | + if(!is_array($_parameters)) { |
|
35 | + throw new JException("Parameter must be an array."); |
|
36 | + } |
|
35 | 37 | $parser = self::setParser($_type); |
36 | - if($parser === -1) |
|
37 | - return $_text; |
|
38 | + if($parser === -1) { |
|
39 | + return $_text; |
|
40 | + } |
|
38 | 41 | return $parser->drawText($_text, $_parameters); |
39 | 42 | } |
40 | 43 | public static function parseFileMan( $_path, $_parameters = [], $_type = "html" ) { |
41 | - if(!is_string($_path)) |
|
42 | - throw new JException("Parameter must be a string."); |
|
43 | - if(!file_exists($_path)) |
|
44 | - throw new JException("File [$_path] not found."); |
|
44 | + if(!is_string($_path)) { |
|
45 | + throw new JException("Parameter must be a string."); |
|
46 | + } |
|
47 | + if(!file_exists($_path)) { |
|
48 | + throw new JException("File [$_path] not found."); |
|
49 | + } |
|
45 | 50 | $string = file_get_contents($_path); |
46 | 51 | try { |
47 | 52 | $text = self::parseText($string, $_parameters, $_type); |
@@ -51,8 +56,9 @@ discard block |
||
51 | 56 | return $text; |
52 | 57 | } |
53 | 58 | public static function parseFile( $_path, $_parameters = [] ) { |
54 | - if(!is_string($_path)) |
|
55 | - throw new JException("Parameter must be a string."); |
|
59 | + if(!is_string($_path)) { |
|
60 | + throw new JException("Parameter must be a string."); |
|
61 | + } |
|
56 | 62 | $extension = explode(".", $_path); |
57 | 63 | $extension = $extension[count($extension)-1]; |
58 | 64 | $extension = strtolower($extension); |
@@ -2,67 +2,67 @@ |
||
2 | 2 | requireComponents("Adapters"); |
3 | 3 | jRequire("../JException/JException.php"); |
4 | 4 | class Parser { |
5 | - private static function setParser ( $_type ) { |
|
6 | - $parser = null; |
|
7 | - $_type = strtolower($_type); |
|
8 | - switch ($_type) { |
|
9 | - case "twig": |
|
10 | - case "sql": |
|
11 | - $parser = new TwigAdapter(); |
|
12 | - break; |
|
13 | - case "jate": |
|
14 | - $parser = new JTagAdapter(); |
|
15 | - break; |
|
16 | - case 'jade': |
|
17 | - case "pug": |
|
18 | - $parser = new PugAdapter(); |
|
19 | - break; |
|
20 | - case "md": |
|
21 | - case "markdown": |
|
22 | - case "parsedown": |
|
23 | - $parser = new ParsedownAdapter(); |
|
24 | - break; |
|
25 | - default: |
|
26 | - $parser = -1; |
|
27 | - break; |
|
28 | - } |
|
29 | - return $parser; |
|
30 | - } |
|
31 | - public static function parseText( $_text, $_parameters = [], $_type = "html" ) { |
|
32 | - if(!is_string($_text) || !is_string($_type)) |
|
33 | - throw new JException("Parameter must be a string."); |
|
34 | - if(!is_array($_parameters)) |
|
35 | - throw new JException("Parameter must be an array."); |
|
36 | - $parser = self::setParser($_type); |
|
37 | - if($parser === -1) |
|
38 | - return $_text; |
|
39 | - return $parser->drawText($_text, $_parameters); |
|
40 | - } |
|
41 | - public static function parseFileMan( $_path, $_parameters = [], $_type = "html" ) { |
|
42 | - if(!is_string($_path)) |
|
43 | - throw new JException("Parameter must be a string."); |
|
44 | - if(!file_exists($_path)) |
|
45 | - throw new JException("File [$_path] not found."); |
|
46 | - $string = file_get_contents($_path); |
|
47 | - try { |
|
48 | - $text = self::parseText($string, $_parameters, $_type); |
|
49 | - } catch (Exception $e) { |
|
50 | - throw new JException($e->getMessage()); |
|
51 | - } |
|
52 | - return $text; |
|
53 | - } |
|
54 | - public static function parseFile( $_path, $_parameters = [] ) { |
|
55 | - if(!is_string($_path)) |
|
56 | - throw new JException("Parameter must be a string."); |
|
57 | - $extension = explode(".", $_path); |
|
58 | - $extension = $extension[count($extension)-1]; |
|
59 | - $extension = strtolower($extension); |
|
60 | - try { |
|
61 | - $text = self::parseFileMan($_path, $_parameters, $extension); |
|
62 | - } catch (Exception $e) { |
|
63 | - throw new JException($e->getMessage()); |
|
64 | - } |
|
65 | - return $text; |
|
66 | - } |
|
5 | + private static function setParser ( $_type ) { |
|
6 | + $parser = null; |
|
7 | + $_type = strtolower($_type); |
|
8 | + switch ($_type) { |
|
9 | + case "twig": |
|
10 | + case "sql": |
|
11 | + $parser = new TwigAdapter(); |
|
12 | + break; |
|
13 | + case "jate": |
|
14 | + $parser = new JTagAdapter(); |
|
15 | + break; |
|
16 | + case 'jade': |
|
17 | + case "pug": |
|
18 | + $parser = new PugAdapter(); |
|
19 | + break; |
|
20 | + case "md": |
|
21 | + case "markdown": |
|
22 | + case "parsedown": |
|
23 | + $parser = new ParsedownAdapter(); |
|
24 | + break; |
|
25 | + default: |
|
26 | + $parser = -1; |
|
27 | + break; |
|
28 | + } |
|
29 | + return $parser; |
|
30 | + } |
|
31 | + public static function parseText( $_text, $_parameters = [], $_type = "html" ) { |
|
32 | + if(!is_string($_text) || !is_string($_type)) |
|
33 | + throw new JException("Parameter must be a string."); |
|
34 | + if(!is_array($_parameters)) |
|
35 | + throw new JException("Parameter must be an array."); |
|
36 | + $parser = self::setParser($_type); |
|
37 | + if($parser === -1) |
|
38 | + return $_text; |
|
39 | + return $parser->drawText($_text, $_parameters); |
|
40 | + } |
|
41 | + public static function parseFileMan( $_path, $_parameters = [], $_type = "html" ) { |
|
42 | + if(!is_string($_path)) |
|
43 | + throw new JException("Parameter must be a string."); |
|
44 | + if(!file_exists($_path)) |
|
45 | + throw new JException("File [$_path] not found."); |
|
46 | + $string = file_get_contents($_path); |
|
47 | + try { |
|
48 | + $text = self::parseText($string, $_parameters, $_type); |
|
49 | + } catch (Exception $e) { |
|
50 | + throw new JException($e->getMessage()); |
|
51 | + } |
|
52 | + return $text; |
|
53 | + } |
|
54 | + public static function parseFile( $_path, $_parameters = [] ) { |
|
55 | + if(!is_string($_path)) |
|
56 | + throw new JException("Parameter must be a string."); |
|
57 | + $extension = explode(".", $_path); |
|
58 | + $extension = $extension[count($extension)-1]; |
|
59 | + $extension = strtolower($extension); |
|
60 | + try { |
|
61 | + $text = self::parseFileMan($_path, $_parameters, $extension); |
|
62 | + } catch (Exception $e) { |
|
63 | + throw new JException($e->getMessage()); |
|
64 | + } |
|
65 | + return $text; |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | ?> |
@@ -22,6 +22,10 @@ |
||
22 | 22 | throw new JException($e->getMessage(), 1); |
23 | 23 | } |
24 | 24 | } |
25 | + |
|
26 | + /** |
|
27 | + * @param Connection $_connection |
|
28 | + */ |
|
25 | 29 | public function addConnectionMan( $_connection, $_name = "default") { |
26 | 30 | if(!is_object($_connection) || !is_a($_connection, "Connection")) |
27 | 31 | throw new JException("Parameter must be a Connection object.", 1); |
@@ -3,104 +3,104 @@ |
||
3 | 3 | jRequire("../JConfig/JConfig.php"); |
4 | 4 | jRequire("../Connection/Connection.php"); |
5 | 5 | trait Query { |
6 | - public $connection; |
|
7 | - public $currentConnection; |
|
8 | - public function __construct() { |
|
9 | - $this->connection = []; |
|
10 | - $this->currentConnection = null; |
|
11 | - } |
|
12 | - public function addConnection( $_path, $_name = "default" ) { |
|
13 | - if(!is_string($_path)) |
|
14 | - throw new JException("Parameter must be a string.", 1); |
|
15 | - try { |
|
16 | - $jConfig = new JConfig($_path); |
|
17 | - if($jConfig->enable) { |
|
18 | - $connection = new Connection($jConfig); |
|
19 | - $this->addConnectionMan($connection, $_name); |
|
20 | - } |
|
21 | - } catch (Exception $e) { |
|
22 | - throw new JException($e->getMessage(), 1); |
|
23 | - } |
|
24 | - } |
|
25 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
27 | - throw new JException("Parameter must be a Connection object.", 1); |
|
28 | - try { |
|
29 | - $this->connection["$_name"] = $_connection; |
|
30 | - $this->currentConnection = $_connection; |
|
31 | - foreach ($this->modules as &$module) |
|
32 | - if(isset($this->currentConnection)) |
|
33 | - $module->addConnectionMan($this->currentConnection, $_name); |
|
34 | - } catch (Exception $e) { |
|
35 | - throw new JException($e->getMessage(), 1); |
|
36 | - } |
|
37 | - } |
|
38 | - public function setConnection( $_name = "default" ) { |
|
39 | - if(!is_string($_name)) |
|
40 | - throw new JException("Parameter must be a string.", 1); |
|
41 | - if(!isset($this->connection["$_name"])) |
|
42 | - throw new JException("This connection name does not exist.", 1); |
|
43 | - $this->currentConnection = $this->connection["$_name"]; |
|
44 | - } |
|
45 | - public function query( $_query ) { |
|
46 | - if(!is_string($_query)) |
|
47 | - throw new JException("Parameter must be a string.", 1); |
|
48 | - if($this->currentConnection == null) |
|
49 | - throw new JException("No connection selected.", 1); |
|
50 | - try { |
|
51 | - $temp = $this->currentConnection->database->query($_query); |
|
52 | - } catch (Exception $e) { |
|
53 | - throw new JException($e->getMessage(), 1); |
|
54 | - } |
|
55 | - return $temp; |
|
56 | - } |
|
57 | - public function queryInsert( $_query ) { |
|
58 | - if(!is_string($_query)) |
|
59 | - throw new JException("Parameter must be a string.", 1); |
|
60 | - if($this->currentConnection == null) |
|
61 | - throw new JException("No connection selected.", 1); |
|
62 | - try { |
|
63 | - $temp = $this->currentConnection->database->queryInsert($_query); |
|
64 | - } catch (Exception $e) { |
|
65 | - throw new JException($e->getMessage(), 1); |
|
66 | - } |
|
67 | - return $temp; |
|
68 | - } |
|
69 | - public function queryFetch( $_query ) { |
|
70 | - if(!is_string($_query)) |
|
71 | - throw new JException("Parameter must be a string.", 1); |
|
72 | - if($this->currentConnection == null) |
|
73 | - throw new JException("No connection selected.", 1); |
|
74 | - try { |
|
75 | - $temp = $this->currentConnection->database->queryFetch($_query); |
|
76 | - } catch (Exception $e) { |
|
77 | - throw new JException($e->getMessage(), 1); |
|
78 | - } |
|
79 | - return $temp; |
|
80 | - } |
|
81 | - public function queryArray( $_query ) { |
|
82 | - if(!is_string($_query)) |
|
83 | - throw new JException("Parameter must be a string.", 1); |
|
84 | - if($this->currentConnection == null) |
|
85 | - throw new JException("No connection selected.", 1); |
|
86 | - try { |
|
87 | - $temp = $this->currentConnection->database->queryArray($_query); |
|
88 | - } catch (Exception $e) { |
|
89 | - throw new JException($e->getMessage(), 1); |
|
90 | - } |
|
91 | - return $temp; |
|
92 | - } |
|
93 | - public function newTable( $_query ) { |
|
94 | - if(!is_string($_query)) |
|
95 | - throw new JException("Parameter must be a string.", 1); |
|
96 | - if($this->currentConnection == null) |
|
97 | - throw new JException("No connection selected.", 1); |
|
98 | - try { |
|
99 | - $temp = $this->currentConnection->database->newTable($_query); |
|
100 | - } catch (Exception $e) { |
|
101 | - throw new JException($e->getMessage(), 1); |
|
102 | - } |
|
103 | - return $temp; |
|
104 | - } |
|
6 | + public $connection; |
|
7 | + public $currentConnection; |
|
8 | + public function __construct() { |
|
9 | + $this->connection = []; |
|
10 | + $this->currentConnection = null; |
|
11 | + } |
|
12 | + public function addConnection( $_path, $_name = "default" ) { |
|
13 | + if(!is_string($_path)) |
|
14 | + throw new JException("Parameter must be a string.", 1); |
|
15 | + try { |
|
16 | + $jConfig = new JConfig($_path); |
|
17 | + if($jConfig->enable) { |
|
18 | + $connection = new Connection($jConfig); |
|
19 | + $this->addConnectionMan($connection, $_name); |
|
20 | + } |
|
21 | + } catch (Exception $e) { |
|
22 | + throw new JException($e->getMessage(), 1); |
|
23 | + } |
|
24 | + } |
|
25 | + public function addConnectionMan( $_connection, $_name = "default") { |
|
26 | + if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
27 | + throw new JException("Parameter must be a Connection object.", 1); |
|
28 | + try { |
|
29 | + $this->connection["$_name"] = $_connection; |
|
30 | + $this->currentConnection = $_connection; |
|
31 | + foreach ($this->modules as &$module) |
|
32 | + if(isset($this->currentConnection)) |
|
33 | + $module->addConnectionMan($this->currentConnection, $_name); |
|
34 | + } catch (Exception $e) { |
|
35 | + throw new JException($e->getMessage(), 1); |
|
36 | + } |
|
37 | + } |
|
38 | + public function setConnection( $_name = "default" ) { |
|
39 | + if(!is_string($_name)) |
|
40 | + throw new JException("Parameter must be a string.", 1); |
|
41 | + if(!isset($this->connection["$_name"])) |
|
42 | + throw new JException("This connection name does not exist.", 1); |
|
43 | + $this->currentConnection = $this->connection["$_name"]; |
|
44 | + } |
|
45 | + public function query( $_query ) { |
|
46 | + if(!is_string($_query)) |
|
47 | + throw new JException("Parameter must be a string.", 1); |
|
48 | + if($this->currentConnection == null) |
|
49 | + throw new JException("No connection selected.", 1); |
|
50 | + try { |
|
51 | + $temp = $this->currentConnection->database->query($_query); |
|
52 | + } catch (Exception $e) { |
|
53 | + throw new JException($e->getMessage(), 1); |
|
54 | + } |
|
55 | + return $temp; |
|
56 | + } |
|
57 | + public function queryInsert( $_query ) { |
|
58 | + if(!is_string($_query)) |
|
59 | + throw new JException("Parameter must be a string.", 1); |
|
60 | + if($this->currentConnection == null) |
|
61 | + throw new JException("No connection selected.", 1); |
|
62 | + try { |
|
63 | + $temp = $this->currentConnection->database->queryInsert($_query); |
|
64 | + } catch (Exception $e) { |
|
65 | + throw new JException($e->getMessage(), 1); |
|
66 | + } |
|
67 | + return $temp; |
|
68 | + } |
|
69 | + public function queryFetch( $_query ) { |
|
70 | + if(!is_string($_query)) |
|
71 | + throw new JException("Parameter must be a string.", 1); |
|
72 | + if($this->currentConnection == null) |
|
73 | + throw new JException("No connection selected.", 1); |
|
74 | + try { |
|
75 | + $temp = $this->currentConnection->database->queryFetch($_query); |
|
76 | + } catch (Exception $e) { |
|
77 | + throw new JException($e->getMessage(), 1); |
|
78 | + } |
|
79 | + return $temp; |
|
80 | + } |
|
81 | + public function queryArray( $_query ) { |
|
82 | + if(!is_string($_query)) |
|
83 | + throw new JException("Parameter must be a string.", 1); |
|
84 | + if($this->currentConnection == null) |
|
85 | + throw new JException("No connection selected.", 1); |
|
86 | + try { |
|
87 | + $temp = $this->currentConnection->database->queryArray($_query); |
|
88 | + } catch (Exception $e) { |
|
89 | + throw new JException($e->getMessage(), 1); |
|
90 | + } |
|
91 | + return $temp; |
|
92 | + } |
|
93 | + public function newTable( $_query ) { |
|
94 | + if(!is_string($_query)) |
|
95 | + throw new JException("Parameter must be a string.", 1); |
|
96 | + if($this->currentConnection == null) |
|
97 | + throw new JException("No connection selected.", 1); |
|
98 | + try { |
|
99 | + $temp = $this->currentConnection->database->newTable($_query); |
|
100 | + } catch (Exception $e) { |
|
101 | + throw new JException($e->getMessage(), 1); |
|
102 | + } |
|
103 | + return $temp; |
|
104 | + } |
|
105 | 105 | } |
106 | 106 | ?> |
@@ -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,30 +22,30 @@ 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 | - if($this->currentConnection == null) |
|
48 | + if ($this->currentConnection == null) |
|
49 | 49 | throw new JException("No connection selected.", 1); |
50 | 50 | try { |
51 | 51 | $temp = $this->currentConnection->database->query($_query); |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | } |
55 | 55 | return $temp; |
56 | 56 | } |
57 | - public function queryInsert( $_query ) { |
|
58 | - if(!is_string($_query)) |
|
57 | + public function queryInsert($_query) { |
|
58 | + if (!is_string($_query)) |
|
59 | 59 | throw new JException("Parameter must be a string.", 1); |
60 | - if($this->currentConnection == null) |
|
60 | + if ($this->currentConnection == null) |
|
61 | 61 | throw new JException("No connection selected.", 1); |
62 | 62 | try { |
63 | 63 | $temp = $this->currentConnection->database->queryInsert($_query); |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | } |
67 | 67 | return $temp; |
68 | 68 | } |
69 | - public function queryFetch( $_query ) { |
|
70 | - if(!is_string($_query)) |
|
69 | + public function queryFetch($_query) { |
|
70 | + if (!is_string($_query)) |
|
71 | 71 | throw new JException("Parameter must be a string.", 1); |
72 | - if($this->currentConnection == null) |
|
72 | + if ($this->currentConnection == null) |
|
73 | 73 | throw new JException("No connection selected.", 1); |
74 | 74 | try { |
75 | 75 | $temp = $this->currentConnection->database->queryFetch($_query); |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | } |
79 | 79 | return $temp; |
80 | 80 | } |
81 | - public function queryArray( $_query ) { |
|
82 | - if(!is_string($_query)) |
|
81 | + public function queryArray($_query) { |
|
82 | + if (!is_string($_query)) |
|
83 | 83 | throw new JException("Parameter must be a string.", 1); |
84 | - if($this->currentConnection == null) |
|
84 | + if ($this->currentConnection == null) |
|
85 | 85 | throw new JException("No connection selected.", 1); |
86 | 86 | try { |
87 | 87 | $temp = $this->currentConnection->database->queryArray($_query); |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | } |
91 | 91 | return $temp; |
92 | 92 | } |
93 | - public function newTable( $_query ) { |
|
94 | - if(!is_string($_query)) |
|
93 | + public function newTable($_query) { |
|
94 | + if (!is_string($_query)) |
|
95 | 95 | throw new JException("Parameter must be a string.", 1); |
96 | - if($this->currentConnection == null) |
|
96 | + if ($this->currentConnection == null) |
|
97 | 97 | throw new JException("No connection selected.", 1); |
98 | 98 | try { |
99 | 99 | $temp = $this->currentConnection->database->newTable($_query); |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | $this->currentConnection = null; |
11 | 11 | } |
12 | 12 | public function addConnection( $_path, $_name = "default" ) { |
13 | - if(!is_string($_path)) |
|
14 | - throw new JException("Parameter must be a string.", 1); |
|
13 | + if(!is_string($_path)) { |
|
14 | + throw new JException("Parameter must be a string.", 1); |
|
15 | + } |
|
15 | 16 | try { |
16 | 17 | $jConfig = new JConfig($_path); |
17 | 18 | if($jConfig->enable) { |
@@ -23,30 +24,36 @@ discard block |
||
23 | 24 | } |
24 | 25 | } |
25 | 26 | public function addConnectionMan( $_connection, $_name = "default") { |
26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
27 | - throw new JException("Parameter must be a Connection object.", 1); |
|
27 | + if(!is_object($_connection) || !is_a($_connection, "Connection")) { |
|
28 | + throw new JException("Parameter must be a Connection object.", 1); |
|
29 | + } |
|
28 | 30 | try { |
29 | 31 | $this->connection["$_name"] = $_connection; |
30 | 32 | $this->currentConnection = $_connection; |
31 | - foreach ($this->modules as &$module) |
|
32 | - if(isset($this->currentConnection)) |
|
33 | + foreach ($this->modules as &$module) { |
|
34 | + if(isset($this->currentConnection)) |
|
33 | 35 | $module->addConnectionMan($this->currentConnection, $_name); |
36 | + } |
|
34 | 37 | } catch (Exception $e) { |
35 | 38 | throw new JException($e->getMessage(), 1); |
36 | 39 | } |
37 | 40 | } |
38 | 41 | public function setConnection( $_name = "default" ) { |
39 | - if(!is_string($_name)) |
|
40 | - throw new JException("Parameter must be a string.", 1); |
|
41 | - if(!isset($this->connection["$_name"])) |
|
42 | - throw new JException("This connection name does not exist.", 1); |
|
42 | + if(!is_string($_name)) { |
|
43 | + throw new JException("Parameter must be a string.", 1); |
|
44 | + } |
|
45 | + if(!isset($this->connection["$_name"])) { |
|
46 | + throw new JException("This connection name does not exist.", 1); |
|
47 | + } |
|
43 | 48 | $this->currentConnection = $this->connection["$_name"]; |
44 | 49 | } |
45 | 50 | public function query( $_query ) { |
46 | - if(!is_string($_query)) |
|
47 | - throw new JException("Parameter must be a string.", 1); |
|
48 | - if($this->currentConnection == null) |
|
49 | - throw new JException("No connection selected.", 1); |
|
51 | + if(!is_string($_query)) { |
|
52 | + throw new JException("Parameter must be a string.", 1); |
|
53 | + } |
|
54 | + if($this->currentConnection == null) { |
|
55 | + throw new JException("No connection selected.", 1); |
|
56 | + } |
|
50 | 57 | try { |
51 | 58 | $temp = $this->currentConnection->database->query($_query); |
52 | 59 | } catch (Exception $e) { |
@@ -55,10 +62,12 @@ discard block |
||
55 | 62 | return $temp; |
56 | 63 | } |
57 | 64 | public function queryInsert( $_query ) { |
58 | - if(!is_string($_query)) |
|
59 | - throw new JException("Parameter must be a string.", 1); |
|
60 | - if($this->currentConnection == null) |
|
61 | - throw new JException("No connection selected.", 1); |
|
65 | + if(!is_string($_query)) { |
|
66 | + throw new JException("Parameter must be a string.", 1); |
|
67 | + } |
|
68 | + if($this->currentConnection == null) { |
|
69 | + throw new JException("No connection selected.", 1); |
|
70 | + } |
|
62 | 71 | try { |
63 | 72 | $temp = $this->currentConnection->database->queryInsert($_query); |
64 | 73 | } catch (Exception $e) { |
@@ -67,10 +76,12 @@ discard block |
||
67 | 76 | return $temp; |
68 | 77 | } |
69 | 78 | public function queryFetch( $_query ) { |
70 | - if(!is_string($_query)) |
|
71 | - throw new JException("Parameter must be a string.", 1); |
|
72 | - if($this->currentConnection == null) |
|
73 | - throw new JException("No connection selected.", 1); |
|
79 | + if(!is_string($_query)) { |
|
80 | + throw new JException("Parameter must be a string.", 1); |
|
81 | + } |
|
82 | + if($this->currentConnection == null) { |
|
83 | + throw new JException("No connection selected.", 1); |
|
84 | + } |
|
74 | 85 | try { |
75 | 86 | $temp = $this->currentConnection->database->queryFetch($_query); |
76 | 87 | } catch (Exception $e) { |
@@ -79,10 +90,12 @@ discard block |
||
79 | 90 | return $temp; |
80 | 91 | } |
81 | 92 | public function queryArray( $_query ) { |
82 | - if(!is_string($_query)) |
|
83 | - throw new JException("Parameter must be a string.", 1); |
|
84 | - if($this->currentConnection == null) |
|
85 | - throw new JException("No connection selected.", 1); |
|
93 | + if(!is_string($_query)) { |
|
94 | + throw new JException("Parameter must be a string.", 1); |
|
95 | + } |
|
96 | + if($this->currentConnection == null) { |
|
97 | + throw new JException("No connection selected.", 1); |
|
98 | + } |
|
86 | 99 | try { |
87 | 100 | $temp = $this->currentConnection->database->queryArray($_query); |
88 | 101 | } catch (Exception $e) { |
@@ -91,10 +104,12 @@ discard block |
||
91 | 104 | return $temp; |
92 | 105 | } |
93 | 106 | public function newTable( $_query ) { |
94 | - if(!is_string($_query)) |
|
95 | - throw new JException("Parameter must be a string.", 1); |
|
96 | - if($this->currentConnection == null) |
|
97 | - throw new JException("No connection selected.", 1); |
|
107 | + if(!is_string($_query)) { |
|
108 | + throw new JException("Parameter must be a string.", 1); |
|
109 | + } |
|
110 | + if($this->currentConnection == null) { |
|
111 | + throw new JException("No connection selected.", 1); |
|
112 | + } |
|
98 | 113 | try { |
99 | 114 | $temp = $this->currentConnection->database->newTable($_query); |
100 | 115 | } catch (Exception $e) { |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | //JATE SUFF |
6 | 6 | require_once (end($GLOBALS["JATEPath"])."jate/functions/requirer.php"); |
7 | - requireComponent ("modules/JException/JException.php"); |
|
8 | - requireComponent ("functions/folder.php"); |
|
9 | - requireComponent ("modules/JConfig/JConfig.php"); |
|
7 | + requireComponent("modules/JException/JException.php"); |
|
8 | + requireComponent("functions/folder.php"); |
|
9 | + requireComponent("modules/JConfig/JConfig.php"); |
|
10 | 10 | requireComponents("functions"); |
11 | - requireModules ("modules"); |
|
11 | + requireModules("modules"); |
|
12 | 12 | |
13 | 13 | //USER STUFF |
14 | 14 | requireModulesList("config/loader.json"); |
@@ -1,45 +1,45 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("ConnectionInterface.php"); |
3 | 3 | class MysqliAdapter implements ConnectionAdapterInterface { |
4 | - public $connection; |
|
5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
6 | - try { |
|
7 | - $this->connection = new mysqli( $_srv, $_usr, $_pass, $_db ); |
|
8 | - } catch( Exception $e ) { |
|
9 | - throw new JException($e->getMessage()); |
|
10 | - } |
|
11 | - } |
|
12 | - public function query( $_query ) { |
|
13 | - $this->stdQuery($_query); |
|
14 | - return true; |
|
15 | - } |
|
16 | - public function queryInsert( $_query ) { |
|
17 | - $this->stdQuery($_query); |
|
18 | - return $this->connection->insert_id; |
|
19 | - } |
|
20 | - public function queryFetch( $_query ) { |
|
21 | - $result = $this->stdQuery($_query); |
|
22 | - $rows = []; |
|
23 | - while($row = $result->fetch_assoc()) |
|
24 | - $rows[] = $row; |
|
25 | - return $rows; |
|
26 | - } |
|
27 | - public function queryArray( $_query ) { |
|
28 | - $result = $this->stdQuery($_query); |
|
29 | - $rows = []; |
|
30 | - while($row = $result->fetch_array()) |
|
31 | - $rows[] = $row; |
|
32 | - return $rows; |
|
33 | - } |
|
34 | - protected function stdQuery( $_query ) { |
|
35 | - $database = $this->connection; |
|
36 | - $result = $database->query($_query); |
|
37 | - if(!$result) |
|
38 | - throw new JException(json_encode([ |
|
39 | - "query" => $_query, |
|
40 | - "error" => $database->error |
|
41 | - ])); |
|
42 | - return $result; |
|
43 | - } |
|
4 | + public $connection; |
|
5 | + public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
6 | + try { |
|
7 | + $this->connection = new mysqli( $_srv, $_usr, $_pass, $_db ); |
|
8 | + } catch( Exception $e ) { |
|
9 | + throw new JException($e->getMessage()); |
|
10 | + } |
|
11 | + } |
|
12 | + public function query( $_query ) { |
|
13 | + $this->stdQuery($_query); |
|
14 | + return true; |
|
15 | + } |
|
16 | + public function queryInsert( $_query ) { |
|
17 | + $this->stdQuery($_query); |
|
18 | + return $this->connection->insert_id; |
|
19 | + } |
|
20 | + public function queryFetch( $_query ) { |
|
21 | + $result = $this->stdQuery($_query); |
|
22 | + $rows = []; |
|
23 | + while($row = $result->fetch_assoc()) |
|
24 | + $rows[] = $row; |
|
25 | + return $rows; |
|
26 | + } |
|
27 | + public function queryArray( $_query ) { |
|
28 | + $result = $this->stdQuery($_query); |
|
29 | + $rows = []; |
|
30 | + while($row = $result->fetch_array()) |
|
31 | + $rows[] = $row; |
|
32 | + return $rows; |
|
33 | + } |
|
34 | + protected function stdQuery( $_query ) { |
|
35 | + $database = $this->connection; |
|
36 | + $result = $database->query($_query); |
|
37 | + if(!$result) |
|
38 | + throw new JException(json_encode([ |
|
39 | + "query" => $_query, |
|
40 | + "error" => $database->error |
|
41 | + ])); |
|
42 | + return $result; |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | ?> |
@@ -2,39 +2,39 @@ |
||
2 | 2 | jRequire("ConnectionInterface.php"); |
3 | 3 | class MysqliAdapter implements ConnectionAdapterInterface { |
4 | 4 | public $connection; |
5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
5 | + public function __construct($_srv, $_db, $_usr, $_pass) { |
|
6 | 6 | try { |
7 | - $this->connection = new mysqli( $_srv, $_usr, $_pass, $_db ); |
|
8 | - } catch( Exception $e ) { |
|
7 | + $this->connection = new mysqli($_srv, $_usr, $_pass, $_db); |
|
8 | + } catch (Exception $e) { |
|
9 | 9 | throw new JException($e->getMessage()); |
10 | 10 | } |
11 | 11 | } |
12 | - public function query( $_query ) { |
|
12 | + public function query($_query) { |
|
13 | 13 | $this->stdQuery($_query); |
14 | 14 | return true; |
15 | 15 | } |
16 | - public function queryInsert( $_query ) { |
|
16 | + public function queryInsert($_query) { |
|
17 | 17 | $this->stdQuery($_query); |
18 | 18 | return $this->connection->insert_id; |
19 | 19 | } |
20 | - public function queryFetch( $_query ) { |
|
20 | + public function queryFetch($_query) { |
|
21 | 21 | $result = $this->stdQuery($_query); |
22 | 22 | $rows = []; |
23 | - while($row = $result->fetch_assoc()) |
|
23 | + while ($row = $result->fetch_assoc()) |
|
24 | 24 | $rows[] = $row; |
25 | 25 | return $rows; |
26 | 26 | } |
27 | - public function queryArray( $_query ) { |
|
27 | + public function queryArray($_query) { |
|
28 | 28 | $result = $this->stdQuery($_query); |
29 | 29 | $rows = []; |
30 | - while($row = $result->fetch_array()) |
|
30 | + while ($row = $result->fetch_array()) |
|
31 | 31 | $rows[] = $row; |
32 | 32 | return $rows; |
33 | 33 | } |
34 | - protected function stdQuery( $_query ) { |
|
34 | + protected function stdQuery($_query) { |
|
35 | 35 | $database = $this->connection; |
36 | 36 | $result = $database->query($_query); |
37 | - if(!$result) |
|
37 | + if (!$result) |
|
38 | 38 | throw new JException(json_encode([ |
39 | 39 | "query" => $_query, |
40 | 40 | "error" => $database->error |
@@ -20,25 +20,28 @@ |
||
20 | 20 | public function queryFetch( $_query ) { |
21 | 21 | $result = $this->stdQuery($_query); |
22 | 22 | $rows = []; |
23 | - while($row = $result->fetch_assoc()) |
|
24 | - $rows[] = $row; |
|
23 | + while($row = $result->fetch_assoc()) { |
|
24 | + $rows[] = $row; |
|
25 | + } |
|
25 | 26 | return $rows; |
26 | 27 | } |
27 | 28 | public function queryArray( $_query ) { |
28 | 29 | $result = $this->stdQuery($_query); |
29 | 30 | $rows = []; |
30 | - while($row = $result->fetch_array()) |
|
31 | - $rows[] = $row; |
|
31 | + while($row = $result->fetch_array()) { |
|
32 | + $rows[] = $row; |
|
33 | + } |
|
32 | 34 | return $rows; |
33 | 35 | } |
34 | 36 | protected function stdQuery( $_query ) { |
35 | 37 | $database = $this->connection; |
36 | 38 | $result = $database->query($_query); |
37 | - if(!$result) |
|
38 | - throw new JException(json_encode([ |
|
39 | + if(!$result) { |
|
40 | + throw new JException(json_encode([ |
|
39 | 41 | "query" => $_query, |
40 | 42 | "error" => $database->error |
41 | 43 | ])); |
44 | + } |
|
42 | 45 | return $result; |
43 | 46 | } |
44 | 47 | } |
@@ -1,48 +1,48 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("ConnectionInterface.php"); |
3 | 3 | class PostgresqlAdapter implements ConnectionAdapterInterface { |
4 | - public $connection; |
|
5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
6 | - try { |
|
7 | - $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass") |
|
8 | - or die('Could not connect: '.pg_last_error()); |
|
9 | - } catch( Exception $e ) { |
|
10 | - throw new JException($e->getMessage()); |
|
11 | - } |
|
12 | - } |
|
13 | - public function query( $_query ) { |
|
14 | - $this->stdQuery($_query); |
|
15 | - return true; |
|
16 | - } |
|
17 | - public function queryInsert( $_query ) { |
|
18 | - $this->stdQuery($_query); |
|
19 | - return $this->stdQuery("SELECT lastval()"); |
|
20 | - } |
|
21 | - public function queryFetch( $_query ) { |
|
22 | - $result = $this->stdQuery($_query); |
|
23 | - $rows = []; |
|
24 | - while($row = pg_fetch_assoc($result)) |
|
25 | - $rows[] = $row; |
|
26 | - pg_free_result($result); |
|
27 | - return $rows; |
|
28 | - } |
|
29 | - public function queryArray( $_query ) { |
|
30 | - $result = $this->stdQuery($_query); |
|
31 | - $rows = []; |
|
32 | - while($row = pg_fetch_array($result)) |
|
33 | - $rows[] = $row; |
|
34 | - pg_free_result($result); |
|
35 | - return $rows; |
|
36 | - } |
|
37 | - protected function stdQuery( $_query ) { |
|
38 | - $database = $this->connection; |
|
39 | - $result = pg_query($database, $_query); |
|
40 | - if(!$result) |
|
41 | - throw new JException(json_encode([ |
|
42 | - "query" => $_query, |
|
43 | - "error" => pg_last_error() |
|
44 | - ])); |
|
45 | - return $result; |
|
46 | - } |
|
4 | + public $connection; |
|
5 | + public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
6 | + try { |
|
7 | + $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass") |
|
8 | + or die('Could not connect: '.pg_last_error()); |
|
9 | + } catch( Exception $e ) { |
|
10 | + throw new JException($e->getMessage()); |
|
11 | + } |
|
12 | + } |
|
13 | + public function query( $_query ) { |
|
14 | + $this->stdQuery($_query); |
|
15 | + return true; |
|
16 | + } |
|
17 | + public function queryInsert( $_query ) { |
|
18 | + $this->stdQuery($_query); |
|
19 | + return $this->stdQuery("SELECT lastval()"); |
|
20 | + } |
|
21 | + public function queryFetch( $_query ) { |
|
22 | + $result = $this->stdQuery($_query); |
|
23 | + $rows = []; |
|
24 | + while($row = pg_fetch_assoc($result)) |
|
25 | + $rows[] = $row; |
|
26 | + pg_free_result($result); |
|
27 | + return $rows; |
|
28 | + } |
|
29 | + public function queryArray( $_query ) { |
|
30 | + $result = $this->stdQuery($_query); |
|
31 | + $rows = []; |
|
32 | + while($row = pg_fetch_array($result)) |
|
33 | + $rows[] = $row; |
|
34 | + pg_free_result($result); |
|
35 | + return $rows; |
|
36 | + } |
|
37 | + protected function stdQuery( $_query ) { |
|
38 | + $database = $this->connection; |
|
39 | + $result = pg_query($database, $_query); |
|
40 | + if(!$result) |
|
41 | + throw new JException(json_encode([ |
|
42 | + "query" => $_query, |
|
43 | + "error" => pg_last_error() |
|
44 | + ])); |
|
45 | + return $result; |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | ?> |
@@ -2,42 +2,42 @@ |
||
2 | 2 | jRequire("ConnectionInterface.php"); |
3 | 3 | class PostgresqlAdapter implements ConnectionAdapterInterface { |
4 | 4 | public $connection; |
5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
5 | + public function __construct($_srv, $_db, $_usr, $_pass) { |
|
6 | 6 | try { |
7 | 7 | $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass") |
8 | 8 | or die('Could not connect: '.pg_last_error()); |
9 | - } catch( Exception $e ) { |
|
9 | + } catch (Exception $e) { |
|
10 | 10 | throw new JException($e->getMessage()); |
11 | 11 | } |
12 | 12 | } |
13 | - public function query( $_query ) { |
|
13 | + public function query($_query) { |
|
14 | 14 | $this->stdQuery($_query); |
15 | 15 | return true; |
16 | 16 | } |
17 | - public function queryInsert( $_query ) { |
|
17 | + public function queryInsert($_query) { |
|
18 | 18 | $this->stdQuery($_query); |
19 | 19 | return $this->stdQuery("SELECT lastval()"); |
20 | 20 | } |
21 | - public function queryFetch( $_query ) { |
|
21 | + public function queryFetch($_query) { |
|
22 | 22 | $result = $this->stdQuery($_query); |
23 | 23 | $rows = []; |
24 | - while($row = pg_fetch_assoc($result)) |
|
24 | + while ($row = pg_fetch_assoc($result)) |
|
25 | 25 | $rows[] = $row; |
26 | 26 | pg_free_result($result); |
27 | 27 | return $rows; |
28 | 28 | } |
29 | - public function queryArray( $_query ) { |
|
29 | + public function queryArray($_query) { |
|
30 | 30 | $result = $this->stdQuery($_query); |
31 | 31 | $rows = []; |
32 | - while($row = pg_fetch_array($result)) |
|
32 | + while ($row = pg_fetch_array($result)) |
|
33 | 33 | $rows[] = $row; |
34 | 34 | pg_free_result($result); |
35 | 35 | return $rows; |
36 | 36 | } |
37 | - protected function stdQuery( $_query ) { |
|
37 | + protected function stdQuery($_query) { |
|
38 | 38 | $database = $this->connection; |
39 | 39 | $result = pg_query($database, $_query); |
40 | - if(!$result) |
|
40 | + if (!$result) |
|
41 | 41 | throw new JException(json_encode([ |
42 | 42 | "query" => $_query, |
43 | 43 | "error" => pg_last_error() |
@@ -21,27 +21,30 @@ |
||
21 | 21 | public function queryFetch( $_query ) { |
22 | 22 | $result = $this->stdQuery($_query); |
23 | 23 | $rows = []; |
24 | - while($row = pg_fetch_assoc($result)) |
|
25 | - $rows[] = $row; |
|
24 | + while($row = pg_fetch_assoc($result)) { |
|
25 | + $rows[] = $row; |
|
26 | + } |
|
26 | 27 | pg_free_result($result); |
27 | 28 | return $rows; |
28 | 29 | } |
29 | 30 | public function queryArray( $_query ) { |
30 | 31 | $result = $this->stdQuery($_query); |
31 | 32 | $rows = []; |
32 | - while($row = pg_fetch_array($result)) |
|
33 | - $rows[] = $row; |
|
33 | + while($row = pg_fetch_array($result)) { |
|
34 | + $rows[] = $row; |
|
35 | + } |
|
34 | 36 | pg_free_result($result); |
35 | 37 | return $rows; |
36 | 38 | } |
37 | 39 | protected function stdQuery( $_query ) { |
38 | 40 | $database = $this->connection; |
39 | 41 | $result = pg_query($database, $_query); |
40 | - if(!$result) |
|
41 | - throw new JException(json_encode([ |
|
42 | + if(!$result) { |
|
43 | + throw new JException(json_encode([ |
|
42 | 44 | "query" => $_query, |
43 | 45 | "error" => pg_last_error() |
44 | 46 | ])); |
47 | + } |
|
45 | 48 | return $result; |
46 | 49 | } |
47 | 50 | } |
@@ -2,10 +2,10 @@ |
||
2 | 2 | use Pug as Pug; |
3 | 3 | jRequire("ParserAbstract.php"); |
4 | 4 | class PugAdapter extends ParserAbstract { |
5 | - public function draw( $_text, $_parameters = [] ) { |
|
6 | - $pug = new Pug\Pug(); |
|
7 | - $page = $pug->render($_text, $_parameters); |
|
8 | - return $page; |
|
9 | - } |
|
5 | + public function draw( $_text, $_parameters = [] ) { |
|
6 | + $pug = new Pug\Pug(); |
|
7 | + $page = $pug->render($_text, $_parameters); |
|
8 | + return $page; |
|
9 | + } |
|
10 | 10 | } |
11 | 11 | ?> |
@@ -2,7 +2,7 @@ |
||
2 | 2 | use Pug as Pug; |
3 | 3 | jRequire("ParserAbstract.php"); |
4 | 4 | class PugAdapter extends ParserAbstract { |
5 | - public function draw( $_text, $_parameters = [] ) { |
|
5 | + public function draw($_text, $_parameters = []) { |
|
6 | 6 | $pug = new Pug\Pug(); |
7 | 7 | $page = $pug->render($_text, $_parameters); |
8 | 8 | return $page; |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("ParserAbstract.php"); |
3 | 3 | class JTagAdapter extends ParserAbstract { |
4 | - public function draw( $_text, $_parameters = [] ) { |
|
5 | - foreach($_parameters as $key => $value) |
|
6 | - if(!is_array($value)) |
|
7 | - $_text = str_replace("<_${key}_>", "$value", $_text); |
|
8 | - $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
|
9 | - return $_text; |
|
10 | - } |
|
4 | + public function draw( $_text, $_parameters = [] ) { |
|
5 | + foreach($_parameters as $key => $value) |
|
6 | + if(!is_array($value)) |
|
7 | + $_text = str_replace("<_${key}_>", "$value", $_text); |
|
8 | + $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
|
9 | + return $_text; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | ?> |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | jRequire("ParserAbstract.php"); |
3 | 3 | class JTagAdapter extends ParserAbstract { |
4 | - public function draw( $_text, $_parameters = [] ) { |
|
5 | - foreach($_parameters as $key => $value) |
|
6 | - if(!is_array($value)) |
|
4 | + public function draw($_text, $_parameters = []) { |
|
5 | + foreach ($_parameters as $key => $value) |
|
6 | + if (!is_array($value)) |
|
7 | 7 | $_text = str_replace("<_${key}_>", "$value", $_text); |
8 | 8 | $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
9 | 9 | return $_text; |
@@ -2,9 +2,10 @@ |
||
2 | 2 | jRequire("ParserAbstract.php"); |
3 | 3 | class JTagAdapter extends ParserAbstract { |
4 | 4 | public function draw( $_text, $_parameters = [] ) { |
5 | - foreach($_parameters as $key => $value) |
|
6 | - if(!is_array($value)) |
|
5 | + foreach($_parameters as $key => $value) { |
|
6 | + if(!is_array($value)) |
|
7 | 7 | $_text = str_replace("<_${key}_>", "$value", $_text); |
8 | + } |
|
8 | 9 | $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
9 | 10 | return $_text; |
10 | 11 | } |
@@ -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); |