/[drupal]/contributions/modules/dbfm/dbfm_views.inc
ViewVC logotype

Contents of /contributions/modules/dbfm/dbfm_views.inc

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


Revision 1.1 - (show annotations) (download) (as text)
Thu Oct 18 21:05:24 2007 UTC (2 years, 1 month ago) by rooey
Branch: MAIN
CVS Tags: DRUPAL-5--3-3, DRUPAL-5--3-2, DRUPAL-5--3-1, DRUPAL-5--3-0, DRUPAL-5--2-2, DRUPAL-5--2-0, DRUPAL-5--3-4, DRUPAL-5--1-0-BETA2a, DRUPAL-5--3-2-RC0, DRUPAL-5--2-1, DRUPAL-5--3-2-RC-1, DRUPAL-5--3-0-ALPHA1, DRUPAL-5--1-0-BETA1, DRUPAL-5--3-0-RC0, DRUPAL-5--3-4-BETA-1, DRUPAL-5--1-0-BETA2, DRUPAL-5--2-1-RC0, DRUPAL-5--1-0, DRUPAL-5--3-1-RC0, HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
by rooey. Initial checkin of DBFM code - based on <a href=http://drupal.org/user/28334>robmilne</a>'s <a href=http://drupal.org/project/webfm>WebFM</a>.
1 <?php
2 /* $id$ */
3
4 function webfm_views_tables(){
5 $tables = array();
6
7 /**
8 * The webfm_attach table links directly to the node table,
9 * via the nid field
10 */
11
12 $tables['webfm_attach'] = array('name' => 'webfm_attach',
13 'join' => array(
14 'type' => 'inner',
15 'left' => array(
16 'table' => 'node',
17 'field' => 'nid'
18 ),
19 'right' => array(
20 'field' => 'nid'
21 ),
22 ),
23 );
24 $tables['webfm_file'] = array('name' => 'webfm_file',
25 'join' => array(
26 'type' => 'inner',
27 'left' => array(
28 'table' => 'webfm_attach',
29 'field' => 'fid'
30 ),
31 'right' => array(
32 'table' => 'webfm_file',
33 'field' => 'fid'
34 ),
35 ),
36 'fields' => array(
37 'all_files' => array(
38 'name' => t('WebFM: All files by name'),
39 'notafield' => true,
40 'handler' => 'webfm_views_handler_file_all_files',
41 'option' => array(
42 '#type' => 'select',
43 '#options' => array(
44 'link' => t('With links'),
45 'nolink' => t('Without links'),
46 )
47 ),
48 'sortable' => false,
49 'help' => t('Display ALL the files that have been attached a node via WebFM (with or without links to the files themselves). All files are displayed in a single field per node.'),
50 ),
51 'fname' => array(
52 'name' => t('WebFM: File name'),
53 'handler' => array (
54 'webfm_views_handler_file_filename_download' => t('With links'),
55 'webfm_views_handler_file_filename' => t('Without links'),
56 ),
57 'sortable' => true,
58 // consider 'option' --> link inline - or link force download - extra arg for webfm send
59 'addlfields' => array('fid'),
60 'help' => t('Display the name of files that have been attached to a node via WebFM (with or without links to the files themselves)'),
61 ),
62 'fsize' => array(
63 'name' => t('WebFM: File size'),
64 'sortable' => true,
65 'handler' => 'webfm_views_handler_file_size',
66 'help' => t('Display the file size of files that have been attached to a node via WebFM')
67 ),
68 'fmime' => array(
69 'name' => t('WebFM: File mime type'),
70 'sortable' => true,
71 'help' => t('Display the file mime type of files that have been attached to a node via WebFM'),
72 ),
73 'ftitle' => array(
74 'name' => t('WebFM metadata: file title'),
75 'sortable' => true,
76 'help' => t('Display the file title of files that have been attached to a node via WebFM')
77 ),
78 'fdesc' => array(
79 'name' => t('WebFM metadata: File description'),
80 'sortable' => true,
81 'help' => t('Display the description of files that have been attached to a node via WebFM')
82 ),
83 'flang' => array(
84 'name' => t('WebFM metadata: File language'),
85 'sortable' => true,
86 'help' => t('Display the language of files that have been attached to a node via WebFM')
87 ),
88 'fpublisher' => array(
89 'name' => t('WebFM metadata: File publisher'),
90 'sortable' => true,
91 'help' => t('Display the publisher of files that have been attached to a node via WebFM')
92 )
93 ),
94 'filters' => array(
95 'fname' => array(
96 'name' => t('WebFM: File name'),
97 'operator' => 'views_handler_operator_like',
98 'handler' => 'views_handler_filter_like',
99 'help' => t('This filter allows nodes to be filtered by the names of files that have been attached via WebFM. e.g. show only nodes with a file called "foo.txt" attached to them'),
100 ),
101 'fsize' => array(
102 'name' => t('WebFM: File size'),
103 'operator' => 'views_handler_operator_gtlt',
104 'help' => t('This filter allows nodes to be filtered by the size of files that have been attached via WebFM. e.g. show only nodes with files larger than 1M attached to them'),
105 ),
106 'fmime' => array(
107 'name' => t('WebFM: File mime type'),
108 'operator' => 'views_handler_operator_like',
109 'handler' => 'views_handler_filter_like',
110 'help' => t('This filter allows nodes to be filtered by the mime type of files that have been attached via WebFM. e.g. show only nodes with a .pdf document attached to them'),
111 ),
112 'ftitle' => array(
113 'name' => t('WebFM metadata: File title'),
114 'operator' => 'views_handler_operator_like',
115 'handler' => 'views_handler_filter_like',
116 'help' => t('This filter allows nodes to be filtered by the title of files that have been attached via WebFM. e.g. show only nodes with a file attached wich has a metadata title like "bar"'),
117 ),
118 'fdesc' => array(
119 'name' => t('WebFM metadata: File description'),
120 'operator' => 'views_handler_operator_like',
121 'handler' => 'views_handler_filter_like',
122 'help' => t('This filter allows nodes to be filtered by the description of files that have been attached via WebFM. e.g. show only nodes with a file attached which have a metadata description which contains all the words "foo, bar and baz"'),
123 ),
124 'flang' => array(
125 'name' => t('WebFM metadata: File language'),
126 'operator' => 'views_handler_operator_like',
127 'handler' => 'views_handler_filter_like',
128 'help' => t('This filter allows nodes to be filtered by the language of files that have been attached via WebFM. e.g. show only nodes with a file attached which have a metadata language equal to "fr"'),
129 ),
130 ),
131 'sorts' => array(
132 'fname' => array(
133 'name' => t('WebFM: Sort by file name'),
134 'help' => t('Sort by file name'),
135 ),
136 'fsize' => array(
137 'name' => t('WebFM: Sort by file size'),
138 'help' => t('Sort by file size.'),
139 ),
140 'fmime' => array(
141 'name' => t('WebFM: Sort by mime type'),
142 'help' => t('Sort by mime type.'),
143 ),
144 'ftitle' => array(
145 'name' => t('WebFM metadata: Sort by file title'),
146 'help' => t('Sort by file metadata title'),
147 ),
148 'flang' => array(
149 'name' => t('WebFM metadata: Sort by file language'),
150 'help' => t('Sort by mime type.'),
151 ),
152 'fpublisher' => array(
153 'name' => t('WebFM metadata: Sort by file publisher'),
154 'help' => t('Sort by mime type.'),
155 ),
156 )
157 );
158
159 return $tables;
160
161 }
162
163 function webfm_views_handler_file_all_files($fieldinfo, $fielddata, $value, $data){
164 //global $base_url;
165 $links = array();
166
167 $query = "SELECT wf.* FROM {webfm_file} wf INNER JOIN {webfm_attach} wa ON wf.fid = wa.fid WHERE wa.nid = %d ORDER BY %s";
168 $result = db_query($query, $data->nid, 'wa.weight');
169 while ($file = db_fetch_object($result)) {
170 if ($fielddata['options'] == 'nolink') {
171 $links[] = check_plain($file->fname);
172 }
173 else {
174 // could add the icon here - really this should be all a theme thing where the user decides...
175 // but until then lets just provide the links with the file names
176 //$icon_path = $base_url.'/'.variable_get('webfm_icon_dir', 'modules/webfm/image/icon').'/f.gif';
177 //$links[] = l('<img src="'.$icon_path.'" alt="[file]" />&nbsp;', 'webfm_send/'.$file->fid.'/0', '', '' , '' , '', TRUE). l(check_plain($file->fname), 'webfm_send/'.$file->fid);
178 $links[] = l(check_plain($file->fname), 'webfm_send/'.$file->fid);
179 }
180 }
181 return implode(' | ', $links);
182 }
183
184 function webfm_views_handler_file_filename($fieldinfo, $fielddata, $value, $data){
185 return $value;
186 }
187
188 function webfm_views_handler_file_filename_download($fieldinfo, $fielddata, $value, $data){
189 return l(check_plain($value), 'webfm_send/'.$data->webfm_file_fid);
190 }
191
192 function webfm_views_handler_file_size($fieldinfo, $fielddata, $value, $data){
193 return format_size($value);
194 }
195
196
197 function webfm_views_default_views(){
198
199
200 }

  ViewVC Help
Powered by ViewVC 1.1.2