GitHub

Admin interface

Public methods that can be overridden while extending \AdminNeo\Admin class. How to extend Admin class.

HTTP headers
Admin::sendHeaders Sends additional HTTP headers.
Admin::updateCspHeader Updates the list of directives for Content-Security-Policy HTTP header.
Security
Admin::authenticate Authenticates the user.
Admin::verifyDefaultPassword Verifies given password if database itself does not require any password.
Admin::getCredentials Returns connection parameters.
Admin::getPrivateKey Returns a private key used for permanent login.
Admin::getBruteForceKey Returns key used to group brute force attacks.
HTML head
Admin::printFavicons Prints HTML links to favicons.
Admin::printToHead Prints additional HTML code at the end of the <head>.
Admin::getCssUrls Returns configured URLs of the CSS files together with autoloaded adminneo.css if exists.
Admin::isLightModeForced Returns whether light mode is forced.
Admin::isDarkModeForced Returns whether dark mode is forced.
Admin::getJsUrls Returns configured URLs of the JS files together with autoloaded adminneo.js if exists.
Database
Admin::getDatabase Returns the name of selected database.
Admin::getDatabases Returns cached list of databases.
Admin::getSchemas Returns the list of schemas.
Admin::getCollations Returns the list of collations.
Admin::getQueryTimeout Specifies the limit for waiting on some slow queries like DB list.
Admin::getForeignKeys Returns foreign keys for table.
Admin::getBackwardKeys Returns backward keys for given table.
User interface
Admin::getServiceTitle Returns HTML code for the service title.
Admin::printLoginForm Prints login form.
Admin::getLoginFormRow Returns composed row for login form field.
Admin::printLogout Prints username and logout button.
Admin::getServerName Returns server name displayed in breadcrumbs. Can be empty string.
Admin::getTableName Returns table name used in navigation and headings.
Admin::getFieldName Returns field name used in select and edit.
Admin::formatComment Returns formatted comment.
Admin::printNavigation Prints the main navigation.
Admin::printDatabaseSwitcher Prints databases selection in main navigation.
Admin::printDatabaseMenu Prints top menu on database page.
Admin::printTablesFilter Prints input field for filtering table list.
Admin::printTableList Prints table list in main navigation.
Admin::printTableMenu Prints top menu on table selection and structure page.
Admin::printAfterSqlCommand Prints HTML code just before the Execute button in SQL command.
Admin::printBackwardKeys Prints backward keys for given row.
Admin::formatSelectQuery Returns formatted query that will be printed in "Select data" page before its execution.
Admin::formatMessageQuery Returns formatted query that will be printed in message after its execution.
Admin::formatSqlCommandQuery Returns formatted query that will be printed in "SQL command" page before its execution.
Admin::getTableDescriptionFieldName Returns field name that will be used for getting a foreign key description.
Admin::fillForeignDescriptions Fills descriptions of the foreign keys for the whole selection data.
Admin::getFieldValueLink Returns a link to use in select table.
Admin::formatSelectionValue Formats field value for select table.
Admin::formatFieldValue Formats field value for select table and edit form.
Admin::printTableStructure Prints table structure in tabular format.
Admin::printTablePartitions Prints the definition of table partitioning.
Admin::printTableIndexes Prints the list of table indexes.
Admin::printSelectionColumns Prints columns box in selection filter.
Admin::printSelectionSearch Prints search box in selection filter.
Admin::printSelectionOrder Prints order box in selection filter.
Admin::printSelectionLimit Prints limit box in selection filter.
Admin::printSelectionLength Prints text length box in selection filter.
Admin::printSelectionAction Prints action box in selection filter.
Admin::processSelectionColumns Processes columns box in selection filter.
Admin::processSelectionSearch Processes search box in selection filter.
Admin::processSelectionOrder Processes order box in selection filter.
Admin::processSelectionLimit Processed limit box in select.
Admin::processSelectionLength Processes length box in selection filter.
Admin::getSettingsRows Returns rows for settings table organised in groups.
Editing
Admin::getFieldFunctions Return the list of functions displayed in edit form.
Admin::getFieldInput Customize input field.
Admin::getFieldInputHint Returns hint for edit field.
Admin::processFieldInput Processes sent input.
Admin::detectJson Detect JSON field or value and optionally reformat the value.
Admin::getImportFilePath Returns the path of the file for webserver import.
Database dump
Admin::getDumpOutputs Returns export output options.
Admin::getDumpFormats Returns export format options.
Admin::sendDumpHeaders Sends headers for export.
Admin::dumpDatabase Exports database structure.
Admin::dumpTable Exports table structure.
Admin::dumpData Exports table data.
Miscellaneous
Admin::init Initializes the Admin.
Admin::addError Appends error message to the list of messages.
Admin::getErrors Returns the array of HTML-formatted error messages.

