You are here

function UIkitViewsPluginStyleTable::build_sort_post in UIkit Components 7.2

Same name and namespace in other branches
  1. 7.3 uikit_views/plugins/UIkitViewsPluginStyleTable.inc \UIkitViewsPluginStyleTable::build_sort_post()

Add our actual sort criteria

Overrides views_plugin_style::build_sort_post

File

uikit_views/plugins/UIkitViewsPluginStyleTable.inc, line 74
Contains the table style plugin.

Class

UIkitViewsPluginStyleTable
Style plugin to render each item as a row in a UIkit table.

Code

function build_sort_post() {
  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'];
    if (!empty($this->options['info'][$sort]['default_sort_order'])) {
      $this->order = $this->options['info'][$sort]['default_sort_order'];
    }
    else {
      $this->order = !empty($this->options['order']) ? $this->options['order'] : 'asc';
    }
  }
  else {
    $sort = $_GET['order'];

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

  // 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 = 'asc';
  }

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

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