@@ -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); |
@@ -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; |
@@ -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."); |
@@ -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 | } |
@@ -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(); |
@@ -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 | ?> |
@@ -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."); |
@@ -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); |
@@ -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) { |
@@ -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) { |