00001 <?php
00002
00006 class views_plugin_exposed_form_input_required extends views_plugin_exposed_form {
00007
00008 function option_definition() {
00009 $options = parent::option_definition();
00010
00011 $options['text_input_required'] = array('default' => t('Select any filter and click on Apply to see results'), 'translatable' => TRUE);
00012 $options['text_input_required_format'] = array('default' => NULL);
00013 return $options;
00014 }
00015
00016 function options_form(&$form, &$form_state) {
00017 parent::options_form($form, $form_state);
00018
00019 $form['text_input_required'] = array(
00020 '#type' => 'text_format',
00021 '#title' => t('Text on demand'),
00022 '#description' => t('Text to display instead of results until the user selects and applies an exposed filter.'),
00023 '#default_value' => $this->options['text_input_required'],
00024 '#format' => isset($this->options['text_input_required_format']) ? $this->options['text_input_required_format'] : filter_default_format(),
00025 '#wysiwyg' => FALSE,
00026 );
00027 }
00028
00029 function options_submit(&$form, &$form_state) {
00030 $form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['exposed_form_options']['text_input_required']['format'];
00031 $form_state['values']['exposed_form_options']['text_input_required'] = $form_state['values']['exposed_form_options']['text_input_required']['value'];
00032 parent::options_submit($form, $form_state);
00033 }
00034
00035 function exposed_filter_applied() {
00036 static $cache = NULL;
00037 if (!isset($cache)) {
00038 $view = $this->view;
00039 if (is_array($view->filter) && count($view->filter)) {
00040 foreach ($view->filter as $filter_id => $filter) {
00041 if ($filter->is_exposed()) {
00042 $identifier = $filter->options['expose']['identifier'];
00043 if (isset($view->exposed_input[$identifier])) {
00044 $cache = TRUE;
00045 return $cache;
00046 }
00047 }
00048 }
00049 }
00050 $cache = FALSE;
00051 }
00052
00053 return $cache;
00054 }
00055
00056 function pre_render($values) {
00057 if (!$this->exposed_filter_applied()) {
00058 $options = array(
00059 'id' => 'area',
00060 'table' => 'views',
00061 'field' => 'area',
00062 'label' => '',
00063 'relationship' => 'none',
00064 'group_type' => 'group',
00065 'content' => $this->options['text_input_required'],
00066 'format' => $this->options['text_input_required_format'],
00067 );
00068 $handler = views_get_handler('views', 'area', 'area');
00069 $handler->init($this->view, $options);
00070 $this->display->handler->handlers['empty'] = array(
00071 'area' => $handler,
00072 );
00073 $this->display->handler->set_option('empty', array('text' => $options));
00074 }
00075 }
00076
00077 function query() {
00078 if (!$this->exposed_filter_applied()) {
00079
00080 $this->view->built = TRUE;
00081 $this->view->executed = TRUE;
00082 $this->view->result = array();
00083 }
00084 else {
00085 parent::query();
00086 }
00087 }
00088
00089 }