WorkspacePreview implements MiddlewareInterface uses CookieHeaderTrait

Middleware to - evaluate ADMCMD_prev as GET parameter or from a cookie - initializes the PreviewUser as $GLOBALS['BE_USER'] - renders a message about a possible workspace previewing currently

Internal

Table of Contents

Interfaces

MiddlewareInterface

Properties

$previewKey  : string
The GET parameter to be used (also the cookie name)

Methods

process()  : ResponseInterface
Initializes a possible preview user (by checking for GET/cookie of name "ADMCMD_prev")
addCookie()  : ResponseInterface
Adds a cookie for logging in a preview user into the HTTP response
getLanguageService()  : LanguageService
getLogoutTemplateMessage()  : string
Renders the logout template when the "logout" button was pressed.
getPreviewData()  : mixed
Look for keyword configuration record in the database, but check if the keyword has expired already
getPreviewInputCode()  : string
Returns the input code value from the admin command variable If no inputcode and a cookie is set, load input code from cookie
getTypoScriptFrontendController()  : TypoScriptFrontendController|null
getWorkspaceIdFromRequest()  : int|null
Looking for an ADMCMD_prev code, looks it up if found and returns configuration data.
getWorkspaceTitle()  : string
Fetches the title of the workspace
initializePreviewUser()  : PreviewUserAuthentication|null
Creates a preview user and sets the workspace ID
removePreviewParameterFromUrl()  : UriInterface
Used for generating URLs (e.g. in logout page) without the existing ADMCMD_prev keyword as GET variable
renderPreviewInfo()  : string
Renders a message at the bottom of the HTML page, can be modified via
setBackendUserAspect()  : mixed
Register or override the backend user as aspect, as well as the workspace information the user object is holding

Properties

$previewKey

The GET parameter to be used (also the cookie name)

protected string $previewKey = 'ADMCMD_prev'

Methods

process()

Initializes a possible preview user (by checking for GET/cookie of name "ADMCMD_prev")

public process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface

The GET parameter "ADMCMD_prev=LIVE" can be used to preview a live workspace from the backend even if the backend user is in a different workspace.

Additionally, if a workspace is previewed, an additional message text is shown.

Parameters
$request : ServerRequestInterface
$handler : RequestHandlerInterface
Tags
throws
Exception
Return values
ResponseInterface

addCookie()

Adds a cookie for logging in a preview user into the HTTP response

protected addCookie(string $keyword, NormalizedParams $normalizedParams, ResponseInterface $response) : ResponseInterface
Parameters
$keyword : string
$normalizedParams : NormalizedParams
$response : ResponseInterface
Return values
ResponseInterface

getLogoutTemplateMessage()

Renders the logout template when the "logout" button was pressed.

protected getLogoutTemplateMessage(UriInterface $currentUrl) : string

Returns a string which can be put into a HttpResponse.

Parameters
$currentUrl : UriInterface
Return values
string

getPreviewData()

Look for keyword configuration record in the database, but check if the keyword has expired already

protected getPreviewData(string $keyword) : mixed
Parameters
$keyword : string
Return values
mixed

array of the result set or null

getPreviewInputCode()

Returns the input code value from the admin command variable If no inputcode and a cookie is set, load input code from cookie

protected getPreviewInputCode(ServerRequestInterface $request) : string
Parameters
$request : ServerRequestInterface
Return values
string

keyword

getWorkspaceIdFromRequest()

Looking for an ADMCMD_prev code, looks it up if found and returns configuration data.

protected getWorkspaceIdFromRequest(string $inputCode) : int|null

Background: From the backend a request to the frontend to show a page, possibly with workspace preview can be "recorded" and associated with a keyword. When the frontend is requested with this keyword the associated request parameters are restored from the database AND the backend user is loaded - only for that request. The main point is that a special URL valid for a limited time, eg. http://localhost/typo3site/index.php?ADMCMD_prev=035d9bf938bd23cb657735f68a8cedbf will open up for a preview that doesn't require login. Thus, it's useful for sending in an email to someone without backend account.

Parameters
$inputCode : string
Tags
throws
Exception
Return values
int|null

Workspace ID stored in the preview configuration array of a sys_preview record.

getWorkspaceTitle()

Fetches the title of the workspace

protected getWorkspaceTitle(int $workspaceId) : string
Parameters
$workspaceId : int
Return values
string

the title of the workspace

initializePreviewUser()

Creates a preview user and sets the workspace ID

protected initializePreviewUser(int $workspaceUid) : PreviewUserAuthentication|null
Parameters
$workspaceUid : int

the workspace ID to set

Return values
PreviewUserAuthentication|null

if the set up of the workspace was successful, the user is returned.

removePreviewParameterFromUrl()

Used for generating URLs (e.g. in logout page) without the existing ADMCMD_prev keyword as GET variable

protected removePreviewParameterFromUrl(UriInterface $url[, string $newAdminCommand = '' ]) : UriInterface
Parameters
$url : UriInterface
$newAdminCommand : string = ''
Return values
UriInterface

renderPreviewInfo()

Renders a message at the bottom of the HTML page, can be modified via

protected renderPreviewInfo(TypoScriptFrontendController $tsfe, UriInterface $currentUrl) : string

config.disablePreviewNotification = 1 (to disable the additional info text)

and

config.message_preview_workspace = This is not the online version but the version of "%s" workspace (ID: %s).

via TypoScript.

Parameters
$tsfe : TypoScriptFrontendController
$currentUrl : UriInterface
Return values
string

        
On this page

Search results