@@ -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 | ?> |
@@ -9,6 +9,9 @@ |
||
9 | 9 | return jBlockEnd($_type, $_parameters); |
10 | 10 | } |
11 | 11 | |
12 | + /** |
|
13 | + * @param string $_path |
|
14 | + */ |
|
12 | 15 | function jBlockFile( $_path, $_parameters = [] ) { |
13 | 16 | try { |
14 | 17 | $temp = Parser::parseFile($_path, $_parameters); |
@@ -2,46 +2,46 @@ |
||
2 | 2 | jRequire("../modules/Parser/Parser.php"); |
3 | 3 | jRequire("../modules/JException/JException.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 | - try { |
|
14 | - $temp = Parser::parseFile($_path, $_parameters); |
|
15 | - } catch (Exception $e) { |
|
16 | - throw new JException($e->getMessage()); |
|
17 | - } |
|
18 | - return $temp; |
|
13 | + try { |
|
14 | + $temp = Parser::parseFile($_path, $_parameters); |
|
15 | + } catch (Exception $e) { |
|
16 | + throw new JException($e->getMessage()); |
|
17 | + } |
|
18 | + return $temp; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function jBlockFileMan( $_path, $_type, $_parameters = [] ) { |
22 | - try { |
|
23 | - $temp = Parser::parseFileMan($_path, $_parameters, $_type); |
|
24 | - } catch (Exception $e) { |
|
25 | - throw new JException($e->getMessage()); |
|
26 | - } |
|
27 | - return $temp; |
|
22 | + try { |
|
23 | + $temp = Parser::parseFileMan($_path, $_parameters, $_type); |
|
24 | + } catch (Exception $e) { |
|
25 | + throw new JException($e->getMessage()); |
|
26 | + } |
|
27 | + return $temp; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | function jBlockEnd( $_type = "html", $_parameters = [] ) { |
31 | - $text = ob_get_clean(); |
|
32 | - try { |
|
33 | - $temp = Parser::parseText($text, $_parameters, $_type); |
|
34 | - } catch (Exception $e) { |
|
35 | - throw new JException($e->getMessage()); |
|
36 | - } |
|
37 | - return $temp; |
|
31 | + $text = ob_get_clean(); |
|
32 | + try { |
|
33 | + $temp = Parser::parseText($text, $_parameters, $_type); |
|
34 | + } catch (Exception $e) { |
|
35 | + throw new JException($e->getMessage()); |
|
36 | + } |
|
37 | + return $temp; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | function minifyOutput($_buffer) { |
41 | - $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
42 | - $replace = array ( '>', '<', '\\1' ); |
|
43 | - if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
44 | - $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
|
45 | - return utf8_encode($_buffer); |
|
41 | + $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
42 | + $replace = array ( '>', '<', '\\1' ); |
|
43 | + if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
44 | + $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
|
45 | + return utf8_encode($_buffer); |
|
46 | 46 | } |
47 | 47 | ?> |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | return ob_start(); |
6 | 6 | } |
7 | 7 | |
8 | - function jBlockClose( $_type = "html", $_parameters = [] ) { |
|
8 | + function jBlockClose($_type = "html", $_parameters = []) { |
|
9 | 9 | return jBlockEnd($_type, $_parameters); |
10 | 10 | } |
11 | 11 | |
12 | - function jBlockFile( $_path, $_parameters = [] ) { |
|
12 | + function jBlockFile($_path, $_parameters = []) { |
|
13 | 13 | try { |
14 | 14 | $temp = Parser::parseFile($_path, $_parameters); |
15 | 15 | } catch (Exception $e) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | return $temp; |
19 | 19 | } |
20 | 20 | |
21 | - function jBlockFileMan( $_path, $_type, $_parameters = [] ) { |
|
21 | + function jBlockFileMan($_path, $_type, $_parameters = []) { |
|
22 | 22 | try { |
23 | 23 | $temp = Parser::parseFileMan($_path, $_parameters, $_type); |
24 | 24 | } catch (Exception $e) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return $temp; |
28 | 28 | } |
29 | 29 | |
30 | - function jBlockEnd( $_type = "html", $_parameters = [] ) { |
|
30 | + function jBlockEnd($_type = "html", $_parameters = []) { |
|
31 | 31 | $text = ob_get_clean(); |
32 | 32 | try { |
33 | 33 | $temp = Parser::parseText($text, $_parameters, $_type); |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | function minifyOutput($_buffer) { |
41 | - $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
42 | - $replace = array ( '>', '<', '\\1' ); |
|
43 | - if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
41 | + $search = array('/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'); |
|
42 | + $replace = array('>', '<', '\\1'); |
|
43 | + if (preg_match("/\<html/i", $_buffer) == 1 && preg_match("/\<\/html\>/i", $_buffer) == 1) |
|
44 | 44 | $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
45 | 45 | return utf8_encode($_buffer); |
46 | 46 | } |
@@ -1,4 +1,7 @@ |
||
1 | 1 | <?php |
2 | + /** |
|
3 | + * @param integer $number |
|
4 | + */ |
|
2 | 5 | function jateErrorHandler($number, $message, $file, $line) { |
3 | 6 | if (!(error_reporting() & $number)) { |
4 | 7 | return false; |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function jateErrorHandler($number, $message, $file, $line) { |
3 | - if (!(error_reporting() & $number)) { |
|
4 | - return false; |
|
5 | - } |
|
6 | - ob_end_clean(); |
|
7 | - $message = JException::decode($message); |
|
8 | - echo " |
|
3 | + if (!(error_reporting() & $number)) { |
|
4 | + return false; |
|
5 | + } |
|
6 | + ob_end_clean(); |
|
7 | + $message = JException::decode($message); |
|
8 | + echo " |
|
9 | 9 | <div id='error'> |
10 | 10 | <header> |
11 | 11 | JATE ERROR |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | } |
52 | 52 | </style> |
53 | 53 | "; |
54 | - exit(1); |
|
55 | - return true; |
|
54 | + exit(1); |
|
55 | + return true; |
|
56 | 56 | } |
57 | 57 | function fatalErrorShutdownHandler() { |
58 | - $last_error = error_get_last(); |
|
59 | - if ($last_error['type'] === E_ERROR) { |
|
60 | - jateErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
61 | - } |
|
58 | + $last_error = error_get_last(); |
|
59 | + if ($last_error['type'] === E_ERROR) { |
|
60 | + jateErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | set_error_handler('jateErrorHandler'); |
64 | 64 | register_shutdown_function('fatalErrorShutdownHandler'); |
@@ -3,6 +3,10 @@ |
||
3 | 3 | class Connection { |
4 | 4 | public $database; |
5 | 5 | public $info; |
6 | + |
|
7 | + /** |
|
8 | + * @param JConfig $_object |
|
9 | + */ |
|
6 | 10 | public function __construct( $_object ) { |
7 | 11 | if(!is_object($_object)) |
8 | 12 | throw new InvalidArgumentException("Parameter must be an object."); |
@@ -1,42 +1,42 @@ |
||
1 | 1 | <?php |
2 | 2 | requireComponents("Adapters"); |
3 | 3 | class Connection { |
4 | - public $database; |
|
5 | - public $info; |
|
6 | - public function __construct( $_object ) { |
|
7 | - if(!is_object($_object)) |
|
8 | - throw new InvalidArgumentException("Parameter must be an object."); |
|
9 | - $this->setConnection( |
|
10 | - $_object->server, |
|
11 | - $_object->database, |
|
12 | - $_object->user, |
|
13 | - $_object->password, |
|
14 | - $this->getConnectionType($_object->engine) |
|
15 | - ); |
|
16 | - } |
|
17 | - protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
18 | - switch ($_type) { |
|
19 | - case "mysqli": |
|
20 | - $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); |
|
21 | - break; |
|
22 | - case "postgresql": |
|
23 | - $this->database = new PostgresqlAdapter($_srv, $_db, $_usr, $_pass); |
|
24 | - break; |
|
25 | - case "memory": |
|
26 | - $this->database = new PdoMemoryAdapter($_srv, $_db, $_usr, $_pass); |
|
27 | - break; |
|
28 | - case "pdo": |
|
29 | - default: |
|
30 | - $this->database = new PdoAdapter($_srv, $_db, $_usr, $_pass); |
|
31 | - break; |
|
32 | - } |
|
33 | - } |
|
34 | - protected function getConnectionType( $_type ) { |
|
35 | - $array = (array)$_type; |
|
36 | - foreach ($array as $key => $value) |
|
37 | - if($value) |
|
38 | - return $key; |
|
39 | - return "pdo"; |
|
40 | - } |
|
4 | + public $database; |
|
5 | + public $info; |
|
6 | + public function __construct( $_object ) { |
|
7 | + if(!is_object($_object)) |
|
8 | + throw new InvalidArgumentException("Parameter must be an object."); |
|
9 | + $this->setConnection( |
|
10 | + $_object->server, |
|
11 | + $_object->database, |
|
12 | + $_object->user, |
|
13 | + $_object->password, |
|
14 | + $this->getConnectionType($_object->engine) |
|
15 | + ); |
|
16 | + } |
|
17 | + protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
18 | + switch ($_type) { |
|
19 | + case "mysqli": |
|
20 | + $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); |
|
21 | + break; |
|
22 | + case "postgresql": |
|
23 | + $this->database = new PostgresqlAdapter($_srv, $_db, $_usr, $_pass); |
|
24 | + break; |
|
25 | + case "memory": |
|
26 | + $this->database = new PdoMemoryAdapter($_srv, $_db, $_usr, $_pass); |
|
27 | + break; |
|
28 | + case "pdo": |
|
29 | + default: |
|
30 | + $this->database = new PdoAdapter($_srv, $_db, $_usr, $_pass); |
|
31 | + break; |
|
32 | + } |
|
33 | + } |
|
34 | + protected function getConnectionType( $_type ) { |
|
35 | + $array = (array)$_type; |
|
36 | + foreach ($array as $key => $value) |
|
37 | + if($value) |
|
38 | + return $key; |
|
39 | + return "pdo"; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | ?> |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | class Connection { |
4 | 4 | public $database; |
5 | 5 | public $info; |
6 | - public function __construct( $_object ) { |
|
7 | - if(!is_object($_object)) |
|
6 | + public function __construct($_object) { |
|
7 | + if (!is_object($_object)) |
|
8 | 8 | throw new InvalidArgumentException("Parameter must be an object."); |
9 | 9 | $this->setConnection( |
10 | 10 | $_object->server, |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $this->getConnectionType($_object->engine) |
15 | 15 | ); |
16 | 16 | } |
17 | - protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
17 | + protected function setConnection($_srv, $_db, $_usr, $_pass, $_type) { |
|
18 | 18 | switch ($_type) { |
19 | 19 | case "mysqli": |
20 | 20 | $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | break; |
32 | 32 | } |
33 | 33 | } |
34 | - protected function getConnectionType( $_type ) { |
|
35 | - $array = (array)$_type; |
|
34 | + protected function getConnectionType($_type) { |
|
35 | + $array = (array) $_type; |
|
36 | 36 | foreach ($array as $key => $value) |
37 | - if($value) |
|
37 | + if ($value) |
|
38 | 38 | return $key; |
39 | 39 | return "pdo"; |
40 | 40 | } |
@@ -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 | } |
@@ -47,6 +47,10 @@ |
||
47 | 47 | if(!(file_exists($_file) || $this->isCorrectUrl($_file))) |
48 | 48 | throw new JException("File [$_file] not found."); |
49 | 49 | } |
50 | + |
|
51 | + /** |
|
52 | + * @param string $_url |
|
53 | + */ |
|
50 | 54 | protected function isCorrectUrl( $_url ) { |
51 | 55 | return strpos(@get_headers($_url)[0],'200') === false ? false : true; |
52 | 56 | } |
@@ -1,54 +1,54 @@ |
||
1 | 1 | <?php |
2 | 2 | trait File { |
3 | - private $files; |
|
4 | - public function __construct() { |
|
5 | - $this->files = [ |
|
6 | - "required" => [], |
|
7 | - "attached" => [] |
|
8 | - ]; |
|
9 | - } |
|
10 | - public function addFile( $_file ) { |
|
11 | - try { |
|
12 | - $this->isCorrectPath($_file); |
|
13 | - } catch( Exception $e) { |
|
14 | - throw new JException($e->getMessage()); |
|
15 | - } |
|
16 | - $this->files["attached"][] = $_file; |
|
17 | - } |
|
18 | - public function addFileRequired( $_file ) { |
|
19 | - try { |
|
20 | - $this->isCorrectPath($_file); |
|
21 | - } catch( Exception $e) { |
|
22 | - throw new JException($e->getMessage()); |
|
23 | - } |
|
24 | - $this->files["required"][] = $_file; |
|
25 | - } |
|
26 | - public function addFiles( $_files ) { |
|
27 | - if(!is_array($_files)) |
|
28 | - throw new JException("Parameter must be an array."); |
|
29 | - foreach ($_files as $value) |
|
30 | - $this->addFile($value); |
|
31 | - } |
|
32 | - public function addFilesRequired( $_files ) { |
|
33 | - if(!is_array($_files)) |
|
34 | - throw new JException("Parameter must be an array."); |
|
35 | - foreach ($_files as $value) |
|
36 | - $this->addFileRequired($value); |
|
37 | - } |
|
38 | - public function getFiles() { |
|
39 | - return $this->files["attached"]; |
|
40 | - } |
|
41 | - public function getFilesRequired() { |
|
42 | - return $this->files["required"]; |
|
43 | - } |
|
44 | - protected function isCorrectPath( $_file ) { |
|
45 | - if(!is_string($_file)) |
|
46 | - throw new JException("Path must be a string."); |
|
47 | - if(!(file_exists($_file) || $this->isCorrectUrl($_file))) |
|
48 | - throw new JException("File [$_file] not found."); |
|
49 | - } |
|
50 | - protected function isCorrectUrl( $_url ) { |
|
51 | - return strpos(@get_headers($_url)[0],'200') === false ? false : true; |
|
52 | - } |
|
3 | + private $files; |
|
4 | + public function __construct() { |
|
5 | + $this->files = [ |
|
6 | + "required" => [], |
|
7 | + "attached" => [] |
|
8 | + ]; |
|
9 | + } |
|
10 | + public function addFile( $_file ) { |
|
11 | + try { |
|
12 | + $this->isCorrectPath($_file); |
|
13 | + } catch( Exception $e) { |
|
14 | + throw new JException($e->getMessage()); |
|
15 | + } |
|
16 | + $this->files["attached"][] = $_file; |
|
17 | + } |
|
18 | + public function addFileRequired( $_file ) { |
|
19 | + try { |
|
20 | + $this->isCorrectPath($_file); |
|
21 | + } catch( Exception $e) { |
|
22 | + throw new JException($e->getMessage()); |
|
23 | + } |
|
24 | + $this->files["required"][] = $_file; |
|
25 | + } |
|
26 | + public function addFiles( $_files ) { |
|
27 | + if(!is_array($_files)) |
|
28 | + throw new JException("Parameter must be an array."); |
|
29 | + foreach ($_files as $value) |
|
30 | + $this->addFile($value); |
|
31 | + } |
|
32 | + public function addFilesRequired( $_files ) { |
|
33 | + if(!is_array($_files)) |
|
34 | + throw new JException("Parameter must be an array."); |
|
35 | + foreach ($_files as $value) |
|
36 | + $this->addFileRequired($value); |
|
37 | + } |
|
38 | + public function getFiles() { |
|
39 | + return $this->files["attached"]; |
|
40 | + } |
|
41 | + public function getFilesRequired() { |
|
42 | + return $this->files["required"]; |
|
43 | + } |
|
44 | + protected function isCorrectPath( $_file ) { |
|
45 | + if(!is_string($_file)) |
|
46 | + throw new JException("Path must be a string."); |
|
47 | + if(!(file_exists($_file) || $this->isCorrectUrl($_file))) |
|
48 | + throw new JException("File [$_file] not found."); |
|
49 | + } |
|
50 | + protected function isCorrectUrl( $_url ) { |
|
51 | + return strpos(@get_headers($_url)[0],'200') === false ? false : true; |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | ?> |
@@ -7,30 +7,30 @@ discard block |
||
7 | 7 | "attached" => [] |
8 | 8 | ]; |
9 | 9 | } |
10 | - public function addFile( $_file ) { |
|
10 | + public function addFile($_file) { |
|
11 | 11 | try { |
12 | 12 | $this->isCorrectPath($_file); |
13 | - } catch( Exception $e) { |
|
13 | + } catch (Exception $e) { |
|
14 | 14 | throw new JException($e->getMessage()); |
15 | 15 | } |
16 | 16 | $this->files["attached"][] = $_file; |
17 | 17 | } |
18 | - public function addFileRequired( $_file ) { |
|
18 | + public function addFileRequired($_file) { |
|
19 | 19 | try { |
20 | 20 | $this->isCorrectPath($_file); |
21 | - } catch( Exception $e) { |
|
21 | + } catch (Exception $e) { |
|
22 | 22 | throw new JException($e->getMessage()); |
23 | 23 | } |
24 | 24 | $this->files["required"][] = $_file; |
25 | 25 | } |
26 | - public function addFiles( $_files ) { |
|
27 | - if(!is_array($_files)) |
|
26 | + public function addFiles($_files) { |
|
27 | + if (!is_array($_files)) |
|
28 | 28 | throw new JException("Parameter must be an array."); |
29 | 29 | foreach ($_files as $value) |
30 | 30 | $this->addFile($value); |
31 | 31 | } |
32 | - public function addFilesRequired( $_files ) { |
|
33 | - if(!is_array($_files)) |
|
32 | + public function addFilesRequired($_files) { |
|
33 | + if (!is_array($_files)) |
|
34 | 34 | throw new JException("Parameter must be an array."); |
35 | 35 | foreach ($_files as $value) |
36 | 36 | $this->addFileRequired($value); |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | public function getFilesRequired() { |
42 | 42 | return $this->files["required"]; |
43 | 43 | } |
44 | - protected function isCorrectPath( $_file ) { |
|
45 | - if(!is_string($_file)) |
|
44 | + protected function isCorrectPath($_file) { |
|
45 | + if (!is_string($_file)) |
|
46 | 46 | throw new JException("Path must be a string."); |
47 | - if(!(file_exists($_file) || $this->isCorrectUrl($_file))) |
|
47 | + if (!(file_exists($_file) || $this->isCorrectUrl($_file))) |
|
48 | 48 | throw new JException("File [$_file] not found."); |
49 | 49 | } |
50 | - protected function isCorrectUrl( $_url ) { |
|
51 | - return strpos(@get_headers($_url)[0],'200') === false ? false : true; |
|
50 | + protected function isCorrectUrl($_url) { |
|
51 | + return strpos(@get_headers($_url)[0], '200') === false ? false : true; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | ?> |
@@ -24,16 +24,20 @@ discard block |
||
24 | 24 | $this->files["required"][] = $_file; |
25 | 25 | } |
26 | 26 | public function addFiles( $_files ) { |
27 | - if(!is_array($_files)) |
|
28 | - throw new JException("Parameter must be an array."); |
|
29 | - foreach ($_files as $value) |
|
30 | - $this->addFile($value); |
|
27 | + if(!is_array($_files)) { |
|
28 | + throw new JException("Parameter must be an array."); |
|
29 | + } |
|
30 | + foreach ($_files as $value) { |
|
31 | + $this->addFile($value); |
|
32 | + } |
|
31 | 33 | } |
32 | 34 | public function addFilesRequired( $_files ) { |
33 | - if(!is_array($_files)) |
|
34 | - throw new JException("Parameter must be an array."); |
|
35 | - foreach ($_files as $value) |
|
36 | - $this->addFileRequired($value); |
|
35 | + if(!is_array($_files)) { |
|
36 | + throw new JException("Parameter must be an array."); |
|
37 | + } |
|
38 | + foreach ($_files as $value) { |
|
39 | + $this->addFileRequired($value); |
|
40 | + } |
|
37 | 41 | } |
38 | 42 | public function getFiles() { |
39 | 43 | return $this->files["attached"]; |
@@ -42,10 +46,12 @@ discard block |
||
42 | 46 | return $this->files["required"]; |
43 | 47 | } |
44 | 48 | protected function isCorrectPath( $_file ) { |
45 | - if(!is_string($_file)) |
|
46 | - throw new JException("Path must be a string."); |
|
47 | - if(!(file_exists($_file) || $this->isCorrectUrl($_file))) |
|
48 | - throw new JException("File [$_file] not found."); |
|
49 | + if(!is_string($_file)) { |
|
50 | + throw new JException("Path must be a string."); |
|
51 | + } |
|
52 | + if(!(file_exists($_file) || $this->isCorrectUrl($_file))) { |
|
53 | + throw new JException("File [$_file] not found."); |
|
54 | + } |
|
49 | 55 | } |
50 | 56 | protected function isCorrectUrl( $_url ) { |
51 | 57 | return strpos(@get_headers($_url)[0],'200') === false ? false : true; |
@@ -83,6 +83,11 @@ |
||
83 | 83 | $this->tags["js"] = $this->getJs(); |
84 | 84 | $this->tags["jsVar"] = $this->getJsVars(); |
85 | 85 | } |
86 | + |
|
87 | + /** |
|
88 | + * @param string $_function |
|
89 | + * @param string $_extenction |
|
90 | + */ |
|
86 | 91 | protected function getRequire( $_function, $_extenction) { |
87 | 92 | $temp = []; |
88 | 93 | $filesRequired = $this->getFilesRequired(); |
@@ -3,99 +3,99 @@ |
||
3 | 3 | requireComponent("../Module/Module.php"); |
4 | 4 | requireComponent("../JException/JException.php"); |
5 | 5 | abstract class Html extends Module { |
6 | - public $template; |
|
7 | - public $app; |
|
8 | - public $page; |
|
9 | - public $tags; |
|
10 | - public $jsVars; |
|
11 | - public function __construct() { |
|
12 | - parent::__construct(); |
|
13 | - $this->template = ""; |
|
14 | - $this->app = []; |
|
15 | - $this->page = []; |
|
16 | - $this->jsVars = []; |
|
17 | - $this->tags = [ |
|
18 | - "css" => [], |
|
19 | - "js" => [], |
|
20 | - "jsVar" => [], |
|
21 | - "base" => "" |
|
22 | - ]; |
|
23 | - } |
|
24 | - public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { |
|
25 | - $this->app = $_parameters["app"]; |
|
26 | - $this->page = $_parameters["page"]; |
|
27 | - } |
|
28 | - abstract public function init(); |
|
29 | - public function draw() { |
|
30 | - if($this->template == "") |
|
31 | - throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
|
32 | - $server = new ServerVars(); |
|
33 | - $this->addDipendences(); |
|
34 | - $this->tags["css"] = array_unique($this->tags["css"]); |
|
35 | - $this->tags["js"] = array_unique($this->tags["js"]); |
|
36 | - $this->tags["base"] = $server->server["RELATIVE"]."/"; |
|
37 | - $this->stringifyDipendences(); |
|
38 | - return jBlockFile($this->template, $this->tags); |
|
39 | - } |
|
40 | - public function getCss() { |
|
41 | - return $this->getRequire("getCss",".css"); |
|
42 | - } |
|
43 | - public function getJs() { |
|
44 | - return $this->getRequire("getJs",".js"); |
|
45 | - } |
|
46 | - public function getJsVars() { |
|
47 | - return $this->jsVars; |
|
48 | - } |
|
49 | - public function addJsVar( $_name, $_value ) { |
|
50 | - if(!is_string($_name)) |
|
51 | - throw new InvalidArgumentException("Parameter name must be a string."); |
|
52 | - if(!is_string($_value)) |
|
53 | - throw new InvalidArgumentException("Parameter value must be a string."); |
|
54 | - $this->jsVars[] = [$_name, $_value]; |
|
55 | - } |
|
56 | - public function addJsVars( $_array ) { |
|
57 | - if(!is_array($_array)) |
|
58 | - throw new InvalidArgumentException("Parameter must be an array."); |
|
59 | - foreach ($_array as $value) |
|
60 | - $this->addJsVar($value[0], $value[1]); |
|
61 | - } |
|
62 | - protected function stringifyDipendences() { |
|
63 | - $tempStr = ""; |
|
64 | - $timeParameter = "?t=".time(); |
|
65 | - $time = ($this->app->cache->css == true) ? "" : $timeParameter; |
|
66 | - foreach ($this->tags["css"] as $i) |
|
67 | - $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
68 | - $this->tags["css"] = $tempStr; |
|
69 | - $tempStr = ""; |
|
70 | - $time = ($this->app->cache->js == true) ? "" : $timeParameter; |
|
71 | - foreach ($this->tags["js"] as $i) |
|
72 | - $tempStr .= "<script src='$i$time'></script>"; |
|
73 | - $this->tags["js"] = $tempStr; |
|
74 | - $tempStr = ""; |
|
75 | - $tempStr .= "<script type='text/javascript'>"; |
|
76 | - foreach ($this->tags["jsVar"] as $i) |
|
77 | - $tempStr .= " $i[0] = $i[1];\n"; |
|
78 | - $tempStr .= "</script>"; |
|
79 | - $this->tags["jsVar"] = $tempStr; |
|
80 | - } |
|
81 | - protected function addDipendences() { |
|
82 | - $this->tags["css"] = $this->getCss(); |
|
83 | - $this->tags["js"] = $this->getJs(); |
|
84 | - $this->tags["jsVar"] = $this->getJsVars(); |
|
85 | - } |
|
86 | - protected function getRequire( $_function, $_extenction) { |
|
87 | - $temp = []; |
|
88 | - $filesRequired = $this->getFilesRequired(); |
|
89 | - $files = $this->getFiles(); |
|
90 | - foreach ($filesRequired as $i) |
|
91 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
92 | - $temp[] = $i; |
|
93 | - foreach ($this->modules as $i) |
|
94 | - $temp = array_merge( $temp, $i->$_function() ); |
|
95 | - foreach ($files as $i) |
|
96 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
97 | - $temp[] = $i; |
|
98 | - return $temp; |
|
99 | - } |
|
6 | + public $template; |
|
7 | + public $app; |
|
8 | + public $page; |
|
9 | + public $tags; |
|
10 | + public $jsVars; |
|
11 | + public function __construct() { |
|
12 | + parent::__construct(); |
|
13 | + $this->template = ""; |
|
14 | + $this->app = []; |
|
15 | + $this->page = []; |
|
16 | + $this->jsVars = []; |
|
17 | + $this->tags = [ |
|
18 | + "css" => [], |
|
19 | + "js" => [], |
|
20 | + "jsVar" => [], |
|
21 | + "base" => "" |
|
22 | + ]; |
|
23 | + } |
|
24 | + public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { |
|
25 | + $this->app = $_parameters["app"]; |
|
26 | + $this->page = $_parameters["page"]; |
|
27 | + } |
|
28 | + abstract public function init(); |
|
29 | + public function draw() { |
|
30 | + if($this->template == "") |
|
31 | + throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
|
32 | + $server = new ServerVars(); |
|
33 | + $this->addDipendences(); |
|
34 | + $this->tags["css"] = array_unique($this->tags["css"]); |
|
35 | + $this->tags["js"] = array_unique($this->tags["js"]); |
|
36 | + $this->tags["base"] = $server->server["RELATIVE"]."/"; |
|
37 | + $this->stringifyDipendences(); |
|
38 | + return jBlockFile($this->template, $this->tags); |
|
39 | + } |
|
40 | + public function getCss() { |
|
41 | + return $this->getRequire("getCss",".css"); |
|
42 | + } |
|
43 | + public function getJs() { |
|
44 | + return $this->getRequire("getJs",".js"); |
|
45 | + } |
|
46 | + public function getJsVars() { |
|
47 | + return $this->jsVars; |
|
48 | + } |
|
49 | + public function addJsVar( $_name, $_value ) { |
|
50 | + if(!is_string($_name)) |
|
51 | + throw new InvalidArgumentException("Parameter name must be a string."); |
|
52 | + if(!is_string($_value)) |
|
53 | + throw new InvalidArgumentException("Parameter value must be a string."); |
|
54 | + $this->jsVars[] = [$_name, $_value]; |
|
55 | + } |
|
56 | + public function addJsVars( $_array ) { |
|
57 | + if(!is_array($_array)) |
|
58 | + throw new InvalidArgumentException("Parameter must be an array."); |
|
59 | + foreach ($_array as $value) |
|
60 | + $this->addJsVar($value[0], $value[1]); |
|
61 | + } |
|
62 | + protected function stringifyDipendences() { |
|
63 | + $tempStr = ""; |
|
64 | + $timeParameter = "?t=".time(); |
|
65 | + $time = ($this->app->cache->css == true) ? "" : $timeParameter; |
|
66 | + foreach ($this->tags["css"] as $i) |
|
67 | + $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
68 | + $this->tags["css"] = $tempStr; |
|
69 | + $tempStr = ""; |
|
70 | + $time = ($this->app->cache->js == true) ? "" : $timeParameter; |
|
71 | + foreach ($this->tags["js"] as $i) |
|
72 | + $tempStr .= "<script src='$i$time'></script>"; |
|
73 | + $this->tags["js"] = $tempStr; |
|
74 | + $tempStr = ""; |
|
75 | + $tempStr .= "<script type='text/javascript'>"; |
|
76 | + foreach ($this->tags["jsVar"] as $i) |
|
77 | + $tempStr .= " $i[0] = $i[1];\n"; |
|
78 | + $tempStr .= "</script>"; |
|
79 | + $this->tags["jsVar"] = $tempStr; |
|
80 | + } |
|
81 | + protected function addDipendences() { |
|
82 | + $this->tags["css"] = $this->getCss(); |
|
83 | + $this->tags["js"] = $this->getJs(); |
|
84 | + $this->tags["jsVar"] = $this->getJsVars(); |
|
85 | + } |
|
86 | + protected function getRequire( $_function, $_extenction) { |
|
87 | + $temp = []; |
|
88 | + $filesRequired = $this->getFilesRequired(); |
|
89 | + $files = $this->getFiles(); |
|
90 | + foreach ($filesRequired as $i) |
|
91 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
92 | + $temp[] = $i; |
|
93 | + foreach ($this->modules as $i) |
|
94 | + $temp = array_merge( $temp, $i->$_function() ); |
|
95 | + foreach ($files as $i) |
|
96 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
97 | + $temp[] = $i; |
|
98 | + return $temp; |
|
99 | + } |
|
100 | 100 | } |
101 | 101 | ?> |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | "base" => "" |
22 | 22 | ]; |
23 | 23 | } |
24 | - public function setParameters( $_parameters = [ "app" => null, "page" => null] ) { |
|
24 | + public function setParameters($_parameters = ["app" => null, "page" => null]) { |
|
25 | 25 | $this->app = $_parameters["app"]; |
26 | 26 | $this->page = $_parameters["page"]; |
27 | 27 | } |
28 | 28 | abstract public function init(); |
29 | 29 | public function draw() { |
30 | - if($this->template == "") |
|
30 | + if ($this->template == "") |
|
31 | 31 | throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
32 | 32 | $server = new ServerVars(); |
33 | 33 | $this->addDipendences(); |
@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | return jBlockFile($this->template, $this->tags); |
39 | 39 | } |
40 | 40 | public function getCss() { |
41 | - return $this->getRequire("getCss",".css"); |
|
41 | + return $this->getRequire("getCss", ".css"); |
|
42 | 42 | } |
43 | 43 | public function getJs() { |
44 | - return $this->getRequire("getJs",".js"); |
|
44 | + return $this->getRequire("getJs", ".js"); |
|
45 | 45 | } |
46 | 46 | public function getJsVars() { |
47 | 47 | return $this->jsVars; |
48 | 48 | } |
49 | - public function addJsVar( $_name, $_value ) { |
|
50 | - if(!is_string($_name)) |
|
49 | + public function addJsVar($_name, $_value) { |
|
50 | + if (!is_string($_name)) |
|
51 | 51 | throw new InvalidArgumentException("Parameter name must be a string."); |
52 | - if(!is_string($_value)) |
|
52 | + if (!is_string($_value)) |
|
53 | 53 | throw new InvalidArgumentException("Parameter value must be a string."); |
54 | 54 | $this->jsVars[] = [$_name, $_value]; |
55 | 55 | } |
56 | - public function addJsVars( $_array ) { |
|
57 | - if(!is_array($_array)) |
|
56 | + public function addJsVars($_array) { |
|
57 | + if (!is_array($_array)) |
|
58 | 58 | throw new InvalidArgumentException("Parameter must be an array."); |
59 | 59 | foreach ($_array as $value) |
60 | 60 | $this->addJsVar($value[0], $value[1]); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->tags["js"] = $this->getJs(); |
84 | 84 | $this->tags["jsVar"] = $this->getJsVars(); |
85 | 85 | } |
86 | - protected function getRequire( $_function, $_extenction) { |
|
86 | + protected function getRequire($_function, $_extenction) { |
|
87 | 87 | $temp = []; |
88 | 88 | $filesRequired = $this->getFilesRequired(); |
89 | 89 | $files = $this->getFiles(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
92 | 92 | $temp[] = $i; |
93 | 93 | foreach ($this->modules as $i) |
94 | - $temp = array_merge( $temp, $i->$_function() ); |
|
94 | + $temp = array_merge($temp, $i->$_function()); |
|
95 | 95 | foreach ($files as $i) |
96 | 96 | if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
97 | 97 | $temp[] = $i; |
@@ -27,8 +27,9 @@ discard block |
||
27 | 27 | } |
28 | 28 | abstract public function init(); |
29 | 29 | public function draw() { |
30 | - if($this->template == "") |
|
31 | - throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
|
30 | + if($this->template == "") { |
|
31 | + throw new JException("The variable \$this->template must be set in class $this->name function init()."); |
|
32 | + } |
|
32 | 33 | $server = new ServerVars(); |
33 | 34 | $this->addDipendences(); |
34 | 35 | $this->tags["css"] = array_unique($this->tags["css"]); |
@@ -47,34 +48,41 @@ discard block |
||
47 | 48 | return $this->jsVars; |
48 | 49 | } |
49 | 50 | public function addJsVar( $_name, $_value ) { |
50 | - if(!is_string($_name)) |
|
51 | - throw new InvalidArgumentException("Parameter name must be a string."); |
|
52 | - if(!is_string($_value)) |
|
53 | - throw new InvalidArgumentException("Parameter value must be a string."); |
|
51 | + if(!is_string($_name)) { |
|
52 | + throw new InvalidArgumentException("Parameter name must be a string."); |
|
53 | + } |
|
54 | + if(!is_string($_value)) { |
|
55 | + throw new InvalidArgumentException("Parameter value must be a string."); |
|
56 | + } |
|
54 | 57 | $this->jsVars[] = [$_name, $_value]; |
55 | 58 | } |
56 | 59 | public function addJsVars( $_array ) { |
57 | - if(!is_array($_array)) |
|
58 | - throw new InvalidArgumentException("Parameter must be an array."); |
|
59 | - foreach ($_array as $value) |
|
60 | - $this->addJsVar($value[0], $value[1]); |
|
60 | + if(!is_array($_array)) { |
|
61 | + throw new InvalidArgumentException("Parameter must be an array."); |
|
62 | + } |
|
63 | + foreach ($_array as $value) { |
|
64 | + $this->addJsVar($value[0], $value[1]); |
|
65 | + } |
|
61 | 66 | } |
62 | 67 | protected function stringifyDipendences() { |
63 | 68 | $tempStr = ""; |
64 | 69 | $timeParameter = "?t=".time(); |
65 | 70 | $time = ($this->app->cache->css == true) ? "" : $timeParameter; |
66 | - foreach ($this->tags["css"] as $i) |
|
67 | - $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
71 | + foreach ($this->tags["css"] as $i) { |
|
72 | + $tempStr .= "<link rel='stylesheet' href='$i$time'>"; |
|
73 | + } |
|
68 | 74 | $this->tags["css"] = $tempStr; |
69 | 75 | $tempStr = ""; |
70 | 76 | $time = ($this->app->cache->js == true) ? "" : $timeParameter; |
71 | - foreach ($this->tags["js"] as $i) |
|
72 | - $tempStr .= "<script src='$i$time'></script>"; |
|
77 | + foreach ($this->tags["js"] as $i) { |
|
78 | + $tempStr .= "<script src='$i$time'></script>"; |
|
79 | + } |
|
73 | 80 | $this->tags["js"] = $tempStr; |
74 | 81 | $tempStr = ""; |
75 | 82 | $tempStr .= "<script type='text/javascript'>"; |
76 | - foreach ($this->tags["jsVar"] as $i) |
|
77 | - $tempStr .= " $i[0] = $i[1];\n"; |
|
83 | + foreach ($this->tags["jsVar"] as $i) { |
|
84 | + $tempStr .= " $i[0] = $i[1];\n"; |
|
85 | + } |
|
78 | 86 | $tempStr .= "</script>"; |
79 | 87 | $this->tags["jsVar"] = $tempStr; |
80 | 88 | } |
@@ -87,14 +95,17 @@ discard block |
||
87 | 95 | $temp = []; |
88 | 96 | $filesRequired = $this->getFilesRequired(); |
89 | 97 | $files = $this->getFiles(); |
90 | - foreach ($filesRequired as $i) |
|
91 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
98 | + foreach ($filesRequired as $i) { |
|
99 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
92 | 100 | $temp[] = $i; |
93 | - foreach ($this->modules as $i) |
|
94 | - $temp = array_merge( $temp, $i->$_function() ); |
|
95 | - foreach ($files as $i) |
|
96 | - if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
101 | + } |
|
102 | + foreach ($this->modules as $i) { |
|
103 | + $temp = array_merge( $temp, $i->$_function() ); |
|
104 | + } |
|
105 | + foreach ($files as $i) { |
|
106 | + if (!is_array($i) && strpos($i, $_extenction) !== FALSE) |
|
97 | 107 | $temp[] = $i; |
108 | + } |
|
98 | 109 | return $temp; |
99 | 110 | } |
100 | 111 | } |
@@ -1,8 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | abstract class ParserAbstract { |
3 | + |
|
4 | + /** |
|
5 | + * @param string $_text |
|
6 | + */ |
|
3 | 7 | public function drawText( $_text, $_parameters = [] ) { |
4 | 8 | return $this->draw(trim($_text), $_parameters); |
5 | 9 | } |
10 | + |
|
11 | + /** |
|
12 | + * @param string $_text |
|
13 | + */ |
|
6 | 14 | abstract public function draw( $_text, $_parameters = [] ); |
7 | 15 | } |
8 | 16 | ?> |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | abstract class ParserAbstract { |
3 | - public function drawText( $_text, $_parameters = [] ) { |
|
4 | - return $this->draw(trim($_text), $_parameters); |
|
5 | - } |
|
6 | - abstract public function draw( $_text, $_parameters = [] ); |
|
3 | + public function drawText( $_text, $_parameters = [] ) { |
|
4 | + return $this->draw(trim($_text), $_parameters); |
|
5 | + } |
|
6 | + abstract public function draw( $_text, $_parameters = [] ); |
|
7 | 7 | } |
8 | 8 | ?> |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | abstract class ParserAbstract { |
3 | - public function drawText( $_text, $_parameters = [] ) { |
|
3 | + public function drawText($_text, $_parameters = []) { |
|
4 | 4 | return $this->draw(trim($_text), $_parameters); |
5 | 5 | } |
6 | - abstract public function draw( $_text, $_parameters = [] ); |
|
6 | + abstract public function draw($_text, $_parameters = []); |
|
7 | 7 | } |
8 | 8 | ?> |
@@ -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,66 +2,66 @@ |
||
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 | - $parser = new TwigAdapter(); |
|
11 | - break; |
|
12 | - case "jate": |
|
13 | - $parser = new JTagAdapter(); |
|
14 | - break; |
|
15 | - case 'jade': |
|
16 | - case "pug": |
|
17 | - $parser = new PugAdapter(); |
|
18 | - break; |
|
19 | - case "md": |
|
20 | - case "markdown": |
|
21 | - case "parsedown": |
|
22 | - $parser = new ParsedownAdapter(); |
|
23 | - break; |
|
24 | - default: |
|
25 | - $parser = -1; |
|
26 | - break; |
|
27 | - } |
|
28 | - return $parser; |
|
29 | - } |
|
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."); |
|
35 | - $parser = self::setParser($_type); |
|
36 | - if($parser === -1) |
|
37 | - return $_text; |
|
38 | - return $parser->drawText($_text, $_parameters); |
|
39 | - } |
|
40 | - 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."); |
|
45 | - $string = file_get_contents($_path); |
|
46 | - try { |
|
47 | - $text = self::parseText($string, $_parameters, $_type); |
|
48 | - } catch (Exception $e) { |
|
49 | - throw new JException($e->getMessage()); |
|
50 | - } |
|
51 | - return $text; |
|
52 | - } |
|
53 | - public static function parseFile( $_path, $_parameters = [] ) { |
|
54 | - if(!is_string($_path)) |
|
55 | - throw new JException("Parameter must be a string."); |
|
56 | - $extension = explode(".", $_path); |
|
57 | - $extension = $extension[count($extension)-1]; |
|
58 | - $extension = strtolower($extension); |
|
59 | - try { |
|
60 | - $text = self::parseFileMan($_path, $_parameters, $extension); |
|
61 | - } catch (Exception $e) { |
|
62 | - throw new JException($e->getMessage()); |
|
63 | - } |
|
64 | - return $text; |
|
65 | - } |
|
5 | + private static function setParser ( $_type ) { |
|
6 | + $parser = null; |
|
7 | + $_type = strtolower($_type); |
|
8 | + switch ($_type) { |
|
9 | + case "twig": |
|
10 | + $parser = new TwigAdapter(); |
|
11 | + break; |
|
12 | + case "jate": |
|
13 | + $parser = new JTagAdapter(); |
|
14 | + break; |
|
15 | + case 'jade': |
|
16 | + case "pug": |
|
17 | + $parser = new PugAdapter(); |
|
18 | + break; |
|
19 | + case "md": |
|
20 | + case "markdown": |
|
21 | + case "parsedown": |
|
22 | + $parser = new ParsedownAdapter(); |
|
23 | + break; |
|
24 | + default: |
|
25 | + $parser = -1; |
|
26 | + break; |
|
27 | + } |
|
28 | + return $parser; |
|
29 | + } |
|
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."); |
|
35 | + $parser = self::setParser($_type); |
|
36 | + if($parser === -1) |
|
37 | + return $_text; |
|
38 | + return $parser->drawText($_text, $_parameters); |
|
39 | + } |
|
40 | + 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."); |
|
45 | + $string = file_get_contents($_path); |
|
46 | + try { |
|
47 | + $text = self::parseText($string, $_parameters, $_type); |
|
48 | + } catch (Exception $e) { |
|
49 | + throw new JException($e->getMessage()); |
|
50 | + } |
|
51 | + return $text; |
|
52 | + } |
|
53 | + public static function parseFile( $_path, $_parameters = [] ) { |
|
54 | + if(!is_string($_path)) |
|
55 | + throw new JException("Parameter must be a string."); |
|
56 | + $extension = explode(".", $_path); |
|
57 | + $extension = $extension[count($extension)-1]; |
|
58 | + $extension = strtolower($extension); |
|
59 | + try { |
|
60 | + $text = self::parseFileMan($_path, $_parameters, $extension); |
|
61 | + } catch (Exception $e) { |
|
62 | + throw new JException($e->getMessage()); |
|
63 | + } |
|
64 | + return $text; |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | ?> |
@@ -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); |
@@ -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,84 +3,84 @@ |
||
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 | - try { |
|
49 | - $temp = $this->currentConnection->database->query($_query); |
|
50 | - } catch (Exception $e) { |
|
51 | - throw new JException($e->getMessage(), 1); |
|
52 | - } |
|
53 | - return $temp; |
|
54 | - } |
|
55 | - public function queryInsert( $_query ) { |
|
56 | - if(!is_string($_query)) |
|
57 | - throw new JException("Parameter must be a string.", 1); |
|
58 | - try { |
|
59 | - $temp = $this->currentConnection->database->queryInsert($_query); |
|
60 | - } catch (Exception $e) { |
|
61 | - throw new JException($e->getMessage(), 1); |
|
62 | - } |
|
63 | - return $temp; |
|
64 | - } |
|
65 | - public function queryFetch( $_query ) { |
|
66 | - if(!is_string($_query)) |
|
67 | - throw new JException("Parameter must be a string.", 1); |
|
68 | - try { |
|
69 | - $temp = $this->currentConnection->database->queryFetch($_query); |
|
70 | - } catch (Exception $e) { |
|
71 | - throw new JException($e->getMessage(), 1); |
|
72 | - } |
|
73 | - return $temp; |
|
74 | - } |
|
75 | - public function queryArray( $_query ) { |
|
76 | - if(!is_string($_query)) |
|
77 | - throw new JException("Parameter must be a string.", 1); |
|
78 | - try { |
|
79 | - $temp = $this->currentConnection->database->queryArray($_query); |
|
80 | - } catch (Exception $e) { |
|
81 | - throw new JException($e->getMessage(), 1); |
|
82 | - } |
|
83 | - return $temp; |
|
84 | - } |
|
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 | + try { |
|
49 | + $temp = $this->currentConnection->database->query($_query); |
|
50 | + } catch (Exception $e) { |
|
51 | + throw new JException($e->getMessage(), 1); |
|
52 | + } |
|
53 | + return $temp; |
|
54 | + } |
|
55 | + public function queryInsert( $_query ) { |
|
56 | + if(!is_string($_query)) |
|
57 | + throw new JException("Parameter must be a string.", 1); |
|
58 | + try { |
|
59 | + $temp = $this->currentConnection->database->queryInsert($_query); |
|
60 | + } catch (Exception $e) { |
|
61 | + throw new JException($e->getMessage(), 1); |
|
62 | + } |
|
63 | + return $temp; |
|
64 | + } |
|
65 | + public function queryFetch( $_query ) { |
|
66 | + if(!is_string($_query)) |
|
67 | + throw new JException("Parameter must be a string.", 1); |
|
68 | + try { |
|
69 | + $temp = $this->currentConnection->database->queryFetch($_query); |
|
70 | + } catch (Exception $e) { |
|
71 | + throw new JException($e->getMessage(), 1); |
|
72 | + } |
|
73 | + return $temp; |
|
74 | + } |
|
75 | + public function queryArray( $_query ) { |
|
76 | + if(!is_string($_query)) |
|
77 | + throw new JException("Parameter must be a string.", 1); |
|
78 | + try { |
|
79 | + $temp = $this->currentConnection->database->queryArray($_query); |
|
80 | + } catch (Exception $e) { |
|
81 | + throw new JException($e->getMessage(), 1); |
|
82 | + } |
|
83 | + return $temp; |
|
84 | + } |
|
85 | 85 | } |
86 | 86 | ?> |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | $this->connection = []; |
10 | 10 | $this->currentConnection = null; |
11 | 11 | } |
12 | - public function addConnection( $_path, $_name = "default" ) { |
|
13 | - if(!is_string($_path)) |
|
12 | + public function addConnection($_path, $_name = "default") { |
|
13 | + if (!is_string($_path)) |
|
14 | 14 | throw new JException("Parameter must be a string.", 1); |
15 | 15 | try { |
16 | 16 | $jConfig = new JConfig($_path); |
17 | - if($jConfig->enable) { |
|
17 | + if ($jConfig->enable) { |
|
18 | 18 | $connection = new Connection($jConfig); |
19 | 19 | $this->addConnectionMan($connection, $_name); |
20 | 20 | } |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | throw new JException($e->getMessage(), 1); |
23 | 23 | } |
24 | 24 | } |
25 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
25 | + public function addConnectionMan($_connection, $_name = "default") { |
|
26 | + if (!is_object($_connection) || !is_a($_connection, "Connection")) |
|
27 | 27 | throw new JException("Parameter must be a Connection object.", 1); |
28 | 28 | try { |
29 | 29 | $this->connection["$_name"] = $_connection; |
30 | 30 | $this->currentConnection = $_connection; |
31 | 31 | foreach ($this->modules as &$module) |
32 | - if(isset($this->currentConnection)) |
|
32 | + if (isset($this->currentConnection)) |
|
33 | 33 | $module->addConnectionMan($this->currentConnection, $_name); |
34 | 34 | } catch (Exception $e) { |
35 | 35 | throw new JException($e->getMessage(), 1); |
36 | 36 | } |
37 | 37 | } |
38 | - public function setConnection( $_name = "default" ) { |
|
39 | - if(!is_string($_name)) |
|
38 | + public function setConnection($_name = "default") { |
|
39 | + if (!is_string($_name)) |
|
40 | 40 | throw new JException("Parameter must be a string.", 1); |
41 | - if(!isset($this->connection["$_name"])) |
|
41 | + if (!isset($this->connection["$_name"])) |
|
42 | 42 | throw new JException("This connection name does not exist.", 1); |
43 | 43 | $this->currentConnection = $this->connection["$_name"]; |
44 | 44 | } |
45 | - public function query( $_query ) { |
|
46 | - if(!is_string($_query)) |
|
45 | + public function query($_query) { |
|
46 | + if (!is_string($_query)) |
|
47 | 47 | throw new JException("Parameter must be a string.", 1); |
48 | 48 | try { |
49 | 49 | $temp = $this->currentConnection->database->query($_query); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | } |
53 | 53 | return $temp; |
54 | 54 | } |
55 | - public function queryInsert( $_query ) { |
|
56 | - if(!is_string($_query)) |
|
55 | + public function queryInsert($_query) { |
|
56 | + if (!is_string($_query)) |
|
57 | 57 | throw new JException("Parameter must be a string.", 1); |
58 | 58 | try { |
59 | 59 | $temp = $this->currentConnection->database->queryInsert($_query); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | } |
63 | 63 | return $temp; |
64 | 64 | } |
65 | - public function queryFetch( $_query ) { |
|
66 | - if(!is_string($_query)) |
|
65 | + public function queryFetch($_query) { |
|
66 | + if (!is_string($_query)) |
|
67 | 67 | throw new JException("Parameter must be a string.", 1); |
68 | 68 | try { |
69 | 69 | $temp = $this->currentConnection->database->queryFetch($_query); |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | } |
73 | 73 | return $temp; |
74 | 74 | } |
75 | - public function queryArray( $_query ) { |
|
76 | - if(!is_string($_query)) |
|
75 | + public function queryArray($_query) { |
|
76 | + if (!is_string($_query)) |
|
77 | 77 | throw new JException("Parameter must be a string.", 1); |
78 | 78 | try { |
79 | 79 | $temp = $this->currentConnection->database->queryArray($_query); |
@@ -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,28 +24,33 @@ 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); |
|
51 | + if(!is_string($_query)) { |
|
52 | + throw new JException("Parameter must be a string.", 1); |
|
53 | + } |
|
48 | 54 | try { |
49 | 55 | $temp = $this->currentConnection->database->query($_query); |
50 | 56 | } catch (Exception $e) { |
@@ -53,8 +59,9 @@ discard block |
||
53 | 59 | return $temp; |
54 | 60 | } |
55 | 61 | public function queryInsert( $_query ) { |
56 | - if(!is_string($_query)) |
|
57 | - throw new JException("Parameter must be a string.", 1); |
|
62 | + if(!is_string($_query)) { |
|
63 | + throw new JException("Parameter must be a string.", 1); |
|
64 | + } |
|
58 | 65 | try { |
59 | 66 | $temp = $this->currentConnection->database->queryInsert($_query); |
60 | 67 | } catch (Exception $e) { |
@@ -63,8 +70,9 @@ discard block |
||
63 | 70 | return $temp; |
64 | 71 | } |
65 | 72 | public function queryFetch( $_query ) { |
66 | - if(!is_string($_query)) |
|
67 | - throw new JException("Parameter must be a string.", 1); |
|
73 | + if(!is_string($_query)) { |
|
74 | + throw new JException("Parameter must be a string.", 1); |
|
75 | + } |
|
68 | 76 | try { |
69 | 77 | $temp = $this->currentConnection->database->queryFetch($_query); |
70 | 78 | } catch (Exception $e) { |
@@ -73,8 +81,9 @@ discard block |
||
73 | 81 | return $temp; |
74 | 82 | } |
75 | 83 | public function queryArray( $_query ) { |
76 | - if(!is_string($_query)) |
|
77 | - throw new JException("Parameter must be a string.", 1); |
|
84 | + if(!is_string($_query)) { |
|
85 | + throw new JException("Parameter must be a string.", 1); |
|
86 | + } |
|
78 | 87 | try { |
79 | 88 | $temp = $this->currentConnection->database->queryArray($_query); |
80 | 89 | } catch (Exception $e) { |
@@ -1,51 +1,51 @@ |
||
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 if(is_object($i)) |
|
43 | - echo "$_tab<b>object:</b> [Object]<br>"; |
|
44 | - else |
|
45 | - echo "$_tab<b>$k:</b> $i<br>"; |
|
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 if(is_object($i)) |
|
43 | + echo "$_tab<b>object:</b> [Object]<br>"; |
|
44 | + else |
|
45 | + echo "$_tab<b>$k:</b> $i<br>"; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | function htmlParser( $_str) { |
49 | - return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); |
|
49 | + return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); |
|
50 | 50 | } |
51 | 51 | ?> |
@@ -1,27 +1,27 @@ discard block |
||
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 | - function travelStringArray ( $_array, $_function ) { |
|
14 | + function travelStringArray($_array, $_function) { |
|
15 | 15 | if (is_array($_array)) { |
16 | 16 | foreach ($_array as $k => $v) { |
17 | 17 | $_array[$k] = travelStringArray($v, $_function); |
18 | 18 | } |
19 | - } else if (is_string ($_array)) { |
|
20 | - return call_user_func($_function,$_array); |
|
19 | + } else if (is_string($_array)) { |
|
20 | + return call_user_func($_function, $_array); |
|
21 | 21 | } |
22 | 22 | return $_array; |
23 | 23 | } |
24 | - function arrayDepth( $_array ) { |
|
24 | + function arrayDepth($_array) { |
|
25 | 25 | $maxDepth = 1; |
26 | 26 | foreach ($_array as $value) { |
27 | 27 | if (is_array($value)) { |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | } |
34 | 34 | return $maxDepth; |
35 | 35 | } |
36 | - function arrayDump( $_array, $_name = "Array", $_tab = " " ) { |
|
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 | 39 | foreach ($_array as $k => $i) |
40 | - if(is_array($i)) |
|
41 | - arrayDump( $i, $k, " $_tab" ); |
|
42 | - else if(is_object($i)) |
|
40 | + if (is_array($i)) |
|
41 | + arrayDump($i, $k, " $_tab"); |
|
42 | + else if (is_object($i)) |
|
43 | 43 | echo "$_tab<b>object:</b> [Object]<br>"; |
44 | 44 | else |
45 | 45 | echo "$_tab<b>$k:</b> $i<br>"; |
46 | 46 | } |
47 | 47 | |
48 | - function htmlParser( $_str) { |
|
48 | + function htmlParser($_str) { |
|
49 | 49 | return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); |
50 | 50 | } |
51 | 51 | ?> |
@@ -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) { |