| 1 |
<?php |
<?php |
| 2 |
// $Id: views_plugin_display.inc,v 1.20.2.10 2009/11/02 23:17:12 merlinofchaos Exp $ |
// $Id: views_plugin_display.inc,v 1.20.2.11 2009/11/02 23:58:04 merlinofchaos Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Contains the base display plugin. |
* Contains the base display plugin. |
| 130 |
} |
} |
| 131 |
|
|
| 132 |
/** |
/** |
| 133 |
|
* Does the display have a more link enabled? |
| 134 |
|
*/ |
| 135 |
|
function use_group_by() { |
| 136 |
|
return $this->get_option('group_by'); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
/** |
| 140 |
* Should the enabled display more link be shown when no more items? |
* Should the enabled display more link be shown when no more items? |
| 141 |
*/ |
*/ |
| 142 |
function use_more_always() { |
function use_more_always() { |
| 263 |
'exposed_block' => TRUE, |
'exposed_block' => TRUE, |
| 264 |
|
|
| 265 |
'link_display' => TRUE, |
'link_display' => TRUE, |
| 266 |
|
'group_by' => TRUE, |
| 267 |
|
|
| 268 |
'style_plugin' => TRUE, |
'style_plugin' => TRUE, |
| 269 |
'style_options' => TRUE, |
'style_options' => TRUE, |
| 369 |
'distinct' => array( |
'distinct' => array( |
| 370 |
'default' => FALSE, |
'default' => FALSE, |
| 371 |
), |
), |
| 372 |
|
'group_by' => array( |
| 373 |
|
'default' => FALSE, |
| 374 |
|
), |
| 375 |
|
|
| 376 |
'style_plugin' => array( |
'style_plugin' => array( |
| 377 |
'default' => 'default', |
'default' => 'default', |
| 570 |
$types = views_object_types(); |
$types = views_object_types(); |
| 571 |
$plural = $types[$type]['plural']; |
$plural = $types[$type]['plural']; |
| 572 |
foreach ($this->get_option($plural) as $id => $info) { |
foreach ($this->get_option($plural) as $id => $info) { |
| 573 |
$handler = views_get_handler($info['table'], $info['field'], $type); |
// If aggregation is on, the group type might override the actual |
| 574 |
|
// handler that is in use. This piece of code checks that and, |
| 575 |
|
// if necessary, sets the override handler. |
| 576 |
|
$override = NULL; |
| 577 |
|
if ($this->use_group_by() && !empty($info['group_type'])) { |
| 578 |
|
if (empty($this->view->query)) { |
| 579 |
|
$this->view->init_query(); |
| 580 |
|
} |
| 581 |
|
$aggregate = $this->view->query->get_aggregation_info(); |
| 582 |
|
if (!empty($aggregate[$info['group_type']]['handler'][$type])) { |
| 583 |
|
$override = $aggregate[$info['group_type']]['handler'][$type]; |
| 584 |
|
} |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
$handler = views_get_handler($info['table'], $info['field'], $type, $override); |
| 588 |
if ($handler) { |
if ($handler) { |
| 589 |
$handler->init($this->view, $info); |
$handler->init($this->view, $info); |
| 590 |
$this->handlers[$type][$id] = &$handler; |
$this->handlers[$type][$id] = &$handler; |
| 756 |
'desc' => t('Display only distinct items, without duplicates.'), |
'desc' => t('Display only distinct items, without duplicates.'), |
| 757 |
); |
); |
| 758 |
|
|
| 759 |
|
$this->view->init_query(); |
| 760 |
|
if ($this->view->query->get_aggregation_info()) { |
| 761 |
|
$options['group_by'] = array( |
| 762 |
|
'category' => 'advanced', |
| 763 |
|
'title' => t('Use grouping'), |
| 764 |
|
'value' => $this->get_option('group_by') ? t('Yes') : t('No'), |
| 765 |
|
'desc' => t('Allow grouping and aggregation (calculation) of fields.'), |
| 766 |
|
); |
| 767 |
|
} |
| 768 |
|
|
| 769 |
$access_plugin = $this->get_access_plugin(); |
$access_plugin = $this->get_access_plugin(); |
| 770 |
if (!$access_plugin) { |
if (!$access_plugin) { |
| 771 |
// default to the no access control plugin. |
// default to the no access control plugin. |
| 981 |
'#default_value' => $this->get_option('distinct'), |
'#default_value' => $this->get_option('distinct'), |
| 982 |
); |
); |
| 983 |
break; |
break; |
| 984 |
|
case 'group_by': |
| 985 |
|
$form['#title'] .= t('Allow grouping and aggregation (calculation) of fields.'); |
| 986 |
|
$form['group_by'] = array( |
| 987 |
|
'#type' => 'checkbox', |
| 988 |
|
'#title' => t('Group by'), |
| 989 |
|
'#description' => t('If enabled, some fields may become unavailable. All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.'), |
| 990 |
|
'#default_value' => $this->get_option('distinct'), |
| 991 |
|
); |
| 992 |
|
break; |
| 993 |
case 'access': |
case 'access': |
| 994 |
$form['#title'] .= t('Access restrictions'); |
$form['#title'] .= t('Access restrictions'); |
| 995 |
$form['access'] = array( |
$form['access'] = array( |
| 1570 |
case 'distinct': |
case 'distinct': |
| 1571 |
$this->set_option($section, $form_state['values'][$section]); |
$this->set_option($section, $form_state['values'][$section]); |
| 1572 |
break; |
break; |
| 1573 |
|
case 'group_by': |
| 1574 |
|
$this->set_option($section, $form_state['values'][$section]); |
| 1575 |
|
break; |
| 1576 |
case 'row_plugin': |
case 'row_plugin': |
| 1577 |
// This if prevents resetting options to default if they don't change |
// This if prevents resetting options to default if they don't change |
| 1578 |
// the plugin. |
// the plugin. |