Test Failed
Push — master ( cc6e3b...03f570 )
by Federico
02:11
created
dist/jate/modules/Angular/Angular.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
   requireComponent("../Html/Html.php");
3 3
   class Angular extends Html {
4
-    public function init() {
5
-      header("Access-Control-Allow-Origin: *");
6
-      header("Content-Type: application/json; charset=UTF-8");
7
-    }
8
-    public function draw() {}
4
+	public function init() {
5
+	  header("Access-Control-Allow-Origin: *");
6
+	  header("Content-Type: application/json; charset=UTF-8");
7
+	}
8
+	public function draw() {}
9 9
   }
10 10
 ?>
Please login to merge, or discard this patch.
dist/jate/functions/block.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -2,64 +2,64 @@
 block discarded – undo
2 2
   jRequire("../modules/Parser/Parser.php");
3 3
   jRequire("../modules/JException/JException.php");
4 4
   function jBlock() {
5
-    return ob_start();
5
+	return ob_start();
6 6
   }
7 7
 
8 8
   function jBlockClose( $_type = "html", $_parameters = [] ) {
9
-    return jBlockEnd($_type, $_parameters);
9
+	return jBlockEnd($_type, $_parameters);
10 10
   }
11 11
 
12 12
   function jBlockFile( $_path, $_parameters = [] ) {
13
-    try {
14
-      $temp = Parser::parseFile($_path, $_parameters);
15
-    } catch (Exception $e) {
16
-      throw new JException($e->getMessage(), 1);
17
-    }
18
-    return $temp;
13
+	try {
14
+	  $temp = Parser::parseFile($_path, $_parameters);
15
+	} catch (Exception $e) {
16
+	  throw new JException($e->getMessage(), 1);
17
+	}
18
+	return $temp;
19 19
   }
20 20
 
21 21
   function view( $_path, $_parameters = [] ) {
22
-    try {
23
-      $temp = jBlockFile("bundles/views/$_path", $_parameters);
24
-    } catch (Exception $e) {
25
-      throw new JException($e->getMessage(), 1);
26
-    }
27
-    return $temp;
22
+	try {
23
+	  $temp = jBlockFile("bundles/views/$_path", $_parameters);
24
+	} catch (Exception $e) {
25
+	  throw new JException($e->getMessage(), 1);
26
+	}
27
+	return $temp;
28 28
   }
29 29
 
30 30
   function sql( $_path, $_parameters = [] ) {
31
-    try {
32
-      $temp = jBlockFileMan("bundles/sql/$_path", "sql", $_parameters);
33
-    } catch (Exception $e) {
34
-      throw new JException($e->getMessage(), 1);
35
-    }
36
-    return $temp;
31
+	try {
32
+	  $temp = jBlockFileMan("bundles/sql/$_path", "sql", $_parameters);
33
+	} catch (Exception $e) {
34
+	  throw new JException($e->getMessage(), 1);
35
+	}
36
+	return $temp;
37 37
   }
38 38
 
39 39
   function jBlockFileMan( $_path, $_type, $_parameters = [] ) {
40
-    try {
41
-      $temp = Parser::parseFileMan($_path, $_parameters, $_type);
42
-    } catch (Exception $e) {
43
-      throw new JException($e->getMessage(), 1);
44
-    }
45
-    return $temp;
40
+	try {
41
+	  $temp = Parser::parseFileMan($_path, $_parameters, $_type);
42
+	} catch (Exception $e) {
43
+	  throw new JException($e->getMessage(), 1);
44
+	}
45
+	return $temp;
46 46
   }
47 47
 
48 48
   function jBlockEnd( $_type = "html", $_parameters = [] ) {
49
-    $text = ob_get_clean();
50
-    try {
51
-      $temp = Parser::parseText($text, $_parameters, $_type);
52
-    } catch (Exception $e) {
53
-      throw new JException($e->getMessage(), 1);
54
-    }
55
-    return $temp;
49
+	$text = ob_get_clean();
50
+	try {
51
+	  $temp = Parser::parseText($text, $_parameters, $_type);
52
+	} catch (Exception $e) {
53
+	  throw new JException($e->getMessage(), 1);
54
+	}
55
+	return $temp;
56 56
   }
