You are here

function _addressfield_sample_addresses in Address Field 7

Returns an array of sample addresses.

Return value

An array of addressfield arrays

1 call to _addressfield_sample_addresses()
_addressfield_devel_generate in ./addressfield.devel_generate.inc

File

./addressfield.devel_generate.inc, line 39

Code

function _addressfield_sample_addresses() {
  $fields =& drupal_static(__FUNCTION__);
  if (!isset($fields)) {
    $filepath = DRUPAL_ROOT . '/' . drupal_get_path('module', 'addressfield');
    $fields = array();
    if ($handle = @fopen("{$filepath}/addresses.txt", 'r')) {
      if (is_resource($handle)) {
        while (($buffer = fgets($handle)) !== FALSE) {
          list($country, $administrative_area, $sub_administrative_area, $locality, $dependent_locality, $postal_code, $thoroughfare, $premise, $sub_premise) = explode("\t", $buffer);
          $fields[] = array(
            'country' => $country == 'NULL' ? NULL : trim($country),
            'administrative_area' => $administrative_area == 'NULL' ? NULL : trim($administrative_area),
            'sub_administrative_area' => $sub_administrative_area == 'NULL' ? NULL : trim($sub_administrative_area),
            'locality' => $locality == 'NULL' ? NULL : trim($locality),
            'dependent_locality' => $dependent_locality == 'NULL' ? NULL : trim($dependent_locality),
            'postal_code' => $postal_code == 'NULL' ? NULL : trim($postal_code),
            'thoroughfare' => $thoroughfare == 'NULL' ? NULL : trim($thoroughfare),
            'premise' => $premise == 'NULL' ? NULL : trim($premise),
            'sub_premise' => $sub_premise == 'NULL' ? NULL : trim($sub_premise),
          );
        }
      }
      fclose($handle);
    }
  }
  return $fields;
}