@@ -51,8 +51,9 @@ |
||
51 | 51 | function minifyOutput($_buffer) { |
52 | 52 | $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
53 | 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)); |
|
54 | + if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) { |
|
55 | + $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
|
56 | + } |
|
56 | 57 | return utf8_encode($_buffer); |
57 | 58 | } |
58 | 59 | ?> |
@@ -36,13 +36,15 @@ |
||
36 | 36 | function arrayDump( $_array, $_name = "Array", $_tab = " " ) { |
37 | 37 | $position = preg_replace('/ /', '', $_tab, 1); |
38 | 38 | echo "$position<span style=\"color:rgb(230,0,0)\">$_name:</span><br>"; |
39 | - foreach ($_array as $k => $i) |
|
40 | - if(is_array($i)) |
|
39 | + foreach ($_array as $k => $i) { |
|
40 | + if(is_array($i)) |
|
41 | 41 | arrayDump( $i, $k, " $_tab" ); |
42 | - else if(is_object($i)) |
|
43 | - echo "$_tab<b>object:</b> [Object]<br>"; |
|
44 | - else |
|
45 | - echo "$_tab<b>$k:</b> $i<br>"; |
|
42 | + } |
|
43 | + else if(is_object($i)) { |
|
44 | + echo "$_tab<b>object:</b> [Object]<br>"; |
|
45 | + } else { |
|
46 | + echo "$_tab<b>$k:</b> $i<br>"; |
|
47 | + } |
|
46 | 48 | } |
47 | 49 | |
48 | 50 | function htmlParser( $_str) { |
@@ -4,8 +4,9 @@ discard block |
||
4 | 4 | public $database; |
5 | 5 | public $info; |
6 | 6 | public function __construct( $_object ) { |
7 | - if(!is_object($_object)) |
|
8 | - throw new InvalidArgumentException("Parameter must be an object."); |
|
7 | + if(!is_object($_object)) { |
|
8 | + throw new InvalidArgumentException("Parameter must be an object."); |
|
9 | + } |
|
9 | 10 | $this->setConnection( |
10 | 11 | $_object->server, |
11 | 12 | $_object->database, |
@@ -33,9 +34,10 @@ discard block |
||
33 | 34 | } |
34 | 35 | protected function getConnectionType( $_type ) { |
35 | 36 | $array = (array)$_type; |
36 | - foreach ($array as $key => $value) |
|
37 | - if($value) |
|
37 | + foreach ($array as $key => $value) { |
|
38 | + if($value) |
|
38 | 39 | return $key; |
40 | + } |
|
39 | 41 | return "pdo"; |
40 | 42 | } |
41 | 43 | } |
@@ -30,14 +30,15 @@ |
||
30 | 30 | $database = $this->connection; |
31 | 31 | $query = $database->prepare($_query); |
32 | 32 | $result = $query->execute(); |
33 | - if(!$result) |
|
34 | - throw new JException(json_encode([ |
|
33 | + if(!$result) { |
|
34 | + throw new JException(json_encode([ |
|
35 | 35 | "query" => $_query, |
36 | 36 | "error" => [ |
37 | 37 | $query->errorInfo(), |
38 | 38 | $database->errorInfo() |
39 | 39 | ] |
40 | 40 | ])); |
41 | + } |
|
41 | 42 | return $query; |
42 | 43 | } |
43 | 44 | } |
@@ -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 | } |
@@ -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,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 | } |
@@ -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); |
@@ -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; |