Completed
Push — master ( a847da...ede37a )
by Federico
03:15
created
dist/jate/functions/errorHandler.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
   function jateErrorHandler($number, $message, $file, $line) {
3
-    if (!(error_reporting() & $number)) {
4
-      return false;
5
-    }
6
-    ob_end_clean();
7
-    $message = JException::decode($message);
8
-    echo "
3
+	if (!(error_reporting() & $number)) {
4
+	  return false;
5
+	}
6
+	ob_end_clean();
7
+	$message = JException::decode($message);
8
+	echo "
9 9
     <div id='jate-body'>
10 10
       <div id='jate-error'>
11 11
         <header>
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
       }
55 55
     </style>
56 56
     ";
57
-    exit(1);
58
-    return true;
57
+	exit(1);
58
+	return true;
59 59
   }
60 60
   function fatalErrorShutdownHandler() {
61
-    $last_error = error_get_last();
62
-    if ($last_error['type'] === E_ERROR) {
63
-      jateErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
64
-    }
61
+	$last_error = error_get_last();
62
+	if ($last_error['type'] === E_ERROR) {
63
+	  jateErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
64
+	}
65 65
   }
66 66
   set_error_handler('jateErrorHandler');
67 67
   register_shutdown_function('fatalErrorShutdownHandler');
Please login to merge, or discard this patch.
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/Connection.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,49 +1,49 @@
 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-mysql":
29
-        default:
30
-          $this->database = new PdoAdapterMysql($_srv, $_db, $_usr, $_pass);
31
-        break;
32
-      }
33
-      $this->info = [
34
-        "srv"  => $_srv,
35
-        "db"   => $_db,
36
-        "usr"  => $_usr,
37
-        "pass" => $_pass,
38
-        "type" => $_type
39
-      ];
40
-    }
41
-    protected function getConnectionType( $_type ) {
42
-      $array = (array)$_type;
43
-      foreach ($array as $key => $value)
44
-        if($value)
45
-          return $key;
46
-      return "pdo";
47
-    }
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-mysql":
29
+		default:
30
+		  $this->database = new PdoAdapterMysql($_srv, $_db, $_usr, $_pass);
31
+		break;
32
+	  }
33
+	  $this->info = [
34
+		"srv"  => $_srv,
35
+		"db"   => $_db,
36
+		"usr"  => $_usr,
37
+		"pass" => $_pass,
38
+		"type" => $_type
39
+	  ];
40
+	}
41
+	protected function getConnectionType( $_type ) {
42
+	  $array = (array)$_type;
43
+	  foreach ($array as $key => $value)
44
+		if($value)
45
+		  return $key;
46
+	  return "pdo";
47
+	}
48 48
   }
49 49
 ?>
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/Query/Query.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -3,104 +3,104 @@
 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
-        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
-      if($this->currentConnection == null)
49
-        throw new JException("No connection selected.", 1);
50
-      try {
51
-        $temp = $this->currentConnection->database->query($_query);
52
-      } catch (Exception $e) {
53
-        throw new JException($e->getMessage(), 1);
54
-      }
55
-      return $temp;
56
-    }
57
-    public function queryInsert( $_query ) {
58
-      if(!is_string($_query))
59
-        throw new JException("Parameter must be a string.", 1);
60
-      if($this->currentConnection == null)
61
-        throw new JException("No connection selected.", 1);
62
-      try {
63
-        $temp = $this->currentConnection->database->queryInsert($_query);
64
-      } catch (Exception $e) {
65
-        throw new JException($e->getMessage(), 1);
66
-      }
67
-      return $temp;
68
-    }
69
-    public function queryFetch( $_query ) {
70
-      if(!is_string($_query))
71
-        throw new JException("Parameter must be a string.", 1);
72
-      if($this->currentConnection == null)
73
-        throw new JException("No connection selected.", 1);
74
-      try {
75
-        $temp = $this->currentConnection->database->queryFetch($_query);
76
-      } catch (Exception $e) {
77
-        throw new JException($e->getMessage(), 1);
78
-      }
79
-      return $temp;
80
-    }
81
-    public function queryArray( $_query ) {
82
-      if(!is_string($_query))
83
-        throw new JException("Parameter must be a string.", 1);
84
-      if($this->currentConnection == null)
85
-        throw new JException("No connection selected.", 1);
86
-      try {
87
-        $temp = $this->currentConnection->database->queryArray($_query);
88
-      } catch (Exception $e) {
89
-        throw new JException($e->getMessage(), 1);
90
-      }
91
-      return $temp;
92
-    }
93
-    public function newTable( $_query ) {
94
-      if(!is_string($_query))
95
-        throw new JException("Parameter must be a string.", 1);
96
-      if($this->currentConnection == null)
97
-        throw new JException("No connection selected.", 1);
98
-      try {
99
-        $temp = $this->currentConnection->database->newTable($_query);
100
-      } catch (Exception $e) {
101
-        throw new JException($e->getMessage(), 1);
102
-      }
103
-      return $temp;
104
-    }
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
+	  if($this->currentConnection == null)
49
+		throw new JException("No connection selected.", 1);
50
+	  try {
51
+		$temp = $this->currentConnection->database->query($_query);
52
+	  } catch (Exception $e) {
53
+		throw new JException($e->getMessage(), 1);
54
+	  }
55
+	  return $temp;
56
+	}
57
+	public function queryInsert( $_query ) {
58
+	  if(!is_string($_query))
59
+		throw new JException("Parameter must be a string.", 1);
60
+	  if($this->currentConnection == null)
61
+		throw new JException("No connection selected.", 1);
62
+	  try {
63
+		$temp = $this->currentConnection->database->queryInsert($_query);
64
+	  } catch (Exception $e) {
65
+		throw new JException($e->getMessage(), 1);
66
+	  }
67
+	  return $temp;
68
+	}
69
+	public function queryFetch( $_query ) {
70
+	  if(!is_string($_query))
71
+		throw new JException("Parameter must be a string.", 1);
72
+	  if($this->currentConnection == null)
73
+		throw new JException("No connection selected.", 1);
74
+	  try {
75
+		$temp = $this->currentConnection->database->queryFetch($_query);
76
+	  } catch (Exception $e) {
77
+		throw new JException($e->getMessage(), 1);
78
+	  }
79
+	  return $temp;
80
+	}
81
+	public function queryArray( $_query ) {
82
+	  if(!is_string($_query))
83
+		throw new JException("Parameter must be a string.", 1);
84
+	  if($this->currentConnection == null)
85
+		throw new JException("No connection selected.", 1);
86
+	  try {
87
+		$temp = $this->currentConnection->database->queryArray($_query);
88
+	  } catch (Exception $e) {
89
+		throw new JException($e->getMessage(), 1);
90
+	  }
91
+	  return $temp;
92
+	}
93
+	public function newTable( $_query ) {
94
+	  if(!is_string($_query))
95
+		throw new JException("Parameter must be a string.", 1);
96
+	  if($this->currentConnection == null)
97
+		throw new JException("No connection selected.", 1);
98
+	  try {
99
+		$temp = $this->currentConnection->database->newTable($_query);
100
+	  } catch (Exception $e) {
101
+		throw new JException($e->getMessage(), 1);
102
+	  }
103
+	  return $temp;
104
+	}
105 105
   }
106 106
 ?>
Please login to merge, or discard this patch.