You are here

class scald_plugin_style_library in Scald: Media Management made easy 6

Same name and namespace in other branches
  1. 7 modules/library/scald_dnd_library/includes/scald_plugin_style_library.inc \scald_plugin_style_library

@file Provides the library style plugin. Ideally, this shouldn't be needed, but I haven't figured out a cleaner way to do this yet.

Hierarchy

Expanded class hierarchy of scald_plugin_style_library

1 string reference to 'scald_plugin_style_library'
scald_dnd_library_views_plugins in scald_dnd_library/includes/scald_dnd_library.views.inc
Implements hook_views_plugins(). TODO: Maybe try to get rid of the style plugin ? The display should probably just set it.

File

scald_dnd_library/includes/scald_plugin_style_library.inc, line 7
Provides the library style plugin. Ideally, this shouldn't be needed, but I haven't figured out a cleaner way to do this yet.

View source
class scald_plugin_style_library extends views_plugin_style {
  function option_definition() {
    $options = parent::option_definition();
    $options['default'] = array(
      'default' => 'sid',
    );
    $options['override'] = array(
      'default' => TRUE,
    );
    $options['order'] = array(
      'default' => 'desc',
    );
    return $options;
  }
  function build_sort() {
    return FALSE;
  }
  function build_sort_post() {
    $default_sort = 'sid';
    foreach ($this->view->field as $name => $field) {
      if ($field->definition['click sortable']) {
        $default_sort = $name;
        break;
      }
    }
    $this->options['default'] = $default_sort;
    $this->options['order'] = 'desc';
    if (!isset($_GET['order'])) {

      // check for a 'default' clicksort. If there isn't one, exit gracefully.
      if (empty($this->options['default'])) {
        return;
      }
      $sort = $this->options['default'];
      $this->order = !empty($this->options['order']) ? $this->options['order'] : 'desc';
    }
    else {
      $sort = $_GET['order'];

      // Store the $order for later use.
      $this->order = !empty($_GET['sort']) ? strtolower($_GET['sort']) : 'desc';
    }

    // If a sort we don't know anything about gets through, exit gracefully.
    if (empty($this->view->field[$sort])) {
      return;
    }

    // Ensure $this->order is valid.
    if ($this->order != 'asc' && $this->order != 'desc') {
      $this->order = 'desc';
    }

    // Store the $sort for later use.
    $this->active = $sort;

    // Tell the field to click sort.
    $this->view->field[$sort]
      ->click_sort($this->order);
    return;
  }

}

Members