Documentation

CRM_Utils_Sort
in package

Base class to provide generic sort functionality.

Note that some ideas have been borrowed from the drupal tablesort.inc code.

Also note that since the Pager and Sort class are similar, do match the function names if introducing additional functionality

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Constants

ASCENDING  = 1
Constants to determine what direction each variable is to be sorted
DESCENDING  = 2
Constants to determine what direction each variable is to be sorted
DONTCARE  = 4
Constants to determine what direction each variable is to be sorted
SORT_DIRECTION  = 'crmSortDirection'
The name for the sort GET/POST param
SORT_ID  = 'crmSID'
The name for the sort GET/POST param
SORT_ORDER  = 'crmSortOrder'
The name for the sort GET/POST param

Properties

$_response  : array<string|int, mixed>
The output generated for the current form
$_vars  : array<string|int, mixed>
Array of variables that influence the query
$_currentSortDirection  : string
What direction are we sorting on
$_currentSortID  : string
What variable are we currently sorting on
$_link  : string
The newly formulated base url to be used as links for various table elements
$_name  : string
Name of the sort function. Used to isolate session variables
$_urlVar  : string
What's the name of the sort variable in a REQUEST

Methods

__construct()  : CRM_Utils_Sort
The constructor takes an assoc array key names of variable (which should be the same as the column name) value: ascending or descending
cmpFunc()  : int
Universal callback function for sorting by weight, id, title or name
getCurrentSortDirection()  : int
Getter for currentSortDirection.
getCurrentSortID()  : int
Getter for currentSortID.
initialize()  : mixed
Init the object.
initSortID()  : mixed
Init the sort ID values in the object.
orderBy()  : string
Function returns the string for the order by clause.
sortIDValue()  : string
Create the sortID string to be used in the GET param.

Constants

ASCENDING

Constants to determine what direction each variable is to be sorted

public int ASCENDING = 1

DESCENDING

Constants to determine what direction each variable is to be sorted

public int DESCENDING = 2

DONTCARE

Constants to determine what direction each variable is to be sorted

public int DONTCARE = 4

SORT_DIRECTION

The name for the sort GET/POST param

public string SORT_DIRECTION = 'crmSortDirection'

SORT_ID

The name for the sort GET/POST param

public string SORT_ID = 'crmSID'

SORT_ORDER

The name for the sort GET/POST param

public string SORT_ORDER = 'crmSortOrder'

Properties

$_response

The output generated for the current form

public array<string|int, mixed> $_response

$_vars

Array of variables that influence the query

public array<string|int, mixed> $_vars

$_currentSortDirection

What direction are we sorting on

protected string $_currentSortDirection

$_currentSortID

What variable are we currently sorting on

protected string $_currentSortID

The newly formulated base url to be used as links for various table elements

protected string $_link

$_name

Name of the sort function. Used to isolate session variables

protected string $_name

$_urlVar

What's the name of the sort variable in a REQUEST

protected string $_urlVar

Methods

__construct()

The constructor takes an assoc array key names of variable (which should be the same as the column name) value: ascending or descending

public __construct(mixed $vars[, string $defaultSortOrder = NULL ]) : CRM_Utils_Sort
Parameters
$vars : mixed

Assoc array as described above.

$defaultSortOrder : string = NULL

Order to sort.

Return values
CRM_Utils_Sort

cmpFunc()

Universal callback function for sorting by weight, id, title or name

public static cmpFunc(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
$a : array<string|int, mixed>
$b : array<string|int, mixed>
Return values
int

(-1 or 1)

getCurrentSortDirection()

Getter for currentSortDirection.

public getCurrentSortDirection() : int
Return values
int

returns of the current sort direction

getCurrentSortID()

Getter for currentSortID.

public getCurrentSortID() : int
Return values
int

returns of the current sort id

initialize()

Init the object.

public initialize(string $defaultSortOrder) : mixed
Parameters
$defaultSortOrder : string

The sort order to use by default.

initSortID()

Init the sort ID values in the object.

public initSortID(string $defaultSortOrder) : mixed
Parameters
$defaultSortOrder : string

The sort order to use by default.

orderBy()

Function returns the string for the order by clause.

public orderBy() : string
Return values
string

the order by clause

sortIDValue()

Create the sortID string to be used in the GET param.

public static sortIDValue(int $index, int $dir) : string
Parameters
$index : int

The field index.

$dir : int

The direction of the sort.

Return values
string

the string to append to the url


        
On this page

Search results