PMA\libraries\DisplayResults::_getSortByKeyDropDown PHP Method

_getSortByKeyDropDown() private method

Prepare sort by key dropdown - html code segment
See also: _getTableHeaders()
private _getSortByKeyDropDown ( Index[] $indexes, string $sort_expression, string $unsorted_sql_query ) : string
$indexes Index[] the indexes of the table for sort criteria
$sort_expression string the sort expression
$unsorted_sql_query string the unsorted sql query
return string $drop_down_html html content
    private function _getSortByKeyDropDown($indexes, $sort_expression, $unsorted_sql_query)
    {
        $drop_down_html = '';
        $drop_down_html .= '<form action="sql.php" method="post" ' . 'class="print_ignore">' . "\n" . URL::getHiddenInputs($this->__get('db'), $this->__get('table')) . URL::getHiddenFields(array('sort_by_key' => '1')) . __('Sort by key') . ': <select name="sql_query" class="autosubmit">' . "\n";
        $used_index = false;
        $local_order = isset($sort_expression) ? $sort_expression : '';
        foreach ($indexes as $index) {
            $asc_sort = '`' . implode('` ASC, `', array_keys($index->getColumns())) . '` ASC';
            $desc_sort = '`' . implode('` DESC, `', array_keys($index->getColumns())) . '` DESC';
            $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
            if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|' . 'FOR UPDATE|LOCK IN SHARE MODE))@is', $unsorted_sql_query, $my_reg)) {
                $unsorted_sql_query_first_part = $my_reg[1];
                $unsorted_sql_query_second_part = $my_reg[2];
            } else {
                $unsorted_sql_query_first_part = $unsorted_sql_query;
                $unsorted_sql_query_second_part = '';
            }
            $drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query_first_part . "\n" . ' ORDER BY ' . $asc_sort . $unsorted_sql_query_second_part) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($index->getName()) . ' (ASC)</option>';
            $drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query_first_part . "\n" . ' ORDER BY ' . $desc_sort . $unsorted_sql_query_second_part) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($index->getName()) . ' (DESC)</option>';
        }
        $drop_down_html .= '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . __('None') . '</option>' . '</select>' . "\n" . '</form>' . "\n";
        return $drop_down_html;
    }
DisplayResults