private function _getOrderLinkAndSortedHeaderHtml($fields_meta, $sort_expression, $sort_expression_nodirection, $column_index, $unsorted_sql_query, $session_max_rows, $comments, $sort_direction, $col_visib, $col_visib_j)
{
$sorted_header_html = '';
// Checks if the table name is required; it's the case
// for a query with a "JOIN" statement and if the column
// isn't aliased, or in queries like
// SELECT `1`.`master_field` , `2`.`master_field`
// FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
$sort_tbl = isset($fields_meta->table) && strlen($fields_meta->table) > 0 && $fields_meta->orgname == $fields_meta->name ? Util::backquote($fields_meta->table) . '.' : '';
$name_to_use_in_sort = $fields_meta->name;
// Generates the orderby clause part of the query which is part
// of URL
list($single_sort_order, $multi_sort_order, $order_img) = $this->_getSingleAndMultiSortUrls($sort_expression, $sort_expression_nodirection, $sort_tbl, $name_to_use_in_sort, $sort_direction, $fields_meta, $column_index);
if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|' . 'LOCK IN SHARE MODE))@is', $unsorted_sql_query, $regs3)) {
$single_sorted_sql_query = $regs3[1] . $single_sort_order . $regs3[2];
$multi_sorted_sql_query = $regs3[1] . $multi_sort_order . $regs3[2];
} else {
$single_sorted_sql_query = $unsorted_sql_query . $single_sort_order;
$multi_sorted_sql_query = $unsorted_sql_query . $multi_sort_order;
}
$_single_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'sql_query' => $single_sorted_sql_query, 'session_max_rows' => $session_max_rows, 'is_browse_distinct' => $this->__get('is_browse_distinct'));
$_multi_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'sql_query' => $multi_sorted_sql_query, 'session_max_rows' => $session_max_rows, 'is_browse_distinct' => $this->__get('is_browse_distinct'));
$single_order_url = 'sql.php' . URL::getCommon($_single_url_params);
$multi_order_url = 'sql.php' . URL::getCommon($_multi_url_params);
// Displays the sorting URL
// enable sort order swapping for image
$order_link = $this->_getSortOrderLink($order_img, $column_index, $fields_meta, $single_order_url, $multi_order_url);
$sorted_header_html .= $this->_getDraggableClassForSortableColumns($col_visib, $col_visib_j, $fields_meta, $order_link, $comments);
return array($order_link, $sorted_header_html);
}