function _draggableviews_get_draggable_sort in DraggableViews 7.2
Get the draggable views weight sort of a view if there is one and return its ID. If there are multiple of these sorts, either the one matching a specified table alias or the first one is returned.
Parameters
$view: The view object.
string $preferred_table_alias: (optional) In case there are multiple sorts, return the ID of one which has this table alias, if it exists. If it doesn't exist, return the first sort.
Return value
string The ID of the sort or empty string if there isn't one.
2 calls to _draggableviews_get_draggable_sort()
- draggableviews_join_handler::build_join in views/
draggableviews_join_handler.inc - Build the SQL for the join this object represents.
- _draggableviews_get_order_view_display in ./
draggableviews.module - Get the view display identifier.
File
- ./
draggableviews.module, line 402
Code
function _draggableviews_get_draggable_sort($view, $preferred_table_alias = '') {
$default_sort_id = '';
foreach ($view->sort as $id => $sort) {
if ($sort->definition['handler'] == 'draggableviews_handler_sort') {
if (!$preferred_table_alias || $sort->table_alias == $preferred_table_alias) {
return $id;
}
if (!$default_sort_id) {
// Return this ID if no sort matching $preferred_table_alias is found.
$default_sort_id = $id;
}
}
}
return $default_sort_id;
}