You are here

class views_fluid_grid_plugin_style in Views Fluid Grid 7.3

Same name and namespace in other branches
  1. 6 views/views_fluid_grid_plugin_style.inc \views_fluid_grid_plugin_style

Style plugin to render items in a fluid grid.

Hierarchy

Expanded class hierarchy of views_fluid_grid_plugin_style

1 string reference to 'views_fluid_grid_plugin_style'
views_fluid_grid_views_plugins in views/views_fluid_grid.views.inc
Implementation of hook_views_plugins().

File

views/views_fluid_grid_plugin_style.inc, line 13
Contains the fluid grid style plugin.

View source
class views_fluid_grid_plugin_style extends views_plugin_style {

  /**
   * Set default options.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['items_width'] = array(
      'default' => 200,
    );
    $options['items_height'] = array(
      'default' => '',
    );
    $options['advanced_layout'] = array(
      'default' => array(),
    );
    $options['list_alignment'] = array(
      'default' => '',
    );
    $options['items_alignment'] = array(
      'default' => '',
    );
    $options['items_h_margin'] = array(
      'default' => '',
    );
    $options['items_v_margin'] = array(
      'default' => '',
    );
    $options['box_shadow'] = array(
      'default' => 0,
    );
    $options['border_radius'] = array(
      'default' => 0,
    );
    return $options;
  }

  /**
   * Provide a form to edit options for this plugin.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $alignment_options = array(
      '' => t('Inherit'),
      'left' => t('Left'),
      'right' => t('Right'),
      'center' => t('Center'),
      'justify' => t('Justify'),
    );
    $items_width_options = array(
      '' => t('Auto'),
    ) + drupal_map_assoc(variable_get('views_fluid_grid_plugin_style_widths', array(
      100,
      150,
      180,
      200,
      250,
      300,
      350,
      400,
      450,
      500,
    )));
    $items_height_options = array(
      '' => t('Auto'),
    ) + drupal_map_assoc(variable_get('views_fluid_grid_plugin_style_heights', array(
      100,
      150,
      200,
      250,
      300,
      350,
      400,
      450,
      500,
    )));
    $items_margin_options = array(
      '' => t('None'),
    ) + drupal_map_assoc(variable_get('views_fluid_grid_plugin_style_margins', array(
      '0',
      '2px',
      '4px',
      '6px',
      '8px',
      '10px',
      '0.2em',
      '0.5em',
      '0.8em',
      '1em',
      '1.2em',
      '1.5em',
      '1.8em',
      '2em',
    )));
    $form['size'] = array(
      '#type' => 'fieldset',
      '#title' => t('Items size'),
    );
    $form['size']['items_width'] = array(
      '#type' => 'select',
      '#title' => t('Width'),
      '#options' => $items_width_options,
      '#default_value' => $this->options['items_width'],
    );
    $form['size']['items_height'] = array(
      '#type' => 'select',
      '#title' => t('Height'),
      '#options' => $items_height_options,
      '#default_value' => $this->options['items_height'],
    );
    $form['advanced_layout'] = array(
      '#type' => 'value',
      '#value' => $this->options['advanced_layout'],
    );
    $form['advanced'] = array(
      '#type' => 'fieldset',
      '#title' => t('Advanced layout options'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($this->options['advanced_layout']),
    );
    $form['advanced']['align'] = array(
      '#type' => 'fieldset',
      '#title' => t('Alignment'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($this->options['advanced_layout']['align']),
    );
    $form['advanced']['align']['list_alignment'] = array(
      '#type' => 'select',
      '#title' => t('Items in the list'),
      '#options' => $alignment_options,
      '#default_value' => $this->options['list_alignment'],
      '#description' => t('Horizontal alignment for the items in the list. Note: text-align:justify does not seem to work in IE6.'),
    );
    $form['advanced']['align']['items_alignment'] = array(
      '#type' => 'select',
      '#title' => t('Content of the items'),
      '#options' => $alignment_options,
      '#default_value' => $this->options['items_alignment'],
      '#description' => t('Horizontal alignment for the content of the items.'),
    );
    $form['advanced']['margins'] = array(
      '#type' => 'fieldset',
      '#title' => t('Margins'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($this->options['advanced_layout']['margins']),
    );
    $form['advanced']['margins']['items_h_margin'] = array(
      '#type' => 'select',
      '#title' => t('Horizontal'),
      '#options' => $items_margin_options,
      '#default_value' => $this->options['items_h_margin'],
      '#description' => t('Horizontal margin between items.'),
    );
    $form['advanced']['margins']['items_v_margin'] = array(
      '#type' => 'select',
      '#title' => t('Vertical'),
      '#options' => $items_margin_options,
      '#default_value' => $this->options['items_v_margin'],
      '#description' => t('Vertical margin between items.'),
    );
    $form['advanced']['css3'] = array(
      '#type' => 'fieldset',
      '#title' => t('CSS3 style properties'),
      '#description' => t('Note that these style properties may not be supported by all browsers.'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($this->options['advanced_layout']['css3']),
    );
    $form['advanced']['css3']['box_shadow'] = array(
      '#type' => 'radios',
      '#title' => t('Box shadow'),
      '#options' => array(
        0 => t('Disabled'),
        1 => t('Enabled'),
      ),
      '#default_value' => $this->options['box_shadow'],
    );
    $form['advanced']['css3']['border_radius'] = array(
      '#type' => 'radios',
      '#title' => t('Border radius'),
      '#options' => array(
        0 => t('Disabled'),
        1 => t('Enabled'),
      ),
      '#default_value' => $this->options['border_radius'],
    );
  }

  /**
   * Process the options form.
   */
  function options_submit(&$form, &$form_state) {
    foreach ($form_state['values']['style_options']['size'] as $key => $value) {
      $form_state['values']['style_options'][$key] = $value;
    }
    unset($form_state['values']['style_options']['size']);
    $advanced_layout_fieldsets = array(
      'align',
      'margins',
      'css3',
    );
    $advanced_layout_options = array();
    $option_definitions = $this
      ->option_definition();
    foreach ($advanced_layout_fieldsets as $fieldset) {
      if (isset($form_state['values']['style_options']['advanced'][$fieldset])) {
        foreach ($form_state['values']['style_options']['advanced'][$fieldset] as $key => $value) {
          $form_state['values']['style_options'][$key] = $value;
          if ($option_definitions[$key]['default'] != $value) {
            $advanced_layout_options[$fieldset] = TRUE;
          }
        }
      }
    }
    unset($form_state['values']['style_options']['advanced']);
    $form_state['values']['style_options']['advanced_layout'] = $advanced_layout_options;
    parent::options_submit($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_fluid_grid_plugin_style::options_form function Provide a form to edit options for this plugin. Overrides views_plugin_style::options_form
views_fluid_grid_plugin_style::options_submit function Process the options form. Overrides views_plugin::options_submit
views_fluid_grid_plugin_style::option_definition function Set default options. Overrides views_plugin_style::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::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_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::options_validate public function Validate the options form. Overrides views_plugin::options_validate
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.
views_plugin_style::validate public function Validate that the plugin is correct and can be saved. Overrides views_plugin::validate