aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-04-08 11:55:02 -0300
committerSilvio <silvio@devlet.com.br>2010-04-08 11:55:02 -0300
commit1f0a5aa6b243e2b8bba66fc62bd029e2fa801e4b (patch)
tree42a49cfc1cf5422c5b42364b711c5b2597956cfb /classes
parent923e3c23d05dc235f26d8cc3d96e4f43e1754b32 (diff)
downloadcinisis-1f0a5aa6b243e2b8bba66fc62bd029e2fa801e4b.tar.gz
cinisis-1f0a5aa6b243e2b8bba66fc62bd029e2fa801e4b.tar.bz2
Sorting out folder schene
Diffstat (limited to 'classes')
-rw-r--r--classes/CinisisDb.php41
-rw-r--r--classes/PhpIsisDb.php4
2 files changed, 40 insertions, 5 deletions
diff --git a/classes/CinisisDb.php b/classes/CinisisDb.php
index 3dead27..eb09f9e 100644
--- a/classes/CinisisDb.php
+++ b/classes/CinisisDb.php
@@ -23,16 +23,16 @@ class CinisisDb {
* Optional parameter to set alternative config file or array
* with configuration.
*/
- function __construct($config = 'config/config.yaml') {
+ function __construct($config = NULL) {
try {
// Check main configuration.
- $config = $this->parse($config);
+ $config = $this->parse($this->file($config));
// Set database implementation.
$this->implementation = $config['implementation'] .'Db';
// Check database schema.
- $schema = $this->parse('schemas/'. $config['database'] .'.yaml', $this->implementation);
+ $schema = $this->parse($this->file($config['database'] .'.yaml', 'schemas'), $this->implementation);
} catch (Exception $e) {
echo __CLASS__ .' caught exception: ', $e->getMessage(), "\n";
return FALSE;
@@ -106,4 +106,39 @@ class CinisisDb {
return $config;
}
+
+ /**
+ * Get library base folder.
+ *
+ * @return
+ * Return base folder.
+ */
+ public function base() {
+ global $cinisis_basedir;
+ return $cinisis_basedir;
+ }
+
+ /**
+ * Get a file path.
+ *
+ * @param $config
+ * Config file name (either relative to the library or absolute).
+ *
+ * @param $section
+ * Config file section (ignored for absolute files).
+ *
+ * @return
+ * Return the assembled file path.
+ */
+ public function file($config = NULL, $section = 'config') {
+ // Check for NULL or relative config path.
+ if ($config == NULL) {
+ $config = "$section/config.yaml";
+ }
+ elseif (substr($config, 0, 1) != '/') {
+ $config = "$section/$config";
+ }
+
+ return call_user_func(array(__CLASS__, 'base')) .'/'. $config;
+ }
}
diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php
index a6b3c7e..c568743 100644
--- a/classes/PhpIsisDb.php
+++ b/classes/PhpIsisDb.php
@@ -32,7 +32,7 @@ class PhpIsisDb implements IsisDb {
// Open the database.
$name = $schema['db']['name'];
- $this->db = isis_open("db/$name/$name");
+ $this->db = isis_open(CinisisDb::file("$name/$name", 'db'));
}
/**
@@ -57,7 +57,7 @@ class PhpIsisDb implements IsisDb {
$data = $this->tag(isis_fetch_array($results));
// Charset conversion.
- array_walk_recursive($data, array('PhpIsisDb', 'charset'));
+ array_walk_recursive($data, array(__CLASS__, 'charset'));
// Return the result.
return $data;