From 8af0c38eded66d9ec8fbb85731a2d98084a9e065 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 8 Jun 2010 12:36:06 -0300 Subject: Adding method has_subfields into BiblioIsis --- classes/BiblioIsisDb.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'classes') diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php index 8f341bd..06826a6 100644 --- a/classes/BiblioIsisDb.php +++ b/classes/BiblioIsisDb.php @@ -172,9 +172,16 @@ class BiblioIsisDb implements IsisDb { return $data; } - function subfield(&$data, $name, $key) { - if (isset($this->format['fields'][$key]['subfields']) && is_array($data[$name])) { + function has_subfields($key) { + if (isset($this->format['fields'][$key]['subfields'])) { + return TRUE; + } + + return FALSE; + } + function subfield(&$data, $name, $key) { + if ($this->has_subfields($key) && is_array($data[$name])) { foreach ($data[$name] as $subkey => $subvalue) { if (isset($this->format['fields'][$key]['subfields'][$subkey])) { $subname = $this->format['fields'][$key]['subfields'][$subkey]; @@ -188,7 +195,6 @@ class BiblioIsisDb implements IsisDb { unset($data[$name][$subkey]); } } - } } @@ -204,6 +210,10 @@ 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']) && -- cgit v1.2.3