From 21bd1c86b53d26645a8d6f36624cd6bfb0041f61 Mon Sep 17 00:00:00 2001 From: Silvio Date: Thu, 16 Sep 2010 11:11:08 -0300 Subject: New map methods --- classes/IsisMap.php | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'classes/IsisMap.php') diff --git a/classes/IsisMap.php b/classes/IsisMap.php index 5e800f8..05a954e 100644 --- a/classes/IsisMap.php +++ b/classes/IsisMap.php @@ -347,4 +347,81 @@ class IsisMap extends IsisReader { return FALSE; } + + /** + * Get attributes based on field and subfield. + * + * @param $field + * Field data from ISIS database schema. + * + * @param $subfield + * Subfield name. + * + * @return + * Attributes. + */ + public function getAttributes(&$model, $field, $subfield = null) + { + $attributes = array(); + $map = $this->getFullMap($field); + + if ($map) + { + if (isset($map['attributes']['field'])) + { + $attributes = $map['attributes']['field']; + } + + if ($subfield == null) + { + return $attributes; + } + + $key = $this->getSubfieldKey($field, $subfield); + + if (isset($map['attributes'][$key])) + { + $attributes = array_merge($attributes, $map['attributes'][$key]); + } + } + + return $attributes; + } + + /** + * Defines the denied field combinations. + * + * @param $field + * Field data from ISIS database schema. + * + * @return + * Denied field combinations. + */ + public function getDeniedCombinations($field) + { + /** + * Sample denied combination. + */ + /** + $sample = array( + 0 => array('a', 'b', 'c'), // a AND b AND c OR + 1 => array('a', 'c', '!d'), // a AND b BUT WITHOUT d OR + 2 => array('a', 'b', '*'), // a AND b AND any other item OR + 3 => array('*2'), // ANY two items together OR + 4 => array('main', '*'), // main AND ANY other item OR + ); + */ + + $map = $this->getFullMap($field); + + if ($map) + { + if (isset($map['denied'])) + { + return $map['denied']; + } + } + + return array(); + } } -- cgit v1.2.3