[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/views/modules/ -> upload.views.inc (source)

   1  <?php
   2  // $Id: upload.views.inc,v 1.16.2.1 2009/11/02 23:25:14 merlinofchaos Exp $
   3  /**
   4   * @file
   5   *
   6   * Provide views data and handlers for upload tables that are not represented by
   7   * their own module.
   8   */
   9  
  10  /**
  11   * @defgroup views_upload_module upload.module handlers
  12   *
  13   * @{
  14   */
  15  
  16  /**
  17   * Implementation of hook_views_data()
  18   */
  19  function upload_views_data() {
  20    $data = array();
  21  
  22    // ----------------------------------------------------------------------
  23    // upload table
  24  
  25    $data['upload']['table']['group']  = t('Upload');
  26  
  27    $data['upload']['table']['join'] = array(
  28      'node' => array(
  29        'left_field' => 'vid',
  30        'field' => 'vid',
  31      ),
  32      'node_revisions' => array(
  33        'left_field' => 'vid',
  34        'field' => 'vid',
  35      ),
  36      'files' => array(
  37        'left_field' => 'fid',
  38        'field' => 'fid',
  39      ),
  40    );
  41  
  42    $data['upload']['vid'] = array(
  43      'title' => t('Node'),
  44      'help' => t('The node the uploaded file is attached to'),
  45      'relationship' => array(
  46        'label' => t('upload'),
  47        'base' => 'node',
  48        'base field' => 'vid',
  49        // This allows us to not show this relationship if the base is already
  50        // node so users won't create circular relationships.
  51        'skip base' => array('node', 'node_revisions'),
  52      ),
  53    );
  54  
  55    $data['upload']['description'] = array(
  56      'title' => t('Description'),
  57      'help' => t('The description of the uploaded file.'),
  58      'field' => array(
  59        'handler' => 'views_handler_field_upload_description',
  60        'click sortable' => TRUE,
  61       ),
  62      'sort' => array(
  63        'handler' => 'views_handler_sort',
  64      ),
  65      'filter' => array(
  66        'handler' => 'views_handler_filter_string',
  67      ),
  68      'argument' => array(
  69        'handler' => 'views_handler_argument_string',
  70      ),
  71    );
  72  
  73    $data['upload']['list'] = array(
  74      'title' => t('Listed'),
  75      'help' => t('Whether or not the file is marked to be listed.'),
  76      'field' => array(
  77        'handler' => 'views_handler_field_boolean',
  78        'click sortable' => TRUE,
  79      ),
  80      'filter' => array(
  81        'handler' => 'views_handler_filter_boolean_operator',
  82        'label' => t('Published'),
  83        'type' => 'yes-no',
  84      ),
  85      'sort' => array(
  86        'handler' => 'views_handler_sort',
  87      ),
  88    );
  89  
  90    $data['upload']['weight'] = array(
  91      'title' => t('Weight'),
  92      'help' => t('The weight, used for sorting.'),
  93      'field' => array(
  94        'handler' => 'views_handler_field_numeric',
  95        'click sortable' => TRUE,
  96       ),
  97      'sort' => array(
  98        'handler' => 'views_handler_sort',
  99      ),
 100      'filter' => array(
 101        'handler' => 'views_handler_filter_numeric',
 102      ),
 103    );
 104  
 105    return $data;
 106  }
 107  
 108  /**
 109   * Implementation of hook_views_data_alter()
 110   */
 111  function upload_views_data_alter(&$data) {
 112    $data['node']['upload_fid'] = array(
 113      'group' => t('Upload'),
 114      'title' => t('Attached files'),
 115      'help' => t('All files attached to a node with upload.module.'),
 116      'real field' => 'vid',
 117      'field' => array(
 118        'handler' => 'views_handler_field_upload_fid',
 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   */
 143  function 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   */


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7