protected static function collectDBFields($class)
    {
        if (isset(self::$collectorCache[$class])) {
            return self::$collectorCache[$class];
        }

        if (isset(self::$collectorLock[$class]) && self::$collectorLock[$class]) {
            return null;
        }
        self::$collectorLock[$class] = true;

        // Get all DB Fields
        $fields = array();
        Config::inst()->get($class, 'db', Config::EXCLUDE_EXTRA_SOURCES, $fields);

        // Get all arguments
        $arguments = self::get_arguments($class);

        $locales = self::get_target_locales();

        // remove the default locale
        if (($index = array_search(Translatable::default_locale(), $locales)) !== false) {
            array_splice($locales, $index, 1);
        }

        // fields that should be translated
        $fieldsToTranslate = array();

        // validate the arguments
        if ($arguments) {
            foreach ($arguments as $field) {
                // only allow fields that are actually in our field list
                if (array_key_exists($field, $fields)) {
                    $fieldsToTranslate[] = $field;
                }
            }
        } else {
            // check for the given default field types and add all fields of that type
            foreach ($fields as $field => $type) {
                $typeClean = (($p = strpos($type, '(')) !== false) ? substr($type, 0, $p) : $type;
                $defaultFields = self::config()->default_field_types;

                if (is_array($defaultFields) && in_array($typeClean, $defaultFields)) {
                    $fieldsToTranslate[] = $field;
                }
            }
        }


        // gather all the DB fields
        $additionalFields = array();
        self::$localizedFields[$class] = array();
        foreach ($fieldsToTranslate as $field) {
            self::$localizedFields[$class][$field] = array();
            foreach ($locales as $locale) {
                $localizedName = self::localized_field($field, $locale);
                self::$localizedFields[$class][$field][] = $localizedName;
                $additionalFields[$localizedName] = $fields[$field];
            }
        }

        self::$collectorCache[$class] = $additionalFields;
        self::$collectorLock[$class] = false;
        return $additionalFields;
    }
protected static function collectDBFields($class)
    {
        if (isset(self::$collectorCache[$class])) {
            return self::$collectorCache[$class];
        }

        if (isset(self::$collectorLock[$class]) && self::$collectorLock[$class]) {
            return null;
        }
        self::$collectorLock[$class] = true;

        // Get all DB Fields
        $fields = array();
        Config::inst()->get($class, 'db', Config::EXCLUDE_EXTRA_SOURCES, $fields);

        // Get all arguments
        $arguments = self::get_arguments($class);

        $locales = self::get_target_locales();

        // remove the default locale
        if (($index = array_search(Translatable::default_locale(), $locales)) !== false) {
            array_splice($locales, $index, 1);
        }

        // fields that should be translated
        $fieldsToTranslate = array();

        // validate the arguments
        if ($arguments) {
            foreach ($arguments as $field) {
                // only allow fields that are actually in our field list
                if (array_key_exists($field, $fields)) {
                    $fieldsToTranslate[] = $field;
                }
            }
        } else {
            // check for the given default field types and add all fields of that type
            foreach ($fields as $field => $type) {
                $typeClean = (($p = strpos($type, '(')) !== false) ? substr($type, 0, $p) : $type;
                $defaultFields = self::config()->default_field_types;

                if (is_array($defaultFields) && in_array($typeClean, $defaultFields)) {
                    $fieldsToTranslate[] = $field;
                }
            }
        }


        // gather all the DB fields
        $additionalFields = array();
        self::$localizedFields[$class] = array();
        foreach ($fieldsToTranslate as $field) {
            self::$localizedFields[$class][$field] = array();
            foreach ($locales as $locale) {
                $localizedName = self::localized_field($field, $locale);
                self::$localizedFields[$class][$field][] = $localizedName;
                $additionalFields[$localizedName] = $fields[$field];
            }
        }

        self::$collectorCache[$class] = $additionalFields;
        self::$collectorLock[$class] = false;
        return $additionalFields;
    }
protected static function collectDBFields ( $ class ) { if ( isset ( self :: $ collectorCache [ $ class ] ) ) { return self :: $ collectorCache [ $ class ] ; } if ( isset ( self :: $ collectorLock [ $ class ] ) && self :: $ collectorLock [ $ class ] ) { return null ; } self :: $ collectorLock [ $ class ] = true ; // Get all DB Fields $ fields = array ( ) ; Config :: inst ( ) -> get ( $ class , 'db' , Config :: EXCLUDE_EXTRA_SOURCES , $ fields ) ; // Get all arguments $ arguments = self :: get_arguments ( $ class ) ; $ locales = self :: get_target_locales ( ) ; // remove the default locale if ( ( $ index = array_search ( Translatable :: default_locale ( ) , $ locales ) ) !== false ) { array_splice ( $ locales , $ index , 1 ) ; } // fields that should be translated $ fieldsToTranslate = array ( ) ; // validate the arguments if ( $ arguments ) { foreach ( $ arguments as $ field ) { // only allow fields that are actually in our field list if ( array_key_exists ( $ field , $ fields ) ) { $ fieldsToTranslate [ ] = $ field ; } } } else { // check for the given default field types and add all fields of that type foreach ( $ fields as $ field => $ type ) { $ typeClean = ( ( $ p = strpos ( $ type , '(' ) ) !== false ) ? substr ( $ type , 0 , $ p ) : $ type ; $ defaultFields = self :: config ( ) -> default_field_types ; if ( is_array ( $ defaultFields ) && in_array ( $ typeClean , $ defaultFields ) ) { $ fieldsToTranslate [ ] = $ field ; } } } // gather all the DB fields $ additionalFields = array ( ) ; self :: $ localizedFields [ $ class ] = array ( ) ; foreach ( $ fieldsToTranslate as $ field ) { self :: $ localizedFields [ $ class ] [ $ field ] = array ( ) ; foreach ( $ locales as $ locale ) { $ localizedName = self :: localized_field ( $ field , $ locale ) ; self :: $ localizedFields [ $ class ] [ $ field ] [ ] = $ localizedName ; $ additionalFields [ $ localizedName ] = $ fields [ $ field ] ; } } self :: $ collectorCache [ $ class ] = $ additionalFields ; self :: $ collectorLock [ $ class ] = false ; return $ additionalFields ; }
Collect all additional database fields of the given class.
@param string $class
@return array fieldnames that should be added
Collect all additional database fields of the given class .