From e66cda93a6bb085aacf9ae90d74d7084378672b6 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 13 Jul 2010 13:56:42 -0300 Subject: Adding getSubfieldName() and hasSubfield() at IsisConnector --- classes/IsisConnector.php | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php index 6ea24cf..710048a 100644 --- a/classes/IsisConnector.php +++ b/classes/IsisConnector.php @@ -456,8 +456,7 @@ class IsisConnector { * @return * Normalized field name */ - static function normalizeFieldName($name) - { + static function normalizeFieldName($name) { return ucfirst(preg_replace('/[^a-z0-9_]/', '', strtolower($name))); } @@ -470,8 +469,49 @@ class IsisConnector { * @return * Map name */ - static function mapName($name) - { + static function mapName($name) { return 'set'. self::normalizeFieldName($name); } + + /** + * Check if a field result has a given subfield. + * + * @param $field + * Field data. + * + * @param $subfield + * Subfield. + * + * @param $row + * Row number. + * + * @return + * True if result has the subfield, false otherwise. + */ + public function hasSubfield($field, $subfield, $row) { + $value = $this->getSubfield($field, $subfield, $row); + + if (!empty($value)) { + return TRUE; + } + else { + return FALSE; + } + } + + /** + * Get a subfield name. + * + * @param $field_key + * Field key. + * + * @param $subfield_key + * Subfield key. + * + * @return + * Subfield name. + */ + public function getSubfieldName($field_key, $subfield_key) { + return $this->format['fields'][$field_key]['subfields'][$subfield_key]; + } } -- cgit v1.2.3