aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/IsisConnector.php39
-rw-r--r--classes/IsisNormalSubfieldFilterIterator.php14
-rw-r--r--classes/IsisSubfieldIterator.php2
3 files changed, 55 insertions, 0 deletions
diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php
index cc4bf62..c731d9a 100644
--- a/classes/IsisConnector.php
+++ b/classes/IsisConnector.php
@@ -543,4 +543,43 @@ class IsisConnector {
return false;
}
+
+ /**
+ * Deal with special subfields.
+ *
+ * @param $field
+ * Field data from ISIS database schema.
+ *
+ * @param $subfield
+ * Subfield name.
+ *
+ * @param $return
+ * Specify return type.
+ *
+ * @return
+ * True if special subfield, false otherwise of special return type
+ */
+ public function specialSubfield($field, $subfield, $return = 'boolean') {
+ if (isset($field['special'])) {
+ $field_key = $this->getFieldKey($field);
+ $subfield_key = $this->getSubfieldKey($field, $subfield);
+ $name = $field['name'] .':'. $subfield;
+ $code = $field_key .':'. $subfield_key;
+
+ if (array_search($subfield_key, $field['special'])) {
+ $this->log("Found special subfield $name", 'debug');
+
+ if ($return == 'boolean') {
+ return true;
+ }
+ elseif ($return == 'code') {
+ return $code;
+ }
+
+ return $name;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/classes/IsisNormalSubfieldFilterIterator.php b/classes/IsisNormalSubfieldFilterIterator.php
new file mode 100644
index 0000000..98494a6
--- /dev/null
+++ b/classes/IsisNormalSubfieldFilterIterator.php
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * Isis normal subfield iterator. Filter out special subfields.
+ */
+class IsisNormalSubfieldFilterIterator extends FilterIterator {
+ public function accept()
+ {
+ $field = $this->getInnerIterator()->field;
+ $class = $this->getInnerIterator()->class;
+ $subfield = $this->getInnerIterator()->current();
+ return !$class->specialSubfield($field, $subfield);
+ }
+}
diff --git a/classes/IsisSubfieldIterator.php b/classes/IsisSubfieldIterator.php
index 8a35399..36d3d06 100644
--- a/classes/IsisSubfieldIterator.php
+++ b/classes/IsisSubfieldIterator.php
@@ -23,6 +23,8 @@ class IsisSubfieldIterator implements Iterator
* Field to iterate over.
*/
public function __construct($class, $field) {
+ $this->class = $class;
+ $this->field = $field;
$this->rows = $class->getRows($field);
$this->fieldset = $class->getSubfieldList($field);
$this->keys = array_keys($this->fieldset);