@@ -2,10 +2,10 @@ |
||
2 | 2 | jRequire("PdoAdapter.php"); |
3 | 3 | class PdoMemoryAdapter extends PdoAdapter { |
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 = new PDO("sqlite::memory:"); |
8 | - } catch( Exception $e ) { |
|
8 | + } catch (Exception $e) { |
|
9 | 9 | throw new JException($e->getMessage()); |
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,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,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 | ]); |
@@ -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 | ?> |
@@ -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); |
@@ -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); |
@@ -3,26 +3,26 @@ |
||
3 | 3 | static protected $escapeString = "|jate|"; |
4 | 4 | public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
5 | 5 | parent::__construct($_message, $_code, $_previous); |
6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
6 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
7 | 7 | $this->file = debug_backtrace()[$_level]["file"]; |
8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
8 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
9 | 9 | $this->line = debug_backtrace()[$_level]["line"]; |
10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
10 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
11 | 11 | $this->function = debug_backtrace()[$_level]["function"]; |
12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
12 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
13 | 13 | $this->class = debug_backtrace()[$_level]["class"]; |
14 | 14 | } |
15 | 15 | public function __toString() { |
16 | 16 | return JException::encode(JException::decode($this->message)); |
17 | 17 | } |
18 | - static public function decode( $_message ) { |
|
18 | + static public function decode($_message) { |
|
19 | 19 | $messageSplitted = explode(JException::$escapeString, $_message); |
20 | - if(count($messageSplitted) == 3) |
|
20 | + if (count($messageSplitted) == 3) |
|
21 | 21 | return $messageSplitted[1]; |
22 | 22 | else |
23 | 23 | return $_message; |
24 | 24 | } |
25 | - static public function encode( $_message ) { |
|
25 | + static public function encode($_message) { |
|
26 | 26 | $escape = JException::$escapeString; |
27 | 27 | return "$escape$_message$escape"; |
28 | 28 |
@@ -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 | ?> |