function location_node_nodeapi in Location 6.3
Same name and namespace in other branches
- 5.3 location_node.module \location_node_nodeapi()
Implementation of hook_nodeapi().
File
- ./
location_node.module, line 26 - Associate locations with nodes.
Code
function location_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'delete revision':
$locations = array();
location_save_locations($locations, array(
'vid' => $node->vid,
));
break;
case 'delete':
$locations = array();
location_save_locations($locations, array(
'nid' => $node->nid,
));
break;
case 'load':
$locations = location_load_locations($node->vid);
$location = count($locations) ? $locations[0] : array();
return array(
'locations' => $locations,
'location' => $location,
);
case 'insert':
case 'update':
if (!empty($node->locations)) {
location_save_locations($node->locations, array(
'nid' => $node->nid,
'vid' => $node->vid,
));
}
break;
case 'view':
if (variable_get('location_display_location', 1)) {
$settings = variable_get('location_settings_node_' . $node->type, array());
if (isset($settings['display']['teaser']) && isset($settings['display']['full'])) {
if ($a3 && $settings['display']['teaser'] || !$a3 && $settings['display']['full']) {
$node->content['locations'] = location_display($settings, $node->locations);
}
}
}
break;
case 'rss item':
$items = array();
$settings = variable_get('location_settings_node_' . $node->type, array());
$mode = isset($settings['rss']['mode']) ? $settings['rss']['mode'] : 'simple';
if ($mode == 'none') {
return;
}
if (is_array($node->locations)) {
foreach ($node->locations as $location) {
if ($item = location_rss_item($location, $mode)) {
$items[] = $item;
}
}
}
return $items;
}
}