@@ -11,6 +11,10 @@ |
||
| 11 | 11 | function arrayHtmlParser($_array) { |
| 12 | 12 | return travelStringArray($_array,"htmlParser"); |
| 13 | 13 | } |
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * @param string $_function |
|
| 17 | + */ |
|
| 14 | 18 | function travelStringArray ( $_array, $_function ) { |
| 15 | 19 | if (is_array($_array)) { |
| 16 | 20 | foreach ($_array as $k => $v) { |
@@ -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) { |
@@ -17,6 +17,10 @@ |
||
| 17 | 17 | }); |
| 18 | 18 | return $temp; |
| 19 | 19 | } |
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @param Closure $_function |
|
| 23 | + */ |
|
| 20 | 24 | function fetchInSubFolder( $_dir = "./", $_function) { |
| 21 | 25 | $temp = []; |
| 22 | 26 | if (is_dir($_dir)) { |
@@ -21,10 +21,11 @@ discard block |
||
| 21 | 21 | $temp = []; |
| 22 | 22 | if (is_dir($_dir)) { |
| 23 | 23 | if ($dirOpened = opendir($_dir)) { |
| 24 | - while (($file = readdir($dirOpened)) !== false) |
|
| 25 | - if( ($file !='.')&&($file !='..') ) |
|
| 24 | + while (($file = readdir($dirOpened)) !== false) { |
|
| 25 | + if( ($file !='.')&&($file !='..') ) |
|
| 26 | 26 | if($_function($file)) |
| 27 | 27 | array_push($temp,$file); |
| 28 | + } |
|
| 28 | 29 | closedir($dirOpened); |
| 29 | 30 | } |
| 30 | 31 | } |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | } |
| 33 | 34 | function requireSubfolder( $_dir = "./" ) { |
| 34 | 35 | $temp = subFolderFile($_dir); |
| 35 | - foreach ($temp as $i) |
|
| 36 | - jRequire($_dir."/".$i); |
|
| 36 | + foreach ($temp as $i) { |
|
| 37 | + jRequire($_dir."/".$i); |
|
| 38 | + } |
|
| 37 | 39 | } |
| 38 | 40 | function require_js( $_dir = "./" ) { |
| 39 | 41 | $tempArray = []; |
| 40 | 42 | $temp = subFolderFile($_dir); |
| 41 | - foreach ($temp as $i) |
|
| 42 | - array_push($tempArray, $_dir."/".$i); |
|
| 43 | + foreach ($temp as $i) { |
|
| 44 | + array_push($tempArray, $_dir."/".$i); |
|
| 45 | + } |
|
| 43 | 46 | return $tempArray; |
| 44 | 47 | } |
| 45 | 48 | ?> |
@@ -1,6 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | interface ConnectionAdapterInterface { |
| 3 | + |
|
| 4 | + /** |
|
| 5 | + * @return void |
|
| 6 | + */ |
|
| 3 | 7 | public function __construct( $_srv, $_db, $_usr, $_pass); |
| 8 | + |
|
| 9 | + /** |
|
| 10 | + * @return boolean |
|
| 11 | + */ |
|
| 4 | 12 | public function query( $_query ); |
| 5 | 13 | public function queryFetch( $_query ); |
| 6 | 14 | public function queryArray( $_query ); |
@@ -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,6 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - if(!isset($GLOBALS["JATEPath"])) |
|
| 3 | - $GLOBALS["JATEPath"] = []; |
|
| 2 | + if(!isset($GLOBALS["JATEPath"])) { |
|
| 3 | + $GLOBALS["JATEPath"] = []; |
|
| 4 | + } |
|
| 4 | 5 | $commonLocations = [ |
| 5 | 6 | "bower_components/JATE/dist/" |
| 6 | 7 | , "vendor/xaberr/jate/dist/" |
@@ -9,13 +10,15 @@ discard block |
||
| 9 | 10 | , dirname(__FILE__)."/" |
| 10 | 11 | ]; |
| 11 | 12 | $jSuccess = false; |
| 12 | - foreach ($commonLocations as $path) |
|
| 13 | - if(file_exists("${path}jate/coreEngine.php")) { |
|
| 13 | + foreach ($commonLocations as $path) { |
|
| 14 | + if(file_exists("${path}jate/coreEngine.php")) { |
|
| 14 | 15 | array_push($GLOBALS["JATEPath"], $path); |
| 16 | + } |
|
| 15 | 17 | require_once("${path}jate/coreEngine.php"); |
| 16 | 18 | $jSuccess = true; |
| 17 | 19 | break; |
| 18 | 20 | } |
| 19 | - if( !$jSuccess ) |
|
| 20 | - throw new Exception("JATE can't find coreEngine.php."); |
|
| 21 | -?> |
|
| 21 | + if( !$jSuccess ) { |
|
| 22 | + throw new Exception("JATE can't find coreEngine.php."); |
|
| 23 | + } |
|
| 24 | + ?> |
|
@@ -1,4 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | + /** |
|
| 3 | + * @param string $_path |
|
| 4 | + */ |
|
| 2 | 5 | function requireComponent( $_path, $_local = true ) { |
| 3 | 6 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 4 | 7 | if(file_exists($path) && isPhp($path)) |
@@ -26,6 +29,10 @@ discard block |
||
| 26 | 29 | $info = pathinfo($_file); |
| 27 | 30 | return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
| 28 | 31 | } |
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @param string $_path |
|
| 35 | + */ |
|
| 29 | 36 | function requireModules( $_path, $_local = true ) { |
| 30 | 37 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 31 | 38 | $subFolders = subFolderDir($path); |
@@ -36,6 +43,10 @@ discard block |
||
| 36 | 43 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 37 | 44 | require_once( $path ); |
| 38 | 45 | } |
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param boolean $_local |
|
| 49 | + */ |
|
| 39 | 50 | function getJFolder( $_path, $_local, $_stack ) { |
| 40 | 51 | if($_local) { |
| 41 | 52 | $stackInfo = $_stack; |
@@ -1,36 +1,43 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | function requireComponent( $_path, $_local = true ) { |
| 3 | 3 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 4 | - if(file_exists($path) && isPhp($path)) |
|
| 5 | - jRequire($path, false, 0); |
|
| 6 | - else |
|
| 7 | - requireError($_path); |
|
| 4 | + if(file_exists($path) && isPhp($path)) { |
|
| 5 | + jRequire($path, false, 0); |
|
| 6 | + } else { |
|
| 7 | + requireError($_path); |
|
| 8 | + } |
|
| 8 | 9 | } |
| 9 | 10 | function requireComponents( $_path, $_local = true ) { |
| 10 | 11 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 11 | 12 | if(file_exists($path)) { |
| 12 | 13 | $files = subFolderFile($path); |
| 13 | - foreach ($files as $i) |
|
| 14 | - if(isPhp("$path/$i")) |
|
| 14 | + foreach ($files as $i) { |
|
| 15 | + if(isPhp("$path/$i")) |
|
| 15 | 16 | requireComponent($path."/".$i, false); |
| 16 | - } else |
|
| 17 | - requireError($_path); |
|
| 17 | + } |
|
| 18 | + } else { |
|
| 19 | + requireError($_path); |
|
| 20 | + } |
|
| 18 | 21 | } |
| 19 | 22 | function requireError( $_path ) { |
| 20 | 23 | global $DEBUG; |
| 21 | - if( $DEBUG == 1 ) |
|
| 22 | - echo "Error load ($_path)<br>"; |
|
| 24 | + if( $DEBUG == 1 ) { |
|
| 25 | + echo "Error load ($_path)<br>"; |
|
| 26 | + } |
|
| 23 | 27 | } |
| 24 | 28 | function isPhp ( $_file ) { |
| 25 | - if(!is_file($_file)) return false; |
|
| 29 | + if(!is_file($_file)) { |
|
| 30 | + return false; |
|
| 31 | + } |
|
| 26 | 32 | $info = pathinfo($_file); |
| 27 | 33 | return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
| 28 | 34 | } |
| 29 | 35 | function requireModules( $_path, $_local = true ) { |
| 30 | 36 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 31 | 37 | $subFolders = subFolderDir($path); |
| 32 | - foreach ($subFolders as $i) |
|
| 33 | - requireComponents("$path/$i", false); |
|
| 38 | + foreach ($subFolders as $i) { |
|
| 39 | + requireComponents("$path/$i", false); |
|
| 40 | + } |
|
| 34 | 41 | } |
| 35 | 42 | function jRequire( $_path, $_local = true ) { |
| 36 | 43 | $path = getJFolder($_path, $_local, debug_backtrace()); |
@@ -41,21 +48,24 @@ discard block |
||
| 41 | 48 | $stackInfo = $_stack; |
| 42 | 49 | $folder = dirname($stackInfo[0]["file"]); |
| 43 | 50 | $file = "$folder/$_path"; |
| 44 | - } else |
|
| 45 | - $file = $_path; |
|
| 51 | + } else { |
|
| 52 | + $file = $_path; |
|
| 53 | + } |
|
| 46 | 54 | return $file; |
| 47 | 55 | } |
| 48 | 56 | function requireModulesList( $_path ) { |
| 49 | - if(!file_exists($_path)) |
|
| 50 | - return; |
|
| 57 | + if(!file_exists($_path)) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 51 | 60 | $data = file_get_contents($_path); |
| 52 | 61 | $data = json_decode($data); |
| 53 | - if($data === NULL) |
|
| 54 | - throw new Exception("Error in the file format [$_path]", 1); |
|
| 62 | + if($data === NULL) { |
|
| 63 | + throw new Exception("Error in the file format [$_path]", 1); |
|
| 64 | + } |
|
| 55 | 65 | foreach ($data as $item) { |
| 56 | - if(substr($item, -1) == "*") |
|
| 57 | - requireModules(substr($item, 0, -2), false); |
|
| 58 | - else { |
|
| 66 | + if(substr($item, -1) == "*") { |
|
| 67 | + requireModules(substr($item, 0, -2), false); |
|
| 68 | + } else { |
|
| 59 | 69 | $path = getJFolder($item, false, debug_backtrace()); |
| 60 | 70 | requireComponents("$path", false); |
| 61 | 71 | } |
@@ -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; |