public class Sortable

class.sortable.php #18

This class handles sortable objects via the $_REQUEST parameters. Sortable standardizes the ordering parameters, and provides a method, buildTableHeaders, which builds the correct URL's and markup to sort backend objects and update the Table UI appropriately.

This class is designed to work in the Symphony backend only, and not on the Frontend.

Methods

static array buildTableHeaders(array $columns, string $sort, string $order, string $extra_url_params)

This method builds the markup for sorting-aware table headers. It accepts an $columns array, as well as the current sorting axis $sort and the current sort order, $order. If $extra_url_params are provided, they are appended to the redirect string upon clicking on a table header.

	              'label' => 'Column label',
	    'sortable' => (true|false),
	    'handle' => 'handle for the column (i.e. the field ID), used as value for $sort',
	    'attrs' => array(
	        'HTML <a> attribute' => 'value',
	        [...]
	    )
	
	        
Parameters
  • $columns arrayAn array of columns that will be converted into table headers.

  • $sort stringThe current field (or axis) the objects are sorted by.

  • $order stringThe current sort order (i.e. 'asc' or 'desc').

  • $extra_url_params string(optional) A string of URL parameters that will be appended to the redirect string.

Returns

An array of table headers that can be directly passed to Widget::TableHead.

static void initialize(object $object, array $result, string $sort, string $order, array $params)

This method initializes the $result, $sort and $order variables by using the $_REQUEST array. The $result is passed by reference, and is return of calling the $object->sort() method. It is this method that actually invokes the sorting inside the $object.

Parameters
  • $object objectThe object responsible for sorting the items. It must implement a sort() method.

  • $result arrayThis variable stores an array sorted objects. Once set, its value is available to the client class of Sortable.

  • $sort stringThis variable stores the field (or axis) the objects are sorted by. Once set, its value is available to the client class of Sortable.

  • $order stringThis variable stores the sort order (i.e. 'asc' or 'desc'). Once set, its value is available to the client class of Sortable.

  • $params array(optional) An array of parameters that can be passed to the context-based method.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details