function photos_views_data_alter in Album Photos 7.3
Same name and namespace in other branches
- 8.5 photos.module \photos_views_data_alter()
- 6.0.x photos.module \photos_views_data_alter()
Implements hook_views_data_alter().
File
- inc/
views/ photos.views.inc, line 243 - Integrate with the views module.
Code
function photos_views_data_alter(&$views_data) {
// Join node info to albums.
$views_data['node']['table']['join']['photos_album'] = array(
'left_field' => 'pid',
'field' => 'nid',
);
if (module_exists('votingapi')) {
// Add relationship handlers for both votingapi tables, for album photos.
$default_relationships[] = array(
'description' => t('photos'),
'entity_type' => 'image',
'base_table' => 'photos_image',
'entity_id_column' => 'fid',
'pseudo_vote' => 'votingapi_vote',
// for legacy compatability w/RC1.
'pseudo_cache' => 'votingapi_cache',
);
foreach ($default_relationships as $data) {
$pseudo = str_replace(array(
' ',
'-',
'.',
), '_', $data['entity_type'] . '_' . $data['entity_id_column']);
$pseudo_vote = empty($data['pseudo_vote']) ? 'vapi_' . $pseudo : $data['pseudo_vote'];
$pseudo_cache = empty($data['pseudo_cache']) ? 'vapic_' . $pseudo : $data['pseudo_cache'];
$views_data[$data['base_table']][$pseudo_vote]['relationship'] = array(
'title' => 'Votes',
'help' => 'Votes cast by users on ' . $data['description'] . '.',
'base' => 'votingapi_vote',
'field' => 'entity_id',
'relationship field' => $data['entity_id_column'],
'handler' => 'votingapi_views_handler_relationship',
'extra' => array(
array(
'field' => 'entity_type',
'value' => $data['entity_type'],
'numeric' => FALSE,
),
),
);
$views_data[$data['base_table']][$pseudo_cache]['relationship'] = array(
'title' => 'Vote results',
'help' => 'Aggregate results of votes cast on ' . $data['description'] . '.',
'base' => 'votingapi_cache',
'field' => 'entity_id',
'relationship field' => $data['entity_id_column'],
'handler' => 'votingapi_views_handler_relationship',
'extra' => array(
array(
'field' => 'entity_type',
'value' => $data['entity_type'],
'numeric' => FALSE,
),
),
);
}
}
}