‪TYPO3CMS  11.5
TYPO3\CMS\Workspaces\Service\WorkspaceService Class Reference
Inheritance diagram for TYPO3\CMS\Workspaces\Service\WorkspaceService:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

array getAvailableWorkspaces ()
 
int getCurrentWorkspace ()
 
int getPreviewLinkLifetime ()
 
array getCmdArrayForPublishWS ($wsid, $_=false, $pageId=0, $language=null)
 
array getCmdArrayForFlushWS ($wsid, $flush=true, $pageId=0, $language=null)
 
array selectVersionsInWorkspace ($wsid, $stage=-99, $pageId=-1, $recursionLevel=0, $selectionType='tables_select', $language=null)
 
bool hasPageRecordVersions ($workspaceId, $pageId)
 
array getPagesWithVersionsInTable ($workspaceId)
 

Static Public Member Functions

static string getWorkspaceTitle ($wsId)
 
static bool isNewPage ($id, $language=0)
 

Public Attributes

const TABLE_WORKSPACE = 'sys_workspace'
 
const LIVE_WORKSPACE_ID = 0
 

Protected Member Functions

array selectAllVersionsFromPages ($table, $pageList, $wsid, $stage, $language=null)
 
array getNewVersionsForPages (string $table, string $pageList, int $wsid, int $stage, ?int $language)
 
array getMovedRecordsFromPages ($table, $pageList, $wsid, $stage)
 
string getTreeUids ($pageId, $wsid, $recursionLevel)
 
int[] getPageChildrenRecursive (int $pid, int $depth, int $begin, string $permsClause)
 
array filterPermittedElements ($recs, $table)
 
bool isPageAccessibleForCurrentUser ($table, array $record)
 
bool isLanguageAccessibleForCurrentUser ($table, array $record)
 
array fetchPagesWithVersionsInTable ($workspaceId, $tableName)
 
QueryBuilder createQueryBuilderForTable (string $tableName)
 

Static Protected Member Functions

static LanguageService null getLanguageService ()
 

Protected Attributes

array $versionsOnPageCache = array( )
 
array $pagesWithVersionsInTable = array( )
 

Detailed Description

Workspace service

Definition at line 35 of file WorkspaceService.php.

Member Function Documentation

◆ createQueryBuilderForTable()

QueryBuilder TYPO3\CMS\Workspaces\Service\WorkspaceService::createQueryBuilderForTable ( string  $tableName)
protected
Parameters
string$tableName
Returns
‪QueryBuilder

Definition at line 1059 of file WorkspaceService.php.

◆ fetchPagesWithVersionsInTable()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::fetchPagesWithVersionsInTable (   $workspaceId,
  $tableName 
)
protected

Gets all pages that have workspace versions in a particular table.

Result: [ 1 => true, 11 => true, 13 => true, 15 => true ],

Parameters
int$workspaceId
string$tableName
Returns
‪array

