diff options
author | Silvio <silvio@devlet.com.br> | 2010-06-08 12:55:04 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-06-08 12:55:04 -0300 |
commit | c03504bb8db8297d730d92d62bb811a46d798166 (patch) | |
tree | 48de97ea8e0ae217f73115ea8a8a04daae9e719d | |
parent | 8af0c38eded66d9ec8fbb85731a2d98084a9e065 (diff) | |
download | cinisis-c03504bb8db8297d730d92d62bb811a46d798166.tar.gz cinisis-c03504bb8db8297d730d92d62bb811a46d798166.tar.bz2 |
Fixing subfield handling on BiblioIsis
-rw-r--r-- | classes/BiblioIsisDb.php | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php index 06826a6..2da17e2 100644 --- a/classes/BiblioIsisDb.php +++ b/classes/BiblioIsisDb.php @@ -161,15 +161,14 @@ class BiblioIsisDb implements IsisDb { continue; } + // Format, repetition and subfield handling. $name = $this->format['fields'][$key]['name']; $data[$name] = $this->repetition($key, $value); - - // Subfield handling. - $this->subfield($data, $name, $key); + $data[$name] = $this->subfields($data[$name], $key); } } - return $data; + return $data; } function has_subfields($key) { @@ -180,22 +179,36 @@ class BiblioIsisDb implements IsisDb { 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]; - } else { - $subname = $subkey; - } + function subfields_switch($key, &$value) { + foreach ($value as $subkey => $subvalue) { + if (isset($this->format['fields'][$key]['subfields'][$subkey])) { + $subname = $this->format['fields'][$key]['subfields'][$subkey]; + } else { + $subname = $subkey; + } - $data[$name][$subname] = $subvalue; + $value[$subname] = $subvalue; - if ($subkey != $subname) { - unset($data[$name][$subkey]); + if ($subkey != $subname) { + unset($value[$subkey]); + } + } + } + + function subfields($name, $key) { + if ($this->has_subfields($key) && is_array($name)) { + if ($this->is_repetitive($key, $name)) { + foreach ($name as $entry => $value) { + $this->subfields_switch($key, $value); + $name[$entry] = $value; } } + else { + $this->subfields_switch($key, $name); + } } + + return $name; } /** |