aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2010-08-18 18:29:51 -0300
committerSilvio <silvio@devlet.com.br>2010-08-18 18:29:51 -0300
commit70d0c6f95279f67f863cf6cb8e2a0528534c4519 (patch)
tree288388e487f92d6d87df9896c4f98dae27a84853 /classes
parent8c00b2a834fef61639ab3a657cdd99b2fdc8de4b (diff)
downloadcinisis-70d0c6f95279f67f863cf6cb8e2a0528534c4519.tar.gz
cinisis-70d0c6f95279f67f863cf6cb8e2a0528534c4519.tar.bz2
Enhancing nextSubfield() from IsisFinder
Diffstat (limited to 'classes')
-rw-r--r--classes/IsisConnector.php2
-rw-r--r--classes/IsisFinder.php30
2 files changed, 27 insertions, 5 deletions
diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php
index e0c87c2..64a6c59 100644
--- a/classes/IsisConnector.php
+++ b/classes/IsisConnector.php
@@ -633,7 +633,7 @@ class IsisConnector {
}
/**
- * Check if a field result has a given subfield.
+ * Check if a field result and row has a given subfield.
*
* @param $field
* Field data.
diff --git a/classes/IsisFinder.php b/classes/IsisFinder.php
index 80057c1..1f8ed0f 100644
--- a/classes/IsisFinder.php
+++ b/classes/IsisFinder.php
@@ -80,8 +80,7 @@ class IsisFinder extends IsisConnector {
* Next occurrence.
*
* @todo
- * The subfield might be in any now and not just
- * in the first one.
+ * Test.
*/
public function nextSubfield($entry = 1, $field, $subfield) {
$entry--;
@@ -92,12 +91,35 @@ class IsisFinder extends IsisConnector {
if ($entry == $entries) {
break;
}
- } while (!isset($result[$field][0][$subfield]));
+ $has = $this->hasSubfieldInRows($field, $subfield);
+ } while ($has === FALSE);
- if (!isset($result[$field][0][$subfield])) {
+ if (!isset($result[$field][$has][$subfield])) {
return FALSE;
}
return array($entry, $result);
}
+
+ /**
+ * Check if a field result has a given subfield.
+ *
+ * @param $field
+ * Field data.
+ *
+ * @param $subfield
+ * Subfield.
+ *
+ * @return
+ * True if result has the subfield, false otherwise.
+ */
+ public function hasSubfieldInRows($field, $subfield) {
+ foreach (new IsisRowIterator($this, $field) as $row) {
+ if ($this->hasSubfield($field, $subfield, $row)) {
+ return $row;
+ }
+ }
+
+ return FALSE;
+ }
}