‪TYPO3CMS  11.5
TYPO3\CMS\Workspaces\Middleware\WorkspacePreview Class Reference
Inheritance diagram for TYPO3\CMS\Workspaces\Middleware\WorkspacePreview:

Public Member Functions

ResponseInterface process (ServerRequestInterface $request, RequestHandlerInterface $handler)
 

Protected Member Functions

string getLogoutTemplateMessage (UriInterface $currentUrl)
 
int null getWorkspaceIdFromRequest (string $inputCode)
 
PreviewUserAuthentication null initializePreviewUser (int $workspaceUid)
 
ResponseInterface addCookie (string $keyword, NormalizedParams $normalizedParams, ResponseInterface $response)
 
string getPreviewInputCode (ServerRequestInterface $request)
 
mixed getPreviewData (string $keyword)
 
string renderPreviewInfo (TypoScriptFrontendController $tsfe, UriInterface $currentUrl)
 
string getWorkspaceTitle (int $workspaceId)
 
UriInterface removePreviewParameterFromUrl (UriInterface $url, string $newAdminCommand='')
 
 getLanguageService ()
 
 setBackendUserAspect (Context $context, BackendUserAuthentication $user=null)
 
 getTypoScriptFrontendController ()
 

Protected Attributes

string $previewKey = 'ADMCMD_prev'
 

Detailed Description

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

Definition at line 52 of file WorkspacePreview.php.

Member Function Documentation

◆ addCookie()

ResponseInterface TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::addCookie ( string  $keyword,
NormalizedParams  $normalizedParams,
ResponseInterface  $response 
)
protected

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

Parameters
string$keyword
NormalizedParams$normalizedParams
ResponseInterface$response
Returns
‪ResponseInterface

Definition at line 233 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Core\Http\NormalizedParams\getSitePath(), and TYPO3\CMS\Core\Http\NormalizedParams\isHttps().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getLanguageService()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getLanguageService ( )
protected

◆ getLogoutTemplateMessage()

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getLogoutTemplateMessage ( UriInterface  $currentUrl)
protected

Renders the logout template when the "logout" button was pressed. Returns a string which can be put into a HttpResponse.

Parameters
UriInterface$currentUrl
Returns
‪string

Definition at line 160 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLanguageService(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\removePreviewParameterFromUrl().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getPreviewData()

mixed TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getPreviewData ( string  $keyword)
protected

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

Parameters
string$keyword
Returns
‪mixed array of the result set or null

Definition at line 273 of file WorkspacePreview.php.

References $GLOBALS, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getWorkspaceIdFromRequest().

◆ getPreviewInputCode()

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getPreviewInputCode ( ServerRequestInterface  $request)
protected

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

Parameters
ServerRequestInterface$request
Returns
‪string keyword

Definition at line 262 of file WorkspacePreview.php.

References TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\$previewKey.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getTypoScriptFrontendController()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getTypoScriptFrontendController ( )
protected

Definition at line 421 of file WorkspacePreview.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getWorkspaceIdFromRequest()

int null TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getWorkspaceIdFromRequest ( string  $inputCode)
protected

Looking for an ADMCMD_prev code, looks it up if found and returns configuration data. 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
string$inputCode
Returns
‪int|null Workspace ID stored in the preview configuration array of a sys_preview record.
Exceptions

Definition at line 195 of file WorkspacePreview.php.

References TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getPreviewData().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getWorkspaceTitle()

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getWorkspaceTitle ( int  $workspaceId)
protected

Fetches the title of the workspace

Parameters
int$workspaceId
Returns
‪string the title of the workspace

Definition at line 366 of file WorkspacePreview.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\renderPreviewInfo().

◆ initializePreviewUser()

PreviewUserAuthentication null TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::initializePreviewUser ( int  $workspaceUid)
protected

Creates a preview user and sets the workspace ID

Parameters
int$workspaceUid‪the workspace ID to set
Returns
‪PreviewUserAuthentication|null if the set up of the workspace was successful, the user is returned.

Definition at line 216 of file WorkspacePreview.php.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ process()

ResponseInterface TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::process ( ServerRequestInterface  $request,
RequestHandlerInterface  $handler 
)

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

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
ServerRequestInterface$request
RequestHandlerInterface$handler
Returns
‪ResponseInterface
Exceptions

Definition at line 75 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\$previewKey, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\addCookie(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLogoutTemplateMessage(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getPreviewInputCode(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getTypoScriptFrontendController(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getWorkspaceIdFromRequest(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\initializePreviewUser(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\renderPreviewInfo(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\setBackendUserAspect().

◆ removePreviewParameterFromUrl()

UriInterface TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::removePreviewParameterFromUrl ( UriInterface  $url,
string  $newAdminCommand = '' 
)
protected

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

Parameters
UriInterface$url
string$newAdminCommand
Returns
‪UriInterface

Definition at line 391 of file WorkspacePreview.php.

References TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\$previewKey.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLogoutTemplateMessage(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\renderPreviewInfo().

◆ renderPreviewInfo()

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::renderPreviewInfo ( TypoScriptFrontendController  $tsfe,
UriInterface  $currentUrl 
)
protected

Code regarding adding a custom preview message, when previewing a workspace Renders a message at the bottom of the HTML page, can be modified via

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
TypoScriptFrontendController$tsfe
UriInterface$currentUrl
Returns
‪string

Definition at line 314 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLanguageService(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getWorkspaceTitle(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\removePreviewParameterFromUrl(), and TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\whichWorkspace().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ setBackendUserAspect()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::setBackendUserAspect ( Context  $context,
BackendUserAuthentication  $user = null 
)
protected

Register or override the backend user as aspect, as well as the workspace information the user object is holding

Definition at line 415 of file WorkspacePreview.php.

References TYPO3\CMS\Core\Context\Context\setAspect().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

Member Data Documentation

◆ $previewKey

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::$previewKey = 'ADMCMD_prev'
protected