PHP Class PMA\libraries\Util

ファイルを表示 Open project: phpmyadmin/phpmyadmin Class Usage Examples

Public Methods

Method Description
addMicroseconds ( string $value ) : string Add fractional seconds to time, datetime and timestamp strings.
asWKT ( string $data, boolean $includeSRID = false ) : string Converts GIS data to Well Known Text format
backquote ( mixed $a_name, boolean $do_it = true ) : mixed Adds backquotes on both sides of a database, table or field name.
backquoteCompat ( mixed $a_name, string $compatibility = 'MSSQL', boolean $do_it = true ) : mixed Adds backquotes on both sides of a database, table or field name.
buildActionTitles ( ) : array Build titles and icons for action links
cacheExists ( string $var ) : boolean Verifies if something is cached in the session
cacheGet ( string $var, Closure $callback = null ) : mixed Gets cached information from the session
cacheSet ( string $var, mixed $val = null ) : mixed Caches information in the session
cacheUnset ( string $var ) : void Removes cached information from the session
checkParameters ( string[] $params, boolean $request = true ) : void Function added to avoid path disclosures.
clearUserCache ( ) : void Clears cache content which needs to be refreshed on user change.
configureCurl ( resource $curl_handle ) : resource Updates an existing curl as necessary
containsNonPrintableAscii ( string $value ) : integer Verifies whether the value contains a non-printable character
convertBitDefaultValue ( string $bit_default_value ) : string Converts a BIT type default value for example, b'010' becomes 010
createGISData ( string $gis_string ) : string Generates GIS data based on the string passed.
currentUserHasPrivilege ( string $priv, mixed $db = null, mixed $tbl = null ) : boolean Checks if the current user has a specific privilege and returns true if the user indeed has that privilege or false if (s)he doesn't. This function must only be used for features that are available since MySQL 5, because it relies on the INFORMATION_SCHEMA database to be present.
duplicateFirstNewline ( string $string ) : string If the string starts with a \r\n pair (0x0d0a) add an extra \n
escapeMysqlWildcards ( string $name ) : string Add slashes before "_" and "%" characters for using them in MySQL database, table and field names.
expandUserString ( string $string, array | string $escape = null, array $updates = [] ) : string Formats user string, expanding @VARIABLES@, accepting strftime format string.
extractColumnSpec ( string $columnspec ) : array Extracts the various parts from a column spec
extractValueFromFormattedSize ( string $formatted_size ) : integer Returns the number of bytes when a formatted size is given
formatByteDown ( double | integer $value, integer $limes = 6, integer $comma ) : array Formats $value to byte view
formatNumber ( double $value, integer $digits_left = 3, integer $digits_right, boolean $only_down = false, boolean $noTrailingZero = true ) : string Formats $value to the given length and appends SI prefixes with a $length of 0 no truncation occurs, number is only formatted to the current locale
formatSql ( string $sqlQuery, boolean $truncate = false ) : string format sql strings
generateHiddenMaxFileSize ( integer $max_size ) : string Generates a hidden field which should indicate to the browser the maximum size for upload
getBrowseUploadFileBlock ( string $max_upload_size ) : String Prepare the form used to browse anywhere on the local server for a file to import
getButton ( ) : String Prepare HTML code for display button.
getButtonOrImage ( string $button_name, string $button_class, string $text, string $image, string $value = '' ) : string Generate a button or image tag
getCharsetQueryPart ( string $collation, $override = false ) : string Generate the charset query part
getClassForType ( string $type ) : string Returns the proper class clause according to the column type
getCollateForIS ( ) : string Provide COLLATE clause, if required, to perform case sensitive comparisons for queries on information_schema.
getCompressionMimeType ( resource $file ) : string Reads the file, detects the compression MIME type, closes the file and returns the MIME type
getDbInfo ( string $db, string $sub_part ) : array Gets the list of tables in the current db and information about these tables if possible
getDbLink ( string $database = null ) : string returns html code for db link to default db page
getDefaultFunctionForField ( array $field, boolean $insert_mode ) : string Returns default function for a particular column.
getDivForSliderEffect ( string $id = '', string $message = '' ) : string Generates a slider effect (jQjuery) Takes care of generating the initial
and the link controlling the slider; you have to generate the
yourself after the sliding section.
getDocuLink ( string $page, string $anchor = '' ) : string Returns link to documentation.
getDropdown ( string $select_name, array $choices, string $active_choice, string $id, string $class = '', string $placeholder = null ) : string Generates and returns an HTML dropdown
getExternalBug ( string $functionality, string $component, string $minimum_version, string $bugref ) : String Prepare a lightbulb hint explaining a known external bug that affects a functionality
getFKCheckbox ( ) : string Get HTML for Foreign key check checkbox
getFirstOccurringRegularExpression ( array $regex_array, String $query ) : String Get regular expression which occur first inside the given sql query.
getFormattedMaximumUploadSize ( integer $max_upload_size ) : string Returns the formatted maximum size for an upload
getFunctionsForField ( array $field, boolean $insert_mode, $foreignData ) : string Creates a dropdown box with MySQL functions for a particular column.
getGISDatatypes ( boolean $upper_case = false ) : string[] Return GIS data types
getGISFunctions ( string $geom_type = null, boolean $binary = true, boolean $display = false ) : array Returns the names and details of the functions that can be applied on geometry data types.
getHtmlTab ( array $tab, array $url_params = [] ) : string returns a tab for tabbed navigation.
getHtmlTabs ( array $tabs, array $url_params, string $menu_id, boolean $resizable = false ) : string returns html-code for a tab navigation
getIcon ( string $icon, string $alternate = '', boolean $force_text = false, boolean $menu_icon = false, string $control_param = 'ActionLinksMode' ) : string Returns an HTML IMG tag for a particular icon from a theme, which may be an actual file or an icon from a sprite.
getImage ( string $image, string $alternate = '', array $attributes = [] ) : string Returns an HTML IMG tag for a particular image from a theme, which may be an actual file or an icon from a sprite
getListNavigator ( integer $count, integer $pos, array $_url_params, string $script, string $frame, integer $max_count, string $name = 'pos', string[] $classes = [] ) : string Prepare navigation for a list
getMenuTabList ( string $level = null ) : array Return the list of tabs for the menu with corresponding names
getMessage ( Message | string $message, string $sql_query = null, string $type = 'notice' ) : string Prepare the message and the query usually the message is the result of the query executed
getMySQLDocuURL ( string $link, string $anchor = '' ) : string Get a URL link to the official MySQL documentation
getNavigationLink ( string $link, boolean $showText, string $text, boolean $showIcon, string $icon, string $linkId = '', boolean $disableAjax = false, string $linkTarget = '', array $classes = [] ) : string Renders a single link for the top of the navigation panel
getRadioFields ( string $html_field_name, array $choices, string $checked_choice = '', boolean $line_break = true, boolean $escape_label = true, string $class = '', string $id_prefix = '' ) : string Generates a set of radio HTML fields
getScriptNameForOption ( string $target, string $location ) : string Get the script name corresponding to a plain English config word in order to append in links on navigation and main panel
getSelectUploadFileBlock ( ImportPlugin[] $import_list, string $uploaddir ) : String Prepare the form used to select a file to import from the server upload directory
getServerType ( ) : string Returns server type for current connection
getStartAndNumberOfRowsPanel ( string $sql_query ) : string Function to get html for the start row and number of rows panel
getSupportedDatatypes ( boolean $html = false, string $selected = '' ) : mixed This function processes the datatypes supported by the DB, as specified in Types->getColumns() and either returns an array (useful for quickly checking if a datatype is supported) or an HTML snippet that creates a drop-down list.
getTableList ( string $db, string $tables = null, integer $limit_offset, integer | boolean $limit_count = false ) : array returns array with tables of given db with extended information and grouped
getTablesWhenOpen ( string $db, object $db_info_result ) : array Gets the list of tables in the current db, taking into account that they might be "in use"
getTitleForTarget ( string $target ) : string Get the action word corresponding to a script name in order to display it as a title in navigation panel
getUniqueCondition ( resource $handle, integer $fields_cnt, array $fields_meta, array $row, boolean $force_unique = false, string | boolean $restrict_to_table = false, array $analyzed_sql_results = null ) : array Function to generate unique condition for specified row.
handleContext ( array $context ) : array Returns information with regards to handling the http request
handleDisableFKCheckCleanup ( boolean $default_fk_check_value ) : void Cleanup changes done for foreign key check
handleDisableFKCheckInit ( ) : boolean Handle foreign key check request
httpRequest ( string $url, string $method, boolean $return_only_status = false, mixed $content = null, string $header = "" ) : mixed Creates HTTP request
httpRequestCurl ( string $url, string $method, boolean $return_only_status = false, mixed $content = null, string $header = "" ) : mixed Creates HTTP request using curl
httpRequestFopen ( string $url, string $method, boolean $return_only_status = false, mixed $content = null, string $header = "" ) : mixed Creates HTTP request using file_get_contents
httpRequestReturn ( mixed $response, interger $http_status, boolean $return_only_status ) : mixed Creates HTTP request using curl
isForeignKeyCheck ( ) : boolean Is Foreign key check enabled?
isForeignKeySupported ( string $engine ) : boolean Verifies if this table's engine supports foreign keys
isVirtualColumnsSupported ( ) : boolean Returns whether the database server supports virtual columns
linkOrButton ( string $url, string $message, mixed $tag_params = [], boolean $new_form = true, boolean $strip_img = false, string $target = '', boolean $force_button = false ) : string Displays a link, or a button if the link's URL is too large, to accommodate some browsers' limitations
listPHPExtensions ( ) : array Returs list of used PHP extensions.
localisedDate ( integer $timestamp, string $format = '' ) : string Writes localised date
mysqlDie ( string | boolean $server_msg = '', string $sql_query = '', boolean $is_modify_link = true, string $back_url = '', boolean $exit = true ) : string Displays a MySQL error message in the main panel when $exit is true.
pageselector ( string $name, integer $rows, integer $pageNow = 1, integer $nbTotalPage = 1, integer $showAll = 200, integer $sliceStart = 5, integer $sliceEnd = 5, integer $percent = 20, integer $range = 10, string $prompt = '' ) : string Generate a pagination selector for browsing resultsets
parseEnumSetValues ( string $definition, boolean $escapeHtml = true ) : array Parses ENUM/SET values
printableBitValue ( integer $value, integer $length ) : string Converts a bit value to printable format; in MySQL a BIT field can be from 1 to 64 bits so we need this function because in PHP, decbin() supports only 32 bits on 32-bit servers
processIndexData ( array $indexes ) : array Process the index data.
profilingSupported ( ) : boolean Verifies if current MySQL server supports profiling
requestString ( mixed $value ) : string Converts given (request) paramter to string
showDocLink ( string $link, string $target = 'documentation', boolean $bbcode = false ) : string Displays a link to the documentation as an icon
showDocu ( string $page, string $anchor = '', boolean $bbcode = false ) : string Displays a link to the phpMyAdmin documentation
showHint ( string $message ) : string Returns HTML code for a tooltip
showIcons ( string $value ) : boolean Checks whether configuration value tells to show icons.
showMySQLDocu ( string $link, boolean $big_icon = false, string $anchor = '', boolean $just_open = false ) : string Displays a link to the official MySQL documentation
showPHPDocu ( string $target ) : string Displays a link to the PHP documentation
showText ( string $value ) : boolean Checks whether configuration value tells to show text.
splitURLQuery ( string $url ) : array Splits a URL string by parameter
timespanFormat ( integer $seconds ) : string Returns a given timespan value in a readable format.
toggleButton ( string $action, string $select_name, array $options, string $callback ) : string Creates an AJAX sliding toggle button (or and equivalent form when AJAX is disabled)
unQuote ( string $quoted_string, string $quote = null ) : string removes quotes (',",`) from a quoted string
unescapeMysqlWildcards ( string $name ) : string removes slashes before "_" and "%" characters Note: This function does not unescape backslashes!
unsupportedDatatypes ( ) : array Returns a list of datatypes that are not (yet) handled by PMA.
userDir ( string $dir ) : string replaces %u in given path with current user name
whichCrlf ( ) : string Defines the value depending on the user OS.

Private Methods

Method Description
_checkRowCount ( string $db, array $table ) : integer Check the correct row count
_generateRowQueryOutput ( string $sqlQuery ) : string Execute an EXPLAIN query and formats results similar to MySQL command line utility.

Method Details

addMicroseconds() public static method

If the string contains fractional seconds, pads it with 0s up to 6 decimal places.
public static addMicroseconds ( string $value ) : string
$value string time, datetime or timestamp strings
return string time, datetime or timestamp strings with fractional seconds

asWKT() public static method

Converts GIS data to Well Known Text format
public static asWKT ( string $data, boolean $includeSRID = false ) : string
$data string GIS data
$includeSRID boolean Add SRID to the WKT
return string GIS data in Well Know Text format

backquote() public static method

and escapes backquotes inside the name with another backquote example: echo backquote('owners db'); // owners db
public static backquote ( mixed $a_name, boolean $do_it = true ) : mixed
$a_name mixed the database, table or field name to "backquote" or array of it
$do_it boolean a flag to bypass this function (used by dump functions)
return mixed the "backquoted" database, table or field name

backquoteCompat() public static method

in compatibility mode example: echo backquoteCompat('owners db'); // owners db
public static backquoteCompat ( mixed $a_name, string $compatibility = 'MSSQL', boolean $do_it = true ) : mixed
$a_name mixed the database, table or field name to "backquote" or array of it
$compatibility string string compatibility mode (used by dump functions)
$do_it boolean a flag to bypass this function (used by dump functions)
return mixed the "backquoted" database, table or field name

buildActionTitles() public static method

Build titles and icons for action links
public static buildActionTitles ( ) : array
return array the action titles

cacheExists() public static method

Verifies if something is cached in the session
public static cacheExists ( string $var ) : boolean
$var string variable name
return boolean

cacheGet() public static method

Gets cached information from the session
public static cacheGet ( string $var, Closure $callback = null ) : mixed
$var string variable name
$callback Closure callback to fetch the value
return mixed

cacheSet() public static method

Caches information in the session
public static cacheSet ( string $var, mixed $val = null ) : mixed
$var string variable name
$val mixed value
return mixed

cacheUnset() public static method

Removes cached information from the session
public static cacheUnset ( string $var ) : void
$var string variable name
return void

checkParameters() public static method

Called by each script that needs parameters, it displays an error message and, by default, stops the execution. Not sure we could use a strMissingParameter message here, would have to check if the error message file is always available
public static checkParameters ( string[] $params, boolean $request = true ) : void
$params string[] The names of the parameters needed by the calling script
$request boolean Whether to include this list in checking for special params
return void

clearUserCache() public static method

Clears cache content which needs to be refreshed on user change.
public static clearUserCache ( ) : void
return void

configureCurl() public static method

Updates an existing curl as necessary
public static configureCurl ( resource $curl_handle ) : resource
$curl_handle resource A curl_handle resource created by curl_init which should have several options set
return resource curl_handle with updated options

containsNonPrintableAscii() public static method

Verifies whether the value contains a non-printable character
public static containsNonPrintableAscii ( string $value ) : integer
$value string value
return integer

convertBitDefaultValue() public static method

Converts a BIT type default value for example, b'010' becomes 010
public static convertBitDefaultValue ( string $bit_default_value ) : string
$bit_default_value string value
return string the converted value

createGISData() public static method

Generates GIS data based on the string passed.
public static createGISData ( string $gis_string ) : string
$gis_string string GIS string
return string GIS data enclosed in 'GeomFromText' function

currentUserHasPrivilege() public static method

Example: currentUserHasPrivilege('CREATE ROUTINE', 'mydb'); Checks if the currently logged in user has the global 'CREATE ROUTINE' privilege or, if not, checks if the user has this privilege on database 'mydb'.
public static currentUserHasPrivilege ( string $priv, mixed $db = null, mixed $tbl = null ) : boolean
$priv string The privilege to check
$db mixed null, to only check global privileges string, db name where to also check for privileges
$tbl mixed null, to only check global/db privileges string, table name where to also check for privileges
return boolean

duplicateFirstNewline() public static method

If the string starts with a \r\n pair (0x0d0a) add an extra \n
public static duplicateFirstNewline ( string $string ) : string
$string string string
return string with the chars replaced

escapeMysqlWildcards() public static method

Note: This function does not escape backslashes!
public static escapeMysqlWildcards ( string $name ) : string
$name string the string to escape
return string the escaped string

expandUserString() public static method

Formats user string, expanding @VARIABLES@, accepting strftime format string.
public static expandUserString ( string $string, array | string $escape = null, array $updates = [] ) : string
$string string Text where to do expansion.
$escape array | string Function to call for escaping variable values. Can also be an array of: - the escape method name - the class that contains the method - location of the class (for inclusion)
$updates array Array with overrides for default parameters (obtained from GLOBALS).
return string

extractColumnSpec() public static method

Extracts the various parts from a column spec
public static extractColumnSpec ( string $columnspec ) : array
$columnspec string Column specification
return array associative array containing type, spec_in_brackets and possibly enum_set_values (another array)

extractValueFromFormattedSize() public static method

Returns the number of bytes when a formatted size is given
public static extractValueFromFormattedSize ( string $formatted_size ) : integer
$formatted_size string the size expression (for example 8MB)
return integer The numerical part of the expression (for example 8)

formatByteDown() public static method

Formats $value to byte view
public static formatByteDown ( double | integer $value, integer $limes = 6, integer $comma ) : array
$value double | integer the value to format
$limes integer the sensitiveness
$comma integer the number of decimals to retain
return array the formatted value and its unit

formatNumber() public static method

examples: echo formatNumber(123456789, 6); // 123,457 k echo formatNumber(-123456789, 4, 2); // -123.46 M echo formatNumber(-0.003, 6); // -3 m echo formatNumber(0.003, 3, 3); // 0.003 echo formatNumber(0.00003, 3, 2); // 0.03 m echo formatNumber(0, 6); // 0
public static formatNumber ( double $value, integer $digits_left = 3, integer $digits_right, boolean $only_down = false, boolean $noTrailingZero = true ) : string
$value double the value to format
$digits_left integer number of digits left of the comma
$digits_right integer number of digits right of the comma
$only_down boolean do not reformat numbers below 1
$noTrailingZero boolean removes trailing zeros right of the comma (default: true)
return string the formatted value and its unit

formatSql() public static method

format sql strings
public static formatSql ( string $sqlQuery, boolean $truncate = false ) : string
$sqlQuery string raw SQL string
$truncate boolean truncate the query if it is too long
return string the formatted sql

generateHiddenMaxFileSize() public static method

Generates a hidden field which should indicate to the browser the maximum size for upload
public static generateHiddenMaxFileSize ( integer $max_size ) : string
$max_size integer the size
return string the INPUT field

getBrowseUploadFileBlock() public static method

Prepare the form used to browse anywhere on the local server for a file to import
public static getBrowseUploadFileBlock ( string $max_upload_size ) : String
$max_upload_size string maximum upload size
return String

getButton() public static method

Prepare HTML code for display button.
public static getButton ( ) : String
return String

getButtonOrImage() public static method

Generate a button or image tag
public static getButtonOrImage ( string $button_name, string $button_class, string $text, string $image, string $value = '' ) : string
$button_name string name of button element
$button_class string class of button or image element
$text string text to display
$image string image to display
$value string value
return string html content

getCharsetQueryPart() static public method

Generate the charset query part
static public getCharsetQueryPart ( string $collation, $override = false ) : string
$collation string Collation
return string

getClassForType() public static method

Returns the proper class clause according to the column type
public static getClassForType ( string $type ) : string
$type string the column type
return string $class_clause the HTML class clause

getCollateForIS() public static method

Provide COLLATE clause, if required, to perform case sensitive comparisons for queries on information_schema.
public static getCollateForIS ( ) : string
return string COLLATE clause if needed or empty string.

getCompressionMimeType() public static method

Reads the file, detects the compression MIME type, closes the file and returns the MIME type
public static getCompressionMimeType ( resource $file ) : string
$file resource the file handle
return string the MIME type for compression, or 'none'

getDbInfo() public static method

Gets the list of tables in the current db and information about these tables if possible
public static getDbInfo ( string $db, string $sub_part ) : array
$db string database name
$sub_part string part of script name
return array

getDefaultFunctionForField() public static method

Returns default function for a particular column.
public static getDefaultFunctionForField ( array $field, boolean $insert_mode ) : string
$field array Data about the column for which to generate the dropdown
$insert_mode boolean Whether the operation is 'insert'
return string An HTML snippet of a dropdown list with function names appropriate for the requested column.

getDivForSliderEffect() public static method

Generates a slider effect (jQjuery) Takes care of generating the initial
and the link controlling the slider; you have to generate the
yourself after the sliding section.
public static getDivForSliderEffect ( string $id = '', string $message = '' ) : string
$id string the id of the
on which to apply the effect
$message string the message to show as a link
return string html div element

getDropdown() public static method

Generates and returns an HTML dropdown
public static getDropdown ( string $select_name, array $choices, string $active_choice, string $id, string $class = '', string $placeholder = null ) : string
$select_name string name for the select element
$choices array choices values
$active_choice string the choice to select by default
$id string id of the select element; can be different in case the dropdown is present more than once on the page
$class string class for the select element
$placeholder string Placeholder for dropdown if nothing else is selected
return string html content

getExternalBug() public static method

Prepare a lightbulb hint explaining a known external bug that affects a functionality
public static getExternalBug ( string $functionality, string $component, string $minimum_version, string $bugref ) : String
$functionality string localized message explaining the func.
$component string 'mysql' (eventually, 'php')
$minimum_version string of this component
$bugref string bug reference for this component
return String

getFKCheckbox() public static method

Get HTML for Foreign key check checkbox
public static getFKCheckbox ( ) : string
return string HTML for checkbox

getFirstOccurringRegularExpression() public static method

Get regular expression which occur first inside the given sql query.
public static getFirstOccurringRegularExpression ( array $regex_array, String $query ) : String
$regex_array array Comparing regular expressions.
$query String SQL query to be checked.
return String Matching regular expression.

getFormattedMaximumUploadSize() public static method

Returns the formatted maximum size for an upload
public static getFormattedMaximumUploadSize ( integer $max_upload_size ) : string
$max_upload_size integer the size
return string the message

getFunctionsForField() public static method

Creates a dropdown box with MySQL functions for a particular column.
public static getFunctionsForField ( array $field, boolean $insert_mode, $foreignData ) : string
$field array Data about the column for which to generate the dropdown
$insert_mode boolean Whether the operation is 'insert'
return string An HTML snippet of a dropdown list with function names appropriate for the requested column.

getGISDatatypes() public static method

Return GIS data types
public static getGISDatatypes ( boolean $upper_case = false ) : string[]
$upper_case boolean whether to return values in upper case
return string[] GIS data types

getGISFunctions() public static method

Returns the names and details of the functions that can be applied on geometry data types.
public static getGISFunctions ( string $geom_type = null, boolean $binary = true, boolean $display = false ) : array
$geom_type string if provided the output is limited to the functions that are applicable to the provided geometry type.
$binary boolean if set to false functions that take two geometries as arguments will not be included.
$display boolean if set to true separators will be added to the output array.
return array names and details of the functions that can be applied on geometry data types.

getHtmlTab() public static method

If the variables $link and $args ar left empty, an inactive tab is created
public static getHtmlTab ( array $tab, array $url_params = [] ) : string
$tab array array with all options
$url_params array tab specific URL parameters
return string html code for one tab, a link if valid otherwise a span

getHtmlTabs() public static method

returns html-code for a tab navigation
public static getHtmlTabs ( array $tabs, array $url_params, string $menu_id, boolean $resizable = false ) : string
$tabs array one element per tab
$url_params array additional URL parameters
$menu_id string HTML id attribute for the menu container
$resizable boolean whether to add a "resizable" class
return string html-code for tab-navigation

getIcon() public static method

This function takes into account the ActionLinksMode configuration setting and wraps the image tag in a span tag.
public static getIcon ( string $icon, string $alternate = '', boolean $force_text = false, boolean $menu_icon = false, string $control_param = 'ActionLinksMode' ) : string
$icon string name of icon file
$alternate string alternate text
$force_text boolean whether to force alternate text to be displayed
$menu_icon boolean whether this icon is for the menu bar or not
$control_param string which directive controls the display
return string an html snippet

getImage() public static method

Returns an HTML IMG tag for a particular image from a theme, which may be an actual file or an icon from a sprite
public static getImage ( string $image, string $alternate = '', array $attributes = [] ) : string
$image string The name of the file to get
$alternate string Used to set 'alt' and 'title' attributes of the image
$attributes array An associative array of other attributes
return string an html IMG tag

getListNavigator() public static method

Prepare navigation for a list
public static getListNavigator ( integer $count, integer $pos, array $_url_params, string $script, string $frame, integer $max_count, string $name = 'pos', string[] $classes = [] ) : string
$count integer number of elements in the list
$pos integer current position in the list
$_url_params array url parameters
$script string script name for form target
$frame string target frame
$max_count integer maximum number of elements to display from the list
$name string the name for the request parameter
$classes string[] additional classes for the container
return string $list_navigator_html the html content

getMenuTabList() public static method

Return the list of tabs for the menu with corresponding names
public static getMenuTabList ( string $level = null ) : array
$level string 'server', 'db' or 'table' level
return array list of tabs for the menu

getMessage() public static method

Prepare the message and the query usually the message is the result of the query executed
public static getMessage ( Message | string $message, string $sql_query = null, string $type = 'notice' ) : string
$message Message | string the message to display
$sql_query string the query to display
$type string the type (level) of the message
return string

getMySQLDocuURL() public static method

Get a URL link to the official MySQL documentation
public static getMySQLDocuURL ( string $link, string $anchor = '' ) : string
$link string contains name of page/anchor that is being linked
$anchor string anchor to page part
return string the URL link

getRadioFields() public static method

Generates a set of radio HTML fields
public static getRadioFields ( string $html_field_name, array $choices, string $checked_choice = '', boolean $line_break = true, boolean $escape_label = true, string $class = '', string $id_prefix = '' ) : string
$html_field_name string the radio HTML field
$choices array the choices values and labels
$checked_choice string the choice to check by default
$line_break boolean whether to add HTML line break after a choice
$escape_label boolean whether to use htmlspecialchars() on label
$class string enclose each choice with a div of this class
$id_prefix string prefix for the id attribute, name will be used if this is not supplied
return string set of html radio fiels

getScriptNameForOption() public static method

Get the script name corresponding to a plain English config word in order to append in links on navigation and main panel
public static getScriptNameForOption ( string $target, string $location ) : string
$target string a valid value for $cfg['NavigationTreeDefaultTabTable'], $cfg['NavigationTreeDefaultTabTable2'], $cfg['DefaultTabTable'], $cfg['DefaultTabDatabase'] or $cfg['DefaultTabServer']
$location string one out of 'server', 'table', 'database'
return string script name corresponding to the config word

getSelectUploadFileBlock() public static method

Prepare the form used to select a file to import from the server upload directory
public static getSelectUploadFileBlock ( ImportPlugin[] $import_list, string $uploaddir ) : String
$import_list PMA\libraries\plugins\ImportPlugin[] array of import plugins
$uploaddir string upload directory
return String

getServerType() public static method

Known types are: MariaDB and MySQL (default)
public static getServerType ( ) : string
return string

getStartAndNumberOfRowsPanel() public static method

Function to get html for the start row and number of rows panel
public static getStartAndNumberOfRowsPanel ( string $sql_query ) : string
$sql_query string sql query
return string html

getSupportedDatatypes() public static method

This function processes the datatypes supported by the DB, as specified in Types->getColumns() and either returns an array (useful for quickly checking if a datatype is supported) or an HTML snippet that creates a drop-down list.
public static getSupportedDatatypes ( boolean $html = false, string $selected = '' ) : mixed
$html boolean Whether to generate an html snippet or an array
$selected string The value to mark as selected in HTML mode
return mixed An HTML snippet or an array of datatypes.

getTableList() public static method

returns array with tables of given db with extended information and grouped
public static getTableList ( string $db, string $tables = null, integer $limit_offset, integer | boolean $limit_count = false ) : array
$db string name of db
$tables string name of tables
$limit_offset integer list offset
$limit_count integer | boolean max tables to return
return array (recursive) grouped table list

getTablesWhenOpen() public static method

Gets the list of tables in the current db, taking into account that they might be "in use"
public static getTablesWhenOpen ( string $db, object $db_info_result ) : array
$db string database name
$db_info_result object result set
return array $tables list of tables

getTitleForTarget() public static method

Get the action word corresponding to a script name in order to display it as a title in navigation panel
public static getTitleForTarget ( string $target ) : string
$target string a valid value for $cfg['NavigationTreeDefaultTabTable'], $cfg['NavigationTreeDefaultTabTable2'], $cfg['DefaultTabTable'] or $cfg['DefaultTabDatabase']
return string Title for the $cfg value

getUniqueCondition() public static method

Function to generate unique condition for specified row.
public static getUniqueCondition ( resource $handle, integer $fields_cnt, array $fields_meta, array $row, boolean $force_unique = false, string | boolean $restrict_to_table = false, array $analyzed_sql_results = null ) : array
$handle resource current query result
$fields_cnt integer number of fields
$fields_meta array meta information about fields
$row array current row
$force_unique boolean generate condition only on pk or unique
$restrict_to_table string | boolean restrict the unique condition to this table or false if none
$analyzed_sql_results array the analyzed query
return array the calculated condition and whether condition is unique

handleContext() public static method

Returns information with regards to handling the http request
public static handleContext ( array $context ) : array
$context array Data about the context for which to http request is sent
return array of updated context information

handleDisableFKCheckCleanup() public static method

Cleanup changes done for foreign key check
public static handleDisableFKCheckCleanup ( boolean $default_fk_check_value ) : void
$default_fk_check_value boolean original value for 'FOREIGN_KEY_CHECKS'
return void

handleDisableFKCheckInit() public static method

Handle foreign key check request
public static handleDisableFKCheckInit ( ) : boolean
return boolean Default foreign key checks value

httpRequest() public static method

Creates HTTP request
public static httpRequest ( string $url, string $method, boolean $return_only_status = false, mixed $content = null, string $header = "" ) : mixed
$url string Url to send the request
$method string HTTP request method (GET, POST, PUT, DELETE, etc)
$return_only_status boolean If set to true, the method would only return response status
$content mixed Content to be sent with HTTP request
$header string Header to be set for the HTTP request
return mixed

httpRequestCurl() public static method

Creates HTTP request using curl
public static httpRequestCurl ( string $url, string $method, boolean $return_only_status = false, mixed $content = null, string $header = "" ) : mixed
$url string Url to send the request
$method string HTTP request method (GET, POST, PUT, DELETE, etc)
$return_only_status boolean If set to true, the method would only return response status
$content mixed Content to be sent with HTTP request
$header string Header to be set for the HTTP request
return mixed

httpRequestFopen() public static method

Creates HTTP request using file_get_contents
public static httpRequestFopen ( string $url, string $method, boolean $return_only_status = false, mixed $content = null, string $header = "" ) : mixed
$url string Url to send the request
$method string HTTP request method (GET, POST, PUT, DELETE, etc)
$return_only_status boolean If set to true, the method would only return response status
$content mixed Content to be sent with HTTP request
$header string Header to be set for the HTTP request
return mixed

httpRequestReturn() public static method

Creates HTTP request using curl
public static httpRequestReturn ( mixed $response, interger $http_status, boolean $return_only_status ) : mixed
$response mixed HTTP response
$http_status interger HTTP response status code
$return_only_status boolean If set to true, the method would only return response status
return mixed

isForeignKeyCheck() public static method

Is Foreign key check enabled?
public static isForeignKeyCheck ( ) : boolean
return boolean

isForeignKeySupported() public static method

Verifies if this table's engine supports foreign keys
public static isForeignKeySupported ( string $engine ) : boolean
$engine string engine
return boolean

isVirtualColumnsSupported() public static method

Returns whether the database server supports virtual columns
public static isVirtualColumnsSupported ( ) : boolean
return boolean

linkOrButton() public static method

Displays a link, or a button if the link's URL is too large, to accommodate some browsers' limitations
public static linkOrButton ( string $url, string $message, mixed $tag_params = [], boolean $new_form = true, boolean $strip_img = false, string $target = '', boolean $force_button = false ) : string
$url string the URL
$message string the link message
$tag_params mixed string: js confirmation array: additional tag params (f.e. style="")
$new_form boolean we set this to false when we are already in a form, to avoid generating nested forms
$strip_img boolean whether to strip the image
$target string target
$force_button boolean use a button even when the URL is not too long
return string the results to be echoed or saved in an array

listPHPExtensions() public static method

Returs list of used PHP extensions.
public static listPHPExtensions ( ) : array
return array of strings

localisedDate() public static method

Writes localised date
public static localisedDate ( integer $timestamp, string $format = '' ) : string
$timestamp integer the current timestamp
$format string format
return string the formatted date

mysqlDie() public static method

Returns the error message otherwise.
public static mysqlDie ( string | boolean $server_msg = '', string $sql_query = '', boolean $is_modify_link = true, string $back_url = '', boolean $exit = true ) : string
$server_msg string | boolean Server's error message.
$sql_query string The SQL query that failed.
$is_modify_link boolean Whether to show a "modify" link or not.
$back_url string URL for the "back" link (full path is not required).
$exit boolean Whether execution should be stopped or the error message should be returned.
return string

pageselector() public static method

Generate a pagination selector for browsing resultsets
public static pageselector ( string $name, integer $rows, integer $pageNow = 1, integer $nbTotalPage = 1, integer $showAll = 200, integer $sliceStart = 5, integer $sliceEnd = 5, integer $percent = 20, integer $range = 10, string $prompt = '' ) : string
$name string The name for the request parameter
$rows integer Number of rows in the pagination set
$pageNow integer current page number
$nbTotalPage integer number of total pages
$showAll integer If the number of pages is lower than this variable, no pages will be omitted in pagination
$sliceStart integer How many rows at the beginning should always be shown?
$sliceEnd integer How many rows at the end should always be shown?
$percent integer Percentage of calculation page offsets to hop to a next page
$range integer Near the current page, how many pages should be considered "nearby" and displayed as well?
$prompt string The prompt to display (sometimes empty)
return string

parseEnumSetValues() public static method

Parses ENUM/SET values
public static parseEnumSetValues ( string $definition, boolean $escapeHtml = true ) : array
$definition string The definition of the column for which to parse the values
$escapeHtml boolean Whether to escape html entities
return array

printableBitValue() public static method

Converts a bit value to printable format; in MySQL a BIT field can be from 1 to 64 bits so we need this function because in PHP, decbin() supports only 32 bits on 32-bit servers
public static printableBitValue ( integer $value, integer $length ) : string
$value integer coming from a BIT field
$length integer length
return string the printable value

processIndexData() public static method

Process the index data.
public static processIndexData ( array $indexes ) : array
$indexes array index data
return array processes index data

profilingSupported() public static method

Verifies if current MySQL server supports profiling
public static profilingSupported ( ) : boolean
return boolean whether profiling is supported

requestString() public static method

Converts given (request) paramter to string
public static requestString ( mixed $value ) : string
$value mixed Value to convert
return string

showDocu() public static method

Displays a link to the phpMyAdmin documentation
public static showDocu ( string $page, string $anchor = '', boolean $bbcode = false ) : string
$page string Page in documentation
$anchor string Optional anchor in page
$bbcode boolean Optional flag indicating whether to output bbcode
return string the html link

showHint() public static method

Returns HTML code for a tooltip
public static showHint ( string $message ) : string
$message string the message for the tooltip
return string

showIcons() public static method

Checks whether configuration value tells to show icons.
public static showIcons ( string $value ) : boolean
$value string Configuration option name
return boolean Whether to show icons.

showMySQLDocu() public static method

Displays a link to the official MySQL documentation
public static showMySQLDocu ( string $link, boolean $big_icon = false, string $anchor = '', boolean $just_open = false ) : string
$link string contains name of page/anchor that is being linked
$big_icon boolean whether to use big icon (like in left frame)
$anchor string anchor to page part
$just_open boolean whether only the opening tag should be returned
return string the html link

showPHPDocu() public static method

Displays a link to the PHP documentation
public static showPHPDocu ( string $target ) : string
$target string anchor in documentation
return string the html link

showText() public static method

Checks whether configuration value tells to show text.
public static showText ( string $value ) : boolean
$value string Configuration option name
return boolean Whether to show text.

splitURLQuery() public static method

Splits a URL string by parameter
public static splitURLQuery ( string $url ) : array
$url string the URL
return array the parameter/value pairs, for example [0] db=sakila

timespanFormat() public static method

Returns a given timespan value in a readable format.
public static timespanFormat ( integer $seconds ) : string
$seconds integer the timespan
return string the formatted value

toggleButton() public static method

Creates an AJAX sliding toggle button (or and equivalent form when AJAX is disabled)
public static toggleButton ( string $action, string $select_name, array $options, string $callback ) : string
$action string The URL for the request to be executed
$select_name string The name for the dropdown box
$options array An array of options (see rte_footer.lib.php)
$callback string A JS snippet to execute when the request is successfully processed
return string HTML code for the toggle button

unQuote() public static method

checks if the string is quoted and removes this quotes
public static unQuote ( string $quoted_string, string $quote = null ) : string
$quoted_string string string to remove quotes from
$quote string type of quote to remove
return string unqoted string

unescapeMysqlWildcards() public static method

removes slashes before "_" and "%" characters Note: This function does not unescape backslashes!
public static unescapeMysqlWildcards ( string $name ) : string
$name string the string to escape
return string the escaped string

unsupportedDatatypes() public static method

Used by: tbl_change.php and libraries/db_routines.inc.php
public static unsupportedDatatypes ( ) : array
return array list of datatypes

userDir() public static method

example: $user_dir = userDir('/var/pma_tmp/%u/'); // '/var/pma_tmp/root/'
public static userDir ( string $dir ) : string
$dir string with wildcard for user
return string per user directory

whichCrlf() public static method

Defines the value depending on the user OS.
public static whichCrlf ( ) : string
return string the value to use