location_www.module in Location 7.3
Add www adress fields to Location address.
File
contrib/location_www/location_www.moduleView source
<?php
/**
* @file
* Add www adress fields to Location address.
*/
/**
* Implements hook_locationapi().
*/
function location_www_locationapi(&$location, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'fields':
return array(
'www' => t('www adress'),
);
case 'defaults':
return array(
'www' => array(
'default' => '',
'collect' => 0,
'weight' => 30,
),
);
case 'field_expand':
if ($a3 == 'www') {
if (is_array($a4)) {
$settings = $a4;
}
else {
// On this $op, $a4 is now expected to be an array,
// but we make an exception for backwards compatibility.
$settings = array(
'default' => NULL,
'weight' => NULL,
'collect' => $a4,
'widget' => NULL,
);
}
return array(
'#type' => 'textfield',
'#title' => t('www adress'),
'#size' => 31,
'#maxlength' => 2048,
'#description' => NULL,
'#required' => $settings['collect'] == 2,
'#default_value' => $location,
);
}
break;
case 'save':
db_delete('location_www')
->condition('lid', $location['lid'])
->execute();
if (!empty($location['www'])) {
db_insert('location_www')
->fields(array(
'lid' => $location['lid'],
'www' => $location['www'],
))
->execute();
}
break;
case 'load':
$fields = array();
$www = db_query('SELECT www FROM {location_www} WHERE lid = :lid', array(
':lid' => $location['lid'],
))
->fetchField();
$fields['www'] = $www ? $www : '';
return $fields;
case 'delete':
db_delete('location_www')
->condition('lid', $location['lid'])
->execute();
break;
}
}
/**
* Implements hook_views_api().
*/
function location_www_views_api() {
return array(
'api' => 3,
);
}
/**
* Implements hook_token_list().
*/
function location_www_token_list($type = 'all') {
if ($type == 'node' || $type == 'user' || $type == 'all') {
$tokens['location']['location-www_N'] = t('Location www adress (If there are multiple locations per node, N is the iteration, starting with 0)');
return $tokens;
}
}
Functions
Name![]() |
Description |
---|---|
location_www_locationapi | Implements hook_locationapi(). |
location_www_token_list | Implements hook_token_list(). |
location_www_views_api | Implements hook_views_api(). |