source: sipes/modules_contrib/views/modules/upload.views.inc @ a8b1f3f

stableversion-3.0
Last change on this file since a8b1f3f was 59029b2, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo la version del modulo views

  • Propiedad mode establecida a 100644
File size: 4.3 KB
Línea 
1<?php
2/**
3 * @file
4 *
5 * Provide views data and handlers for upload tables that are not represented by
6 * their own module.
7 */
8
9/**
10 * @defgroup views_upload_module upload.module handlers
11 *
12 * @{
13 */
14
15/**
16 * Implementation of hook_views_data()
17 */
18function upload_views_data() {
19  $data = array();
20
21  // ----------------------------------------------------------------------
22  // upload table
23
24  $data['upload']['table']['group']  = t('Upload');
25
26  $data['upload']['table']['join'] = array(
27    'node' => array(
28      'left_field' => 'vid',
29      'field' => 'vid',
30    ),
31    'node_revisions' => array(
32      'left_field' => 'vid',
33      'field' => 'vid',
34    ),
35    'files' => array(
36      'left_field' => 'fid',
37      'field' => 'fid',
38    ),
39  );
40
41  $data['upload']['vid'] = array(
42    'title' => t('Node'),
43    'help' => t('The node the uploaded file is attached to'),
44    'relationship' => array(
45      'label' => t('upload'),
46      'base' => 'node',
47      'base field' => 'vid',
48      // This allows us to not show this relationship if the base is already
49      // node so users won't create circular relationships.
50      'skip base' => array('node', 'node_revisions'),
51    ),
52  );
53
54  $data['upload']['description'] = array(
55    'title' => t('Description'),
56    'help' => t('The description of the uploaded file.'),
57    'field' => array(
58      'handler' => 'views_handler_field_upload_description',
59      'click sortable' => TRUE,
60     ),
61    'sort' => array(
62      'handler' => 'views_handler_sort',
63    ),
64    'filter' => array(
65      'handler' => 'views_handler_filter_string',
66    ),
67    'argument' => array(
68      'handler' => 'views_handler_argument_string',
69    ),
70  );
71
72  $data['upload']['list'] = array(
73    'title' => t('Listed'),
74    'help' => t('Whether or not the file is marked to be listed.'),
75    'field' => array(
76      'handler' => 'views_handler_field_boolean',
77      'click sortable' => TRUE,
78    ),
79    'filter' => array(
80      'handler' => 'views_handler_filter_boolean_operator',
81      'label' => t('Published'),
82      'type' => 'yes-no',
83    ),
84    'sort' => array(
85      'handler' => 'views_handler_sort',
86    ),
87  );
88
89  $data['upload']['weight'] = array(
90    'title' => t('Weight'),
91    'help' => t('The weight, used for sorting.'),
92    'field' => array(
93      'handler' => 'views_handler_field_numeric',
94      'click sortable' => TRUE,
95     ),
96    'sort' => array(
97      'handler' => 'views_handler_sort',
98    ),
99    'filter' => array(
100      'handler' => 'views_handler_filter_numeric',
101    ),
102  );
103
104  return $data;
105}
106
107/**
108 * Implementation of hook_views_data_alter()
109 */
110function upload_views_data_alter(&$data) {
111  $data['node']['upload_fid'] = array(
112    'group' => t('Upload'),
113    'title' => t('Attached files'),
114    'help' => t('All files attached to a node with upload.module.'),
115    'real field' => 'vid',
116    'field' => array(
117      'handler' => 'views_handler_field_upload_fid',
118      'no group by' => TRUE,
119    ),
120    'filter' => array(
121      'handler' => 'views_handler_filter_upload_fid',
122      'title' => t('Has attached files'),
123      'type' => 'yes-no',
124      'help' => t('Only display items with attached files. This can cause duplicates if there are multiple attached files.'),
125    ),
126    'relationship' => array(
127      'title' => t('Attached files'),
128      'help' => t('Add a relationship to gain access to more file data for files uploaded by upload.module. Note that this relationship will cause duplicate nodes if there are multiple files attached to the node.'),
129      'relationship table' => 'upload',
130      'relationship field' => 'fid',
131      'base' => 'files',
132      'base field' => 'fid',
133      'handler' => 'views_handler_relationship',
134      'label' => t('Files'),
135    ),
136  );
137}
138
139/**
140 * Implementation of hook_views_handlers() to register all of the basic handlers
141 * views uses.
142 */
143function upload_views_handlers() {
144  return array(
145    'info' => array(
146      'path' => drupal_get_path('module', 'views') . '/modules/upload',
147    ),
148    'handlers' => array(
149      'views_handler_field_upload_fid' => array(
150        'parent' => 'views_handler_field_prerender_list',
151      ),
152      'views_handler_field_upload_description' => array(
153        'parent' => 'views_handler_field',
154      ),
155      'views_handler_filter_upload_fid' => array(
156        'parent' => 'views_handler_filter_boolean_operator',
157      ),
158    ),
159  );
160}
161
162/**
163 * @}
164 */
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.