Methods secification

Admin::sendHeaders

Sends additional HTTP headers.

public function sendHeaders()

Source code (PHP 7.1+)

Admin::updateCspHeader

Updates the list of directives for Content-Security-Policy HTTP header.

public function updateCspHeader(array &$csp)
Params: string[] $csp [directive name => allowed sources].

Source code (PHP 7.1+)

Admin::authenticate

Authenticates the user.

public function authenticate($username, $password)
Params: string $username
string $password
Returns: bool|string True for success, HTML-formatted error message or false for unknown error.

Source code (PHP 7.1+)

Admin::verifyDefaultPassword

Verifies given password if database itself does not require any password.

public function verifyDefaultPassword($password)
Params: string $password
Returns: true|string True for success, plain text string for error message.

Source code (PHP 7.1+)

Admin::getCredentials

Returns connection parameters.

public function getCredentials()
Returns: string[] array($server, $username, $password)

Source code (PHP 7.1+)

Admin::getPrivateKey

Returns a private key used for permanent login.

public function getPrivateKey($create = false)
Params: bool $create
Returns: string|false Cryptic string which gets combined with password or false in case of an error.

Source code (PHP 7.1+)

Admin::getBruteForceKey

Returns key used to group brute force attacks.

Behind a reverse proxy, you want to return the last part of X-Forwarded-For.

public function getBruteForceKey()
Returns: string

Source code (PHP 7.1+)

Admin::printFavicons

Prints HTML links to favicons.

public function printFavicons()

Source code (PHP 7.1+)

Admin::printToHead

Prints additional HTML code at the end of the <head>.

public function printToHead()

Source code (PHP 7.1+)

Admin::getCssUrls

Returns configured URLs of the CSS files together with autoloaded adminneo.css if exists.

public function getCssUrls()
Returns: string[]

Source code (PHP 7.1+)

Admin::isLightModeForced

Returns whether light mode is forced.

public function isLightModeForced()
Returns: bool

Source code (PHP 7.1+)

Admin::isDarkModeForced

Returns whether dark mode is forced.

public function isDarkModeForced()
Returns: bool

Source code (PHP 7.1+)

Admin::getJsUrls

Returns configured URLs of the JS files together with autoloaded adminneo.js if exists.

public function getJsUrls()
Returns: string[]

Source code (PHP 7.1+)

Admin::getDatabase

Returns the name of selected database.

public function getDatabase()
Returns: string

Source code (PHP 7.1+)

Admin::getDatabases

Returns cached list of databases.

public function getDatabases($flush = true)
Params: $flush
Returns: string[]

Source code (PHP 7.1+)

Admin::getSchemas

Returns the list of schemas.

public function getSchemas()
Returns: string[]

Source code (PHP 7.1+)

Admin::getCollations

Returns the list of collations.

public function getCollations(array $keepValues = [])
Params: string[] $keepValues List of collations that can not be removed by filtering.
Returns: string[][]

Source code (PHP 7.1+)

Admin::getQueryTimeout

Specifies the limit for waiting on some slow queries like DB list.

public function getQueryTimeout()
Returns: int Number of seconds.

Source code (PHP 7.1+)

