TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Version\Hook\PreviewHook Class Reference
Inheritance diagram for TYPO3\CMS\Version\Hook\PreviewHook:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 checkForPreview ($params, &$pObj)
 
 overridePagePermissionClause (array $parameters)
 
 overridePermissionCalculation (array $parameters)
 
 getPreviewConfiguration ()
 
 compilePreviewKeyword ($getVarsStr, $backendUserUid, $ttl=172800, $fullWorkspace=null)
 
 getPreviewLinkLifetime ()
 

Protected Member Functions

 getPreviewInputCode ()
 
 getDatabaseConnection ()
 
 createFrontendBackendUser ()
 

Protected Attributes

 $previewKey = 'ADMCMD_prev'
 
 $tsfeObj
 
 $previewConfiguration = false
 
 $forceReadPermissions = false
 

Detailed Description

Hook for checking if the preview mode is activated preview mode = show a page of a workspace without having to log in

Definition at line 28 of file PreviewHook.php.

Member Function Documentation

◆ checkForPreview()

TYPO3\CMS\Version\Hook\PreviewHook::checkForPreview (   $params,
$pObj 
)

◆ compilePreviewKeyword()

TYPO3\CMS\Version\Hook\PreviewHook::compilePreviewKeyword (   $getVarsStr,
  $backendUserUid,
  $ttl = 172800,
  $fullWorkspace = null 
)

Set preview keyword, eg: $previewUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev='.$this->compilePreviewKeyword('id='.$pageId.'&L='.$language.'&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS='.$this->workspace, $GLOBALS['BE_USER']->user['uid'], 120);

Todo:
for sys_preview:
  • Add a comment which can be shown to previewer in frontend in some way (plus maybe ability to write back, take other action?)
  • Add possibility for the preview keyword to work in the backend as well: So it becomes a quick way to a certain action of sorts?
Parameters
string$getVarsStrGet variables to preview, eg. 'id=1150&L=0&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=8'
string$backendUserUid32 byte MD5 hash keyword for the URL: "?ADMCMD_prev=[keyword]
int$ttlTime-To-Live for keyword
int | NULL$fullWorkspaceWhich workspace to preview. Workspace UID, -1 or >0. If set, the getVars is ignored in the frontend, so that string can be empty
Returns
string Returns keyword to use in URL for ADMCMD_prev=

Definition at line 327 of file PreviewHook.php.

References $GLOBALS, and TYPO3\CMS\Version\Hook\PreviewHook\getDatabaseConnection().

◆ createFrontendBackendUser()

TYPO3\CMS\Version\Hook\PreviewHook::createFrontendBackendUser ( )
protected
Returns
FrontendBackendUserAuthentication

Definition at line 367 of file PreviewHook.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Version\Hook\PreviewHook\checkForPreview().

◆ getDatabaseConnection()

TYPO3\CMS\Version\Hook\PreviewHook::getDatabaseConnection ( )
protected

◆ getPreviewConfiguration()

TYPO3\CMS\Version\Hook\PreviewHook::getPreviewConfiguration ( )

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. This can also be used to generate previews of hidden pages, start/endtimes, usergroups and those other settings from the Admin Panel - just not implemented yet.

Exceptions

Definition at line 223 of file PreviewHook.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\GeneralUtility\_GET(), TYPO3\CMS\Core\Utility\GeneralUtility\_GETset(), TYPO3\CMS\Core\Utility\GeneralUtility\_GP(), TYPO3\CMS\Core\Utility\GeneralUtility\_POST(), TYPO3\CMS\Version\Hook\PreviewHook\getDatabaseConnection(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Version\Hook\PreviewHook\getPreviewInputCode(), TYPO3\CMS\Core\Utility\GeneralUtility\getUrl(), and TYPO3\CMS\Core\Utility\GeneralUtility\sanitizeLocalUrl().

Referenced by TYPO3\CMS\Version\Hook\PreviewHook\checkForPreview().

◆ getPreviewInputCode()

TYPO3\CMS\Version\Hook\PreviewHook::getPreviewInputCode ( )
protected

returns the input code value from the admin command variable

Returns
string Input code

Definition at line 303 of file PreviewHook.php.

References TYPO3\CMS\Version\Hook\PreviewHook\$previewKey, and TYPO3\CMS\Core\Utility\GeneralUtility\_GP().

Referenced by TYPO3\CMS\Version\Hook\PreviewHook\getPreviewConfiguration().

◆ getPreviewLinkLifetime()

TYPO3\CMS\Version\Hook\PreviewHook::getPreviewLinkLifetime ( )

easy function to just return the number of hours a preview link is valid, based on the TSconfig value "options.workspaces.previewLinkTTLHours" by default, it's 48hs

Returns
int The hours as a number

Definition at line 350 of file PreviewHook.php.

References $GLOBALS.

◆ overridePagePermissionClause()

TYPO3\CMS\Version\Hook\PreviewHook::overridePagePermissionClause ( array  $parameters)

Overrides the page permission clause in case an admin user has been degraded to a regular user without any user group assignments. This method is used as hook callback.

Parameters
array$parameters
Returns
string
See also
::getPagePermsClause

Definition at line 180 of file PreviewHook.php.

◆ overridePermissionCalculation()

TYPO3\CMS\Version\Hook\PreviewHook::overridePermissionCalculation ( array  $parameters)

Overrides the row permission value in case an admin user has been degraded to a regular user without any user group assignments. This method is used as hook callback.

Parameters
array$parameters
Returns
int
See also
::calcPerms

Definition at line 198 of file PreviewHook.php.

References TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW.

Member Data Documentation

◆ $forceReadPermissions

TYPO3\CMS\Version\Hook\PreviewHook::$forceReadPermissions = false
protected

Definition at line 57 of file PreviewHook.php.

◆ $previewConfiguration

TYPO3\CMS\Version\Hook\PreviewHook::$previewConfiguration = false
protected

Definition at line 49 of file PreviewHook.php.

◆ $previewKey

TYPO3\CMS\Version\Hook\PreviewHook::$previewKey = 'ADMCMD_prev'
protected

◆ $tsfeObj

TYPO3\CMS\Version\Hook\PreviewHook::$tsfeObj
protected

Definition at line 42 of file PreviewHook.php.

Referenced by TYPO3\CMS\Version\Hook\PreviewHook\checkForPreview().