57 57
 
58 58
   function minifyOutput($_buffer) {
59
-    $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' );
60
-    $replace = array ( '>', '<', '\\1' );
61
-    if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1)
62
-      $_buffer = preg_replace($search, $replace, utf8_decode($_buffer));
63
-    return utf8_encode($_buffer);
59
+	$search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' );
60
+	$replace = array ( '>', '<', '\\1' );
61
+	if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1)
62
+	  $_buffer = preg_replace($search, $replace, utf8_decode($_buffer));
63
+	return utf8_encode($_buffer);
64 64
   }
65 65
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Parser.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -2,67 +2,67 @@
 block discarded – undo
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
-        case "sql":
11
-          $parser = new TwigAdapter();
12
-        break;
13
-        case "jate":
14
-          $parser = new JTagAdapter();
15
-        break;
16
-        case 'jade':
17
-        case "pug":
18
-          $parser = new PugAdapter();
19
-        break;
20
-        case "md":
21
-        case "markdown":
22
-        case "parsedown":
23
-          $parser = new ParsedownAdapter();
24
-        break;
25
-        default:
26
-          $parser = -1;
27
-        break;
28
-      }
29
-      return $parser;
30
-    }
31
-    public static function parseText( $_text, $_parameters = [], $_type = "html" ) {
32
-      if(!is_string($_text) || !is_string($_type))
33
-        throw new JException("Parameter must be a string.");
34
-      if(!is_array($_parameters))
35
-        throw new JException("Parameter must be an array.");
36
-      $parser = self::setParser($_type);
37
-      if($parser === -1)
38
-        return $_text;
39
-      return $parser->drawText($_text, $_parameters);
40
-    }
41
-    public static function parseFileMan( $_path, $_parameters = [], $_type = "html"  ) {
42
-      if(!is_string($_path))
43
-        throw new JException("Parameter must be a string.");
44
-      if(!file_exists($_path))
45
-        throw new JException("File [$_path] not found.");
46
-      $string = file_get_contents($_path);
47
-      try {
48
-        $text = self::parseText($string, $_parameters, $_type);
49
-      } catch (Exception $e) {
50
-        throw new JException($e->getMessage());
51
-      }
52
-      return $text;
53
-    }
54
-    public static function parseFile( $_path, $_parameters = [] ) {
55
-      if(!is_string($_path))
56
-        throw new JException("Parameter must be a string.");
57
-      $extension = explode(".", $_path);
58
-      $extension = $extension[count($extension)-1];
59
-      $extension = strtolower($extension);
60
-      try {
61
-        $text = self::parseFileMan($_path, $_parameters, $extension);
62
-      } catch (Exception $e) {
63
-        throw new JException($e->getMessage());
64
-      }
65
-      return $text;
66
-    }
5
+	private static function setParser ( $_type ) {
6
+	  $parser = null;
7
+	  $_type = strtolower($_type);
8
+	  switch ($_type) {
9
+		case "twig":
10
+		case "sql":
11
+		  $parser = new TwigAdapter();
12
+		break;
13
+		case "jate":
14
+		  $parser = new JTagAdapter();
15
+		break;
16
+		case 'jade':
17
+		case "pug":
18
+		  $parser = new PugAdapter();
19
+		break;
20
+		case "md":
21
+		case "markdown":
22
+		case "parsedown":
23
+		  $parser = new ParsedownAdapter();
24
+		break;
25
+		default:
26
+		  $parser = -1;
27
+		break;
28
+	  }
29
+	  return $parser;
30
+	}
31
+	public static function parseText( $_text, $_parameters = [], $_type = "html" ) {
32
+	  if(!is_string($_text) || !is_string($_type))
33
+		throw new JException("Parameter must be a string.");
34
+	  if(!is_array($_parameters))
35
+		throw new JException("Parameter must be an array.");
36
+	  $parser = self::setParser($_type);
37
+	  if($parser === -1)
38
+		return $_text;
39
+	  return $parser->drawText($_text, $_parameters);
40
+	}
41
+	public static function parseFileMan( $_path, $_parameters = [], $_type = "html"  ) {
42
+	  if(!is_string($_path))
43
+		throw new JException("Parameter must be a string.");
44
+	  if(!file_exists($_path))
45
+		throw new JException("File [$_path] not found.");
46
+	  $string = file_get_contents($_path);
47
+	  try {
48
+		$text = self::parseText($string, $_parameters, $_type);
49
+	  } catch (Exception $e) {
50
+		throw new JException($e->getMessage());
51
+	  }
52
+	  return $text;
53
+	}
54
+	public static function parseFile( $_path, $_parameters = [] ) {
55
+	  if(!is_string($_path))
56
+		throw new JException("Parameter must be a string.");
57
+	  $extension = explode(".", $_path);
58
+	  $extension = $extension[count($extension)-1];
59
+	  $extension = strtolower($extension);
60
+	  try {
61
+		$text = self::parseFileMan($_path, $_parameters, $extension);
62
+	  } catch (Exception $e) {
63
+		throw new JException($e->getMessage());
64
+	  }
65
+	  return $text;
66
+	}
67 67
   }
