geo/geo.module, line 17
- Versions
- 6
geo($op = NULL)
Call an API function from the geo backend databases. This function will find and load the database backend files, and call the requested op from the backend or the default library, as needed.
Return value
mixed The result of the database operation execution.
Code
<?php
function geo($op = NULL) {
static $backend;
// Load common functions.
module_load_include('inc', 'geo');
// Load database-specific functions.
if (!isset($backend)) {
$backend = geo_backend_type();
module_load_include('inc', 'geo', 'db/'. $backend);
}
// Call the appropriate API function: If geo_$backend_$op exists, call that.
// Otherwise, resort to geo_$op. This creates a sort of inheritence system.
$args = func_get_args();
if($args) {
$op = array_shift($args);
if (!function_exists($func = 'geo_'. $backend .'_'. $op)) {
$func = 'geo_'. $op;
}
if (!function_exists($func)) {
drupal_set_message(t('Call to undefined geo operation %op', array('%op' => $op)), 'error');
return FALSE;
}
return call_user_func_array($func, $args);
}
}
?> 