aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/BiblioIsisDb.php54
-rw-r--r--classes/MaleteDb.php5
-rw-r--r--classes/PhpIsisDb.php5
3 files changed, 60 insertions, 4 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php
index c86af0b..d32f548 100644
--- a/classes/BiblioIsisDb.php
+++ b/classes/BiblioIsisDb.php
@@ -261,7 +261,7 @@ class BiblioIsisDb implements IsisDb {
}
else {
foreach ($name as $value) {
- $data[] = array('field' => $value);
+ $data[] = array($this->main_field_name($key) => $value);
}
}
@@ -269,7 +269,12 @@ class BiblioIsisDb implements IsisDb {
}
/**
- * Subfield handling for data read by 'to_hash' method.
+ * Subfield handling for data read by 'to_hash' method. This method
+ * is not fully supported and therefore not recommended.
+ *
+ * It does not deal very well when data has "main" fields and
+ * subfields (like "data1^adata2^bdata3") and doesn't deal with
+ * advanced configuration such as 'join_subfields'.
*
* @param $name
* Dataset.
@@ -311,9 +316,11 @@ class BiblioIsisDb implements IsisDb {
if (substr($value, 0, 1) != '^') {
$field = preg_replace('/\^.*/', '', $value);
$subfields = substr($value, strlen($field) + 1);
+ $subfields = (!empty($subfields)) ? $subfields = explode('^', $subfields) : array();
- $data[$entry]['field'] = $field;
- $subfields = (!empty($subfields)) ? $subfields = explode('^', $subfields) : array();
+ if (isset($field)) {
+ $data[$entry]['field'] = $field;
+ }
}
else {
$subfields = explode('^', substr($value, 1));
@@ -327,12 +334,51 @@ class BiblioIsisDb implements IsisDb {
}
$data[$entry]['subfields'][$subkey] = substr($subvalue, 1);
}
+
+ // Join subfields and main field if needed.
+ if ($this->join_subfields()) {
+ $data[$entry] = $data[$entry]['subfields'];
+ if (isset($field)) {
+ $data[$entry][$this->main_field_name($key)] = $field;
+ }
+ }
}
return $data;
}
/**
+ * Whether to join field and subfields in a single array.
+ *
+ * @return
+ * Boolean.
+ */
+ public function join_subfields() {
+ if ($this->format['db']['join_subfields']) {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Determine the main field name depending on db configuration.
+ *
+ * @param $key
+ * Field key.
+ *
+ * @return
+ * Main field name, 'field' by default;
+ */
+ public function main_field_name($key) {
+ if ($this->join_subfields()) {
+ return $this->format['fields'][$key]['name'];
+ }
+
+ return 'field';
+ }
+
+ /**
* Deals with repetition.
*
* As Biblio::Isis always return field values as arrays, we
diff --git a/classes/MaleteDb.php b/classes/MaleteDb.php
index 201ddc0..e7d50a5 100644
--- a/classes/MaleteDb.php
+++ b/classes/MaleteDb.php
@@ -2,6 +2,11 @@
/**
* Malete implementation of IsisDb.
+ *
+ * @todo
+ * This implementation is currently outdated and lacks
+ * basic functionalities such as subfield handling and
+ * therefore it's use is not recommended.
*/
class MaleteDb implements IsisDb {
/**
diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php
index 6d39d6e..03e9b7c 100644
--- a/classes/PhpIsisDb.php
+++ b/classes/PhpIsisDb.php
@@ -2,6 +2,11 @@
/**
* PHP-Isis implementation of IsisDb.
+ *
+ * @todo
+ * This implementation is currently outdated and lacks
+ * basic functionalities such as subfield handling and
+ * therefore it's use is not recommended.
*/
class PhpIsisDb implements IsisDb {
/**