‪TYPO3CMS  9.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 (string $returnUrl='')
 
array null getPreviewConfigurationFromRequest (ServerRequestInterface $request, string $inputCode)
 
PreviewUserAuthentication bool initializePreviewUser (int $workspaceUid, $requestedPageId)
 
 setCookie (string $inputCode, NormalizedParams $normalizedParams)
 
string getPreviewInputCode (ServerRequestInterface $request)
 
mixed getPreviewData (string $keyword)
 
string renderPreviewInfo (TypoScriptFrontendController $tsfe, NormalizedParams $normalizedParams)
 
string getWorkspaceTitle (int $workspaceId)
 
string removePreviewParameterFromUrl (string $url)
 
LanguageService getLanguageService ()
 
 setBackendUserAspect (Context $context, BackendUserAuthentication $user=null)
 

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 45 of file WorkspacePreview.php.

Member Function Documentation

◆ getLanguageService()

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

◆ getLogoutTemplateMessage()

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getLogoutTemplateMessage ( string  $returnUrl = '')
protected

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

Parameters
string$returnUrl
Returns
‪string

Definition at line 133 of file WorkspacePreview.php.

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

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

◆ getPreviewConfigurationFromRequest()

array null TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getPreviewConfigurationFromRequest ( ServerRequestInterface  $request,
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
ServerRequestInterface$request
string$inputCode
Returns
‪array|null Preview configuration array from sys_preview record.
Exceptions

Definition at line 170 of file WorkspacePreview.php.

References TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getPreviewData(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\setCookie().

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 257 of file WorkspacePreview.php.

References $GLOBALS.

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

◆ 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 246 of file WorkspacePreview.php.

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

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
$workspaceId
Returns
‪string the title of the workspace

Definition at line 351 of file WorkspacePreview.php.

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

◆ initializePreviewUser()

PreviewUserAuthentication bool TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::initializePreviewUser ( int  $workspaceUid,
  $requestedPageId 
)
protected

Creates a preview user and sets the workspace ID and the current page ID (for accessing the page)

Parameters
int$workspaceUid‪the workspace ID to set
mixed$requestedPageId‪pageID or alias to the current page
Returns
‪PreviewUserAuthentication|bool if the set up of the workspace was successful, the user is returned.

Definition at line 199 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_noBeUser" 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 68 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLogoutTemplateMessage(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getPreviewConfigurationFromRequest(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getPreviewInputCode(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\initializePreviewUser(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\renderPreviewInfo(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\setBackendUserAspect(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\setCookie().

◆ removePreviewParameterFromUrl()

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::removePreviewParameterFromUrl ( string  $url)
protected

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

Parameters
string$url
Returns
‪string

Definition at line 375 of file WorkspacePreview.php.

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,
NormalizedParams  $normalizedParams 
)
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
NormalizedParams$normalizedParams
Returns
‪string

Definition at line 298 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLanguageService(), TYPO3\CMS\Core\Http\NormalizedParams\getRequestUri(), TYPO3\CMS\Core\Http\NormalizedParams\getSiteUrl(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getWorkspaceTitle(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\removePreviewParameterFromUrl(), TYPO3\CMS\Core\Localization\LanguageService\sL(), 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 the backend user as aspect

Parameters
Context$context
BackendUserAuthentication$user

Definition at line 394 of file WorkspacePreview.php.

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

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

◆ setCookie()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::setCookie ( string  $inputCode,
NormalizedParams  $normalizedParams 
)
protected

Sets a cookie for logging in a preview user

Parameters
string$inputCode
NormalizedParams$normalizedParams

Definition at line 217 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\getPreviewConfigurationFromRequest(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

Member Data Documentation

◆ $previewKey

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

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

Definition at line 53 of file WorkspacePreview.php.

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