@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | 2 | function requireComponent( $_path, $_local = true ) { |
3 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
4 | - if(file_exists($path) && isPhp($path)) |
|
5 | - jRequire($path, false, 0); |
|
6 | - else |
|
7 | - requireError($_path); |
|
3 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
4 | + if(file_exists($path) && isPhp($path)) |
|
5 | + jRequire($path, false, 0); |
|
6 | + else |
|
7 | + requireError($_path); |
|
8 | 8 | } |
9 | 9 | function requireComponents( $_path, $_local = true ) { |
10 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
11 | - if(file_exists($path)) { |
|
12 | - $files = subFolderFile($path); |
|
13 | - foreach ($files as $i) { |
|
14 | - if(isPhp($path."/".$i)) |
|
15 | - requireComponent($path."/".$i, false, 0); |
|
16 | - } |
|
17 | - } else |
|
18 | - requireError($_path); |
|
10 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
11 | + if(file_exists($path)) { |
|
12 | + $files = subFolderFile($path); |
|
13 | + foreach ($files as $i) { |
|
14 | + if(isPhp($path."/".$i)) |
|
15 | + requireComponent($path."/".$i, false, 0); |
|
16 | + } |
|
17 | + } else |
|
18 | + requireError($_path); |
|
19 | 19 | } |
20 | 20 | function requireError( $_path ) { |
21 | - global $DEBUG; |
|
22 | - if( $DEBUG == 1 ) |
|
23 | - echo "Error load ($_path)<br>"; |
|
21 | + global $DEBUG; |
|
22 | + if( $DEBUG == 1 ) |
|
23 | + echo "Error load ($_path)<br>"; |
|
24 | 24 | } |
25 | 25 | function isPhp ( $_file ) { |
26 | - if(!is_file($_file)) return false; |
|
27 | - $info = pathinfo($_file); |
|
28 | - return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
|
26 | + if(!is_file($_file)) return false; |
|
27 | + $info = pathinfo($_file); |
|
28 | + return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
|
29 | 29 | } |
30 | 30 | function requireModules( $_path, $_local = true ) { |
31 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
32 | - $subFolders = subFolderDir($path); |
|
33 | - foreach ($subFolders as $i) { |
|
34 | - requireComponents($path."/".$i, false, 0); |
|
35 | - } |
|
31 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
32 | + $subFolders = subFolderDir($path); |
|
33 | + foreach ($subFolders as $i) { |
|
34 | + requireComponents($path."/".$i, false, 0); |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | function jRequire( $_path, $_local = true ) { |
38 | - $path = getJFolder($_path, $_local, debug_backtrace()); |
|
39 | - require_once( $path ); |
|
38 | + $path = getJFolder($_path, $_local, debug_backtrace()); |
|
39 | + require_once( $path ); |
|
40 | 40 | } |
41 | 41 | function getJFolder( $_path, $_local, $_stack ) { |
42 | - if($_local) { |
|
43 | - $stackInfo = $_stack; |
|
44 | - $folder = dirname($stackInfo[0]["file"]); |
|
45 | - $file = "$folder/$_path"; |
|
46 | - } else |
|
47 | - $file = $_path; |
|
48 | - return $file; |
|
42 | + if($_local) { |
|
43 | + $stackInfo = $_stack; |
|
44 | + $folder = dirname($stackInfo[0]["file"]); |
|
45 | + $file = "$folder/$_path"; |
|
46 | + } else |
|
47 | + $file = $_path; |
|
48 | + return $file; |
|
49 | 49 | } |
50 | 50 | ?> |
@@ -1,45 +1,45 @@ |
||
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 |
|
43 | - echo "$_tab<b>$k:</b> $i<br>"; |
|
44 | - } |
|
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 |
|
43 | + echo "$_tab<b>$k:</b> $i<br>"; |
|
44 | + } |
|
45 | 45 | ?> |
@@ -1,45 +1,45 @@ |
||
1 | 1 | <?php |
2 | 2 | function subFolder( $_dir = "./" ) { |
3 | - $temp = fetchInSubFolder($_dir, function() { |
|
4 | - return true; |
|
5 | - }); |
|
6 | - return $temp; |
|
3 | + $temp = fetchInSubFolder($_dir, function() { |
|
4 | + return true; |
|
5 | + }); |
|
6 | + return $temp; |
|
7 | 7 | } |
8 | 8 | function subFolderFile( $_dir = "./" ) { |
9 | - $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
10 | - return !is_dir($_file); |
|
11 | - }); |
|
12 | - return $temp; |
|
9 | + $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
10 | + return !is_dir($_file); |
|
11 | + }); |
|
12 | + return $temp; |
|
13 | 13 | } |
14 | 14 | function subFolderDir( $_dir = "./" ) { |
15 | - $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
16 | - return !is_file($_file); |
|
17 | - }); |
|
18 | - return $temp; |
|
15 | + $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
16 | + return !is_file($_file); |
|
17 | + }); |
|
18 | + return $temp; |
|
19 | 19 | } |
20 | 20 | function fetchInSubFolder( $_dir = "./", $_function) { |
21 | - $temp = []; |
|
22 | - if (is_dir($_dir)) { |
|
23 | - if ($dirOpened = opendir($_dir)) { |
|
24 | - while (($file = readdir($dirOpened)) !== false) |
|
25 | - if( ($file !='.')&&($file !='..') ) |
|
26 | - if($_function($file)) |
|
27 | - array_push($temp,$file); |
|
28 | - closedir($dirOpened); |
|
29 | - } |
|
30 | - } |
|
31 | - return $temp; |
|
21 | + $temp = []; |
|
22 | + if (is_dir($_dir)) { |
|
23 | + if ($dirOpened = opendir($_dir)) { |
|
24 | + while (($file = readdir($dirOpened)) !== false) |
|
25 | + if( ($file !='.')&&($file !='..') ) |
|
26 | + if($_function($file)) |
|
27 | + array_push($temp,$file); |
|
28 | + closedir($dirOpened); |
|
29 | + } |
|
30 | + } |
|
31 | + return $temp; |
|
32 | 32 | } |
33 | 33 | function requireSubfolder( $_dir = "./" ) { |
34 | - $temp = subFolderFile($_dir); |
|
35 | - foreach ($temp as $i) |
|
36 | - jRequire($_dir."/".$i); |
|
34 | + $temp = subFolderFile($_dir); |
|
35 | + foreach ($temp as $i) |
|
36 | + jRequire($_dir."/".$i); |
|
37 | 37 | } |
38 | 38 | function require_js( $_dir = "./" ) { |
39 | - $tempArray = []; |
|
40 | - $temp = subFolderFile($_dir); |
|
41 | - foreach ($temp as $i) |
|
42 | - array_push($tempArray, $_dir."/".$i); |
|
43 | - return $tempArray; |
|
39 | + $tempArray = []; |
|
40 | + $temp = subFolderFile($_dir); |
|
41 | + foreach ($temp as $i) |
|
42 | + array_push($tempArray, $_dir."/".$i); |
|
43 | + return $tempArray; |
|
44 | 44 | } |
45 | 45 | ?> |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | function htmlParser( $_str) { |
3 | - return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); |
|
3 | + return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); |
|
4 | 4 | } |
5 | 5 | ?> |
@@ -1,56 +1,56 @@ |
||
1 | 1 | <?php |
2 | 2 | function getGitLog( $_dir = "./" ) { |
3 | - if(!file_exists($_dir)) |
|
4 | - return []; |
|
5 | - $currentDir = getcwd(); |
|
6 | - chdir($_dir); |
|
7 | - $gitHistory = []; |
|
8 | - $gitLogs = []; |
|
9 | - $gitPath = str_replace('\\', '/', exec("git rev-parse --show-toplevel")); |
|
10 | - $rootPath = str_replace('\\', '/', getcwd ()); |
|
11 | - $lastHash = null; |
|
12 | - if( $gitPath != $rootPath ) { |
|
13 | - chdir($currentDir); |
|
14 | - return []; |
|
15 | - } |
|
16 | - exec("git log --decorate=full --tags", $gitLogs); |
|
17 | - foreach ($gitLogs as $line) { |
|
18 | - $line = trim($line); |
|
19 | - if (!empty($line)) { |
|
20 | - if (strpos($line, 'commit') === 0) { |
|
21 | - $hash = explode(' ', $line); |
|
22 | - $hash = trim(end($hash)); |
|
23 | - $gitHistory[$hash] = [ |
|
24 | - 'tag' => '-1.0.0', |
|
25 | - 'author' => '', |
|
26 | - 'date' => '', |
|
27 | - 'message' => '' |
|
28 | - ]; |
|
29 | - $lastHash = $hash; |
|
30 | - if (strpos($line, 'tag') !== false) { |
|
31 | - $tag = explode(':', $line); |
|
32 | - $tag = explode('/', $tag[1]); |
|
33 | - $tag = explode(',', $tag[2]); |
|
34 | - $tag = explode(')', $tag[0]); |
|
35 | - $tag = trim($tag[0]); |
|
36 | - $gitHistory[$lastHash]['tag'] = $tag; |
|
37 | - } |
|
38 | - } |
|
39 | - else if (strpos($line, 'Author') === 0) { |
|
40 | - $author = explode(':', $line); |
|
41 | - $author = trim(end($author)); |
|
42 | - $gitHistory[$lastHash]['author'] = $author; |
|
43 | - } |
|
44 | - else if (strpos($line, 'Date') === 0) { |
|
45 | - $date = explode(':', $line, 2); |
|
46 | - $date = trim(end($date)); |
|
47 | - $gitHistory[$lastHash]['date'] = date('d/m/Y H:i:s A', strtotime($date)); |
|
48 | - } |
|
49 | - else |
|
50 | - $gitHistory[$lastHash]['message'] .= "$line<br>"; |
|
51 | - } |
|
52 | - } |
|
53 | - chdir($currentDir); |
|
54 | - return $gitHistory; |
|
3 | + if(!file_exists($_dir)) |
|
4 | + return []; |
|
5 | + $currentDir = getcwd(); |
|
6 | + chdir($_dir); |
|
7 | + $gitHistory = []; |
|
8 | + $gitLogs = []; |
|
9 | + $gitPath = str_replace('\\', '/', exec("git rev-parse --show-toplevel")); |
|
10 | + $rootPath = str_replace('\\', '/', getcwd ()); |
|
11 | + $lastHash = null; |
|
12 | + if( $gitPath != $rootPath ) { |
|
13 | + chdir($currentDir); |
|
14 | + return []; |
|
15 | + } |
|
16 | + exec("git log --decorate=full --tags", $gitLogs); |
|
17 | + foreach ($gitLogs as $line) { |
|
18 | + $line = trim($line); |
|
19 | + if (!empty($line)) { |
|
20 | + if (strpos($line, 'commit') === 0) { |
|
21 | + $hash = explode(' ', $line); |
|
22 | + $hash = trim(end($hash)); |
|
23 | + $gitHistory[$hash] = [ |
|
24 | + 'tag' => '-1.0.0', |
|
25 | + 'author' => '', |
|
26 | + 'date' => '', |
|
27 | + 'message' => '' |
|
28 | + ]; |
|
29 | + $lastHash = $hash; |
|
30 | + if (strpos($line, 'tag') !== false) { |
|
31 | + $tag = explode(':', $line); |
|
32 | + $tag = explode('/', $tag[1]); |
|
33 | + $tag = explode(',', $tag[2]); |
|
34 | + $tag = explode(')', $tag[0]); |
|
35 | + $tag = trim($tag[0]); |
|
36 | + $gitHistory[$lastHash]['tag'] = $tag; |
|
37 | + } |
|
38 | + } |
|
39 | + else if (strpos($line, 'Author') === 0) { |
|
40 | + $author = explode(':', $line); |
|
41 | + $author = trim(end($author)); |
|
42 | + $gitHistory[$lastHash]['author'] = $author; |
|
43 | + } |
|
44 | + else if (strpos($line, 'Date') === 0) { |
|
45 | + $date = explode(':', $line, 2); |
|
46 | + $date = trim(end($date)); |
|
47 | + $gitHistory[$lastHash]['date'] = date('d/m/Y H:i:s A', strtotime($date)); |
|
48 | + } |
|
49 | + else |
|
50 | + $gitHistory[$lastHash]['message'] .= "$line<br>"; |
|
51 | + } |
|
52 | + } |
|
53 | + chdir($currentDir); |
|
54 | + return $gitHistory; |
|
55 | 55 | } |
56 | 56 | ?> |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | <div class="row" style="margin-top:20px;"> |
16 | 16 | <div class="col-lg-12"> |
17 | 17 | <?php |
18 | - $nPerCol = 6; |
|
19 | - $max = 12; |
|
20 | - $dim = $max / $nPerCol; |
|
21 | - $cont = 0; |
|
22 | - $percent; |
|
23 | - foreach (getGitLog() as $i) { |
|
24 | - $cont++; |
|
25 | - if($cont % $nPerCol == 1) |
|
26 | - echo '<div class="row">'; |
|
27 | - if(isset($i["tag"])) { |
|
28 | - $percent = explode(".",$i["tag"]); |
|
29 | - $percent = 100 * intval($percent[0]) + 10 * intval($percent[1]) + intval($percent[2]); |
|
30 | - } |
|
31 | - ?> |
|
18 | + $nPerCol = 6; |
|
19 | + $max = 12; |
|
20 | + $dim = $max / $nPerCol; |
|
21 | + $cont = 0; |
|
22 | + $percent; |
|
23 | + foreach (getGitLog() as $i) { |
|
24 | + $cont++; |
|
25 | + if($cont % $nPerCol == 1) |
|
26 | + echo '<div class="row">'; |
|
27 | + if(isset($i["tag"])) { |
|
28 | + $percent = explode(".",$i["tag"]); |
|
29 | + $percent = 100 * intval($percent[0]) + 10 * intval($percent[1]) + intval($percent[2]); |
|
30 | + } |
|
31 | + ?> |
|
32 | 32 | <div class="col-lg-<?=$dim?>"> |
33 | 33 | <div class="well well-sm miniblock"> |
34 | 34 | <div class="autor"><b>Autor:</b> <?=$i["author"]?><br></div> |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | </div> |
45 | 45 | </div> |
46 | 46 | <?php |
47 | - if($cont % $nPerCol == 0) |
|
48 | - echo '</div>'; |
|
49 | - } ?> |
|
47 | + if($cont % $nPerCol == 0) |
|
48 | + echo '</div>'; |
|
49 | + } ?> |
|
50 | 50 | </div> |
51 | 51 | </div> |
52 | 52 | </div> |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | if(!isset($GLOBALS["JATEPath"])) |
3 | - $GLOBALS["JATEPath"] = []; |
|
3 | + $GLOBALS["JATEPath"] = []; |
|
4 | 4 | $commonLocations = [ |
5 | - "bower_components/JATE/dist/" |
|
6 | - , "vendor/xaberr/jate/dist/" |
|
7 | - , "../../dist/" |
|
8 | - , "../dist/" |
|
9 | - , dirname(__FILE__)."/" |
|
5 | + "bower_components/JATE/dist/" |
|
6 | + , "vendor/xaberr/jate/dist/" |
|
7 | + , "../../dist/" |
|
8 | + , "../dist/" |
|
9 | + , dirname(__FILE__)."/" |
|
10 | 10 | ]; |
11 | 11 | $jSuccess = false; |
12 | 12 | foreach ($commonLocations as $path) |
13 | - if(file_exists("${path}jate/coreEngine.php")) { |
|
14 | - array_push($GLOBALS["JATEPath"], $path); |
|
15 | - require_once("${path}jate/coreEngine.php"); |
|
16 | - $jSuccess = true; |
|
17 | - break; |
|
18 | - } |
|
13 | + if(file_exists("${path}jate/coreEngine.php")) { |
|
14 | + array_push($GLOBALS["JATEPath"], $path); |
|
15 | + require_once("${path}jate/coreEngine.php"); |
|
16 | + $jSuccess = true; |
|
17 | + break; |
|
18 | + } |
|
19 | 19 | if( !$jSuccess ) |
20 | - throw new Exception("JATE can't find coreEngine.php."); |
|
20 | + throw new Exception("JATE can't find coreEngine.php."); |
|
21 | 21 | ?> |
@@ -2,60 +2,60 @@ |
||
2 | 2 | declare( strict_types = 1 ); |
3 | 3 | // backward compatibility |
4 | 4 | if (!class_exists('\PHPUnit\Framework\TestCase')) { |
5 | - class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); |
|
5 | + class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); |
|
6 | 6 | } |
7 | 7 | use PHPUnit\Framework\TestCase; |
8 | 8 | |
9 | 9 | final class ModuleTest extends TestCase { |
10 | - public function testAddFile() { |
|
11 | - $this->expectException(InvalidArgumentException::class); |
|
12 | - $module = new Module(); |
|
13 | - $module->addFile(123); |
|
14 | - } |
|
15 | - public function testAddFileRequired() { |
|
16 | - $this->expectException(InvalidArgumentException::class); |
|
17 | - $module = new Module(); |
|
18 | - $module->addFileRequired(123); |
|
19 | - } |
|
20 | - public function testAddFiles() { |
|
21 | - $this->expectException(InvalidArgumentException::class); |
|
22 | - $module = new Module(); |
|
23 | - $module->addFiles("/file.php"); |
|
24 | - } |
|
25 | - public function testAddFilesRequired() { |
|
26 | - $this->expectException(InvalidArgumentException::class); |
|
27 | - $module = new Module(); |
|
28 | - $module->addFilesRequired("/file.php"); |
|
29 | - } |
|
30 | - public function testAddModuleClass() { |
|
31 | - $this->expectException(InvalidArgumentException::class); |
|
32 | - $module = new Module(); |
|
33 | - $module->addModule(123); |
|
34 | - } |
|
35 | - public function testAddModuleNoModule() { |
|
36 | - $this->expectException(InvalidArgumentException::class); |
|
37 | - $module = new Module(); |
|
38 | - $module->addModule((object)[1,2,3]); |
|
39 | - } |
|
40 | - public function testAddModules() { |
|
41 | - $this->expectException(InvalidArgumentException::class); |
|
42 | - $module = new Module(); |
|
43 | - $module->addModules("Module"); |
|
44 | - } |
|
45 | - public function testGetCss() { |
|
46 | - $module = new Module(); |
|
47 | - $module->addFiles(["1.css","2.js","3.css","4.js"]); |
|
48 | - $this->assertEquals(["1.css","3.css"], $module->getCss()); |
|
49 | - } |
|
50 | - public function testGetJs() { |
|
51 | - $module = new Module(); |
|
52 | - $module->addFiles(["1.css","2.js","3.css","4.js"]); |
|
53 | - $this->assertEquals(["2.js","4.js"], $module->getJs()); |
|
54 | - } |
|
55 | - public function testGetJsVariables() { |
|
56 | - $module = new Module(); |
|
57 | - $module->addFiles(["1.css",["variable","2"],"3.css","4.js"]); |
|
58 | - $this->assertEquals([["variable","2"]], $module->getJsVariables()); |
|
59 | - } |
|
10 | + public function testAddFile() { |
|
11 | + $this->expectException(InvalidArgumentException::class); |
|
12 | + $module = new Module(); |
|
13 | + $module->addFile(123); |
|
14 | + } |
|
15 | + public function testAddFileRequired() { |
|
16 | + $this->expectException(InvalidArgumentException::class); |
|
17 | + $module = new Module(); |
|
18 | + $module->addFileRequired(123); |
|
19 | + } |
|
20 | + public function testAddFiles() { |
|
21 | + $this->expectException(InvalidArgumentException::class); |
|
22 | + $module = new Module(); |
|
23 | + $module->addFiles("/file.php"); |
|
24 | + } |
|
25 | + public function testAddFilesRequired() { |
|
26 | + $this->expectException(InvalidArgumentException::class); |
|
27 | + $module = new Module(); |
|
28 | + $module->addFilesRequired("/file.php"); |
|
29 | + } |
|
30 | + public function testAddModuleClass() { |
|
31 | + $this->expectException(InvalidArgumentException::class); |
|
32 | + $module = new Module(); |
|
33 | + $module->addModule(123); |
|
34 | + } |
|
35 | + public function testAddModuleNoModule() { |
|
36 | + $this->expectException(InvalidArgumentException::class); |
|
37 | + $module = new Module(); |
|
38 | + $module->addModule((object)[1,2,3]); |
|
39 | + } |
|
40 | + public function testAddModules() { |
|
41 | + $this->expectException(InvalidArgumentException::class); |
|
42 | + $module = new Module(); |
|
43 | + $module->addModules("Module"); |
|
44 | + } |
|
45 | + public function testGetCss() { |
|
46 | + $module = new Module(); |
|
47 | + $module->addFiles(["1.css","2.js","3.css","4.js"]); |
|
48 | + $this->assertEquals(["1.css","3.css"], $module->getCss()); |
|
49 | + } |
|
50 | + public function testGetJs() { |
|
51 | + $module = new Module(); |
|
52 | + $module->addFiles(["1.css","2.js","3.css","4.js"]); |
|
53 | + $this->assertEquals(["2.js","4.js"], $module->getJs()); |
|
54 | + } |
|
55 | + public function testGetJsVariables() { |
|
56 | + $module = new Module(); |
|
57 | + $module->addFiles(["1.css",["variable","2"],"3.css","4.js"]); |
|
58 | + $this->assertEquals([["variable","2"]], $module->getJsVariables()); |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | ?> |
@@ -2,51 +2,51 @@ |
||
2 | 2 | jRequire("../Module/Module.php"); |
3 | 3 | requireComponents("Adapters"); |
4 | 4 | class Connection extends Module { |
5 | - public $database; |
|
6 | - public $info; |
|
7 | - public function __construct() { |
|
8 | - parent::__construct(); |
|
9 | - $args = func_get_args(); |
|
10 | - $count = func_num_args(); |
|
11 | - if (method_exists($this,$func='__construct'.$count)) |
|
12 | - call_user_func_array(array($this,$func),$args); |
|
13 | - } |
|
14 | - public function __construct0() { |
|
15 | - $this->database = null; |
|
16 | - } |
|
17 | - public function __construct4 ( $_srv, $_db, $_usr, $_pass ) { |
|
18 | - $this->setConnection($_srv, $_db, $_usr, $_pass, "pdo"); |
|
19 | - } |
|
20 | - public function __construct5 ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
21 | - $type = $this->getConnectionType($_type); |
|
22 | - $this->setConnection($_srv, $_db, $_usr, $_pass, $type); |
|
23 | - } |
|
24 | - protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
25 | - switch ($_type) { |
|
26 | - case "mysqli": |
|
27 | - $this->database = new ConnectionMysqliAdapter($_srv, $_db, $_usr, $_pass); |
|
28 | - break; |
|
29 | - case "postgresql": |
|
30 | - $this->database = new ConnectionPostgresqlAdapter($_srv, $_db, $_usr, $_pass); |
|
31 | - break; |
|
32 | - default: |
|
33 | - $this->database = new ConnectionPdoAdapter($_srv, $_db, $_usr, $_pass); |
|
34 | - break; |
|
35 | - } |
|
36 | - $this->setConnectionParameters( $_srv, $_db, $_usr, $_pass); |
|
37 | - } |
|
38 | - protected function getConnectionType( $_type ) { |
|
39 | - foreach ($_type as $key => $value) |
|
40 | - if($value) |
|
41 | - return $key; |
|
42 | - return "pdo"; |
|
43 | - } |
|
44 | - protected function setConnectionParameters( $_srv, $_db, $_usr, $_pass) { |
|
45 | - $this->info = []; |
|
46 | - $this->info["server"] = $_srv; |
|
47 | - $this->info["database"] = $_db; |
|
48 | - $this->info["user"] = $_usr; |
|
49 | - $this->info["password"] = $_pass; |
|
50 | - } |
|
5 | + public $database; |
|
6 | + public $info; |
|
7 | + public function __construct() { |
|
8 | + parent::__construct(); |
|
9 | + $args = func_get_args(); |
|
10 | + $count = func_num_args(); |
|
11 | + if (method_exists($this,$func='__construct'.$count)) |
|
12 | + call_user_func_array(array($this,$func),$args); |
|
13 | + } |
|
14 | + public function __construct0() { |
|
15 | + $this->database = null; |
|
16 | + } |
|
17 | + public function __construct4 ( $_srv, $_db, $_usr, $_pass ) { |
|
18 | + $this->setConnection($_srv, $_db, $_usr, $_pass, "pdo"); |
|
19 | + } |
|
20 | + public function __construct5 ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
21 | + $type = $this->getConnectionType($_type); |
|
22 | + $this->setConnection($_srv, $_db, $_usr, $_pass, $type); |
|
23 | + } |
|
24 | + protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
25 | + switch ($_type) { |
|
26 | + case "mysqli": |
|
27 | + $this->database = new ConnectionMysqliAdapter($_srv, $_db, $_usr, $_pass); |
|
28 | + break; |
|
29 | + case "postgresql": |
|
30 | + $this->database = new ConnectionPostgresqlAdapter($_srv, $_db, $_usr, $_pass); |
|
31 | + break; |
|
32 | + default: |
|
33 | + $this->database = new ConnectionPdoAdapter($_srv, $_db, $_usr, $_pass); |
|
34 | + break; |
|
35 | + } |
|
36 | + $this->setConnectionParameters( $_srv, $_db, $_usr, $_pass); |
|
37 | + } |
|
38 | + protected function getConnectionType( $_type ) { |
|
39 | + foreach ($_type as $key => $value) |
|
40 | + if($value) |
|
41 | + return $key; |
|
42 | + return "pdo"; |
|
43 | + } |
|
44 | + protected function setConnectionParameters( $_srv, $_db, $_usr, $_pass) { |
|
45 | + $this->info = []; |
|
46 | + $this->info["server"] = $_srv; |
|
47 | + $this->info["database"] = $_db; |
|
48 | + $this->info["user"] = $_usr; |
|
49 | + $this->info["password"] = $_pass; |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | ?> |