| 1 |
<?php
|
| 2 |
/*
|
| 3 |
* $Id: links_views.inc,v 1.1 2006/05/03 22:48:01 syscrusher Exp $
|
| 4 |
*
|
| 5 |
* Author: Eaton (Drupal.org user #16496)
|
| 6 |
*
|
| 7 |
* RELEASE STATUS: This is BETA code; do not use in production sites.
|
| 8 |
*/
|
| 9 |
|
| 10 |
function links_views_tables() {
|
| 11 |
$tables['links_node'] = array(
|
| 12 |
'name' => 'links_node',
|
| 13 |
"provider" => "links",
|
| 14 |
'join' => array(
|
| 15 |
'left' => array(
|
| 16 |
'table' => 'node',
|
| 17 |
'field' => 'nid'
|
| 18 |
),
|
| 19 |
'right' => array(
|
| 20 |
'field' => 'nid'
|
| 21 |
),
|
| 22 |
),
|
| 23 |
'fields' => array(
|
| 24 |
'link_title' => array(
|
| 25 |
'name' => t('Links: Link title'),
|
| 26 |
'help' => t('The title of the associated link.'),
|
| 27 |
'query_handler' => 'links_qhandler_title',
|
| 28 |
'handler' => array(
|
| 29 |
'links_handler_field_title_clickable' => 'Show as link',
|
| 30 |
'links_handler_field_title' => 'Show as text',
|
| 31 |
),
|
| 32 |
),
|
| 33 |
'clicks' => array(
|
| 34 |
'name' => t('Links: Clickthroughs'),
|
| 35 |
'help' => t('The number of clickthroughs for the associated link.'),
|
| 36 |
),
|
| 37 |
),
|
| 38 |
'sorts' => array(
|
| 39 |
'clicks' => array(
|
| 40 |
'name' => t('Links: Clickthroughs'),
|
| 41 |
'help' => t('This allows you to sort by the number of link clickthroughs.'),
|
| 42 |
)
|
| 43 |
),
|
| 44 |
);
|
| 45 |
$tables['links'] = array(
|
| 46 |
'name' => 'links',
|
| 47 |
"provider" => "links",
|
| 48 |
'join' => array(
|
| 49 |
'left' => array(
|
| 50 |
'table' => 'links_node',
|
| 51 |
'field' => 'lid'
|
| 52 |
),
|
| 53 |
'right' => array(
|
| 54 |
'field' => 'lid'
|
| 55 |
),
|
| 56 |
),
|
| 57 |
'fields' => array(
|
| 58 |
'url' => array(
|
| 59 |
'name' => t('Links: Link URL'),
|
| 60 |
'query_handler' => 'links_qhandler_url',
|
| 61 |
'handler' => 'links_handler_field_url',
|
| 62 |
'help' => t('The clickable URL of the link.'),
|
| 63 |
),
|
| 64 |
),
|
| 65 |
);
|
| 66 |
return $tables;
|
| 67 |
}
|
| 68 |
|
| 69 |
function links_handler_field_url($fieldinfo, $fielddata, $value, $data) {
|
| 70 |
return l($value, $value);
|
| 71 |
}
|
| 72 |
|
| 73 |
function links_handler_field_title_clickable($fieldinfo, $fielddata, $value, $data) {
|
| 74 |
$title = $data->links_node_link_title;
|
| 75 |
if ($title == '') {
|
| 76 |
$title = $data->global_link_title;
|
| 77 |
}
|
| 78 |
return l($title, $data->link_title_url);
|
| 79 |
}
|
| 80 |
|
| 81 |
function links_handler_field_title($fieldinfo, $fielddata, $value, $data) {
|
| 82 |
$title = $data->links_node_link_title;
|
| 83 |
if ($title == '') {
|
| 84 |
$title = $data->global_link_title;
|
| 85 |
}
|
| 86 |
return $title;
|
| 87 |
}
|
| 88 |
|
| 89 |
function links_qhandler_url($field, $fieldinfo, &$query) {
|
| 90 |
$query->ensure_table('links');
|
| 91 |
$query->add_field('link_title', 'links', 'global_link_title');
|
| 92 |
}
|
| 93 |
|
| 94 |
function links_qhandler_title($field, $fieldinfo, &$query) {
|
| 95 |
$query->ensure_table('links');
|
| 96 |
$query->add_field('link_title', 'links', 'global_link_title');
|
| 97 |
$query->add_field('url', 'links', 'link_title_url');
|
| 98 |
}
|