diff options
author | Silvio <silvio@devlet.com.br> | 2010-06-08 16:29:44 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-06-08 16:29:44 -0300 |
commit | ae73a1735df1a9ba3753073fe3201a7ec7604edb (patch) | |
tree | bd15494f64b45fe4fe686d4f071895adb4f1c638 | |
parent | c03504bb8db8297d730d92d62bb811a46d798166 (diff) | |
download | cinisis-ae73a1735df1a9ba3753073fe3201a7ec7604edb.tar.gz cinisis-ae73a1735df1a9ba3753073fe3201a7ec7604edb.tar.bz2 |
Misc changes
-rw-r--r-- | classes/BiblioIsisDb.php | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php index 2da17e2..9b98e3a 100644 --- a/classes/BiblioIsisDb.php +++ b/classes/BiblioIsisDb.php @@ -22,6 +22,12 @@ class BiblioIsisDb implements IsisDb { var $format; /** + * @var $log + * Class action log. + */ + var $log; + + /** * Constructor. * * @see IsisDb::__construct() @@ -40,6 +46,13 @@ class BiblioIsisDb implements IsisDb { } /** + * Class logger. + */ + function logger($message) { + $this->log[] = $message; + } + + /** * Send requests to the perl backend. * * @param $method @@ -146,12 +159,6 @@ class BiblioIsisDb implements IsisDb { * * @return * Tagged database result. - * - * @todo - * Alternative handling for when $key is not set. - * - * @fixme - * Repetitive fields are not being tagged. */ function tag($results) { foreach ($results as $key => $value) { @@ -171,6 +178,15 @@ class BiblioIsisDb implements IsisDb { return $data; } + /** + * Checks whether a field has subfields. + * + * @param $key + * Field key. + * + * @return + * True if has subfields, false otherwise. + */ function has_subfields($key) { if (isset($this->format['fields'][$key]['subfields'])) { return TRUE; @@ -179,7 +195,21 @@ class BiblioIsisDb implements IsisDb { return FALSE; } + /** + * Switch keys on subfields. + * + * @param $key + * Field key. + * + * @param $value + * Dataset. + */ function subfields_switch($key, &$value) { + // TODO: check this condition. + if (!is_array($value)) { + return; + } + foreach ($value as $subkey => $subvalue) { if (isset($this->format['fields'][$key]['subfields'][$subkey])) { $subname = $this->format['fields'][$key]['subfields'][$subkey]; @@ -195,6 +225,15 @@ class BiblioIsisDb implements IsisDb { } } + /** + * Makes subfield substitution in a dataset. + * + * @param $key + * Field key. + * + * @param $value + * Dataset. + */ function subfields($name, $key) { if ($this->has_subfields($key) && is_array($name)) { if ($this->is_repetitive($key, $name)) { @@ -223,14 +262,13 @@ class BiblioIsisDb implements IsisDb { * * @return * True if repetitive, false otherwise. - * - * @todo - * Warn on configuration/data mismatch ("config says that - * $field is non repetitive but data shows a repetition"). */ function is_repetitive($field, $value) { if (isset($this->format['fields'][$field]['repeat']) && - $this->format['fields'][$field]['repeat'] == FALSE && is_array($value)) { + $this->format['fields'][$field]['repeat'] == FALSE) { + if (!is_array($value)) { + $this->logger("$field is configured as non repetitive but data shows a repetition for value $value"); + } return FALSE; } |