aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-04-01 13:59:55 -0300
committerSilvio <silvio@devlet.com.br>2010-04-01 13:59:55 -0300
commit0e67880b97909c08021ef5fa1075082cfc9b6e26 (patch)
tree8bc75fbff2a87c2fa8718d6b36bd29e6687c05c9
parent0bfdde221663dae880797b74da45e2f66a4caada (diff)
downloadcinisis-0e67880b97909c08021ef5fa1075082cfc9b6e26.tar.gz
cinisis-0e67880b97909c08021ef5fa1075082cfc9b6e26.tar.bz2
Charset support on PhpIsisDb
-rw-r--r--classes/CinIsis.php3
-rw-r--r--classes/PhpIsisDb.php25
-rw-r--r--index.php11
-rw-r--r--schemas/anu10.yaml1
-rw-r--r--schemas/tupi.yaml1
5 files changed, 40 insertions, 1 deletions
diff --git a/classes/CinIsis.php b/classes/CinIsis.php
index 300bd61..77804c4 100644
--- a/classes/CinIsis.php
+++ b/classes/CinIsis.php
@@ -21,6 +21,9 @@ class CinIsis {
*
* @param $config
* Alternative config file (defaults to 'config/config.yaml').
+ *
+ * @todo
+ * Config check.
*/
function __construct($config = NULL) {
if ($config == NULL) {
diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php
index 169f832..b8f6566 100644
--- a/classes/PhpIsisDb.php
+++ b/classes/PhpIsisDb.php
@@ -50,6 +50,10 @@ class PhpIsisDb implements IsisDb {
return FALSE;
}
+ // Charset conversion.
+ array_walk_recursive($data, array('PhpIsisDb', 'charset'));
+
+ // Return the result.
return $this->tag(isis_fetch_array($results));
}
@@ -90,6 +94,25 @@ class PhpIsisDb implements IsisDb {
$data[$name] = $value;
}
}
+
return $data;
- }
+ }
+
+ /**
+ * Charset conversion.
+ *
+ * Converts a string from the database charset to UTF-8.
+ *
+ * @param $data
+ * String to be converted.
+ *
+ * @param $count
+ * Data index. Currently unused.
+ *
+ * @return
+ * String converted to UTF-8.
+ */
+ function charset($data, $count) {
+ return iconv($data, $this->format['db']['charset'], 'UTF-8');
+ }
}
diff --git a/index.php b/index.php
index 42140d6..ff40fd8 100644
--- a/index.php
+++ b/index.php
@@ -23,6 +23,16 @@ spl_autoload_register("cinisis_autoload");
// Get a db instance.
$isis = new CinIsis();
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=cp850" />
+ </head>
+ <body>
+<?php
+
// Test connection.
if ($isis->db) {
$result = $isis->db->read(1);
@@ -36,3 +46,4 @@ if ($isis->db) {
}
?>
+</body>
diff --git a/schemas/anu10.yaml b/schemas/anu10.yaml
index 630135b..9900f0e 100644
--- a/schemas/anu10.yaml
+++ b/schemas/anu10.yaml
@@ -1,6 +1,7 @@
---
db:
name: anu10
+ charset: cp850
fields:
1:
name: Periodico
diff --git a/schemas/tupi.yaml b/schemas/tupi.yaml
index e7904cb..a970c54 100644
--- a/schemas/tupi.yaml
+++ b/schemas/tupi.yaml
@@ -1,6 +1,7 @@
---
db:
name: tupi
+ charset: cp850
fields:
1:
name: cod.titulo