From 61f692933d4f7ed9c5bc860d28ee5e9b83f5b125 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 4 Aug 2010 16:39:02 -0300 Subject: Adding more helper methods at IsisConnector --- classes/IsisConnector.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php index 03c2bfe..e82174c 100644 --- a/classes/IsisConnector.php +++ b/classes/IsisConnector.php @@ -391,7 +391,7 @@ class IsisConnector { * Subfield name. * * @return - * Subfield keys. + * Subfield key. */ public function getSubfieldKey($field, $subfield) { $keys = array_flip($field['subfields']); @@ -400,6 +400,27 @@ class IsisConnector { } } + /** + * Get the item key. + * + * @param $field + * Field array. + * + * @param $item + * Item name. + * + * @return + * Item key. + */ + public function getItemKey($field, $item) { + if ($item == 'main') { + return $item; + } + else { + return $this->getSubfieldKey($field, $item); + } + } + /** * Get the key of a field entry. * @@ -674,6 +695,33 @@ class IsisConnector { return $has; } + /** + * Return the existing key items for a result. + * + * @param $field + * Field data. + * + * @param $row + * Row number. + * + * @return + * Array with existing item keys + * + * @todo + * Write and test. + */ + public function existingItemKeys($field, $row = 0) { + $existing = array(); + + foreach (new IsisItemIterator($this, $field)) as $key => $item) { + if ($row == $key) { + $existing[] = $this->getItemKey($field, $item); + } + } + + return $existing; + } + /** * Get a subfield name. * -- cgit v1.2.3