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. |
Sends additional HTTP headers.
public function sendHeaders()
Source code (PHP 7.1+)
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+)
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+)
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+)
Returns connection parameters.
public function getCredentials()
| Returns: | string[] |
array($server, $username, $password) |
|---|
Source code (PHP 7.1+)
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+)
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+)
Prints HTML links to favicons.
public function printFavicons()
Source code (PHP 7.1+)
Prints additional HTML code at the end of the <head>.
public function printToHead()
Source code (PHP 7.1+)
Returns configured URLs of the CSS files together with autoloaded adminneo.css if exists.
public function getCssUrls()
| Returns: | string[] |
|---|
Source code (PHP 7.1+)
Returns whether light mode is forced.
public function isLightModeForced()
| Returns: | bool |
|---|
Source code (PHP 7.1+)
Returns whether dark mode is forced.
public function isDarkModeForced()
| Returns: | bool |
|---|
Source code (PHP 7.1+)
Returns configured URLs of the JS files together with autoloaded adminneo.js if exists.
public function getJsUrls()
| Returns: | string[] |
|---|
Source code (PHP 7.1+)
Returns the name of selected database.
public function getDatabase()
| Returns: | string |
|---|
Source code (PHP 7.1+)
Returns cached list of databases.
public function getDatabases($flush = true)
| Params: | $flush |
|
|---|---|---|
| Returns: | string[] |
Source code (PHP 7.1+)
Returns the list of schemas.
public function getSchemas()
| Returns: | string[] |
|---|
Source code (PHP 7.1+)
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+)
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+)
Returns foreign keys for table.
public function getForeignKeys($table)
| Params: | string $table |
|
|---|---|---|
| Returns: | array |
Source code (PHP 7.1+)
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+)
Returns HTML code for the service title.
public function getServiceTitle()
| Returns: | string |
|---|
Source code (PHP 7.1+)
Prints login form.
public function printLoginForm()
Source code (PHP 7.1+)
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+)
Prints username and logout button.
public function printLogout()
Source code (PHP 7.1+)
Returns server name displayed in breadcrumbs. Can be empty string.
public function getServerName($server)
| Params: | string $server |
|
|---|---|---|
| Returns: | string |
Source code (PHP 7.1+)
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+)
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+)
Returns formatted comment.
public function formatComment($comment)
| Params: | ?string $comment |
|
|---|---|---|
| Returns: | string |
HTML to be printed. |
Source code (PHP 7.1+)
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+)
Prints databases selection in main navigation.
public function printDatabaseSwitcher($missing)
| Params: | ?string $missing |
|---|
Source code (PHP 7.1+)
Prints top menu on database page.
public function printDatabaseMenu()
Source code (PHP 7.1+)
Prints input field for filtering table list.
public function printTablesFilter()
Source code (PHP 7.1+)
Prints table list in main navigation.
public function printTableList(array $tables)
| Params: | array $tables |
Result of table_status('', true) |
|---|
Source code (PHP 7.1+)
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+)
Prints HTML code just before the Execute button in SQL command.
public function printAfterSqlCommand()
Source code (PHP 7.1+)
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+)
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+)
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+)
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+)
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+)
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+)
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+)
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+)
Prints table structure in tabular format.
public function printTableStructure(array $fields)
| Params: | array $fields |
Data about individual fields. |
|---|
Source code (PHP 7.1+)
Prints the definition of table partitioning.
public function printTablePartitions(array $partitionInfo)
| Params: | array $partitionInfo |
|---|
Source code (PHP 7.1+)
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+)
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+)
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+)
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+)
Prints limit box in selection filter.
public function printSelectionLimit($limit)
| Params: | ?int $limit |
|---|
Source code (PHP 7.1+)
Prints text length box in selection filter.
public function printSelectionLength($textLength)
| Params: | ?string $textLength |
The result of processSelectionLength(). |
|---|
Source code (PHP 7.1+)
Prints action box in selection filter.
public function printSelectionAction(array $indexes)
| Params: | array $indexes |
|---|
Source code (PHP 7.1+)
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+)
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+)
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+)
Processed limit box in select.
public function processSelectionLimit()
| Returns: | ?int |
Expression to use in LIMIT, will be escaped. |
|---|
Source code (PHP 7.1+)
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+)
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+)
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+)
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+)
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+)
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+)
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+)
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+)
Returns export output options.
public function getDumpOutputs()
| Returns: | string[] |
|---|
Source code (PHP 7.1+)
Returns export format options.
public function getDumpFormats()
| Returns: | string[] |
Empty to disable export. |
|---|
Source code (PHP 7.1+)
Sends headers for export.
public function sendDumpHeaders($identifier, $multiTable = false)
| Params: | string $identifier |
|
|---|---|---|
bool $multiTable |
||
| Returns: | string |
File extension. |
Source code (PHP 7.1+)
Exports database structure.
public function dumpDatabase($database)
| Params: | string $database |
|---|
Source code (PHP 7.1+)
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+)
Exports table data.
public function dumpData($table, $style, $query)
| Params: | string $table |
|
|---|---|---|
string $style |
||
string $query |
Source code (PHP 7.1+)
Initializes the Admin.
This method is called right before the authentication process.
public function init()
Source code (PHP 7.1+)
Appends error message to the list of messages.
public function addError($error)
| Params: | string $error |
HTML-formatted error message. |
|---|
Source code (PHP 7.1+)
Returns the array of HTML-formatted error messages.
public function getErrors()
| Returns: | string[] |
|---|
Source code (PHP 7.1+)