aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-06-08 12:00:29 -0300
committerSilvio <silvio@devlet.com.br>2010-06-08 12:00:29 -0300
commit6b2c196c75b8b11cc9f9ffc645c25a555532f2f8 (patch)
tree490fdd6ee408925fbfa10251278a40ebbe9e66e5 /classes
parent2c12b819489eec111d3f63fa46f24703011ca8cb (diff)
downloadcinisis-6b2c196c75b8b11cc9f9ffc645c25a555532f2f8.tar.gz
cinisis-6b2c196c75b8b11cc9f9ffc645c25a555532f2f8.tar.bz2
Broken repetitive field handling in two methods at BiblioIsis
Diffstat (limited to 'classes')
-rw-r--r--classes/BiblioIsisDb.php72
1 files changed, 50 insertions, 22 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php
index 4c4e5ce..8f341bd 100644
--- a/classes/BiblioIsisDb.php
+++ b/classes/BiblioIsisDb.php
@@ -165,27 +165,33 @@ class BiblioIsisDb implements IsisDb {
$data[$name] = $this->repetition($key, $value);
// Subfield handling.
- if (isset($this->format['fields'][$key]['subfields']) && 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;
- }
-
- $data[$name][$subname] = $subvalue;
-
- if ($subkey != $subname) {
- unset($data[$name][$subkey]);
- }
- }
- }
+ $this->subfield($data, $name, $key);
}
}
return $data;
}
+ function subfield(&$data, $name, $key) {
+ if (isset($this->format['fields'][$key]['subfields']) && 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;
+ }
+
+ $data[$name][$subname] = $subvalue;
+
+ if ($subkey != $subname) {
+ unset($data[$name][$subkey]);
+ }
+ }
+
+ }
+ }
+
/**
* Deals with repetition.
*
@@ -196,19 +202,41 @@ class BiblioIsisDb implements IsisDb {
* @param $field
* Database field.
*
- * @param $value
- * Query field result.
- *
* @return
- * The value according to the repetition config.
+ * True if repetitive, false otherwise.
*/
- function repetition($field, $value) {
+ function is_repetitive($field, $value) {
if (isset($this->format['fields'][$field]['repeat']) &&
$this->format['fields'][$field]['repeat'] == FALSE && is_array($value)) {
- return $value[0];
+ return FALSE;
}
- return $value;
+ return TRUE;
+ }
+
+ /**
+ * Deals with repetition.
+ *
+ * As Biblio::Isis always return field values as arrays, we
+ * have to check the database schema to see if we have to
+ * convert then to a single value.
+ *
+ * @param $field
+ * Database field.
+ *
+ * @param $value
+ * Query field result.
+ *
+ * @return
+ * The value according to the repetition config.
+ */
+ function repetition($key, $value) {
+ if ($this->is_repetitive($key, $value)) {
+ return $value;
+ }
+ else {
+ return $value[0];
+ }
}
/**