From fa2e699c04c6d59efe968c1811d1ecddb2191b7c Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 4 Aug 2010 14:37:24 -0300 Subject: Adding methods hasItem() and hasMainItem() at IsisConnector --- classes/IsisConnector.php | 62 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'classes') diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php index 886246e..8a2fd45 100644 --- a/classes/IsisConnector.php +++ b/classes/IsisConnector.php @@ -292,9 +292,9 @@ class IsisConnector { */ public function getMap($field, $subfield = NULL) { if ($subfield == NULL) { - if (isset($field['map']['field'])) { - // Custom map provided. - $dest = $this->mapName($field['map']['field']); + if (isset($field['map']['main'])) { + // Custom map provided for the main item. + $dest = $this->mapName($field['map']['main']); } else { // Default map. @@ -353,7 +353,7 @@ class IsisConnector { * TRUE if field has a map, FALSE otherwise. */ public function fieldHasMap($field) { - if (isset($field['map']['field'])) { + if (isset($field['map']['main'])) { return TRUE; } return FALSE; @@ -624,6 +624,60 @@ class IsisConnector { } } + /** + * Check if a field result has a main item. + * + * @param $field + * Field data. + * + * @param $row + * Row number. + * + * @return + * True if result has the main item, false otherwise. + */ + public function hasMainItem($field, $row) + { + $value = $this->getMainItem($field, $row); + + if (!empty($value)) { + return TRUE; + } + else { + return FALSE; + } + } + + /** + * Check if a field result has an item. + * + * @param $field + * Field data. + * + * @param $item + * Item code ('main' for the main item). + * + * @param $row + * Row number. + * + * @return + * True if result has the main item, false otherwise. + */ + public function hasItem($field, $item, $row = 0) + { + if ($item == 'main') + { + $has = $this->hasMainItem($field, $row); + } + else + { + $subfield = $this->getSubfieldName($this->getFieldKey($field), $item); + $has = $this->hasSubfield($field, $subfield, $row); + } + + return $has; + } + /** * Get a subfield name. * -- cgit v1.2.3