| 1 |
<?php |
<?php |
| 2 |
// $Id: views_plugin_display.inc,v 1.20.2.11 2009/11/02 23:58:04 merlinofchaos Exp $ |
// $Id: views_plugin_display.inc,v 1.20.2.12 2009/11/10 23:20:06 merlinofchaos Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Contains the base display plugin. |
* Contains the base display plugin. |
| 187 |
'link_display' => array('link_display'), |
'link_display' => array('link_display'), |
| 188 |
'distinct' => array('distinct'), |
'distinct' => array('distinct'), |
| 189 |
'exposed_block' => array('exposed_block'), |
'exposed_block' => array('exposed_block'), |
| 190 |
|
'exposed_form' => array('exposed_form'), |
| 191 |
|
|
| 192 |
// Force these to cascade properly. |
// Force these to cascade properly. |
| 193 |
'style_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), |
'style_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), |
| 262 |
'use_more_text' => TRUE, |
'use_more_text' => TRUE, |
| 263 |
'distinct' => TRUE, |
'distinct' => TRUE, |
| 264 |
'exposed_block' => TRUE, |
'exposed_block' => TRUE, |
| 265 |
|
'exposed_form' => TRUE, |
| 266 |
|
|
| 267 |
'link_display' => TRUE, |
'link_display' => TRUE, |
| 268 |
'group_by' => TRUE, |
'group_by' => TRUE, |
| 391 |
'exposed_block' => array( |
'exposed_block' => array( |
| 392 |
'default' => FALSE, |
'default' => FALSE, |
| 393 |
), |
), |
| 394 |
|
'exposed_form' => array( |
| 395 |
|
'contains' => array( |
| 396 |
|
'type' => array('default' => 'basic'), |
| 397 |
|
'options' => array('default' => array()), |
| 398 |
|
), |
| 399 |
|
), |
| 400 |
); |
); |
| 401 |
|
|
| 402 |
if ($this->is_default_display()) { |
if ($this->is_default_display()) { |
| 553 |
} |
} |
| 554 |
|
|
| 555 |
/** |
/** |
| 556 |
|
* Get the exposed form plugin |
| 557 |
|
*/ |
| 558 |
|
function get_exposed_form_plugin($name = NULL) { |
| 559 |
|
if (!$name) { |
| 560 |
|
$exposed_form = $this->get_option('exposed_form'); |
| 561 |
|
$name = $exposed_form['type']; |
| 562 |
|
} |
| 563 |
|
|
| 564 |
|
$plugin = views_get_plugin('exposed_form', $name); |
| 565 |
|
if ($plugin) { |
| 566 |
|
$plugin->init($this->view, $this->display); |
| 567 |
|
return $plugin; |
| 568 |
|
} |
| 569 |
|
} |
| 570 |
|
|
| 571 |
|
/** |
| 572 |
* Get the handler object for a single handler. |
* Get the handler object for a single handler. |
| 573 |
*/ |
*/ |
| 574 |
function &get_handler($type, $id) { |
function &get_handler($type, $id) { |
| 859 |
'desc' => t('Allow the exposed form to appear in a block instead of the view.'), |
'desc' => t('Allow the exposed form to appear in a block instead of the view.'), |
| 860 |
); |
); |
| 861 |
|
|
| 862 |
|
$exposed_form_plugin = $this->get_exposed_form_plugin(); |
| 863 |
|
if (!$exposed_form_plugin) { |
| 864 |
|
// default to the no cache control plugin. |
| 865 |
|
$exposed_form_plugin = views_get_plugin('exposed_form', 'basic'); |
| 866 |
|
} |
| 867 |
|
|
| 868 |
|
$exposed_form_str = $exposed_form_plugin->summary_title(); |
| 869 |
|
|
| 870 |
|
$options['exposed_form'] = array( |
| 871 |
|
'category' => 'exposed', |
| 872 |
|
'title' => t('Exposed form style'), |
| 873 |
|
'value' => $exposed_form_str, |
| 874 |
|
'desc' => t('Select the kind of exposed filter to use.'), |
| 875 |
|
); |
| 876 |
|
|
| 877 |
|
if (!empty($exposed_form_plugin->definition['uses options'])) { |
| 878 |
|
$options['exposed_form']['links']['exposed_form_options'] = t('Exposed form settings for this exposed form style.'); |
| 879 |
|
} |
| 880 |
|
|
| 881 |
foreach (array('header' => t('Header'), 'footer' => t('Footer'), 'empty' => t('Empty text')) as $type => $name) { |
foreach (array('header' => t('Header'), 'footer' => t('Footer'), 'empty' => t('Empty text')) as $type => $name) { |
| 882 |
if (!$this->get_option($type)) { |
if (!$this->get_option($type)) { |
| 883 |
$field = t('None'); |
$field = t('None'); |
| 1462 |
'#default_value' => $this->get_option('exposed_block') ? 1 : 0, |
'#default_value' => $this->get_option('exposed_block') ? 1 : 0, |
| 1463 |
); |
); |
| 1464 |
break; |
break; |
| 1465 |
|
case 'exposed_form': |
| 1466 |
|
$form['#title'] .= t('Exposed Form'); |
| 1467 |
|
$form['exposed_form'] = array( |
| 1468 |
|
'#prefix' => '<div class="clear-block">', |
| 1469 |
|
'#suffix' => '</div>', |
| 1470 |
|
'#tree' => TRUE, |
| 1471 |
|
); |
| 1472 |
|
|
| 1473 |
|
$exposed_form = $this->get_option('exposed_form'); |
| 1474 |
|
$form['exposed_form']['type'] = array( |
| 1475 |
|
'#type' => 'radios', |
| 1476 |
|
'#options' => views_fetch_plugin_names('exposed_form'), |
| 1477 |
|
'#default_value' => $exposed_form['type'], |
| 1478 |
|
); |
| 1479 |
|
|
| 1480 |
|
$exposed_form_plugin = views_fetch_plugin_data('exposed_form', $exposed_form['type']); |
| 1481 |
|
if (!empty($exposed_form_plugin['uses options'])) { |
| 1482 |
|
$form['markup'] = array( |
| 1483 |
|
'#prefix' => '<div class="form-item description">', |
| 1484 |
|
'#suffix' => '</div>', |
| 1485 |
|
'#value' => t('You may also adjust the !settings for the currently selected style by clicking on the icon.', array('!settings' => $this->option_link(t('settings'), 'exposed_form_options'))), |
| 1486 |
|
); |
| 1487 |
|
} |
| 1488 |
|
break; |
| 1489 |
|
case 'exposed_form_options': |
| 1490 |
|
$exposed_form = $this->get_option('exposed_form'); |
| 1491 |
|
$plugin = $this->get_exposed_form_plugin(); |
| 1492 |
|
$form['#title'] .= t('Exposed form options'); |
| 1493 |
|
if ($plugin) { |
| 1494 |
|
$form['#help_topic'] = $plugin->definition['help topic']; |
| 1495 |
|
|
| 1496 |
|
$form['exposed_form_options'] = array( |
| 1497 |
|
'#tree' => TRUE, |
| 1498 |
|
); |
| 1499 |
|
$plugin->options_form($form['exposed_form_options'], $form_state); |
| 1500 |
|
} |
| 1501 |
|
break; |
| 1502 |
} |
} |
| 1503 |
} |
} |
| 1504 |
|
|
| 1565 |
$plugin->options_validate($form['cache_options'], $form_state); |
$plugin->options_validate($form['cache_options'], $form_state); |
| 1566 |
} |
} |
| 1567 |
break; |
break; |
| 1568 |
|
case 'exposed_form_options': |
| 1569 |
|
$plugin = $this->get_exposed_form_plugin(); |
| 1570 |
|
if ($plugin) { |
| 1571 |
|
$plugin->options_validate($form['exposed_form_options'], $form_state); |
| 1572 |
|
} |
| 1573 |
|
break; |
| 1574 |
} |
} |
| 1575 |
} |
} |
| 1576 |
|
|
| 1712 |
case 'exposed_block': |
case 'exposed_block': |
| 1713 |
$this->set_option($section, (bool) $form_state['values'][$section]); |
$this->set_option($section, (bool) $form_state['values'][$section]); |
| 1714 |
break; |
break; |
| 1715 |
|
case 'exposed_form': |
| 1716 |
|
$exposed_form = $this->get_option('exposed_form'); |
| 1717 |
|
if ($exposed_form['type'] != $form_state['values']['exposed_form']['type']) { |
| 1718 |
|
$plugin = views_get_plugin('exposed_form', $form_state['values']['exposed_form']['type']); |
| 1719 |
|
if ($plugin) { |
| 1720 |
|
$exposed_form = array('type' => $form_state['values']['exposed_form']['type'], 'options' => array()); |
| 1721 |
|
$this->set_option('exposed_form', $exposed_form); |
| 1722 |
|
if (!empty($plugin->definition['uses options'])) { |
| 1723 |
|
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('exposed_form_options')); |
| 1724 |
|
} |
| 1725 |
|
} |
| 1726 |
|
} |
| 1727 |
|
|
| 1728 |
|
break; |
| 1729 |
|
case 'exposed_form_options': |
| 1730 |
|
$plugin = $this->get_exposed_form_plugin(); |
| 1731 |
|
if ($plugin) { |
| 1732 |
|
$exposed_form = $this->get_option('exposed_form'); |
| 1733 |
|
$plugin->options_submit($form['exposed_form_options'], $form_state); |
| 1734 |
|
$exposed_form['options'] = $form_state['values'][$section]; |
| 1735 |
|
$this->set_option('exposed_form', $exposed_form); |
| 1736 |
|
} |
| 1737 |
|
break; |
| 1738 |
} |
} |
| 1739 |
} |
} |
| 1740 |
|
|