You are here

class views_flag_refresh_plugin_display_extender in Views Flag Refresh 7

This plugin adds additional settings to the Views AJAX options.

Hierarchy

Expanded class hierarchy of views_flag_refresh_plugin_display_extender

1 string reference to 'views_flag_refresh_plugin_display_extender'
views_flag_refresh_views_plugins in ./views_flag_refresh.views.inc
Implements hook_views_plugins().

File

./views_flag_refresh_plugin_display_extender.inc, line 13
Views field view field handler class.

View source
class views_flag_refresh_plugin_display_extender extends views_plugin_display_extender {

  /**
   *  List of new options added by plugin.
   */
  protected function add_options(&$options = array()) {
    $options['use_ajax_flags'] = array(
      'default' => FALSE,
    );
    $options['use_ajax_flags_noscrolltop'] = array(
      'default' => 0,
    );
    $options['use_ajax_flags_widget'] = array(
      'default' => 'default',
    );
  }

  /**
   * Provide a form to edit options for this plugin.
   *
   * Added in Views 3.5.
   */
  function options_definition_alter(&$options = array()) {
    $this
      ->add_options($options);
  }

  /**
   * Provide a form to edit options for this plugin.
   *
   * Used in Views prior to 3.5.
   */
  function option_definition(&$options = array()) {
    $this
      ->add_options($options);
    return $options;
  }

  /**
   * Provide the form to set new option.
   */
  function options_form(&$form, &$form_state) {
    switch ($form_state['section']) {
      case 'views_flag_refresh':
        $form['use_ajax_flags'] = array(
          '#type' => 'checkboxes',
          '#title' => t('Refresh display on flags'),
          '#options' => views_flag_refresh_flag_options_get(),
          '#default_value' => (array) $this->display
            ->get_option('use_ajax_flags'),
          '#description' => t('Refreshes the display via AJAX whenever a user clicks one of the selected flags. This will only take effect if the <em>Use AJAX</em> option is set to <em>Yes</em>.'),
        );
        $form['use_ajax_flags_noscrolltop'] = array(
          '#type' => 'checkbox',
          '#title' => t('Disable scroll to top of this view.'),
          '#default_value' => $this->display
            ->get_option('use_ajax_flags_noscrolltop'),
          '#description' => t('Check if you want disable scroll to the top of this view after AJAX update.'),
        );
        $default_value = $this->display
          ->get_option('use_ajax_flags_widget');
        $form['use_ajax_flags_widget'] = array(
          '#type' => 'radios',
          '#title' => t('Refresh widget'),
          '#options' => views_flag_refresh_widget_options_get(),
          '#default_value' => $default_value ? $default_value : 'default',
          '#description' => t('The widget alters the display of the view as it is refreshing, for example by adding a throbber or textual message.'),
        );
        break;
    }
  }

  /**
   * Inserts the code into the view display.
   */
  function options_submit(&$form, &$form_state) {
    switch ($form_state['section']) {
      case 'views_flag_refresh':
        $this->display
          ->set_option('use_ajax_flags', $form_state['values']['use_ajax_flags']);
        $this->display
          ->set_option('use_ajax_flags_noscrolltop', $form_state['values']['use_ajax_flags_noscrolltop']);
        $this->display
          ->set_option('use_ajax_flags_widget', $form_state['values']['use_ajax_flags_widget']);
        break;
    }
  }

  /**
   * Summarizes new option.
   *
   * Lists the fields as either 'Yes' if there is text or 'None' otherwise and
   * categorizes the fields under the 'Other' category.
   */
  function options_summary(&$categories, &$options) {
    $flags = $this->display
      ->get_option('use_ajax_flags');
    $flags_selected = array();
    if (is_array($flags)) {
      $flags_names = views_flag_refresh_flag_options_get();
      foreach ($flags as $flag) {
        if ($flag) {
          $flags_selected[] = $flags_names[$flag];
        }
      }
    }
    if ($flags_selected) {
      $flags_selected = implode(', ', $flags_selected);
    }
    else {
      $flags_selected = t('None');
    }
    $options['views_flag_refresh'] = array(
      'category' => 'other',
      'title' => t('Flag refresh'),
      'value' => $flags_selected,
      'desc' => t('Choose flags that can refresh display.'),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_flag_refresh_plugin_display_extender::add_options protected function List of new options added by plugin.
views_flag_refresh_plugin_display_extender::options_definition_alter function Provide a form to edit options for this plugin. Overrides views_plugin_display_extender::options_definition_alter
views_flag_refresh_plugin_display_extender::options_form function Provide the form to set new option. Overrides views_plugin_display_extender::options_form
views_flag_refresh_plugin_display_extender::options_submit function Inserts the code into the view display. Overrides views_plugin_display_extender::options_submit
views_flag_refresh_plugin_display_extender::options_summary function Summarizes new option. Overrides views_plugin_display_extender::options_summary
views_flag_refresh_plugin_display_extender::option_definition function Provide a form to edit options for this plugin. Overrides views_object::option_definition
views_object::$definition public property Handler's definition.
views_object::$options public property Except for displays, options for the object will be held here. 1
views_object::altered_option_definition function Collect this handler's option definition and alter them, ready for use.
views_object::construct public function Views handlers use a special construct function. 4
views_object::destroy public function Destructor. 2
views_object::export_option public function 1
views_object::export_options public function
views_object::export_option_always public function Always exports the option, regardless of the default value.
views_object::options Deprecated public function Set default options on this object. 1
views_object::set_default_options public function Set default options.
views_object::set_definition public function Let the handler know what its full definition is.
views_object::unpack_options public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::unpack_translatable public function Unpack a single option definition.
views_object::unpack_translatables public function Unpacks each handler to store translatable texts.
views_object::_set_option_defaults public function
views_plugin::$display public property The current used views display.
views_plugin::$plugin_name public property The plugin name of this plugin, for example table or full.
views_plugin::$plugin_type public property The plugin type of this plugin, for example style or query.
views_plugin::$view public property The top object of a view. Overrides views_object::$view 1
views_plugin::additional_theme_functions public function Provide a list of additional theme functions for the theme info page.
views_plugin::plugin_title public function Return the human readable name of the display.
views_plugin::summary_title public function Returns the summary of the settings in the display. 8
views_plugin::theme_functions public function Provide a full list of possible theme templates used by this style.
views_plugin::validate public function Validate that the plugin is correct and can be saved. 3
views_plugin_display_extender::defaultable_sections public function Static member function to list which sections are defaultable and what items each section contains.
views_plugin_display_extender::init public function
views_plugin_display_extender::options_validate public function Validate the options form. Overrides views_plugin::options_validate
views_plugin_display_extender::pre_execute public function Set up any variables on the view prior to execution.
views_plugin_display_extender::query public function Inject anything into the query that the display_extender handler needs. Overrides views_plugin::query