Admin::getForeignKeys

Returns foreign keys for table.

public function getForeignKeys($table)
Params: string $table
Returns: array

Source code (PHP 7.1+)

Admin::getBackwardKeys

Returns backward keys for given table.

public function getBackwardKeys($table, $tableName)
Params: string $table
string $tableName
Returns: array $return[$id]["table"] = $target_table; $return[$id]["constraints"][$key_name][$target_column] = $source_column; $return[$target_table]["name"] = $this->admin->getTableName($target_table);

Source code (PHP 7.1+)

Admin::getServiceTitle

Returns HTML code for the service title.

public function getServiceTitle()
Returns: string

Source code (PHP 7.1+)

Admin::printLoginForm

Prints login form.

public function printLoginForm()

Source code (PHP 7.1+)

Admin::getLoginFormRow

Returns composed row for login form field.

public function getLoginFormRow($fieldName, $label, $field)
Params: string $fieldName
string $label
string $field
Returns: string

Source code (PHP 7.1+)

Admin::printLogout

Prints username and logout button.

public function printLogout()

Source code (PHP 7.1+)

Admin::getServerName

Returns server name displayed in breadcrumbs. Can be empty string.

public function getServerName($server)
Params: string $server
Returns: string

Source code (PHP 7.1+)

Admin::getTableName

Returns table name used in navigation and headings.

public function getTableName(array $tableStatus)
Params: array $tableStatus The result of SHOW TABLE STATUS.
Returns: string HTML code, "" to ignore table

Source code (PHP 7.1+)

Admin::getFieldName

Returns field name used in select and edit.

public function getFieldName(array $field, $order = 0)
Params: array $field Single field returned from fields().
int $order Order of column in select.
Returns: string HTML code, "" to ignore field.

Source code (PHP 7.1+)

Admin::formatComment

Returns formatted comment.

public function formatComment($comment)
Params: ?string $comment
Returns: string HTML to be printed.

Source code (PHP 7.1+)

Admin::printNavigation

Prints the main navigation.

public function printNavigation($missing)
Params: ?string $missing Can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema.

Source code (PHP 7.1+)

Admin::printDatabaseSwitcher

Prints databases selection in main navigation.

public function printDatabaseSwitcher($missing)
Params: ?string $missing

Source code (PHP 7.1+)

Admin::printDatabaseMenu

Prints top menu on database page.

public function printDatabaseMenu()

Source code (PHP 7.1+)

Admin::printTablesFilter

Prints input field for filtering table list.

public function printTablesFilter()

Source code (PHP 7.1+)

Admin::printTableList

Prints table list in main navigation.

public function printTableList(array $tables)
Params: array $tables Result of table_status('', true)

Source code (PHP 7.1+)

Admin::printTableMenu

Prints top menu on table selection and structure page.

public function printTableMenu(array $tableStatus, $set = "")
Params: array $tableStatus The result of SHOW TABLE STATUS.
?string $set New item options, null for no new item.

Source code (PHP 7.1+)

Admin::printAfterSqlCommand

Prints HTML code just before the Execute button in SQL command.

public function printAfterSqlCommand()

Source code (PHP 7.1+)

Admin::printBackwardKeys

Prints backward keys for given row.

public function printBackwardKeys(array $backwardKeys, array $row)
Params: array $backwardKeys The result of getBackwardKeys().
array $row

Source code (PHP 7.1+)

Admin::formatSelectQuery

Returns formatted query that will be printed in "Select data" page before its execution.

Query printed in select before execution.

public function formatSelectQuery($query, $start, $failed = false)
Params: string $query Query to be executed.
float $start Start time.
bool $failed Whether the execution failed.
Returns: string HTML to be printed.

Source code (PHP 7.1+)

Admin::formatMessageQuery

Returns formatted query that will be printed in message after its execution.

public function formatMessageQuery($query, $time, $failed = false)
Params: string $query Query to be executed.
string $time Formatted elapsed time.
bool $failed Whether the execution failed.
Returns: string HTML to be printed.

