Tripal v1.0 (6.x-1.0)
chado_views_handler_sort.inc
Go to the documentation of this file.
00001 <?php
00002 
00011 class chado_views_handler_sort extends views_handler_sort {
00012 
00016   function options_form(&$form, &$form_state) {
00017 
00018     $form['msg'] = array(
00019       '#type' => 'item',
00020       '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
00021     );
00022 
00023     parent::options_form($form, $form_state);
00024   }
00025 
00030   function query() {
00031 
00032     // Determine if the current field is part of an aggregated table
00033     $table = $this->query->get_table_info($this->table);
00034     if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
00035       $this->aggregated = TRUE;
00036     }
00037     else {
00038       $this->aggregated = FALSE;
00039     }
00040 
00041     // One day when the aggregated sort will work (ie: Postgresql 9.0+)
00042     // it will need to be applied in join handler
00043     // thus tell join handler about the sort
00044     $table['join']->sort[] = array(
00045       'table' => $table['alias'],
00046       'field' => $this->options['field'],
00047       'order' => $this->options['order']
00048     );
00049 
00050 
00051     // if not then add the sort
00052     if (!$this->aggregated) {
00053       parent::query();
00054     }
00055 
00056   }
00057 
00058 }
 All Classes Files Functions Variables