[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

   1  <?php
   2  // $Id: image.views.inc,v 1.4.2.1 2010/08/03 17:43:00 sun Exp $
   3  
   4  /**
   5   * @file
   6   * Views integration for Image module.
   7   */
   8  
   9  /**
  10   * Implementation of hook_views_data().
  11   */
  12  function image_views_data() {
  13    $data = array();
  14  
  15    /**
  16     * {image} table, using {node} as base table.
  17     *
  18     * This is needed for the image_file alias to work. Possibly a bug in views?
  19     * @see http://drupal.org/node/425334
  20     */
  21    $data['image']['table']['group'] = t('Image');
  22    $data['image']['table']['join'] = array(
  23      'node' => array(
  24        'left_field' => 'nid',
  25        'field' => 'nid',
  26      ),
  27      'files' => array(
  28        'left_field' => 'fid',
  29        'field' => 'fid',
  30      ),
  31    );
  32  
  33    /**
  34     * {image} table alias, using {files} as base table.
  35     */
  36    $data['image_file']['table']['group'] = t('Image');
  37    $data['image_file']['table']['join'] = array(
  38      'files' => array(
  39        'table' => 'image',
  40        'left_field' => 'fid',
  41        'field' => 'fid',
  42      ),
  43    );
  44    // The preset size of the image.
  45    $data['image_file']['image_size'] = array(
  46      'title' => t('Image preset size'),
  47      'help' => t('The preset image size of an image, e.g. <em>Original</em>, <em>Thumbnail</em>, etc.'),
  48      'field' => array(
  49        'handler' => 'image_handler_field_image_size',
  50        'click sortable' => TRUE,
  51      ),
  52      'argument' => array(
  53        'handler' => 'image_handler_argument_image_size',
  54        'parent' => 'views_handler_argument_string',
  55      ),
  56      'filter' => array(
  57        'handler' => 'image_handler_filter_image_size',
  58      ),
  59    );
  60    // Relationship to the node base.
  61    // Allows us to go {files} --> {image} --> {node}.
  62    $data['image_file']['nid'] = array(
  63      'relationship' => array(
  64        'title' => t('Node'),
  65        'label' => t('Image node'),
  66        'help' => t('A relationship to gain access to the corresponding node of an image file uploaded via Image module.'),
  67        'base' => 'node',
  68        'field' => 'nid',
  69        'relationship table' => 'image',
  70        'relationship field' => 'nid',
  71        'base field' => 'nid',
  72        'handler' => 'views_handler_relationship',
  73      ),
  74    );
  75  
  76    /**
  77     * {image} table alias, using {node} as base table.
  78     */
  79    $data['image_node']['table']['group'] = t('Image');
  80    $data['image_node']['table']['join'] = array(
  81      'node' => array(
  82        'table' => 'image',
  83        'left_field' => 'nid',
  84        'field' => 'nid',
  85      ),
  86    );
  87  
  88    // Relationship to the files base.
  89    // Allows us to go {node} --> {image} --> {files}.
  90    $data['image_node']['nid'] = array(
  91      'relationship' => array(
  92        'title' => t('File'),
  93        'label' => t('Image file'),
  94        'help' => t('A relationship to gain access to the corresponding file(s) of an image node.'),
  95        'base' => 'files',
  96        'field' => 'fid',
  97        'relationship table' => 'image',
  98        'relationship field' => 'fid',
  99        'base field' => 'fid',
 100        'handler' => 'image_handler_relationship_node_image_file',
 101      ),
 102    );
 103    return $data;
 104  }
 105  
 106  /**
 107   * Implementation of hook_views_data_alter().
 108   */
 109  function image_views_data_alter(&$data) {
 110    // {node} table, prefixed with 'image' to avoid potential clashes.
 111    // The image for an image node. This could technically be #global, but adding
 112    // on {node} allows this field to be used through relationships if needed
 113    // (e.g. through a CCK nodereference field).
 114    $data['node']['image_image'] = array(
 115      'group' => t('Image'),
 116      'field' => array(
 117        'title' => t('Image'),
 118        'help' => t('The rendered image of an Image node, shown at a chosen size. This field can be added without a relationship.'),
 119        'handler' => 'image_handler_field_image_node_image',
 120      ),
 121      'argument' => array(
 122        'title' => t('Image size'),
 123        'help' => t('Allows the size of the Image node image field to be set with the argument.'),
 124        'handler' => 'image_handler_argument_image_node_image_size',
 125      ),
 126    );
 127  }
 128  
 129  /**
 130   * Implementation of hook_views_handlers().
 131   */
 132  function image_views_handlers() {
 133    return array(
 134      'info' => array(
 135        'path' => drupal_get_path('module', 'image') . '/views',
 136      ),
 137      'handlers' => array(
 138        'image_handler_field_image_node_image' => array(
 139          'parent' => 'views_handler_field_node',
 140        ),
 141        'image_handler_field_image_size' => array(
 142          'parent' => 'views_handler_field',
 143        ),
 144        'image_handler_argument_image_size' => array(
 145          'parent' => 'views_handler_argument_string',
 146        ),
 147        'image_handler_argument_image_node_image_size' => array(
 148          'parent' => 'views_handler_argument_string',
 149        ),
 150        'image_handler_filter_image_size' => array(
 151          'parent' => 'views_handler_filter_in_operator',
 152        ),
 153        'image_handler_relationship_node_image_file' => array(
 154          'parent' => 'views_handler_relationship',
 155        ),
 156      ),
 157    );
 158  }
 159  
 160  /**
 161   * Implementation of hook_views_plugins().
 162   */
 163  function image_views_plugins() {
 164    return array(
 165      'style' => array(
 166        /**
 167         * A fluid grid view style for gallery items.
 168         */
 169        'image_gallery' => array(
 170          'title' => 'Gallery',
 171          'help' => t('Displays items in a fluid grid.'),
 172          'parent' => 'list',
 173          'handler' => 'views_plugin_style_list',
 174          'theme path' => drupal_get_path('module', 'image') . '/views/theme',
 175          'theme file' => 'theme.inc',
 176          'theme' => 'image_view_image_gallery',
 177          'uses row plugin' => TRUE,
 178          'uses options' => TRUE,
 179          'type' => 'normal',
 180          'help topic' => 'style-list',
 181        ),
 182      ),
 183      'argument validator' => array(
 184        'image_size' => array(
 185          'title' => t('Image size'),
 186          'handler' => 'image_plugin_argument_validate_image_size',
 187          'path' => drupal_get_path('module', 'image') . '/views',
 188        ),
 189      ),
 190      'argument default' => array(
 191        'image_size' => array(
 192          'title' => t('Image size'),
 193          'handler' => 'image_plugin_argument_default_image_size',
 194          'path' => drupal_get_path('module', 'image') . '/views',
 195          // Include parent class.
 196          'parent' => 'fixed',
 197        ),
 198      ),
 199    );
 200  }
 201  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7