You are here

function _uc_country_import_list in Ubercart 7.3

Returns an array of country files that can be installed or updated.

2 calls to _uc_country_import_list()
uc_country_import_form in uc_store/uc_store.countries.inc
Imports settings from a country file.
uc_store_uc_store_status in uc_store/uc_store.admin.inc
Implements hook_uc_store_status().

File

uc_store/uc_store.module, line 1568
Contains global Ubercart functions and store administration functionality.

Code

function _uc_country_import_list() {
  $dir = drupal_get_path('module', 'uc_store') . '/countries/';
  $countries = array();
  if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
      while (($file = readdir($dh)) !== FALSE) {
        switch (filetype($dir . $file)) {
          case 'file':
            if (substr($file, -4, 4) == '.cif') {
              $pieces = explode('_', substr($file, 0, strlen($file) - 4));
              $country_id = intval($pieces[count($pieces) - 2]);
              $version = $pieces[count($pieces) - 1];
              if (!isset($countries[$country_id])) {
                $countries[$country_id]['version'] = $version;
                $countries[$country_id]['file'] = $file;
              }
              else {
                if ($version > $countries[$country_id]['version']) {
                  $countries[$country_id]['version'] = $version;
                  $countries[$country_id]['file'] = $file;
                }
              }
            }
            break;
        }
      }
      closedir($dh);
    }
  }
  return $countries;
}