You are here

function geophp_load in geoPHP 7

Same name and namespace in other branches
  1. 8 geophp.module \geophp_load()

Loads the geoPHP library.

Return value

Returns the filename of the included geoPHP library when successful, FALSE otherwise.

1 call to geophp_load()
geophp_requirements in ./geophp.module
Implementation of hook_requirements().

File

./geophp.module, line 10

Code

function geophp_load() {
  static $static_cache = FALSE;
  $already_found = FALSE;
  if (!$static_cache) {

    // Edge case: Another module (likely Geofield) has already loaded the class from somewhere else.
    if (class_exists('geoPHP')) {
      $static_cache = TRUE;
      $already_found = TRUE;
    }
    if (module_exists('libraries')) {
      $path = libraries_get_path('geoPHP');
      $file = DRUPAL_ROOT . '/' . $path . '/geoPHP.inc';
      if (file_exists($file) && $static_cache !== TRUE) {
        include_once $file;
        $already_found = TRUE;
        $static_cache = $file;
      }
    }

    // If other options don't exist, load module's copy of geoPHP.
    if (!$already_found) {
      $static_cache = module_load_include('inc', 'geophp', 'geoPHP/geoPHP');
    }
  }
  return $static_cache;
}