Definition at line 991 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Service\WorkspaceService\$pagesWithVersionsInTable, TYPO3\CMS\Core\Versioning\VersionState\NEW_PLACEHOLDER, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\getPagesWithVersionsInTable(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\hasPageRecordVersions().

◆ filterPermittedElements()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::filterPermittedElements (   $recs,
  $table 
)
protected

Remove all records which are not permitted for the user

Parameters
array$recs
string$table
Returns
‪array

Definition at line 795 of file WorkspaceService.php.

References TYPO3\CMS\Workspaces\Service\WorkspaceService\isLanguageAccessibleForCurrentUser(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\isPageAccessibleForCurrentUser().

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ getAvailableWorkspaces()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getAvailableWorkspaces ( )

retrieves the available workspaces from the database and checks whether they're available to the current BE user

Returns
‪array array of workspaces available to the current user

Definition at line 54 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Service\WorkspaceService\getWorkspaceTitle(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\LIVE_WORKSPACE_ID.

◆ getCmdArrayForFlushWS()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getCmdArrayForFlushWS (   $wsid,
  $flush = true,
  $pageId = 0,
  $language = null 
)

Building DataHandler CMD-array for releasing all versions in a workspace.

Parameters
int$wsid‪Real workspace ID, cannot be ONLINE (zero).
bool$flush‪Run Flush (TRUE) or ClearWSID (FALSE) command
int$pageId‪The page id
int$language‪Select specific language only
Returns
‪array Command array for DataHandler

Definition at line 190 of file WorkspaceService.php.

References TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ getCmdArrayForPublishWS()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getCmdArrayForPublishWS (   $wsid,
  $_ = false,
  $pageId = 0,
  $language = null 
)

Building DataHandler CMD-array for publishing all versions in a workspace.

Parameters
int$wsid‪Real workspace ID, cannot be ONLINE (zero).
bool$_‪Unused, previously used to choose between swapping and publishing
int$pageId‪The page id
int | null$language‪Select specific language only
Returns
‪array Command array for DataHandler

Definition at line 149 of file WorkspaceService.php.

References TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace(), and TYPO3\CMS\Workspaces\Service\StagesService\STAGE_PUBLISH_ID.

◆ getCurrentWorkspace()

int TYPO3\CMS\Workspaces\Service\WorkspaceService::getCurrentWorkspace ( )

Gets the current workspace ID.

Returns
‪int The current workspace ID

Definition at line 85 of file WorkspaceService.php.

References $GLOBALS.

◆ getLanguageService()

static LanguageService null TYPO3\CMS\Workspaces\Service\WorkspaceService::getLanguageService ( )
staticprotected
Returns
‪LanguageService|null

Definition at line 1072 of file WorkspaceService.php.

References $GLOBALS.

◆ getMovedRecordsFromPages()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getMovedRecordsFromPages (   $table,
  $pageList,
  $wsid,
  $stage 
)
protected

◆ getNewVersionsForPages()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getNewVersionsForPages ( string  $table,
string  $pageList,
int  $wsid,
int  $stage,
?int  $language 
)
protected

Find all versionized elements which are new (= do not have a live counterpart), so this method does not need to have a JOIN SQL statement.

Parameters
string$table
string$pageList
int$wsid
int$stage
int | null$language
Returns
‪array

Definition at line 417 of file WorkspaceService.php.

References $fields, $GLOBALS, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), TYPO3\CMS\Core\Versioning\VersionState\NEW_PLACEHOLDER, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ getPageChildrenRecursive()

int [] TYPO3\CMS\Workspaces\Service\WorkspaceService::getPageChildrenRecursive ( int  $pid,
int  $depth,
int  $begin,
string  $permsClause 
)
protected

Recursively fetch all children of a given page

Parameters
int$pid‪uid of the page
int$depth
int$begin
string$permsClause
Returns
‪int[] List of child row $uid's

Definition at line 761 of file WorkspaceService.php.

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

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\getTreeUids().

◆ getPagesWithVersionsInTable()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getPagesWithVersionsInTable (   $workspaceId)

Gets all pages that have workspace versions per table.

Result: [ 'sys_template' => [], 'tt_content' => [ 1 => true, 11 => true, 13 => true, 15 => true ], 'tx_something => [ 15 => true, 11 => true, 21 => true ], ]

Parameters
int$workspaceId
Returns
‪array

Definition at line 963 of file WorkspaceService.php.

References $GLOBALS, and TYPO3\CMS\Workspaces\Service\WorkspaceService\fetchPagesWithVersionsInTable().

◆ getPreviewLinkLifetime()

int TYPO3\CMS\Workspaces\Service\WorkspaceService::getPreviewLinkLifetime ( )

easy function to just return the number of hours.

a preview link is valid, based on the workspaces' custom value (default to 48 hours) or falls back to the users' TSconfig value "options.workspaces.previewLinkTTLHours".

by default, it's 48hs.

Returns
‪int The hours as a number

Definition at line 100 of file WorkspaceService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\__construct().

◆ getTreeUids()

string TYPO3\CMS\Workspaces\Service\WorkspaceService::getTreeUids (   $pageId,
  $wsid,
  $recursionLevel 
)
protected

◆ getWorkspaceTitle()

◆ hasPageRecordVersions()

bool TYPO3\CMS\Workspaces\Service\WorkspaceService::hasPageRecordVersions (   $workspaceId,
  $pageId 
)

Determines whether a page has workspace versions.

Parameters
int$workspaceId
int$pageId
Returns
‪bool

Definition at line 903 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Service\WorkspaceService\$versionsOnPageCache, and TYPO3\CMS\Workspaces\Service\WorkspaceService\fetchPagesWithVersionsInTable().

◆ isLanguageAccessibleForCurrentUser()

bool TYPO3\CMS\Workspaces\Service\WorkspaceService::isLanguageAccessibleForCurrentUser (   $table,
array  $record 
)
protected

Check current be users language access on given record.

Parameters
string$table‪Name of the table
array$record‪Record row to be checked
Returns
‪bool

Definition at line 837 of file WorkspaceService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\filterPermittedElements().

◆ isNewPage()

static bool TYPO3\CMS\Workspaces\Service\WorkspaceService::isNewPage (   $id,
  $language = 0 
)
static

Determine whether a specific page is new and not yet available in the LIVE workspace

Parameters
int$id‪Primary key of the page to check
int$language‪Language for which to check the page
Returns
‪bool

Definition at line 854 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Core\Type\Enumeration\cast(), TYPO3\CMS\Core\Versioning\VersionState\NEW_PLACEHOLDER, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Controller\PreviewController\handleRequest().

◆ isPageAccessibleForCurrentUser()

bool TYPO3\CMS\Workspaces\Service\WorkspaceService::isPageAccessibleForCurrentUser (   $table,
array  $record 
)
protected

Checking access to the page the record is on, respecting ignored root level restrictions

Parameters
string$table‪Name of the table
array$record‪Record row to be checked
Returns
‪bool

Definition at line 815 of file WorkspaceService.php.

References $GLOBALS, and TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW.

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\filterPermittedElements().

◆ selectAllVersionsFromPages()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::selectAllVersionsFromPages (   $table,
  $pageList,
  $wsid,
  $stage,
  $language = null 
)
protected

Find all versionized elements except moved and new records.

Parameters
string$table
string$pageList
int$wsid
int$stage
int$language
Returns
‪array

Definition at line 290 of file WorkspaceService.php.

References $fields, $GLOBALS, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), TYPO3\CMS\Core\Versioning\VersionState\MOVE_POINTER, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ selectVersionsInWorkspace()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::selectVersionsInWorkspace (   $wsid,
  $stage = -99,
  $pageId = -1,
  $recursionLevel = 0,
  $selectionType = 'tables_select',
  $language = null 
)

Select all records from workspace pending for publishing Used from backend to display workspace overview User for auto-publishing for selecting versions for publication

Parameters
int$wsid‪Workspace ID. If -99, will select ALL versions from ANY workspace. If -98 will select all but ONLINE. >=-1 will select from the actual workspace
int$stage‪Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10
int$pageId‪Page id: Live page for which to find versions in workspace!
int$recursionLevel‪Recursion Level - select versions recursive - parameter is only relevant if $pageId != -1
string$selectionType‪How to collect records for "listing" or "modify" these tables. Support the permissions of each type of record, see \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::check.
int$language‪Select specific language only
Returns
‪array Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oidfields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid

Definition at line 230 of file WorkspaceService.php.

References $GLOBALS, $output, TYPO3\CMS\Workspaces\Service\WorkspaceService\filterPermittedElements(), TYPO3\CMS\Workspaces\Service\WorkspaceService\getMovedRecordsFromPages(), TYPO3\CMS\Workspaces\Service\WorkspaceService\getNewVersionsForPages(), TYPO3\CMS\Workspaces\Service\WorkspaceService\getTreeUids(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\selectAllVersionsFromPages().

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\getCmdArrayForFlushWS(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\getCmdArrayForPublishWS().

Member Data Documentation

◆ $pagesWithVersionsInTable

array TYPO3\CMS\Workspaces\Service\WorkspaceService::$pagesWithVersionsInTable = array( )
protected

◆ $versionsOnPageCache

array TYPO3\CMS\Workspaces\Service\WorkspaceService::$versionsOnPageCache = array( )
protected

◆ LIVE_WORKSPACE_ID

◆ TABLE_WORKSPACE

const TYPO3\CMS\Workspaces\Service\WorkspaceService::TABLE_WORKSPACE = 'sys_workspace'