aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-07-27 10:52:00 -0300
committerSilvio <silvio@devlet.com.br>2010-07-27 10:52:00 -0300
commit1c7744d7b0298723bcc2783663b60cd8a2c0e67b (patch)
tree0dfe210d998392cf3c0d789b109fff93573aa73b /classes
parent362ddf298200ee6a7dfcc535df48d22ee2478e9c (diff)
downloadcinisis-1c7744d7b0298723bcc2783663b60cd8a2c0e67b.tar.gz
cinisis-1c7744d7b0298723bcc2783663b60cd8a2c0e67b.tar.bz2
Moving join_subfields and main_field_name to CinisisDb
Diffstat (limited to 'classes')
-rw-r--r--classes/BiblioIsisDb.php43
-rw-r--r--classes/CinisisDb.php37
-rw-r--r--classes/IsisConnector.php4
3 files changed, 42 insertions, 42 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php
index eca03e5..2fb02cf 100644
--- a/classes/BiblioIsisDb.php
+++ b/classes/BiblioIsisDb.php
@@ -258,7 +258,7 @@ class BiblioIsisDb implements IsisDb {
}
else {
foreach ($name as $value) {
- $data[] = array($this->main_field_name($key) => $value);
+ $data[] = array(CinisisDb::main_field_name($this->format, $key) => $value);
}
}
@@ -333,10 +333,10 @@ class BiblioIsisDb implements IsisDb {
}
// Join subfields and main field if needed.
- if ($this->join_subfields()) {
+ if (CinisisDb::join_subfields($this->format)) {
$data[$entry] = $data[$entry]['subfields'];
if (isset($field)) {
- $data[$entry][$this->main_field_name($key)] = $field;
+ $data[$entry][CinisisDb::main_field_name($this->format, $key)] = $field;
}
}
}
@@ -345,43 +345,6 @@ class BiblioIsisDb implements IsisDb {
}
/**
- * Whether to join field and subfields in a single array.
- *
- * @return
- * Boolean.
- *
- * @todo
- * Should be added at IsisDb interface?
- */
- 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.
- *
- * @todo
- * Should be added at IsisDb interface?
- */
- 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/CinisisDb.php b/classes/CinisisDb.php
index 32f0a28..a016528 100644
--- a/classes/CinisisDb.php
+++ b/classes/CinisisDb.php
@@ -156,4 +156,41 @@ class CinisisDb {
return call_user_func(array(__CLASS__, 'base')) .'/'. $config;
}
+
+ /**
+ * Whether to join field and subfields in a single array.
+ *
+ * @param $format
+ * Database format.
+ *
+ * @return
+ * Boolean.
+ */
+ static function join_subfields($format) {
+ if ($format['db']['join_subfields']) {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Determine the main field name depending on db configuration.
+ *
+ * @param $key
+ * Field key.
+ *
+ * @param $format
+ * Database format.
+ *
+ * @return
+ * Main field name, 'field' by default.
+ */
+ static function main_field_name($format, $key) {
+ if (self::join_subfields($format)) {
+ return $format['fields'][$key]['name'];
+ }
+
+ return 'field';
+ }
}
diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php
index 4d9683f..4539669 100644
--- a/classes/IsisConnector.php
+++ b/classes/IsisConnector.php
@@ -59,7 +59,7 @@ class IsisConnector {
*/
public function getMainItemName($field) {
$key = $this->getFieldKey($field);
- return $this->isis->db->main_field_name($key);
+ return CinisisDb::main_field_name($this->format, $key);
}
/**
@@ -69,7 +69,7 @@ class IsisConnector {
* Boolean.
*/
public function joinSubfields() {
- if ($this->isis->db->join_subfields()) {
+ if (CinisisDb::join_subfields($this->format)) {
return TRUE;
}