You are here

function _gmap_get_marker_titles in GMap Module 7.2

Same name and namespace in other branches
  1. 5 gmap_markerinfo.inc \_gmap_get_marker_titles()
  2. 6.2 gmap_markerinfo.inc \_gmap_get_marker_titles()
  3. 6 gmap_markerinfo.inc \_gmap_get_marker_titles()
  4. 7 gmap_markerinfo.inc \_gmap_get_marker_titles()

Get marker titles.

1 call to _gmap_get_marker_titles()
gmap_get_marker_titles in ./gmap.module
Get the list of marker titles.

File

./gmap_markerinfo.inc, line 260
GMap marker information routines.

Code

function _gmap_get_marker_titles() {
  $markerdirs = variable_get('gmap_markerfiles', array(
    drupal_get_path('module', 'gmap') . '/markers',
  ));
  $markercustomdir = variable_get('gmap_marker_custom_dir', NULL);
  if ($markercustomdir) {
    $markerdirs[] = $markercustomdir;
  }
  if (module_exists('libraries')) {
    $markercustomdir = libraries_get_path('gmap_markers');
    if ($markercustomdir) {
      $markerdirs[] = $markercustomdir;
    }
  }

  // The following routines are designed to be easy to comprehend, not fast.
  // This whole process gets cached.
  // Get the ini files.
  $titles = array();
  if (is_array($markerdirs)) {
    foreach ($markerdirs as $markerdir) {
      $inifiles = file_scan_directory($markerdir, '/.*\\.ini$/');

      // Parse the ini files and store by path.
      $inis = array();
      foreach ($inifiles as $file) {
        $data = parse_ini_file($file->uri, TRUE);
        if (isset($data['defaults'])) {

          // Ignore defaults.
          unset($data['defaults']);
        }
        foreach ($data as $k => $v) {
          if (strpos($k, '.') !== FALSE) {

            // Ignore files.
            unset($data[$k]);
          }
        }
        $inis[] = $data;
      }
      unset($inifiles);

      // @codingStandardsIgnoreStart
      foreach ($inis as $ini => $inidata) {
        foreach ($inidata as $k => $v) {
          $titles[$k] = t($inis[$ini][$k]['name']);
        }
      }

      // @codingStandardsIgnoreEnd
    }
  }
  return $titles;
}