[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/project/views/plugins/ -> project_plugin_style_project_list.inc (source)

   1  <?php
   2  
   3  /**
   4   * Style plugin to render a list of projects.
   5   */
   6  class project_plugin_style_project_list extends views_plugin_style {
   7    /**
   8     * Store the project type term being browsed for later usage.
   9     */
  10    function pre_render($result) {
  11      if (isset($this->view->args[0])) {
  12        $this->view->project->project_type = _project_views_get_project_type($this->view->args[0]);
  13      }
  14      
  15      // If the first sort criteria is the changed field (for sorting by date),
  16      // then we need to add some information to the results set
  17      // so that they can later be grouped by date in the theming functions.
  18      // Views doesn't allow us to do this via the UI because views can
  19      // only handle grouping if fields, not nodes, are being displayed.
  20      if (is_array($this->view->sort) && isset($this->view->sort['changed']) && $this->view->sort['changed']->position == 0) {
  21        $field_alias = $this->view->sort['changed']->table_alias . "_" . $this->view->sort['changed']->field;
  22        $granularity = $this->view->sort['changed']->options['granularity'];
  23        switch ($granularity) {
  24          case 'second':
  25            $date_format_string = 'YmdHis';
  26            break;
  27          case 'minute':
  28            $date_format_string = 'YmdHi';
  29            break;
  30          case 'hour':
  31            $date_format_string = 'YmdH';
  32            break;
  33          case 'day':
  34            $date_format_string = 'Ymd';
  35            break;
  36          case 'month':
  37            $date_format_string = 'Ym';
  38            break;
  39          case 'year':
  40            $date_format_string = 'Y';
  41            break;
  42          default:
  43            $date_format_string = 'Ymd';
  44        }
  45  
  46        $last_date = '';
  47        foreach ($this->view->result as $i => $value) {
  48          $date = format_date($value->$field_alias, 'custom', $date_format_string);
  49          // If this date is a new date, once the granularity selected has been taken
  50          // into account, set a special property in the results of the view so that
  51          // later on in template_preprocess_project_views_view_row_project_node() we
  52          // can flag a row as having a different changed date than the last row
  53          // so that the actual date can be displayed as a header from the template.
  54          // @TODO:  As written, this only works with second granularity.
  55          if ($date != $last_date) {
  56            $this->view->project->project_new_date[$i] = TRUE;
  57          }
  58          $last_date = $date;
  59        }
  60      }
  61      parent::pre_render($result);
  62    }
  63  }


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