TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PreviewHook Class Reference
Inheritance diagram for PreviewHook:
SingletonInterface

Public Member Functions

 checkForPreview ($params, &$pObj)
 
 initializePreviewUser (&$params, &$pObj)
 
 getPreviewConfiguration ()
 
 compilePreviewKeyword ($getVarsStr, $backendUserUid, $ttl=172800, $fullWorkspace=null)
 
 getPreviewLinkLifetime ()
 

Protected Member Functions

 getPreviewInputCode ()
 

Protected Attributes

 $previewKey = 'ADMCMD_prev'
 
 $tsfeObj
 
 $previewConfiguration = 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 23 of file PreviewHook.php.

Member Function Documentation

checkForPreview (   $params,
$pObj 
)

hook to check if the preview is activated right now, this hook is called at the end of "$TSFE->connectToDB"

Parameters
array$params(not needed right now)
\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController$pObj
Returns
void

Definition at line 54 of file PreviewHook.php.

References $GLOBALS, PreviewHook\$tsfeObj, GeneralUtility\_GP(), PreviewHook\getPreviewConfiguration(), and GeneralUtility\makeInstance().

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 244 of file PreviewHook.php.

References $GLOBALS.

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
\Exception
Returns
array Preview configuration array from sys_preview record.

Definition at line 140 of file PreviewHook.php.

References $GLOBALS, GeneralUtility\_GET(), GeneralUtility\_GETset(), GeneralUtility\_GP(), GeneralUtility\_POST(), elseif, GeneralUtility\getIndpEnv(), PreviewHook\getPreviewInputCode(), GeneralUtility\getUrl(), and GeneralUtility\sanitizeLocalUrl().

Referenced by PreviewHook\checkForPreview().

getPreviewInputCode ( )
protected

returns the input code value from the admin command variable

Returns
string Input code

Definition at line 220 of file PreviewHook.php.

References PreviewHook\$previewKey, and GeneralUtility\_GP().

Referenced by PreviewHook\getPreviewConfiguration().

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 267 of file PreviewHook.php.

References $GLOBALS.

initializePreviewUser ( $params,
$pObj 
)

hook after the regular BE user has been initialized if there is no BE user login, but a preview configuration the BE user of the preview configuration gets initialized

Parameters
array$paramsholding the BE_USER object
\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController$pObj
Returns
void

Definition at line 93 of file PreviewHook.php.

References GeneralUtility\makeInstance().

Member Data Documentation

$previewConfiguration = false
protected

Definition at line 44 of file PreviewHook.php.

$previewKey = 'ADMCMD_prev'
protected

Definition at line 30 of file PreviewHook.php.

Referenced by PreviewHook\getPreviewInputCode().

$tsfeObj
protected

Definition at line 37 of file PreviewHook.php.

Referenced by PreviewHook\checkForPreview().