<commit_before><?php
class Vps_Form_Field_GoogleMapsField extends Vps_Form_Field_SimpleAbstract
{
    public function __construct($field_name = null, $field_label = null)
    {
        parent::__construct($field_name, $field_label);
        $this->setXtype('googlemapsfield');
    }

    protected function _addValidators()
    {
        parent::_addValidators();
        $this->addValidator(new Zend_Validate_Regex("#^(()|(-?[0-9]+\.[0-9]*;-?[0-9]+\.[0-9]*))$#"));
    }
}<commit_msg>Form_Field_GoogleMapsField can be used with db-field 'coordinates' or 'latitude'/'longitude'<commit_after><?php
class Vps_Form_Field_GoogleMapsField extends Vps_Form_Field_SimpleAbstract
{
    protected $_latitudeFieldname = null;
    protected $_longitudeFieldname = null;

    public function __construct($field_name = null, $field_label = null)
    {
        parent::__construct($field_name, $field_label);
        $this->setXtype('googlemapsfield');
    }

    // if called, coordinates will be saved into two seperate fields (necessary if you want to use Vpc_Directories_List_ViewMap_Component)
    public function setCoordinateFieldnames($latitudeFieldname = 'latitude', $longitudeFieldname = 'longitude')
    {
        $this->_latitudeFieldname = $latitudeFieldname;
        $this->_longitudeFieldname = $longitudeFieldname;
        return $this;
    }

    public function load($row, $postData = array())
    {
        if ($this->_latitudeFieldname && $this->_longitudeFieldname) {
            return array(
                $this->getFieldName() =>
                    $row->{$this->_latitudeFieldname} . ';' .
                    $row->{$this->_longitudeFieldname}
            );
        } else {
            return parent::load($row, $postData);
        }
    }

    public function prepareSave(Vps_Model_Row_Interface $row, $postData)
    {
        if ($this->_latitudeFieldname && $this->_longitudeFieldname) {
            if ($this->getSave() !== false) {
                $coords = explode(';', $this->_getValueFromPostData($postData));
                if (isset($coords[0]) && isset($coords[1])) {
                    $row->{$this->_latitudeFieldname} = $coords[0];
                    $row->{$this->_longitudeFieldname} = $coords[1];
                }
            }
        } else {
            return parent::prepareSave($row, $postData);
        }

    }

    protected function _addValidators()
    {
        parent::_addValidators();
        $this->addValidator(new Zend_Validate_Regex("#^(()|(-?[0-9]+\.[0-9]*;-?[0-9]+\.[0-9]*))$#"));
    }
}
{'fraction_non_alphanumeric': 0.14958775029446408, 'fraction_numerical': 0.007852375343541421, 'mean_word_length': 2.7470588235294118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4649286', 'n_tokens_mistral': 782, 'n_tokens_neox': 769, 'n_words': 125}