You are here

function _cck_phone_custom_cc in Phone Number 6

Same name and namespace in other branches
  1. 7 cck_phone.module \_cck_phone_custom_cc()

Get list of country codes that has custom includes.

Return value

Array of country codes abbreviation or empty array if none exist.

4 calls to _cck_phone_custom_cc()
cck_phone_field_settings in ./cck_phone.module
Implementation of hook_field_settings().
_cck_phone_cc_options in ./cck_phone.module
Generate an array of country codes, for use in select or checkboxes form.
_cck_phone_sanitize in ./cck_phone.module
Cleanup user-entered values for a phone number field according to field settings.
_cck_phone_validate in ./cck_phone.module

File

./cck_phone.module, line 375
Defines phone number fields for CCK. Provide some verifications on the phone numbers

Code

function _cck_phone_custom_cc() {
  static $countrycodes;
  if (!isset($countrycodes)) {

    // load custom country codes phone number includes
    $path = drupal_get_path('module', 'cck_phone') . '/includes';

    // scan include phone numbers directory
    $files = file_scan_directory($path, '^phone\\..*\\.inc$');
    $countrycodes = array();
    foreach ($files as $file) {
      module_load_include('inc', 'cck_phone', '/includes/' . $file->name);
      list($dummy, $countrycode) = explode('.', $file->name);

      // faster using array key
      $countrycodes[$countrycode] = $countrycode;
    }
  }
  return $countrycodes;
}