From ad8d8568b683e6935bec64abe88f79bf31706dd7 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 18 Aug 2010 15:22:43 -0300 Subject: Adding audit and finder classes, cleanup and organization --- classes/PhpIsisDb.php | 158 -------------------------------------------------- 1 file changed, 158 deletions(-) delete mode 100644 classes/PhpIsisDb.php (limited to 'classes/PhpIsisDb.php') diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php deleted file mode 100644 index 41319cc..0000000 --- a/classes/PhpIsisDb.php +++ /dev/null @@ -1,158 +0,0 @@ -format = $schema; - - // Setup $fdt. - foreach ($schema['fields'] as $field => $info) { - $this->fdt[$field] = $info['name']; - } - - // Open the database. - $name = $schema['db']['name']; - $this->db = isis_open(CinisisDb::file("$name/$name", 'db')); - } - - /** - * Read an entry. - * - * The PHP-Isis API doen't implement such feature so we - * have to emulate it by geting all entries and using - * isis_data_seek() to get the desired record. - * - * @see IsisDb::read() - * - * @todo - * Subfield handling. - */ - public function read($id) { - $results = isis_search('$', $this->db); - if (!isis_data_seek($results, $id - 1)) { - return FALSE; - } - - // Tag results. - $data = $this->tag(isis_fetch_array($results)); - - // Charset conversion. - array_walk_recursive($data, array(__CLASS__, 'charset')); - - // Return the result. - return $data; - } - - /** - * Return number of entries in the database. - * - * @see IsisDb::entries() - */ - public function entries() { - return isis_last_mfn($this->db); - } - - /** - * Return an example schema. - * - * @see IsisDb::example() - */ - public function example() { - return SchemaDb::example(); - } - - /** - * Check configuration. - * - * @see IsisDb::check() - */ - static function check($schema, $section = NULL) { - // Check API availability. - if (!function_exists('isis_open')) { - throw new Exception('Could not find function isis_open. Please check your php-isis installation.'); - return FALSE; - } - - // Check schema configuration. - return SchemaDb::check($schema, $section); - } - - /** - * Tag results of a db query. - * - * This function converts the keys of query result from field - * numbers to names. - * - * @param $results - * Database query results. - * - * @return - * Tagged database result. - */ - function tag($results) { - foreach ($results as $key => $value) { - if ($key != 'mfn') { - $name = $this->format['fields'][$key]['name']; - $data[$name] = $value; - } - } - - return $data; - } - - /** - * Charset conversion. - * - * Converts a string from the database charset to UTF-8. - * - * @param $data - * String to be converted. - * - * @return - * String converted to UTF-8. - */ - function charset(&$data) { - $data = iconv($this->format['db']['charset'], 'UTF-8', $data); - } - - /** - * Class logger. - * - * @param $message - * Log message. - */ - function logger($message) { - $this->log[] = $message; - } -} -- cgit v1.2.3