aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-07-15 18:07:01 -0300
committerSilvio <silvio@devlet.com.br>2010-07-15 18:07:01 -0300
commitd83a35ce8486256ff865596066c6dbf23bfe5b18 (patch)
treeadbee4754fedb9f981d9a155974854311906f823 /classes
parent1457718f111ea45705555439e6a732e293cc7bef (diff)
downloadcinisis-d83a35ce8486256ff865596066c6dbf23bfe5b18.tar.gz
cinisis-d83a35ce8486256ff865596066c6dbf23bfe5b18.tar.bz2
Adding IsisNormalSubfieldFilterIterator
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);