You are here

class slider_pro_style_plugin in Slider Pro 7

Style plugin to render views as slider pro instance.

Hierarchy

Expanded class hierarchy of slider_pro_style_plugin

1 string reference to 'slider_pro_style_plugin'
slider_pro_views_plugins in views/slider_pro.views.inc
Implements hook_views_plugins().

File

views/slider_pro_style_plugin.inc, line 13
Contains the slider pro style plugin.

View source
class slider_pro_style_plugin extends views_plugin_style {

  /**
   * Provide default options.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['slider_pro'] = array(
      'default' => array(),
    );
    return $options;
  }

  /**
   * Adds Slider Pro configuration form options.
   */
  function options_form(&$form, &$form_state) {

    //parent::options_form($form, $form_state);

    // Check if fields have been added.  Table style plugin will set
    // error_markup if fields are not added.
    // @see views_plugin_style::options_form()
    if (isset($form['error_markup'])) {
      return;
    }
    $field_names = $this->display->handler
      ->get_field_labels();
    $form['slider_pro'] = array(
      '#type' => 'fieldset',
      '#title' => t('Slider Pro settings'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['slider_pro']['width'] = array(
      '#title' => t('Width'),
      '#type' => 'textfield',
      '#default_value' => isset($this->options['slider_pro']['width']) ? $this->options['slider_pro']['width'] : '100%',
      '#description' => t('The width of the slider. Eg 200px or 50%'),
      '#required' => TRUE,
    );
    $form['slider_pro']['visible_size'] = array(
      '#title' => t('Visible size'),
      '#type' => 'textfield',
      '#default_value' => isset($this->options['slider_pro']['visible_size']) ? $this->options['slider_pro']['visible_size'] : 'auto',
      '#description' => t('Sets the size (for example 100%) of the visible area, allowing for more slides to become visible near the selected slide.' . 'Be sure that the width of your slider is less than 100%. <a href="!url" target="_blank">Example</a>', array(
        '!url' => 'http://bqworks.com/slider-pro/#example2',
      )),
      '#required' => TRUE,
    );
    $form['slider_pro']['force_size'] = array(
      '#title' => t('Force size'),
      '#type' => 'select',
      '#options' => array(
        'none' => t('None'),
        'fullWidth' => t('Full width'),
        'fullWindow' => t('Ful window'),
      ),
      '#default_value' => isset($this->options['slider_pro']['force_size']) ? $this->options['slider_pro']['force_size'] : 'none',
      '#description' => t('Indicates if the size of the slider will be forced to full width or full window.'),
      '#required' => TRUE,
    );
    $form['slider_pro']['height'] = array(
      '#title' => t('Height'),
      '#type' => 'textfield',
      '#default_value' => isset($this->options['slider_pro']['height']) ? $this->options['slider_pro']['height'] : '200px',
      '#description' => t('The height of the slider. Eg 200px or 50%'),
      '#required' => TRUE,
    );
    $form['slider_pro']['orientation'] = array(
      '#title' => t('Orientation'),
      '#type' => 'select',
      '#options' => array(
        'horizontal' => t('Horizontal'),
        'vertical' => t('Vertical'),
      ),
      '#default_value' => isset($this->options['slider_pro']['orientation']) ? $this->options['slider_pro']['orientation'] : 'horizontal',
      '#description' => t('Indicates whether the slides will be arranged horizontally or vertically.'),
      '#required' => TRUE,
    );
    $form['slider_pro']['buttons'] = array(
      '#title' => t('Buttons'),
      '#type' => 'select',
      '#options' => array(
        0 => t('No'),
        1 => t('Yes'),
      ),
      '#default_value' => isset($this->options['slider_pro']['buttons']) ? $this->options['slider_pro']['buttons'] : 0,
      '#description' => t('Indicates whether the buttons will be created.'),
      '#required' => TRUE,
    );
    $form['slider_pro']['transition'] = array(
      '#title' => t('Transition'),
      '#type' => 'select',
      '#options' => array(
        0 => t('Slide'),
        1 => t('Fade'),
      ),
      '#default_value' => isset($this->options['slider_pro']['transition']) ? $this->options['slider_pro']['transition'] : 0,
      '#description' => t('Indicates which transition will be used.'),
      '#required' => TRUE,
    );
    $form['slider_pro']['arrows'] = array(
      '#title' => t('Arrows'),
      '#type' => 'select',
      '#options' => array(
        0 => t('No'),
        1 => t('Yes'),
      ),
      '#default_value' => isset($this->options['slider_pro']['arrows']) ? $this->options['slider_pro']['arrows'] : 0,
      '#description' => t('Indicates whether the arrow buttons will be created..'),
      '#required' => TRUE,
    );
    $form['slider_pro']['fields_on_slide'] = array(
      '#title' => t('Fields on slide'),
      '#type' => 'checkboxes',
      '#options' => $field_names,
      '#default_value' => isset($this->options['slider_pro']['fields_on_slide']) ? $this->options['slider_pro']['fields_on_slide'] : array(),
      '#description' => t('Select which fields you want to display on the slider.'),
      '#required' => TRUE,
    );

    // Or AJAX won't work!
    $form_state['no_cache'] = FALSE;
    $use_thumbnails = isset($form_state['values']['style_options']['slider_pro']['thumbnails']['thumbnails_position']) ? $form_state['values']['style_options']['slider_pro']['thumbnails']['thumbnails_position'] : $this->options['slider_pro']['thumbnails']['thumbnails_position'];
    $form['slider_pro']['thumbnails'] = array(
      '#prefix' => '<div id="slider-pro-thumbs">',
      '#suffix' => '</div>',
      '#type' => 'fieldset',
      '#title' => t('Thumbnails'),
      '#collapsible' => TRUE,
      '#collapsed' => !$use_thumbnails,
    );
    $form['slider_pro']['thumbnails']['thumbnails_position'] = array(
      '#title' => t('Thumbnail position'),
      '#type' => 'select',
      '#options' => array(
        0 => t('No thumbs'),
        'left' => t('Left'),
        'right' => t('Right'),
        'top' => t('Top'),
        'bottom' => t('Bottom'),
      ),
      '#default_value' => isset($this->options['slider_pro']['thumbnails']['thumbnails_position']) ? $this->options['slider_pro']['thumbnails']['thumbnails_position'] : 0,
      '#required' => TRUE,
      '#description' => t('Sets the position of the thumbnail scroller.'),
      '#ajax' => array(
        'wrapper' => 'slider-pro-thumbs',
        'callback' => '_slider_pro_plugin_style_refresh_thumbs',
      ),
    );
    if ($use_thumbnails) {
      $form['slider_pro']['thumbnails']['fields_on_thumbs'] = array(
        '#title' => t('Fields on thumb'),
        '#type' => 'checkboxes',
        '#options' => $field_names,
        '#default_value' => isset($this->options['slider_pro']['thumbnails']['fields_on_thumbs']) ? $this->options['slider_pro']['thumbnails']['fields_on_thumbs'] : array(),
        '#description' => t('Select which fields you want to display on the thumbs.'),
        '#required' => TRUE,
      );
      $form['slider_pro']['thumbnails']['width'] = array(
        '#title' => t('Width'),
        '#type' => 'textfield',
        '#default_value' => isset($this->options['slider_pro']['thumbnails']['width']) ? $this->options['slider_pro']['thumbnails']['width'] : '100px',
        '#description' => t('The width of each thumbnail. Eg 200px.'),
        '#required' => TRUE,
      );
      $form['slider_pro']['thumbnails']['height'] = array(
        '#title' => t('Height'),
        '#type' => 'textfield',
        '#default_value' => isset($this->options['slider_pro']['thumbnails']['height']) ? $this->options['slider_pro']['thumbnails']['height'] : '80px',
        '#description' => t('The height of each thumbnail. Eg 200px.'),
        '#required' => TRUE,
      );
    }
    $form['slider_pro']['layers'] = array(
      '#type' => 'fieldset',
      '#title' => t('Layers'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#prefix' => '<div id="slider-pro-layers">',
      '#suffix' => '</div>',
    );
    $form['slider_pro']['layers']['table'] = array(
      '#theme' => 'slider_pro_layers_table',
      '#tree' => TRUE,
    );
    $layers = !empty($this->options['slider_pro']['layers']['table']) ? $this->options['slider_pro']['layers']['table'] : FALSE;
    if (empty($form_state['layers']) && !$layers) {

      // This means the form is loaded for the first time.
      $form_state['layers'] = array();
    }
    else {
      if (!empty($layers) && empty($form_state['layers'])) {

        // This means the form is loaded, but layers have already been saved.
        $form_state['layers'] = array_keys($layers);
      }
    }
    $count = 0;
    foreach ($form_state['layers'] as $layer) {
      $form['slider_pro']['layers']['table']['layer-' . $layer]['fields'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Fields on layer'),
        '#options' => $field_names,
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['fields'] : NULL,
        '#required' => FALSE,
      );
      $form['slider_pro']['layers']['table']['layer-' . $layer]['background'] = array(
        '#type' => 'select',
        '#title' => t('Background'),
        '#options' => array(
          '' => t('None'),
          'sp-white' => t('White transparant'),
          'sp-black' => t('Black transparant'),
        ),
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['background'] : '',
        '#required' => FALSE,
      );
      $form['slider_pro']['layers']['table']['layer-' . $layer]['data_position'] = array(
        '#type' => 'select',
        '#title' => t('Position'),
        '#options' => array(
          'topLeft' => t('Top left'),
          'topCenter' => t('Top center'),
          'topRight' => t('Top right'),
          'bottomLeft' => t('Bottom left'),
          'bottomCenter' => t('Bottom center'),
          'bottomRight' => t('Bottom right'),
          'centerLeft' => t('Center left'),
          'centerRight' => t('Center right'),
          'centerCenter' => t('Center center'),
        ),
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['data_position'] : 'topLeft',
        '#required' => FALSE,
      );
      $form['slider_pro']['layers']['table']['layer-' . $layer]['data_show_transition'] = array(
        '#type' => 'select',
        '#title' => t('Show transition'),
        '#options' => array(
          'left' => t('Left'),
          'right' => t('Right'),
          'up' => t('Up'),
          'down' => t('Down'),
        ),
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['data_show_transition'] : 'right',
        '#required' => FALSE,
      );
      $form['slider_pro']['layers']['table']['layer-' . $layer]['data_hide_transition'] = array(
        '#type' => 'select',
        '#title' => t('Hide transition'),
        '#options' => array(
          'left' => t('Left'),
          'right' => t('Right'),
          'up' => t('Up'),
          'down' => t('Bottom left'),
        ),
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['data_hide_transition'] : 'left',
        '#required' => FALSE,
      );
      $form['slider_pro']['layers']['table']['layer-' . $layer]['data_show_delay'] = array(
        '#type' => 'textfield',
        '#title' => t('Show delay'),
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['data_show_delay'] : 0,
        '#size' => 5,
        '#required' => FALSE,
      );
      $form['slider_pro']['layers']['table']['layer-' . $layer]['data_stay_duration'] = array(
        '#type' => 'textfield',
        '#title' => t('Stay duration'),
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['data_stay_duration'] : 0,
        '#size' => 5,
        '#required' => FALSE,
      );
      if ($count > 0) {
        $form['slider_pro']['layers']['table']['layer-' . $layer]['remove'] = array(
          '#type' => 'submit',
          '#value' => t('Remove layer'),
          '#submit' => array(
            '_slider_pro_plugin_style_remove_layer',
          ),
          '#limit_validation_errors' => array(),
          '#ajax' => array(
            'wrapper' => 'slider-pro-layers',
            'callback' => '_slider_pro_plugin_style_refresh_layers',
          ),
          '#name' => 'remove-' . $count,
        );
      }
      $form['slider_pro']['layers']['table']['layer-' . $layer]['weight'] = array(
        '#type' => 'weight',
        '#title' => t('Weight'),
        '#title_display' => 'invisible',
        '#default_value' => !empty($layers[$layer]) ? $layers[$layer]['weight'] : 10,
        '#attributes' => array(
          'class' => array(
            'order-weight',
          ),
        ),
      );
      $count++;
    }
    $form['slider_pro']['layers']['add_layer'] = array(
      '#type' => 'submit',
      '#value' => t('Add layer'),
      '#submit' => array(
        '_slider_pro_plugin_style_add_layer',
      ),
      '#ajax' => array(
        'wrapper' => 'slider-pro-layers',
        'callback' => '_slider_pro_plugin_style_refresh_layers',
      ),
    );
  }

  /**
   * Add form validation for options.
   */
  function options_validate(&$form, &$form_state) {
    parent::options_validate($form, $form_state);

    // Form_error($form['slider_pro']['height'], 'test');
  }
  function validate() {
    parent::validate();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
slider_pro_style_plugin::options_form function Adds Slider Pro configuration form options. Overrides views_plugin_style::options_form
slider_pro_style_plugin::options_validate function Add form validation for options. Overrides views_plugin_style::options_validate
slider_pro_style_plugin::option_definition function Provide default options. Overrides views_plugin_style::option_definition
slider_pro_style_plugin::validate function Validate that the plugin is correct and can be saved. Overrides views_plugin_style::validate
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::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::options_submit public function Handle any special handling on the validate form. 9
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_style::$row_plugin public property The row plugin, if it's initialized and the style itself supports it.
views_plugin_style::$row_tokens public property Store all available tokens row rows.
views_plugin_style::build_sort public function Called by the view builder to see if this style handler wants to interfere with the sorts. If so it should build; if it returns any non-TRUE value, normal sorting will NOT be added to the query. 1
views_plugin_style::build_sort_post public function Called by the view builder to let the style build a second set of sorts that will come after any other sorts in the view. 1
views_plugin_style::destroy public function Destructor. Overrides views_object::destroy
views_plugin_style::even_empty public function Should the output of the style plugin be rendered even if it's empty. 1
views_plugin_style::get_field public function Get a rendered field.
views_plugin_style::get_field_value public function Get the raw field value.
views_plugin_style::get_row_class public function Return the token replaced row class for the specified row.
views_plugin_style::init public function Initialize a style plugin.
views_plugin_style::pre_render public function Allow the style to do stuff before each row is rendered.
views_plugin_style::query public function Add anything to the query that we might need to. Overrides views_plugin::query 2
views_plugin_style::render public function Render the display in this style. 5
views_plugin_style::render_fields public function Render all of the fields for a given style and store them on the object.
views_plugin_style::render_grouping public function Group records as needed for rendering.
views_plugin_style::render_grouping_sets public function Render the grouping sets.
views_plugin_style::tokenize_value public function Take a value and apply token replacement logic to it.
views_plugin_style::uses_fields public function Return TRUE if this style also uses fields.
views_plugin_style::uses_row_class public function Return TRUE if this style also uses a row plugin.
views_plugin_style::uses_row_plugin public function Return TRUE if this style also uses a row plugin.
views_plugin_style::uses_tokens public function Return TRUE if this style uses tokens.