You are here

class image_gallery_handler_field_gallery_cover_latest_time in Image 6

Same name and namespace in other branches
  1. 7 contrib/image_gallery/views/image_gallery_handler_field_gallery_cover_latest_time.inc \image_gallery_handler_field_gallery_cover_latest_time

Field handler for the gallery's updated time.

Hierarchy

Expanded class hierarchy of image_gallery_handler_field_gallery_cover_latest_time

1 string reference to 'image_gallery_handler_field_gallery_cover_latest_time'
image_gallery_views_data_alter in contrib/image_gallery/views/image_gallery.views.inc
Implementation of hook_views_data_alter(). Add fields for image gallery (ie vocabulary terms) to the term_data table.

File

contrib/image_gallery/views/image_gallery_handler_field_gallery_cover_latest_time.inc, line 6

View source
class image_gallery_handler_field_gallery_cover_latest_time extends image_gallery_handler_field_gallery_cover {
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    // Overwrite the descendants option so the text is relevant.
    $form['descendants']['#description'] = theme('advanced_help_topic', 'image_gallery', 'descendants') . t('Whether to only consider this gallery itself, or consider subgalleries all together, or recurse into subgalleries if the gallery itself is empty.');
    $form['descendants']['#options'] = array(
      'single' => t('Only get latest time from this gallery'),
      'flat' => t('Consider subgalleries, flattened.'),
      'recurse' => t('Consider subgalleries, recursively. (Warning: this can produce many queries per row if your parent galleries are empty!).'),
    );
  }

  /**
   * Returns field html.
   */
  function render($values) {
    $nid = $this
      ->get_cover_node_nid($values);

    // If there is no node (ie gallery empty), suppress the label.
    // Because this is called for each row, but $this->options['label'] applies
    // to everything, we have to muck about and stash the original, user-set
    // value so we can restore it when needed.
    // @todo: views 6.x-2.7 will make all the label stuff superfluous.
    static $original_label;
    if (!isset($original_label)) {
      $original_label = $this->options['label'];
    }
    if (isset($nid)) {
      $this->options['label'] = $original_label;
      $latest_node = node_load($nid);
      $output = theme('image_gallery_updated', $latest_node->changed);
      return $this
        ->render_link($output, $values);
    }
    else {
      $this->options['label'] = '';
    }
  }

}

Members