AdminController
extends BaseController
in package
Controller for administrative functions.
Handles:
- Backup and restore
- Database wizard
- Statistics
- Settings
- Install demo
- Server data
Tags
Table of Contents
Properties
- $adminFacade : AdminFacade
- $ttsService : TtsService
- $viewPath : string
- View base path.
Methods
- __construct() : mixed
- Constructor.
- backup() : void
- Backup and restore page.
- installDemo() : void
- Install demo page.
- saveSetting() : RedirectResponse|null
- Save a setting and redirect to a URL.
- serverData() : void
- Server data page.
- settings() : void
- Settings page.
- statistics() : void
- Statistics page.
- wizard() : void
- Database wizard page.
- endRender() : void
- End page rendering with standard LWT footer.
- execute() : int
- Execute an INSERT/UPDATE/DELETE query.
- get() : string
- Get a string GET parameter.
- getMarkedIds() : array<string|int, int>
- Get IDs from marked checkboxes.
- getValue() : mixed
- Get a single value from the database.
- hasParam() : bool
- Check if a parameter exists in the request.
- isGet() : bool
- Check if the request is a GET request.
- isPost() : bool
- Check if the request is a POST request.
- json() : JsonResponse
- Return JSON response.
- message() : void
- Display a message (success/error) to the user using Bulma notifications.
- param() : string
- Get a string request parameter (GET, POST, or REQUEST).
- paramArray() : array<string|int, mixed>
- Get an array request parameter.
- paramInt() : int|null
- Get an integer request parameter.
- post() : string
- Get a string POST parameter.
- query() : mysqli_result|bool
- Execute a database query using the LWT query wrapper.
- redirect() : RedirectResponse
- Redirect to another URL.
- render() : void
- Start page rendering with standard LWT header.
- requireInt() : int
- Get a required integer request parameter.
- createDefaultFacade() : AdminFacade
- Create the default AdminFacade when not provided via DI.
Properties
$adminFacade
private
AdminFacade
$adminFacade
$ttsService
private
TtsService
$ttsService
$viewPath
View base path.
private
string
$viewPath
Methods
__construct()
Constructor.
public
__construct([AdminFacade|null $adminFacade = null ][, TtsService|null $ttsService = null ]) : mixed
Parameters
- $adminFacade : AdminFacade|null = null
-
Admin facade (optional for BC)
- $ttsService : TtsService|null = null
-
TTS service (optional for BC)
backup()
Backup and restore page.
public
backup(array<string, string> $params) : void
Handles:
- restore=xxx: Restore from uploaded file
- backup=xxx: Download backup
- orig_backup=xxx: Download official format backup
- empty=xxx: Empty the database
Parameters
- $params : array<string, string>
-
Route parameters
Tags
installDemo()
Install demo page.
public
installDemo(array<string, string> $params) : void
Handles:
- install=xxx: Install the demo database
Parameters
- $params : array<string, string>
-
Route parameters
Tags
saveSetting()
Save a setting and redirect to a URL.
public
saveSetting(array<string, string> $params) : RedirectResponse|null
This endpoint replaces the legacy save_setting_redirect.php file.
GET parameters:
- k: Setting key
- v: Setting value
- u: Redirect URL (optional)
Parameters
- $params : array<string, string>
-
Route parameters
Return values
RedirectResponse|nullserverData()
Server data page.
public
serverData(array<string, string> $params) : void
Parameters
- $params : array<string, string>
-
Route parameters
Tags
settings()
Settings page.
public
settings(array<string, string> $params) : void
Handles:
- op=Save: Save all settings
- op=Reset: Reset to defaults
Parameters
- $params : array<string, string>
-
Route parameters
Tags
statistics()
Statistics page.
public
statistics(array<string, string> $params) : void
Parameters
- $params : array<string, string>
-
Route parameters
Tags
wizard()
Database wizard page.
public
wizard(array<string, string> $params) : void
The wizard is a standalone page that can run without database connection. It uses its own self-contained HTML output.
Handles:
- op=Autocomplete: Auto-detect connection settings
- op=Check: Test connection with provided settings
- op=Change: Save new connection settings
Parameters
- $params : array<string, string>
-
Route parameters
Tags
endRender()
End page rendering with standard LWT footer.
protected
endRender() : void
execute()
Execute an INSERT/UPDATE/DELETE query.
protected
execute(string $sql) : int
Parameters
- $sql : string
-
SQL query
Tags
Return values
int —Number of affected rows
get()
Get a string GET parameter.
protected
get(string $key[, string $default = '' ]) : string
Parameters
- $key : string
-
Parameter name
- $default : string = ''
-
Default value if not set
Return values
string —Parameter value or default
getMarkedIds()
Get IDs from marked checkboxes.
protected
getMarkedIds(string|array<string|int, mixed> $marked) : array<string|int, int>
Parameters
- $marked : string|array<string|int, mixed>
-
The 'marked' request parameter value
Tags
Return values
array<string|int, int> —Array of integer IDs
getValue()
Get a single value from the database.
protected
getValue(string $sql) : mixed
Parameters
- $sql : string
-
SQL query (should return single value as 'value')
Return values
mixed —The value or null
hasParam()
Check if a parameter exists in the request.
protected
hasParam(string $key) : bool
Parameters
- $key : string
-
Parameter name
Return values
bool —True if the parameter exists
isGet()
Check if the request is a GET request.
protected
isGet() : bool
Return values
boolisPost()
Check if the request is a POST request.
protected
isPost() : bool
Return values
booljson()
Return JSON response.
protected
json(mixed $data[, int $status = 200 ]) : JsonResponse
Return this from a controller method; the router will send it.
Parameters
- $data : mixed
-
Data to encode as JSON
- $status : int = 200
-
HTTP status code (default: 200)
Return values
JsonResponsemessage()
Display a message (success/error) to the user using Bulma notifications.
protected
message(string $message[, bool $autoHide = true ]) : void
Parameters
- $message : string
-
The message to display
- $autoHide : bool = true
-
Whether to auto-hide the message (default: true)
param()
Get a string request parameter (GET, POST, or REQUEST).
protected
param(string $key[, string $default = '' ]) : string
Parameters
- $key : string
-
Parameter name
- $default : string = ''
-
Default value if not set
Return values
string —Parameter value or default
paramArray()
Get an array request parameter.
protected
paramArray(string $key[, array<string|int, mixed> $default = [] ]) : array<string|int, mixed>
Parameters
- $key : string
-
Parameter name
- $default : array<string|int, mixed> = []
-
Default value if not set
Return values
array<string|int, mixed> —Parameter value or default
paramInt()
Get an integer request parameter.
protected
paramInt(string $key[, int|null $default = null ][, int|null $min = null ][, int|null $max = null ]) : int|null
Parameters
- $key : string
-
Parameter name
- $default : int|null = null
-
Default value if not set
- $min : int|null = null
-
Minimum allowed value
- $max : int|null = null
-
Maximum allowed value
Return values
int|null —Parameter value or default
post()
Get a string POST parameter.
protected
post(string $key[, string $default = '' ]) : string
Parameters
- $key : string
-
Parameter name
- $default : string = ''
-
Default value if not set
Return values
string —Parameter value or default
query()
Execute a database query using the LWT query wrapper.
protected
query(string $sql) : mysqli_result|bool
Parameters
- $sql : string
-
SQL query
Return values
mysqli_result|bool —Query result
redirect()
Redirect to another URL.
protected
redirect(string $url[, int $statusCode = 302 ]) : RedirectResponse
Return this from a controller method; the router will send it.
Parameters
- $url : string
-
URL to redirect to
- $statusCode : int = 302
-
HTTP status code (default: 302)
Return values
RedirectResponserender()
Start page rendering with standard LWT header.
protected
render(string $title[, bool $showMenu = true ]) : void
Parameters
- $title : string
-
Page title
- $showMenu : bool = true
-
Whether to show navigation menu (default: true)
requireInt()
Get a required integer request parameter.
protected
requireInt(string $key[, int|null $min = null ][, int|null $max = null ]) : int
Parameters
- $key : string
-
Parameter name
- $min : int|null = null
-
Minimum allowed value
- $max : int|null = null
-
Maximum allowed value
Tags
Return values
int —Parameter value
createDefaultFacade()
Create the default AdminFacade when not provided via DI.
private
createDefaultFacade() : AdminFacade