From 1c7744d7b0298723bcc2783663b60cd8a2c0e67b Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 27 Jul 2010 10:52:00 -0300 Subject: Moving join_subfields and main_field_name to CinisisDb --- classes/CinisisDb.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'classes/CinisisDb.php') diff --git a/classes/CinisisDb.php b/classes/CinisisDb.php index 32f0a28..a016528 100644 --- a/classes/CinisisDb.php +++ b/classes/CinisisDb.php @@ -156,4 +156,41 @@ class CinisisDb { return call_user_func(array(__CLASS__, 'base')) .'/'. $config; } + + /** + * Whether to join field and subfields in a single array. + * + * @param $format + * Database format. + * + * @return + * Boolean. + */ + static function join_subfields($format) { + if ($format['db']['join_subfields']) { + return TRUE; + } + + return FALSE; + } + + /** + * Determine the main field name depending on db configuration. + * + * @param $key + * Field key. + * + * @param $format + * Database format. + * + * @return + * Main field name, 'field' by default. + */ + static function main_field_name($format, $key) { + if (self::join_subfields($format)) { + return $format['fields'][$key]['name']; + } + + return 'field'; + } } -- cgit v1.2.3