[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

   1  <?php
   2  // $Id: image_attach.views.inc,v 1.6.2.1 2010/08/03 17:43:00 sun Exp $
   3  
   4  /**
   5   * Implementation of hook_views_data().
   6   */
   7  function image_attach_views_data() {
   8    // Basic table information.
   9    $data = array();
  10  
  11    // Define the base group of this table. Fields that don't
  12    // have a group defined will go into this field by default.
  13    $data['image_attach']['table']['group'] = t('Image attach');
  14  
  15    // For other base tables, explain how we join
  16    // LEFT is the default, but let's be explicit
  17    $data['image_attach']['table']['join'] = array(
  18      'node' => array(
  19        'left_field' => 'nid',
  20        'field' => 'nid',
  21        'type' => 'LEFT',
  22      ),
  23    );
  24  
  25    // Attached images relationship: gets us the attached nodes.
  26    // {node} --> {image_attach} --> {node}.
  27    // In other words, given the node, what attached images does it have?
  28    $data['image_attach']['iid'] = array(
  29      // The item it appears as on the UI,
  30      'title' => t('Attached images'),
  31      'help' => t('The images attached to a node.'),
  32      'relationship' => array(
  33        'title' => t('Attached image nodes'),
  34        'label' => t('Attached images'),
  35        'help' => t('The image nodes attached to the given node. May produce multiple rows. To filter out nodes with no attached images, set this relationship to be required.'),
  36        'base' => 'node',
  37        'base field' => 'nid',
  38        'relationship table' => 'image_attach',
  39        'relationship field' => 'iid',
  40        'handler' => 'views_handler_relationship',
  41      ),
  42    );
  43  
  44    // 'Reverse' relationship for attached images.
  45    // This goes from attached image nodes to image attach and thence to nodes,
  46    // but joining first on iid, and only then on nid.
  47    // In other words, given the image, what node(s) have it as an attached image?
  48    $data['image_attach_reverse']['table']['group'] = t('Image attach');
  49  
  50    $data['image_attach_reverse']['table']['join'] = array(
  51      'node' => array(
  52        'table' => 'image_attach',
  53        'left_field' => 'nid',
  54        'field' => 'iid',
  55        'type' => 'LEFT',
  56      ),
  57    );
  58    $data['image_attach_reverse']['nid'] = array(
  59      'title' => t('Attaching nodes'),
  60      'help' => t('The nodes that have attached images.'),
  61      'relationship' => array(
  62        'title' => t('Attaching nodes'),
  63        'label' => t('Attaching nodes'),
  64        'help' => t("The nodes that have attached images. This relationship should be used on a view of image nodes, to get to their attaching 'parent' nodes."),
  65        'base' => 'node',
  66        'base field' => 'nid',
  67        'relationship table' => 'image_attach_reverse',
  68        'relationship field' => 'nid',
  69        'handler' => 'views_handler_relationship',
  70      ),
  71    );
  72  
  73    return $data;
  74  }
  75  
  76  /**
  77   * Implementation of hook_views_data_alter().
  78   */
  79  function image_attach_views_data_alter(&$data) {
  80    // {node} table, prefixed with 'image_attach' to avoid potential clashes.
  81    // The images for attached image nodes.
  82    $data['node']['image_attach_images'] = array(
  83      'group' => t('Image attach'),
  84      'field' => array(
  85        'title' => t('Attached images'),
  86        'help' => t('The attached images, shown at a chosen size. This field can be added without a relationship.'),
  87        'handler' => 'image_attach_views_handler_field_attached_images',
  88      ),
  89    );
  90  }
  91  
  92  /**
  93   * Implementation of hook_views_handlers().
  94   */
  95  function image_attach_views_handlers() {
  96    return array(
  97      'info' => array(
  98        'path' => drupal_get_path('module', 'image_attach'),
  99      ),
 100      'handlers' => array(
 101        'image_attach_views_handler_field_attached_images' => array(
 102          'parent' => 'image_handler_field_image_node_image',
 103        ),
 104      ),
 105    );
 106  }
 107  


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