PMA\libraries\DisplayResults::_getSortedColumnMessage PHP Method

_getSortedColumnMessage() private method

Prepare sorted column message
See also: getTable()
private _getSortedColumnMessage ( &$dt_result, string $sort_expression_nodirection ) : string
$sort_expression_nodirection string sort expression without direction
return string html content null if not found sorted column
    private function _getSortedColumnMessage(&$dt_result, $sort_expression_nodirection)
    {
        $fields_meta = $this->__get('fields_meta');
        // To use array indexes
        if (empty($sort_expression_nodirection)) {
            return null;
        }
        if (mb_strpos($sort_expression_nodirection, '.') === false) {
            $sort_table = $this->__get('table');
            $sort_column = $sort_expression_nodirection;
        } else {
            list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
        }
        $sort_table = Util::unQuote($sort_table);
        $sort_column = Util::unQuote($sort_column);
        // find the sorted column index in row result
        // (this might be a multi-table query)
        $sorted_column_index = false;
        foreach ($fields_meta as $key => $meta) {
            if ($meta->table == $sort_table && $meta->name == $sort_column) {
                $sorted_column_index = $key;
                break;
            }
        }
        if ($sorted_column_index === false) {
            return null;
        }
        // fetch first row of the result set
        $row = $GLOBALS['dbi']->fetchRow($dt_result);
        // initializing default arguments
        $default_function = 'PMA_mimeDefaultFunction';
        $transformation_plugin = $default_function;
        $transform_options = array();
        // check for non printable sorted row data
        $meta = $fields_meta[$sorted_column_index];
        if (stristr($meta->type, self::BLOB_FIELD) || $meta->type == self::GEOMETRY_FIELD) {
            $column_for_first_row = $this->_handleNonPrintableContents($meta->type, $row[$sorted_column_index], $transformation_plugin, $transform_options, $default_function, $meta);
        } else {
            $column_for_first_row = $row[$sorted_column_index];
        }
        $column_for_first_row = mb_strtoupper(mb_substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']) . '...');
        // fetch last row of the result set
        $GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
        $row = $GLOBALS['dbi']->fetchRow($dt_result);
        // check for non printable sorted row data
        $meta = $fields_meta[$sorted_column_index];
        if (stristr($meta->type, self::BLOB_FIELD) || $meta->type == self::GEOMETRY_FIELD) {
            $column_for_last_row = $this->_handleNonPrintableContents($meta->type, $row[$sorted_column_index], $transformation_plugin, $transform_options, $default_function, $meta);
        } else {
            $column_for_last_row = $row[$sorted_column_index];
        }
        $column_for_last_row = mb_strtoupper(mb_substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']) . '...');
        // reset to first row for the loop in _getTableBody()
        $GLOBALS['dbi']->dataSeek($dt_result, 0);
        // we could also use here $sort_expression_nodirection
        return ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
    }
DisplayResults