aboutsummaryrefslogtreecommitdiff
path: root/classes/IsisConnector.php
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-07-19 16:44:48 -0300
committerSilvio <silvio@devlet.com.br>2010-07-19 16:44:48 -0300
commitec7c2ae0788a6423909f93d9fb0c51da29585aa6 (patch)
tree7da4d368313133d423c2547bc9a1c0a041510446 /classes/IsisConnector.php
parent5f0e3d2f891e433f2f0aec1222df6c71eb7cdb62 (diff)
downloadcinisis-ec7c2ae0788a6423909f93d9fb0c51da29585aa6.tar.gz
cinisis-ec7c2ae0788a6423909f93d9fb0c51da29585aa6.tar.bz2
More changes to support join_subfields config option
Diffstat (limited to 'classes/IsisConnector.php')
-rw-r--r--classes/IsisConnector.php49
1 files changed, 43 insertions, 6 deletions
diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php
index e7eb4c6..a5b5227 100644
--- a/classes/IsisConnector.php
+++ b/classes/IsisConnector.php
@@ -39,6 +39,34 @@ class IsisConnector {
}
/**
+ * Get the main field name.
+ *
+ * @param $field
+ * Field data from ISIS database schema.
+ *
+ * @return
+ * Main field name.
+ */
+ public function getMainFieldName($field) {
+ $key = $this->getFieldKey($field);
+ return $this->isis->db->main_field_name($key);
+ }
+
+ /**
+ * Whether to join field and subfields in a single array.
+ *
+ * @return
+ * Boolean.
+ */
+ public function joinSubfields() {
+ if ($this->isis->db->join_subfields()) {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
* Get all values of a given field.
*
* @param $field
@@ -81,8 +109,10 @@ class IsisConnector {
* Field data.
*/
public function getField($field, $row = 0) {
- if (isset($this->result[$field['name']][$row]['field'])) {
- return $this->result[$field['name']][$row]['field'];
+ $name = $this->getMainFieldName($field);
+
+ if (isset($this->result[$field['name']][$row][$name])) {
+ return $this->result[$field['name']][$row][$name];
}
}
@@ -119,8 +149,15 @@ class IsisConnector {
* Subfield data.
*/
public function getSubfield($field, $subfield, $row = 0) {
- if (isset($this->result[$field['name']][$row]['subfields'][$subfield])) {
- return $this->result[$field['name']][$row]['subfields'][$subfield];
+ if ($this->joinSubfields()) {
+ $subfields = $this->result[$field['name']][$row];
+ }
+ else {
+ $subfields = $this->result[$field['name']][$row]['subfields'];
+ }
+
+ if (isset($subfields[$subfield])) {
+ return $subfields[$subfield];
}
}
@@ -536,8 +573,8 @@ class IsisConnector {
public function hasFieldSubfieldCondition($field, $subfield, $key, $subkey) {
$field_key = $this->getFieldKey($field);
$subdield_key = $this->getSubfieldKey($field, $subfield);
- if ($field_key == $key && $subfield_key == $subkey)
- {
+
+ if ($field_key == $key && $subfield_key == $subkey) {
return true;
}