function location_context_create_location in Location 7.3
Same name and namespace in other branches
- 6.3 plugins/contexts/location.inc \location_context_create_location()
- 7.5 plugins/contexts/location.inc \location_context_create_location()
- 7.4 plugins/contexts/location.inc \location_context_create_location()
Create a context, either from configuration or an argument on the URL.
Parameters
bool $empty: If true, just return an empty context.
array $data: If from settings form, a form values array. If from argument, a string.
bool $conf: TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg.
Return value
object a Context object
1 string reference to 'location_context_create_location'
- location_location_ctools_contexts in plugins/
contexts/ location.inc - Implement hook_[context_name]_ctools_contexts().
File
- plugins/
contexts/ location.inc, line 41 - Creates a location context.
Code
function location_context_create_location($empty, $data = NULL, $conf = FALSE) {
$context = new ctools_context('location');
$context->plugin = 'location';
if ($empty) {
return $context;
}
if ($conf) {
$lid = is_array($data) && isset($data['lid']) ? $data['lid'] : (is_object($data) ? $data->lid : 0);
if (is_array($data) || !empty($reload)) {
$nid = isset($data['nid']) ? $data['nid'] : NULL;
$data = location_load_location($lid);
$data['nid'] = is_null($nid) ? FALSE : $nid;
}
}
if (!empty($data)) {
$context->data = $data;
$context->title = isset($data['city']) ? $data['city'] : '';
$context->argument = $data['lid'];
return $context;
}
}