68 68
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Connection/Adapters/PdoAdapterSqLiteMemory.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
   jRequire("PdoAdapterMysql.php");
3 3
   class PdoAdapterSqLiteMemory extends PdoAdapterMysql {
4
-      public $connection;
5
-      public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
-        try {
7
-          $this->connection = new PDO("sqlite::memory:");
8
-        } catch( Exception $e ) {
9
-          throw new JException($e->getMessage());
10
-        }
11
-      }
12
-      public function newTable( $_sql ) {
13
-        try {
14
-          $temp = $this->connection->exec($_sql);
15
-        } catch (Exception $e) {
16
-          throw new JException($e->getMessage());
17
-        }
18
-        return $temp;
19
-      }
4
+	  public $connection;
5
+	  public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
+		try {
7
+		  $this->connection = new PDO("sqlite::memory:");
8
+		} catch( Exception $e ) {
9
+		  throw new JException($e->getMessage());
10
+		}
11
+	  }
12
+	  public function newTable( $_sql ) {
13
+		try {
14
+		  $temp = $this->connection->exec($_sql);
15
+		} catch (Exception $e) {
16
+		  throw new JException($e->getMessage());
17
+		}
18
+		return $temp;
19
+	  }
20 20
   }
21 21
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Connection/Adapters/PdoAdapterMysql.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@
 block discarded – undo
1 1
 <?php
2 2
   jRequire("ConnectionInterface.php");
