class views_plugin_exposed_form_input_required in Views (for Drupal 7) 7.3
Same name and namespace in other branches
- 6.3 plugins/views_plugin_exposed_form_input_required.inc \views_plugin_exposed_form_input_required
Exposed form plugin that provides an exposed form with required input.
Hierarchy
- class \views_object
- class \views_plugin
Expanded class hierarchy of views_plugin_exposed_form_input_required
Related topics
1 string reference to 'views_plugin_exposed_form_input_required'
- views_views_plugins in includes/
plugins.inc - Implements hook_views_plugins().
File
- plugins/
views_plugin_exposed_form_input_required.inc, line 13 - Definition of views_plugin_exposed_form_input_required.
View source
class views_plugin_exposed_form_input_required extends views_plugin_exposed_form {
/**
* {@inheritdoc}
*/
public function option_definition() {
$options = parent::option_definition();
$options['text_input_required'] = array(
'default' => 'Select any filter and click on Apply to see results',
'translatable' => TRUE,
);
$options['text_input_required_format'] = array(
'default' => NULL,
);
return $options;
}
/**
* {@inheritdoc}
*/
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['text_input_required'] = array(
'#type' => 'text_format',
'#title' => t('Text on demand'),
'#description' => t('Text to display instead of results until the user selects and applies an exposed filter.'),
'#default_value' => $this->options['text_input_required'],
'#format' => isset($this->options['text_input_required_format']) ? $this->options['text_input_required_format'] : filter_default_format(),
'#wysiwyg' => FALSE,
);
}
/**
* {@inheritdoc}
*/
public function options_submit(&$form, &$form_state) {
$form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['exposed_form_options']['text_input_required']['format'];
$form_state['values']['exposed_form_options']['text_input_required'] = $form_state['values']['exposed_form_options']['text_input_required']['value'];
parent::options_submit($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function exposed_filter_applied() {
static $cache = NULL;
if (!isset($cache)) {
$view = $this->view;
if (is_array($view->filter) && count($view->filter)) {
foreach ($view->filter as $filter_id => $filter) {
if ($filter
->is_exposed()) {
$identifier = $filter->options['expose']['identifier'];
if (isset($view->exposed_input[$identifier])) {
$cache = TRUE;
return $cache;
}
}
}
}
$cache = FALSE;
}
return $cache;
}
/**
* {@inheritdoc}
*/
public function pre_render($values) {
if (!$this
->exposed_filter_applied()) {
$options = array(
'id' => 'area',
'table' => 'views',
'field' => 'area',
'label' => '',
'relationship' => 'none',
'group_type' => 'group',
'content' => $this->options['text_input_required'],
'format' => $this->options['text_input_required_format'],
'empty' => TRUE,
);
$handler = views_get_handler('views', 'area', 'area');
$handler
->init($this->view, $options);
$this->display->handler->handlers['empty'] = array(
'area' => $handler,
);
$this->display->handler
->set_option('empty', array(
'text' => $options,
));
}
}
/**
* {@inheritdoc}
*/
public function query() {
if (!$this
->exposed_filter_applied()) {
// We return with no query; this will force the empty text.
$this->view->built = TRUE;
$this->view->executed = TRUE;
$this->view->result = array();
}
else {
parent::query();
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
views_object:: |
public | property | Handler's definition. | |
views_object:: |
public | property | Except for displays, options for the object will be held here. | 1 |
views_object:: |
function | Collect this handler's option definition and alter them, ready for use. | ||
views_object:: |
public | function | Views handlers use a special construct function. | 4 |
views_object:: |
public | function | Destructor. | 2 |
views_object:: |
public | function | 1 | |
views_object:: |
public | function | ||
views_object:: |
public | function | Always exports the option, regardless of the default value. | |
views_object:: |
public | function | Set default options on this object. | 1 |
views_object:: |
public | function | Set default options. | |
views_object:: |
public | function | Let the handler know what its full definition is. | |
views_object:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
views_object:: |
public | function | Unpack a single option definition. | |
views_object:: |
public | function | Unpacks each handler to store translatable texts. | |
views_object:: |
public | function | ||
views_plugin:: |
public | property | The current used views display. | |
views_plugin:: |
public | property | The plugin name of this plugin, for example table or full. | |
views_plugin:: |
public | property | The plugin type of this plugin, for example style or query. | |
views_plugin:: |
public | property |
The top object of a view. Overrides views_object:: |
1 |
views_plugin:: |
public | function | Provide a list of additional theme functions for the theme info page. | |
views_plugin:: |
public | function | Validate the options form. | 10 |
views_plugin:: |
public | function | Return the human readable name of the display. | |
views_plugin:: |
public | function | Returns the summary of the settings in the display. | 8 |
views_plugin:: |
public | function | Provide a full list of possible theme templates used by this style. | |
views_plugin:: |
public | function | Validate that the plugin is correct and can be saved. | 3 |
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | This function is executed when exposed form is submited. | |
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | Initialize the plugin. | |
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form:: |
public | function | Render the exposed filter form. | |
views_plugin_exposed_form:: |
public | function | ||
views_plugin_exposed_form_input_required:: |
public | function | ||
views_plugin_exposed_form_input_required:: |
public | function |
Provide a form to edit options for this plugin. Overrides views_plugin_exposed_form:: |
|
views_plugin_exposed_form_input_required:: |
public | function |
Handle any special handling on the validate form. Overrides views_plugin:: |
|
views_plugin_exposed_form_input_required:: |
public | function |
Information about options for all kinds of purposes will be held here. Overrides views_plugin_exposed_form:: |
|
views_plugin_exposed_form_input_required:: |
public | function |
Overrides views_plugin_exposed_form:: |
|
views_plugin_exposed_form_input_required:: |
public | function |
Add anything to the query that we might need to. Overrides views_plugin_exposed_form:: |