You are here

function getlocations_regenerate_markers in Get Locations 6

Same name and namespace in other branches
  1. 6.2 getlocations.module \getlocations_regenerate_markers()
  2. 7.2 getlocations.module \getlocations_regenerate_markers()
  3. 7 getlocations.module \getlocations_regenerate_markers()

Regenerate the markerdata file.

2 calls to getlocations_regenerate_markers()
getlocations_flush_caches in ./getlocations.module
Implementation of hook_flush_caches().
_getlocations_rebuild_marker_js_submit in ./getlocations.admin.inc
Rebuild marker js.

File

./getlocations.module, line 908
Displays locations on a map. for Drupal 6 using version 3 googlemaps API

Code

function getlocations_regenerate_markers() {
  $contents = '';
  $contents .= "// Getlocations marker image data.\n";
  $contents .= "Drupal.getlocations.iconpath = " . drupal_to_js(base_path()) . ";\n";
  $contents .= "Drupal.getlocations.icondata = " . drupal_to_js(getlocations_get_icondata(TRUE)) . ";\n";

  // Create the js/ within the files folder.
  $jspath = getlocations_get_markerfile(TRUE, FALSE);
  $jsfile = getlocations_get_markerfile(FALSE, FALSE);
  if ($jspath && $jsfile && file_check_directory($jspath, FILE_CREATE_DIRECTORY) && file_save_data($contents, $jsfile, FILE_EXISTS_REPLACE)) {

    // Also regenerate the cached marker titles array
    getlocations_get_marker_titles(TRUE);
  }
  else {

    // failed
    drupal_set_message(t('Getlocations is unable to save the marker bundle, so the markers will not work. Please check file system permissions of %filepath!', array(
      '%filepath' => $jsfile,
    )), 'error');
    watchdog('getlocations', 'Getlocations write error when saving the marker bundle to %filepath.', array(
      '%filepath' => $jsfile,
    ), WATCHDOG_ERROR);
  }
}