3 3
   class PdoAdapterMysql implements ConnectionAdapterInterface {
4
-      public $connection;
5
-      public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
-        try {
7
-          $connection = "mysql:host=$_srv;dbname=$_db";
8
-          $this->connection = new PDO( $connection, $_usr, $_pass, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"] );
9
-        } catch( Exception $e ) {
10
-          throw new JException($e->getMessage());
11
-        }
12
-      }
13
-      public function query( $_query ) {
14
-        $this->stdQuery($_query);
15
-        return true;
16
-      }
17
-      public function queryInsert( $_query ) {
18
-        $this->stdQuery($_query);
19
-        return $this->connection->lastInsertId();
20
-      }
21
-      public function queryFetch( $_query ) {
22
-        $temp = $this->stdQuery($_query);
23
-        return $temp->fetchAll(PDO::FETCH_ASSOC);
24
-      }
25
-      public function queryArray( $_query ) {
26
-        $temp = $this->stdQuery($_query);
27
-        return $temp->fetchAll(PDO::FETCH_COLUMN, 0);
28
-      }
29
-      protected function stdQuery( $_query ) {
30
-        $database = $this->connection;
31
-        $query = $database->prepare($_query);
32
-        $result = $query->execute();
33
-        if(!$result)
34
-          throw new JException(json_encode([
35
-            "query" => $_query,
36
-            "error" => [
37
-              $query->errorInfo(),
38
-              $database->errorInfo()
39
-            ]
40
-          ]));
41
-        return $query;
42
-      }
4
+	  public $connection;
5
+	  public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
+		try {
7
+		  $connection = "mysql:host=$_srv;dbname=$_db";
8
+		  $this->connection = new PDO( $connection, $_usr, $_pass, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"] );
9
+		} catch( Exception $e ) {
10
+		  throw new JException($e->getMessage());
11
+		}
12
+	  }
13
+	  public function query( $_query ) {
14
+		$this->stdQuery($_query);
15
+		return true;
16
+	  }
17
+	  public function queryInsert( $_query ) {
18
+		$this->stdQuery($_query);
19
+		return $this->connection->lastInsertId();
20
+	  }
21
+	  public function queryFetch( $_query ) {
22
+		$temp = $this->stdQuery($_query);
23
+		return $temp->fetchAll(PDO::FETCH_ASSOC);
24
+	  }
25
+	  public function queryArray( $_query ) {
26
+		$temp = $this->stdQuery($_query);
27
+		return $temp->fetchAll(PDO::FETCH_COLUMN, 0);
28
+	  }
29
+	  protected function stdQuery( $_query ) {
30
+		$database = $this->connection;
31
+		$query = $database->prepare($_query);
32
+		$result = $query->execute();
33
+		if(!$result)
34
+		  throw new JException(json_encode([
35
+			"query" => $_query,
36
+			"error" => [
37
+			  $query->errorInfo(),
38
+			  $database->errorInfo()
39
+			]
40
+		  ]));
41
+		return $query;
42
+	  }
43 43
   }
44 44
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Connection/Adapters/PdoAdapterSqLiteFile.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
   jRequire("PdoAdapterMysql.php");
3 3
   class PdoAdapterSqLiteFile extends PdoAdapterMysql {
4
-      public $connection;
5
-      public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
-        try {
7
-          $this->connection = new PDO("sqlite:$_srv");
8
-        } catch( Exception $e ) {
9
-          throw new JException($e->getMessage());
10
-        }
11
-      }
12
-      public function newTable( $_sql ) {
13
-        try {
14
-          $temp = $this->connection->exec($_sql);
15
-        } catch (Exception $e) {
16
-          throw new JException($e->getMessage());
17
-        }
18
-        return $temp;
19
-      }
4
+	  public $connection;
5
+	  public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
+		try {
7
+		  $this->connection = new PDO("sqlite:$_srv");
8
+		} catch( Exception $e ) {
9
+		  throw new JException($e->getMessage());
10
+		}
11
+	  }
12
+	  public function newTable( $_sql ) {
13
+		try {
14
+		  $temp = $this->connection->exec($_sql);
15
+		} catch (Exception $e) {
16
+		  throw new JException($e->getMessage());
17
+		}
18
+		return $temp;
19
+	  }
20 20
   }
21 21
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Connection/Connection.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@
 block discarded – undo
1 1
 <?php
2 2
   requireComponents("Adapters");
