aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/IsisConnector.php21
-rw-r--r--classes/iterators/IsisItemIterator.php15
2 files changed, 28 insertions, 8 deletions
diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php
index c82d479..ff057c6 100644
--- a/classes/IsisConnector.php
+++ b/classes/IsisConnector.php
@@ -196,7 +196,7 @@ class IsisConnector {
* @return
* Item data.
*/
- public function getItem($field, $item, $row) {
+ public function getItem($field, $item, $row = 0) {
$main_field = $this->getMainItemName($field);
if ($field == $main_field) {
@@ -518,6 +518,25 @@ class IsisConnector {
}
/**
+ * Explode brackets for a given item, avoiding null entries.
+ *
+ * @param $field
+ * Field data.
+ *
+ * @param $item
+ * Item.
+ *
+ * @param $row
+ * Row number.
+ *
+ * @return
+ * Exploded item data.
+ */
+ public function explodeItem($field, $item, $row) {
+ return array_filter($this->explodeValue($this->getItem($field, $item, $row)));
+ }
+
+ /**
* Filter brackets for a given subfield.
*
* @param $field
diff --git a/classes/iterators/IsisItemIterator.php b/classes/iterators/IsisItemIterator.php
index 2fc4780..9435146 100644
--- a/classes/iterators/IsisItemIterator.php
+++ b/classes/iterators/IsisItemIterator.php
@@ -7,8 +7,8 @@ class IsisItemIterator implements Iterator
{
private $keys;
private $fieldset;
- private $row = 0;
- private $rows = 0;
+ private $row = 0;
+ private $rows = 0;
private $item = 0;
private $items = 0;
@@ -26,18 +26,19 @@ class IsisItemIterator implements Iterator
* By default no mapping is made.
*/
public function __construct($class, $field, $main = false) {
+ // Setup.
$this->class = $class;
$this->field = $field;
$this->rows = $class->getRows($field);
- // Handle subfields
+ // Handle subfields.
$this->fieldset = $class->getSubfieldList($field);
$this->keys = array_keys($this->fieldset);
$this->items = count($this->keys);
- // Sum up main item
- $this->fieldset[] = $class->getMainItem($field);
- $this->keys[] = $class->getMainItemName($field);
+ // Sum up main item.
+ $this->fieldset['main'] = $class->getMainItemName($field);
+ $this->keys[] = 'main';
$this->items++;
}
@@ -45,7 +46,7 @@ class IsisItemIterator implements Iterator
* Rewind the Iterator to the first element.
*/
function rewind() {
- $this->row = 0;
+ $this->row = 0;
$this->item = 0;
}