FaviconController
extends AdminBaseController
in package
uses
CommonDataTrait
Favicon settings.
Tags
Table of Contents
Constants
- allowedFileExtensions = ['ico', 'gif', 'png']
- faviconFolderContainer = 'rdbadmin-public/favicon'
- imageSizes = [[16, 16], [32, 32], [180, 180], [192, 192], [270, 270]]
- maxImgHeight = 2048
- maxImgWidth = 2048
- origImgHeight = 512
- origImgWidth = 512
Properties
- $Input : Input
- $Languages : Languages
- $runnedCronResult : array<string|int, mixed>
- $totalLoggedInSessions : int
- $userSessionCookieData : array<string|int, mixed>
Methods
- __construct() : mixed
- Class constructor.
- allowedFileExtensions() : array<string|int, mixed>
- Get allowed file extensions for favicon.
- deleteAction() : string
- Delete favicon.
- recommendedSize() : string
- Get recommended size.
- updateAction() : string
- Upload, change favicon.
- checkLogin() : mixed
- Check for logged in, if not then redirect to login page.
- checkPermission() : mixed
- Check permission and (redirect OR response error message).
- deleteFile() : array<string|int, mixed>
- Delete selected file with all resizes file names.
- deletePreviousFavicon() : array<string|int, mixed>
- Delete previous favicon.
- getConfigDb() : array<string|int, mixed>
- Get config from DB.
- getPageHtmlClasses() : string
- Get page HTML classes.
- getPageHtmlTitle() : string
- Get page HTML title including site name if it was set.
- getRdbAdminAssets() : array<string|int, mixed>
- Get RdbAdmin module's assets.
- isUserLoggedIn() : bool
- Check if user is logged in.
- maybeRunCron() : mixed
- Maybe run cron job if config is set to not use server cron.
- moveUploadedFile() : array<string|int, mixed>
- Move uploaded file.
- prepareRdbAdminPublicFolder() : mixed
- Prepare 'rdbadmin-public' folder on public path (root web).
- resizeImage() : array<string|int, mixed>
- Resize image.
- responseJson() : string
- {@inheritDoc}
- responseXml() : string
- {@inheritDoc}
- sessionTraitLogoutAll() : mixed
- Logout all succeeded login sessions, lock user account, send login link to user's email.
- setBasicConfig() : mixed
- Setup basic PHP configurations such as default timezone.
- setCssAssets() : mixed
- Set CSS assets for common admin pages.
- setHeaderAllowOrigin() : mixed
- Set header allow origin for CORS.
- setJsAssetsAndObject() : mixed
- Set JS assets and its object for XHR common data.
- isModuleExcute() : bool
- Check if current call is `Modules->execute()`
- sessionsTraitCheckIsLoggedInFromContainer() : array<string|int, mixed>
- Check is logged in from container if exists.
- sessionTraitLogoutPreviousSessions() : mixed
- Logout all sessions before latest succeeded login. (logout only succeeded login).
Constants
allowedFileExtensions
public
array<string|int, mixed>
allowedFileExtensions
= ['ico', 'gif', 'png']
Allowed file extension for favicon. Extension without dot.
faviconFolderContainer
public
string
faviconFolderContainer
= 'rdbadmin-public/favicon'
The folder path that contain favicon. Related from public path (web root), use forward slash, not begins nor end with slashes.
imageSizes
public
array<string|int, mixed>
imageSizes
= [[16, 16], [32, 32], [180, 180], [192, 192], [270, 270]]
The all sizes that will be use for resize. Each array contain width (array index 0), height (array index 1) from smallest to largest.
maxImgHeight
public
mixed
maxImgHeight
= 2048
maxImgWidth
public
mixed
maxImgWidth
= 2048
origImgHeight
public
int
origImgHeight
= 512
Original image file height. It will be resize original image dimension to this value.
origImgWidth
public
int
origImgWidth
= 512
Original image file width. It will be resize original image dimension to this value.
Properties
$Input
protected
Input
$Input
$Languages
protected
Languages
$Languages
$runnedCronResult
protected
array<string|int, mixed>
$runnedCronResult
= []
Runned cron jobs result.
This is for use in case that set cron job, cron tab to run by URL.
The CronController
will be call to this BaseController
.
So, it is no need to using Libraries\Cron
class to run jobs again.
Just get the run result from this property.
This property will be set by maybeRunCron()
method.
$totalLoggedInSessions
protected
int
$totalLoggedInSessions
= 0
The number of sessions that found this user logged in. This property is able to access after called to isUserLoggedIn()
method.
$userSessionCookieData
protected
array<string|int, mixed>
$userSessionCookieData
= []
The cookie data of logged in user. This property is able to access after called to isUserLoggedIn()
method.
Methods
__construct()
Class constructor.
public
__construct(Container $Container) : mixed
Parameters
- $Container : Container
allowedFileExtensions()
Get allowed file extensions for favicon.
public
static allowedFileExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed> —Return file extensions of allowed favicon.
deleteAction()
Delete favicon.
public
deleteAction() : string
Return values
stringrecommendedSize()
Get recommended size.
public
static recommendedSize() : string
Use in views page.
Return values
string —Recommended size.
updateAction()
Upload, change favicon.
public
updateAction() : string
Return values
stringcheckLogin()
Check for logged in, if not then redirect to login page.
protected
checkLogin() : mixed
checkPermission()
Check permission and (redirect OR response error message).
protected
checkPermission(string $moduleSystemName, string $page, string|array<string|int, mixed> $action[, array<string|int, mixed> $identity = [] ]) : mixed
This will be redirect user to /admin page if request from web page.
This will be response error message if request via REST API or AJAX.
Parameters
- $moduleSystemName : string
-
The module (module system name or folder name) to check.
- $page : string
-
The page name to check.
- $action : string|array<string|int, mixed>
-
The action(s) on that page. Use string if check for single action, use array if check for multiple actions.
If checking for multiple actions, any single action matched with certain module, page will be returntrue
. - $identity : array<string|int, mixed> = []
-
The associative array of identity.
Tags
deleteFile()
Delete selected file with all resizes file names.
protected
deleteFile(string $filePath) : array<string|int, mixed>
Parameters
- $filePath : string
-
Relative image path from public path (root web). Not begins with slash.
Return values
array<string|int, mixed> —Return associative array with keys:
result
(array) The associative array where key is file name found in search with glob pattern. The value is boolean where it is result of unlink()
.
allDeleted
(bool) It is true
if all file size names were deleted, false
for otherwise.
deletePreviousFavicon()
Delete previous favicon.
protected
deletePreviousFavicon([bool $updateToEmpty = false ]) : array<string|int, mixed>
Parameters
- $updateToEmpty : bool = false
-
Set to
true
to update this config value in DB to empty. Set tofalse
for update nothing.
Return values
array<string|int, mixed> —Return associative array with keys:
deleteFileResult
(array) The result from deleteFile()
method. Only exists if found config value and not empty.
noPreviousValueToDelete
(bool) It will be true
if there is no previous config value to delete.
updateToEmptyResult
(bool) The result from update command. Only exists if $updateToEmpty
attribute is set to true
.
getConfigDb()
Get config from DB.
protected
getConfigDb() : array<string|int, mixed>
This will get commonly used between admin controllers with these data.
rdbadmin_SiteName, rdbadmin_SiteTimezone, rdbadmin_AdminItemsPerPage,
Return values
array<string|int, mixed>getPageHtmlClasses()
Get page HTML classes.
protected
getPageHtmlClasses([array<string|int, mixed> $classes = [] ]) : string
Parameters
- $classes : array<string|int, mixed> = []
-
The classes to set for this html page.
Tags
Return values
string —Return generated html classes names.
getPageHtmlTitle()
Get page HTML title including site name if it was set.
protected
getPageHtmlTitle(string $title[, string|null|false $siteName = false ]) : string
Parameters
- $title : string
-
The site title.
- $siteName : string|null|false = false
-
Site name should be string.
Set to empty string ornull
will not include the site name.
Set tofalse
to automatic get the site name from config DB.
Tags
Return values
stringgetRdbAdminAssets()
Get RdbAdmin module's assets.
protected
getRdbAdminAssets() : array<string|int, mixed>
These contain the assets that is required for admin page to work.
Return values
array<string|int, mixed> —Return associative array with 'css' and 'js' in keys.
isUserLoggedIn()
Check if user is logged in.
protected
isUserLoggedIn([int $user_id = null ][, string $userlogin_session_key = '' ]) : bool
After called this method and it was true
then you can access total sessions via totalLoggedInSessions
property.
After called this method and cookie is valid then you can access cookie data via userSessionCookieData
property.
If there is simultaneous login and user's setting is something that is not allowed (such as logout previous, logout all), it will be process here.
Parameters
- $user_id : int = null
-
The user ID. Set to
null
(default) to auto detect from cookie. - $userlogin_session_key : string = ''
-
The logged in session key. Set to empty string (default) to auto detect from cookie.
Return values
bool —Return true
if logged in, false
for not.
maybeRunCron()
Maybe run cron job if config is set to not use server cron.
protected
maybeRunCron() : mixed
moveUploadedFile()
Move uploaded file.
protected
moveUploadedFile() : array<string|int, mixed>
Return values
array<string|int, mixed> —Return associative array with keys:
formValidated
(bool) Form validated. The value will be true
on validated all passed, but will be false
if contain errors.
If only uploaded success, the following array keys exists.
uploadData
(array) The uploaded data. See Rundiz\Upload\Upload::getUploadedData()
.
newName
(string) The new file name with extension, no path.
fullPathNewName
(string) The full path to new file name.
relPathNewName
(string) The relative path from public path (root web). Directory separator is forward slash (/).
prepareRdbAdminPublicFolder()
Prepare 'rdbadmin-public' folder on public path (root web).
protected
prepareRdbAdminPublicFolder() : mixed
resizeImage()
Resize image.
protected
resizeImage(string $filePath) : array<string|int, mixed>
Parameters
- $filePath : string
-
Relative image path from public path (root web). Not begins with slash.
Return values
array<string|int, mixed> —Return associative array with keys:
resizeResult
(bool) Resize result. If success or no resize work it will be true
, otherwise it will be false
.
Array key that exists only success.
resizedFiles
(array) Contain resized file names from smallest to largest and then uploaded size. If no resize work then it will be return only uploaded where same as filePath
attribute.
The array key of resizedFiles
is width x height for resizes and 'upload'
for uploaded size.
Array keys that exists only failure.
formResultStatus
(string) The form result status.
formResultMessage
(string) The form result message.
responseJson()
{@inheritDoc}
protected
responseJson(mixed $output) : string
Parameters
- $output : mixed
Return values
stringresponseXml()
{@inheritDoc}
protected
responseXml(mixed $output) : string
Parameters
- $output : mixed
Return values
stringsessionTraitLogoutAll()
Logout all succeeded login sessions, lock user account, send login link to user's email.
protected
sessionTraitLogoutAll(int $user_id, UserLoginsDb $UserLoginsDb, UserFieldsDb $UserFieldsDb) : mixed
This method also set cache that email was sent recently.
This method was called from isUserLoggedIn()
.
This method was called from LoginController->doLogin()
.
Parameters
- $user_id : int
- $UserLoginsDb : UserLoginsDb
- $UserFieldsDb : UserFieldsDb
setBasicConfig()
Setup basic PHP configurations such as default timezone.
protected
setBasicConfig() : mixed
setCssAssets()
Set CSS assets for common admin pages.
protected
setCssAssets(Assets $Assets, array<string|int, mixed> $assetsData) : mixed
This is required to make basic admin pages working correctly.
Parameters
- $Assets : Assets
-
The Assets class.
- $assetsData : array<string|int, mixed>
-
The assets data. Please read more on
\Rdb\Modules\RdbAdmin\Libraries\Assets::addMultipleAssets()
.
setHeaderAllowOrigin()
Set header allow origin for CORS.
protected
setHeaderAllowOrigin() : mixed
setJsAssetsAndObject()
Set JS assets and its object for XHR common data.
protected
setJsAssetsAndObject(Assets $Assets, array<string|int, mixed> $assetsData) : mixed
This is required to make basic admin pages working correctly.
Parameters
- $Assets : Assets
-
The Assets class.
- $assetsData : array<string|int, mixed>
-
The assets data. Please read more on
\Rdb\Modules\RdbAdmin\Libraries\Assets::addMultipleAssets()
.
isModuleExcute()
Check if current call is `Modules->execute()`
private
isModuleExcute() : bool
This method was called from maybeRunCron()
, __construct()
.
Tags
Return values
bool —Return true
if it is, false
if it is not.
sessionsTraitCheckIsLoggedInFromContainer()
Check is logged in from container if exists.
private
sessionsTraitCheckIsLoggedInFromContainer() : array<string|int, mixed>
The check data in container must not older than N seconds.
Tags
Return values
array<string|int, mixed> —Return indexed array where first index is UsersSessionsTrait
object in the container if exists. This value can be null
.
Second index is result of "is logged in". This value can be null
.
sessionTraitLogoutPreviousSessions()
Logout all sessions before latest succeeded login. (logout only succeeded login).
private
sessionTraitLogoutPreviousSessions(int $user_id, UserLoginsDb $UserLoginsDb) : mixed
This method was called from isUserLoggedIn()
.
Parameters
- $user_id : int
- $UserLoginsDb : UserLoginsDb