Source code (PHP 7.1+)

Admin::formatSqlCommandQuery

Returns formatted query that will be printed in "SQL command" page before its execution.

public function formatSqlCommandQuery($query)
Params: string $query Query to be executed.
Returns: string HTML to be printed.

Source code (PHP 7.1+)

Admin::getTableDescriptionFieldName

Returns field name that will be used for getting a foreign key description.

public function getTableDescriptionFieldName($table)
Params: string $table
Returns: string SQL expression, empty string for no description.

Source code (PHP 7.1+)

Admin::fillForeignDescriptions

Fills descriptions of the foreign keys for the whole selection data.

public function fillForeignDescriptions(array $rows, array $foreignKeys)
Params: array $rows All selection data to print.
array $foreignKeys
Returns: array Updated selection data.

Source code (PHP 7.1+)

Returns a link to use in select table.

public function getFieldValueLink($val, ?array $field)
Params: string|int|null $val Raw value of the field.
?array $field Single field returned from fields(). Null for aggregated field.
Returns: ?string

Source code (PHP 7.1+)

Admin::formatSelectionValue

Formats field value for select table.

public function formatSelectionValue($val, $link, ?array $field, $original)
Params: ?string $val HTML-escaped value to print.
?string $link Link to foreign key.
?array $field Single field returned from fields().
?string $original Original value before applying formatFieldValue() and escaping.
Returns: string

Source code (PHP 7.1+)

Admin::formatFieldValue

Formats field value for select table and edit form.

public function formatFieldValue($value, array $field)
Params: string|bool|null $value Field value.
array $field Single field returned from fields().
Returns: ?string

Source code (PHP 7.1+)

Admin::printTableStructure

Prints table structure in tabular format.

public function printTableStructure(array $fields)
Params: array $fields Data about individual fields.

Source code (PHP 7.1+)

Admin::printTablePartitions

Prints the definition of table partitioning.

public function printTablePartitions(array $partitionInfo)
Params: array $partitionInfo

Source code (PHP 7.1+)

Admin::printTableIndexes

Prints the list of table indexes.

public function printTableIndexes(array $indexes)
Params: array $indexes Data about all indexes on a table.

Source code (PHP 7.1+)

Admin::printSelectionColumns

Prints columns box in selection filter.

public function printSelectionColumns(array $select, array $columns)
Params: array $select The result of processSelectionColumns()[0].
array $columns Selectable columns.

Source code (PHP 7.1+)

Admin::printSelectionSearch

Prints search box in selection filter.

public function printSelectionSearch(array $where, array $columns, array $indexes)
Params: array $where The result of processSelectionSearch().
array $columns Selectable columns.
array $indexes

Source code (PHP 7.1+)

Admin::printSelectionOrder

Prints order box in selection filter.

public function printSelectionOrder(array $order, array $columns, array $indexes)
Params: array $order The result of processSelectionOrder().
array $columns Selectable columns.
array $indexes

Source code (PHP 7.1+)

Admin::printSelectionLimit

Prints limit box in selection filter.

public function printSelectionLimit($limit)
Params: ?int $limit

Source code (PHP 7.1+)

Admin::printSelectionLength

Prints text length box in selection filter.

public function printSelectionLength($textLength)
Params: ?string $textLength The result of processSelectionLength().

Source code (PHP 7.1+)

Admin::printSelectionAction

Prints action box in selection filter.

public function printSelectionAction(array $indexes)
Params: array $indexes

Source code (PHP 7.1+)

Admin::processSelectionColumns

Processes columns box in selection filter.

public function processSelectionColumns(array $columns, array $indexes)
Params: array $columns Selectable columns.
array $indexes
Returns: array [[select_expressions], [group_expressions]]

Source code (PHP 7.1+)

Admin::processSelectionSearch

Processes search box in selection filter.

public function processSelectionSearch(array $fields, array $indexes)
Params: array $fields
array $indexes
Returns: array Expressions to join by AND.

Source code (PHP 7.1+)