3 3
   class Connection {
4
-    public $database;
5
-    public $info;
6
-    public function __construct( $_object ) {
7
-      if(!is_object($_object))
8
-        throw new JException("Parameter must be an object.");
9
-      $this->setConnection(
10
-        $_object->server,
11
-        $_object->database,
12
-        $_object->user,
13
-        $_object->password,
14
-        $this->getConnectionType($_object->engine)
15
-      );
16
-    }
17
-    protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) {
18
-      switch ($_type) {
19
-        case "mysqli":
20
-          $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass);
21
-        break;
22
-        case "postgresql":
23
-          $this->database = new PostgresqlAdapter($_srv, $_db, $_usr, $_pass);
24
-        break;
25
-        case "pdo-sqlite-memory":
26
-          $this->database = new PdoAdapterSqLiteMemory($_srv, $_db, $_usr, $_pass);
27
-        break;
28
-        case "pdo-sqlite-file":
29
-          $this->database = new PdoAdapterSqLiteFile($_srv, $_db, $_usr, $_pass);
30
-        break;
31
-        case "pdo-mysql":
32
-        default:
33
-          $this->database = new PdoAdapterMysql($_srv, $_db, $_usr, $_pass);
34
-        break;
35
-      }
36
-      $this->info = [
37
-        "srv"  => $_srv,
38
-        "db"   => $_db,
39
-        "usr"  => $_usr,
40
-        "pass" => $_pass,
41
-        "type" => $_type
42
-      ];
43
-    }
44
-    protected function getConnectionType( $_type ) {
45
-      $array = (array)$_type;
46
-      foreach ($array as $key => $value)
47
-        if($value)
48
-          return $key;
49
-      return "default";
50
-    }
4
+	public $database;
5
+	public $info;
6
+	public function __construct( $_object ) {
7
+	  if(!is_object($_object))
8
+		throw new JException("Parameter must be an object.");
9
+	  $this->setConnection(
10
+		$_object->server,
11
+		$_object->database,
12
+		$_object->user,
13
+		$_object->password,
14
+		$this->getConnectionType($_object->engine)
15
+	  );
16
+	}
17
+	protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) {
18
+	  switch ($_type) {
19
+		case "mysqli":
20
+		  $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass);
21
+		break;
22
+		case "postgresql":
23
+		  $this->database = new PostgresqlAdapter($_srv, $_db, $_usr, $_pass);
24
+		break;
25
+		case "pdo-sqlite-memory":
26
+		  $this->database = new PdoAdapterSqLiteMemory($_srv, $_db, $_usr, $_pass);
27
+		break;
28
+		case "pdo-sqlite-file":
29
+		  $this->database = new PdoAdapterSqLiteFile($_srv, $_db, $_usr, $_pass);
30
+		break;
31
+		case "pdo-mysql":
32
+		default:
33
+		  $this->database = new PdoAdapterMysql($_srv, $_db, $_usr, $_pass);
34
+		break;
35
+	  }
36
+	  $this->info = [
37
+		"srv"  => $_srv,
38
+		"db"   => $_db,
39
+		"usr"  => $_usr,
40
+		"pass" => $_pass,
41
+		"type" => $_type
42
+	  ];
43
+	}
44
+	protected function getConnectionType( $_type ) {
45
+	  $array = (array)$_type;
46
+	  foreach ($array as $key => $value)
47
+		if($value)
48
+		  return $key;
49
+	  return "default";
50
+	}
51 51
   }
