@@ -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 | ?> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class JException extends Exception { |
| 3 | - static protected $escapeString = "|jate|"; |
|
| 4 | - public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
|
| 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"]; |
|
| 14 | - } |
|
| 15 | - public function __toString() { |
|
| 16 | - return JException::encode(JException::decode($this->message)); |
|
| 17 | - } |
|
| 18 | - static public function decode( $_message ) { |
|
| 19 | - $messageSplitted = explode(JException::$escapeString, $_message); |
|
| 20 | - if(count($messageSplitted) == 3) |
|
| 21 | - return $messageSplitted[1]; |
|
| 22 | - else |
|
| 23 | - return $_message; |
|
| 24 | - } |
|
| 25 | - static public function encode( $_message ) { |
|
| 26 | - $escape = JException::$escapeString; |
|
| 27 | - return "$escape$_message$escape"; |
|
| 3 | + static protected $escapeString = "|jate|"; |
|
| 4 | + public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
|
| 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"]; |
|
| 14 | + } |
|
| 15 | + public function __toString() { |
|
| 16 | + return JException::encode(JException::decode($this->message)); |
|
| 17 | + } |
|
| 18 | + static public function decode( $_message ) { |
|
| 19 | + $messageSplitted = explode(JException::$escapeString, $_message); |
|
| 20 | + if(count($messageSplitted) == 3) |
|
| 21 | + return $messageSplitted[1]; |
|
| 22 | + else |
|
| 23 | + return $_message; |
|
| 24 | + } |
|
| 25 | + static public function encode( $_message ) { |
|
| 26 | + $escape = JException::$escapeString; |
|
| 27 | + return "$escape$_message$escape"; |
|
| 28 | 28 | |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | ?> |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class ServerVars { |
| 3 | - public $server; |
|
| 4 | - public function __construct() { |
|
| 5 | - $this->server = []; |
|
| 6 | - $this->server["HTTP_HOST"] = $_SERVER["HTTP_HOST"]; |
|
| 7 | - $this->server["REQUEST_URI"] = $_SERVER["REQUEST_URI"]; |
|
| 8 | - $this->server["PHP_SELF"] = $_SERVER["PHP_SELF"]; |
|
| 9 | - $this->server["RELATIVE"] = str_replace("/index.php", "", $_SERVER["PHP_SELF"]); |
|
| 10 | - } |
|
| 3 | + public $server; |
|
| 4 | + public function __construct() { |
|
| 5 | + $this->server = []; |
|
| 6 | + $this->server["HTTP_HOST"] = $_SERVER["HTTP_HOST"]; |
|
| 7 | + $this->server["REQUEST_URI"] = $_SERVER["REQUEST_URI"]; |
|
| 8 | + $this->server["PHP_SELF"] = $_SERVER["PHP_SELF"]; |
|
| 9 | + $this->server["RELATIVE"] = str_replace("/index.php", "", $_SERVER["PHP_SELF"]); |
|
| 10 | + } |
|
| 11 | 11 | } |
| 12 | 12 | ?> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | jRequire("../Router/Router.php"); |
| 3 | 3 | jRequire("../JConfig/JConfig.php"); |
| 4 | 4 | class WebApp { |
| 5 | - private $router; |
|
| 6 | - private $misc; |
|
| 7 | - public function __construct() { |
|
| 8 | - $configPath = "config"; |
|
| 9 | - $this->misc = new JConfig("$configPath/app.json"); |
|
| 10 | - $this->router = new Router("$configPath/router.json", $this->misc->urlCaseSensitive); |
|
| 11 | - } |
|
| 12 | - public function draw() { |
|
| 13 | - $pageSelected = $this->router->getPage(); |
|
| 14 | - $currentPage = new $pageSelected[0](); |
|
| 15 | - $currentPage->setParameters(["app" => $this->misc, "page" => $pageSelected[1]]); |
|
| 16 | - $currentPage->init(); |
|
| 17 | - echo minifyOutput($currentPage->draw()); |
|
| 18 | - } |
|
| 5 | + private $router; |
|
| 6 | + private $misc; |
|
| 7 | + public function __construct() { |
|
| 8 | + $configPath = "config"; |
|
| 9 | + $this->misc = new JConfig("$configPath/app.json"); |
|
| 10 | + $this->router = new Router("$configPath/router.json", $this->misc->urlCaseSensitive); |
|
| 11 | + } |
|
| 12 | + public function draw() { |
|
| 13 | + $pageSelected = $this->router->getPage(); |
|
| 14 | + $currentPage = new $pageSelected[0](); |
|
| 15 | + $currentPage->setParameters(["app" => $this->misc, "page" => $pageSelected[1]]); |
|
| 16 | + $currentPage->init(); |
|
| 17 | + echo minifyOutput($currentPage->draw()); |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | ?> |