Admin::processSelectionOrder

Processes order box in selection filter.

public function processSelectionOrder(array $fields, array $indexes)
Params: array $fields
array $indexes
Returns: array Expressions to join by comma.

Source code (PHP 7.1+)

Admin::processSelectionLimit

Processed limit box in select.

public function processSelectionLimit()
Returns: ?int Expression to use in LIMIT, will be escaped.

Source code (PHP 7.1+)

Admin::processSelectionLength

Processes length box in selection filter.

public function processSelectionLength()
Returns: string Number of characters to shorten texts, will be escaped.

Source code (PHP 7.1+)

Admin::getSettingsRows

Returns rows for settings table organised in groups.

@param int $groupId: 1 - overall UI settings, 2 - UI elements settings, 3 - other settings.

public function getSettingsRows($groupId)
Params: int $groupId
Returns: string[]

Source code (PHP 7.1+)

Admin::getFieldFunctions

Return the list of functions displayed in edit form.

public function getFieldFunctions(array $field)
Params: array $field Single field returned from fields().
Returns: array

Source code (PHP 7.1+)

Admin::getFieldInput

Customize input field.

public function getFieldInput($table, array $field, $attrs, $value, $function)
Params: ?string $table Table name. Is null in stored procedure calling.
array $field Single field from fields().
string $attrs Attributes to use inside the tag.
string|bool|null $value Field value.
?string $function Value modification function.
Returns: string Custom input field or empty string for default.

Source code (PHP 7.1+)

Admin::getFieldInputHint

Returns hint for edit field.

public function getFieldInputHint($table, array $field, $value)
Params: ?string $table Table name. Is null in stored procedure calling.
array $field Single field from fields().
?string $value Field value.
Returns: string HTML code.

Source code (PHP 7.1+)

Admin::processFieldInput

Processes sent input.

public function processFieldInput(?array $field, $value, $function = "")
Params: ?array $field Single field from fields().
string $value
string $function
Returns: string Expression to use in a query.

Source code (PHP 7.1+)

Admin::detectJson

Detect JSON field or value and optionally reformat the value.

public function detectJson($fieldType, &$value, $pretty = null)
Params: string $fieldType
string|array $value
?bool $pretty True to pretty format, false to compact format, null to skip formatting.
Returns: bool Whether field or value are detected as JSON.

Source code (PHP 7.1+)

Admin::getImportFilePath

Returns the path of the file for webserver import.

public function getImportFilePath()
Returns: string Path of the sql import file. Empty to hide the import.

Source code (PHP 7.1+)

Admin::getDumpOutputs

Returns export output options.

public function getDumpOutputs()
Returns: string[]

Source code (PHP 7.1+)

Admin::getDumpFormats

Returns export format options.

public function getDumpFormats()
Returns: string[] Empty to disable export.

Source code (PHP 7.1+)

Admin::sendDumpHeaders

Sends headers for export.

public function sendDumpHeaders($identifier, $multiTable = false)
Params: string $identifier
bool $multiTable
Returns: string File extension.

Source code (PHP 7.1+)

Admin::dumpDatabase

Exports database structure.

public function dumpDatabase($database)
Params: string $database

Source code (PHP 7.1+)

Admin::dumpTable

Exports table structure.

public function dumpTable($table, $style, $viewType = 0)
Params: string $table
string $style
int $viewType 0 table, 1 view, 2 temporary view table.

Source code (PHP 7.1+)

Admin::dumpData

Exports table data.

public function dumpData($table, $style, $query)
Params: string $table
string $style
string $query

Source code (PHP 7.1+)

Admin::init

Initializes the Admin.

This method is called right before the authentication process.

public function init()

Source code (PHP 7.1+)

Admin::addError

Appends error message to the list of messages.

public function addError($error)
Params: string $error HTML-formatted error message.

Source code (PHP 7.1+)

Admin::getErrors

Returns the array of HTML-formatted error messages.

public function getErrors()
Returns: string[]

Source code (PHP 7.1+)