52 52
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Query/Query.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -3,101 +3,101 @@
 block discarded – undo
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
-      } catch (Exception $e) {
32
-        throw new JException($e->getMessage(), 1);
33
-      }
34
-    }
35
-    public function setConnection( $_name = "default" ) {
36
-      if(!is_string($_name))
37
-        throw new JException("Parameter must be a string.", 1);
38
-      if(!isset($this->connection["$_name"]))
39
-        throw new JException("This connection name does not exist.", 1);
40
-      $this->currentConnection = $this->connection["$_name"];
41
-    }
42
-    public function query( $_query ) {
43
-      if(!is_string($_query))
44
-        throw new JException("Parameter must be a string.", 1);
45
-      if($this->currentConnection == null)
46
-        throw new JException("No connection selected.", 1);
47
-      try {
48
-        $temp = $this->currentConnection->database->query($_query);
49
-      } catch (Exception $e) {
50
-        throw new JException($e->getMessage(), 1);
51
-      }
52
-      return $temp;
53
-    }
54
-    public function queryInsert( $_query ) {
55
-      if(!is_string($_query))
56
-        throw new JException("Parameter must be a string.", 1);
57
-      if($this->currentConnection == null)
58
-        throw new JException("No connection selected.", 1);
59
-      try {
60
-        $temp = $this->currentConnection->database->queryInsert($_query);
61
-      } catch (Exception $e) {
62
-        throw new JException($e->getMessage(), 1);
63
-      }
64
-      return $temp;
65
-    }
66
-    public function queryFetch( $_query ) {
67
-      if(!is_string($_query))
68
-        throw new JException("Parameter must be a string.", 1);
69
-      if($this->currentConnection == null)
70
-        throw new JException("No connection selected.", 1);
71
-      try {
72
-        $temp = $this->currentConnection->database->queryFetch($_query);
73
-      } catch (Exception $e) {
74
-        throw new JException($e->getMessage(), 1);
75
-      }
76
-      return $temp;
77
-    }
78
-    public function queryArray( $_query ) {
79
-      if(!is_string($_query))
80
-        throw new JException("Parameter must be a string.", 1);
81
-      if($this->currentConnection == null)
82
-        throw new JException("No connection selected.", 1);
83
-      try {
84
-        $temp = $this->currentConnection->database->queryArray($_query);
85
-      } catch (Exception $e) {
86
-        throw new JException($e->getMessage(), 1);
87
-      }
88
-      return $temp;
89
-    }
90
-    public function newTable( $_query ) {
91
-      if(!is_string($_query))
92
-        throw new JException("Parameter must be a string.", 1);
93
-      if($this->currentConnection == null)
94
-        throw new JException("No connection selected.", 1);
95
-      try {
96
-        $temp = $this->currentConnection->database->newTable($_query);
97
-      } catch (Exception $e) {
98
-        throw new JException($e->getMessage(), 1);
99
-      }
100
-      return $temp;
101
-    }
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
+	  } catch (Exception $e) {
32
+		throw new JException($e->getMessage(), 1);
33
+	  }
34
+	}
35
+	public function setConnection( $_name = "default" ) {
36
+	  if(!is_string($_name))
37
+		throw new JException("Parameter must be a string.", 1);
38
+	  if(!isset($this->connection["$_name"]))
39
+		throw new JException("This connection name does not exist.", 1);
40
+	  $this->currentConnection = $this->connection["$_name"];
41
+	}
42
+	public function query( $_query ) {
43
+	  if(!is_string($_query))
44
+		throw new JException("Parameter must be a string.", 1);
45
+	  if($this->currentConnection == null)
46
+		throw new JException("No connection selected.", 1);
47
+	  try {
48
+		$temp = $this->currentConnection->database->query($_query);
49
+	  } catch (Exception $e) {
50
+		throw new JException($e->getMessage(), 1);
51
+	  }
52
+	  return $temp;
53
+	}
54
+	public function queryInsert( $_query ) {
55
+	  if(!is_string($_query))
56
+		throw new JException("Parameter must be a string.", 1);
57
+	  if($this->currentConnection == null)
58
+		throw new JException("No connection selected.", 1);
59
+	  try {
60
+		$temp = $this->currentConnection->database->queryInsert($_query);
61
+	  } catch (Exception $e) {
62
+		throw new JException($e->getMessage(), 1);
63
+	  }
64
+	  return $temp;
65
+	}
66
+	public function queryFetch( $_query ) {
67
+	  if(!is_string($_query))
68
+		throw new JException("Parameter must be a string.", 1);
69
+	  if($this->currentConnection == null)
70
+		throw new JException("No connection selected.", 1);
71
+	  try {
72
+		$temp = $this->currentConnection->database->queryFetch($_query);
73
+	  } catch (Exception $e) {
74
+		throw new JException($e->getMessage(), 1);
75
+	  }
76
+	  return $temp;
77
+	}
78
+	public function queryArray( $_query ) {
79
+	  if(!is_string($_query))
80
+		throw new JException("Parameter must be a string.", 1);
81
+	  if($this->currentConnection == null)
82
+		throw new JException("No connection selected.", 1);
83
+	  try {
84
+		$temp = $this->currentConnection->database->queryArray($_query);
85
+	  } catch (Exception $e) {
86
+		throw new JException($e->getMessage(), 1);
87
+	  }
88
+	  return $temp;
89
+	}
90
+	public function newTable( $_query ) {
91
+	  if(!is_string($_query))
92
+		throw new JException("Parameter must be a string.", 1);
93
+	  if($this->currentConnection == null)
94
+		throw new JException("No connection selected.", 1);
95
+	  try {
96
+		$temp = $this->currentConnection->database->newTable($_query);
97
+	  } catch (Exception $e) {
98
+		throw new JException($e->getMessage(), 1);
99
+	  }
100
+	  return $temp;
101
+	}
102 102
   }
