buildSortPost example

if ($this->style_plugin->usesFields()) {
      $this->_build('field');
    }

    // Build our sort criteria if we were instructed to do so.     if (!empty($this->build_sort)) {
      // Allow the style handler to deal with sorting.       if ($this->style_plugin->buildSort()) {
        $this->_build('sort');
      }
      // allow the plugin to build second sorts as well.       $this->style_plugin->buildSortPost();
    }

    // Allow area handlers to affect the query.     $this->_build('header');
    $this->_build('footer');
    $this->_build('empty');

    // Allow display handler to affect the query:     $this->display_handler->query($this->display_handler->useGroupBy());

    // Allow style handler to affect the query:
$this->assertFalse($style_plugin->buildSort(), 'If a valid order is specified and the table is configured to override, the normal sort should not be used.');

    // Test the buildSortPost() method.     $request = new Request();
    $view->setRequest($request);

    // Setup no valid default.     $this->prepareView($view);
    $style_plugin = $view->style_plugin;
    $style_plugin->options['default'] = '';
    $style_plugin->buildSortPost();
    $this->assertNull($style_plugin->order, 'No sort order was set, when no order was specified and no default column was selected.');
    $this->assertNull($style_plugin->active, 'No sort field was set, when no order was specified and no default column was selected.');
    $view->destroy();

    // Setup a valid default + column specific default sort order.     $this->prepareView($view);
    $style_plugin = $view->style_plugin;
    $style_plugin->options['default'] = 'id';
    $style_plugin->options['info']['id']['default_sort_order'] = 'desc';
    $style_plugin->buildSortPost();
    $this->assertSame('desc', $style_plugin->order, 'Fallback to the right default sort order.');
    
Home | Imprint | This part of the site doesn't use cookies.