/[drupal]/contributions/modules/links/links_views.inc
ViewVC logotype

Contents of /contributions/modules/links/links_views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Thu Jun 22 03:01:14 2006 UTC (3 years, 5 months ago) by syscrusher
Branch: MAIN
CVS Tags: DRUPAL-5--1-12-BETA1, DRUPAL-5--1-7, DRUPAL-5--1-9, DRUPAL-5--1-8, DRUPAL-5--1-5, DRUPAL-5--1-6, DRUPAL-5--1-3, DRUPAL-5--1-2, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-4-7--1-1, DRUPAL-5--1-4, DRUPAL-6--1-0-BETA15, DRUPAL-6--1-0-BETA14, DRUPAL-6--1-0-BETA13, DRUPAL-6--1-0-BETA12, DRUPAL-6--1-0-BETA11, DRUPAL-6--1-0-BETA10, DRUPAL-5--1-11, DRUPAL-5--1-10, DRUPAL-5--1-13, DRUPAL-5--1-12, DRUPAL-6--1-0-BETA9, DRUPAL-6--1-0-BETA8, DRUPAL-6--1-0-BETA3, DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA1, DRUPAL-6--1-0-BETA7, DRUPAL-6--1-0-BETA6, DRUPAL-6--1-0-BETA5, HEAD
Branch point for: DRUPAL-4-7, DRUPAL-6--1, DRUPAL-6--2, DRUPAL-5
Changes since 1.1: +31 -35 lines
File MIME type: text/x-php
Committing improvements to "views" support, contributed by Eaton pursuant
to #52639, and a bug fix for the weblinks menu item, contributed by
moggy pursuant to #53942.
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 }

  ViewVC Help
Powered by ViewVC 1.1.2