You are here

function location_context_create_location in Location 7.4

Same name and namespace in other branches
  1. 6.3 plugins/contexts/location.inc \location_context_create_location()
  2. 7.5 plugins/contexts/location.inc \location_context_create_location()
  3. 7.3 plugins/contexts/location.inc \location_context_create_location()

Create a context, either from configuration or an argument on the URL.

Parameters

$empty: If true, just return an empty context.

$data: If from settings form, a form values array. If from argument, a string.

$conf: TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg.

Return value

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 39
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 = $data['nid'];
      $data = location_load_location($lid);
      $data['nid'] = $nid;
    }
  }
  if (!empty($data)) {
    $context->data = $data;
    $context->title = $data['city'];
    $context->argument = $data['lid'];
    return $context;
  }
}