103 103
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Module/Module.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -2,45 +2,45 @@
 block discarded – undo
2 2
   jRequire("../Query/Query.php");
3 3
   jRequire("../File/File.php");
4 4
   class Module {
5
-    use Query {
6
-      Query::__construct as private __queryConstruct;
7
-      Query::addConnectionMan as private __addConnectionMan;
8
-    }
9
-    use File {
10
-      File::__construct as private __fileConstruct;
11
-    }
12
-    public $name;
13
-    public $modules;
14
-    public function __construct() {
15
-      $this->name    = get_class($this);
16
-      $this->modules = [];
17
-      $this->__queryConstruct();
18
-      $this->__fileConstruct();
19
-    }
20
-    public function addModules( $_modules ) {
21
-      if(!is_array($_modules))
22
-        throw new JException("Parameter must be an array.");
23
-      foreach ($_modules as $value)
24
-        $this->addModule($value);
25
-    }
26
-    public function addModule( $_module ) {
27
-      if(!is_object($_module))
28
-        throw new JException("Parameter must be a object.");
29
-      if(! is_subclass_of ($_module, "Module"))
30
-        throw new JException("Parameter must be a object inherited from Module object.");
31
-      $this->modules[$_module->name] = $_module;
32
-      if($this->currentConnection)
33
-        $this->modules[$_module->name]->addConnectionMan($this->currentConnection);
34
-    }
35
-    public function addConnectionMan( $_connection, $_name = "default") {
36
-      try {
37
-        $this->__addConnectionMan($_connection, $_name);
38
-        foreach ($this->modules as &$module)
39
-          if(isset($this->currentConnection))
40
-            $module->addConnectionMan($this->currentConnection, $_name);
41
-      } catch (Exception $e) {
42
-        throw new JException($e->getMessage(), 1);
43
-      }
44
-    }
5
+	use Query {
6
+	  Query::__construct as private __queryConstruct;
7
+	  Query::addConnectionMan as private __addConnectionMan;
8
+	}
9
+	use File {
10
+	  File::__construct as private __fileConstruct;
11
+	}
12
+	public $name;
13
+	public $modules;
14
+	public function __construct() {
15
+	  $this->name    = get_class($this);
16
+	  $this->modules = [];
17
+	  $this->__queryConstruct();
18
+	  $this->__fileConstruct();
19
+	}
20
+	public function addModules( $_modules ) {
21
+	  if(!is_array($_modules))
22
+		throw new JException("Parameter must be an array.");
23
+	  foreach ($_modules as $value)
24
+		$this->addModule($value);
25
+	}
26
+	public function addModule( $_module ) {
27
+	  if(!is_object($_module))
28
+		throw new JException("Parameter must be a object.");
29
+	  if(! is_subclass_of ($_module, "Module"))
30
+		throw new JException("Parameter must be a object inherited from Module object.");
31
+	  $this->modules[$_module->name] = $_module;
32
+	  if($this->currentConnection)
33
+		$this->modules[$_module->name]->addConnectionMan($this->currentConnection);
34
+	}
35
+	public function addConnectionMan( $_connection, $_name = "default") {
36
+	  try {
37
+		$this->__addConnectionMan($_connection, $_name);
38
+		foreach ($this->modules as &$module)
39
+		  if(isset($this->currentConnection))
40
+			$module->addConnectionMan($this->currentConnection, $_name);
41
+	  } catch (Exception $e) {
42
+		throw new JException($e->getMessage(), 1);
43
+	  }
44
+	}
45 45
   }
46 46
 ?>
Please login to merge, or discard this patch.