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

Public Member Functions

 getAvailableWorkspaces ()
 
 getCurrentWorkspace ()
 
 getCmdArrayForPublishWS ($wsid, $doSwap, $pageId=0, $language=null)
 
 getCmdArrayForFlushWS ($wsid, $flush=true, $pageId=0, $language=null)
 
 selectVersionsInWorkspace ($wsid, $filter=0, $stage=-99, $pageId=-1, $recursionLevel=0, $selectionType= 'tables_select', $language=null)
 
 canCreatePreviewLink ($pageUid, $workspaceUid)
 
 generateWorkspacePreviewLink ($uid)
 
 generateWorkspacePreviewLinksForAllLanguages ($uid)
 
 getLivePageUid ($uid)
 
 hasPageRecordVersions ($workspace, $pageId)
 

Static Public Member Functions

static getWorkspaceTitle ($wsId)
 
static isOldStyleWorkspaceUsed ()
 
static isNewPage ($id, $language=0)
 
static viewSingleRecord ($table, $uid, array $liveRecord=null, array $versionRecord=null)
 

Public Attributes

const TABLE_WORKSPACE = 'sys_workspace'
 
const SELECT_ALL_WORKSPACES = -98
 
const LIVE_WORKSPACE_ID = 0
 

Protected Member Functions

 selectAllVersionsFromPages ($table, $pageList, $wsid, $filter, $stage, $language=null)
 
 getMoveToPlaceHolderFromPages ($table, $pageList, $wsid, $filter, $stage)
 
 filterPermittedElements ($recs, $table)
 
 isPageAccessibleForCurrentUser ($table, array $record)
 
 isLanguageAccessibleForCurrentUser ($table, array $record)
 
 getDatabaseConnection ()
 
 getObjectManager ()
 

Protected Attributes

 $pageCache = array()
 
 $versionsOnPageCache = array()
 

Detailed Description

Workspace service

Definition at line 26 of file WorkspaceService.php.

Member Function Documentation

canCreatePreviewLink (   $pageUid,
  $workspaceUid 
)

Determine whether this page for the current

Parameters
int$pageUid
int$workspaceUid
Returns
bool

Definition at line 617 of file WorkspaceService.php.

References $GLOBALS, Enumeration\cast(), VersionState\DELETE_PLACEHOLDER, BackendUtility\getRecord(), GeneralUtility\inList(), and BackendUtility\workspaceOL().

filterPermittedElements (   $recs,
  $table 
)
protected

Remove all records which are not permitted for the user

Parameters
array$recs
string$table
Returns
array

Definition at line 433 of file WorkspaceService.php.

References WorkspaceService\isLanguageAccessibleForCurrentUser(), and WorkspaceService\isPageAccessibleForCurrentUser().

Referenced by WorkspaceService\selectVersionsInWorkspace().

generateWorkspacePreviewLink (   $uid)

Generates a workspace preview link.

Parameters
int$uidThe ID of the record to be linked
Returns
string the full domain including the protocol http:// or https://, but without the trailing '/'

Definition at line 641 of file WorkspaceService.php.

References $GLOBALS, WorkspaceService\getCurrentWorkspace(), GeneralUtility\implodeArrayForUrl(), and GeneralUtility\makeInstance().

Referenced by WorkspaceService\generateWorkspacePreviewLinksForAllLanguages().

generateWorkspacePreviewLinksForAllLanguages (   $uid)

Generate workspace preview links for all available languages of a page

Parameters
int$uid
Returns
array

Definition at line 687 of file WorkspaceService.php.

References WorkspaceService\generateWorkspacePreviewLink().

getAvailableWorkspaces ( )

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

Returns
array array of worspaces available to the current user

Definition at line 47 of file WorkspaceService.php.

References $GLOBALS, and BackendUtility\deleteClause().

Referenced by WorkspaceService\getCurrentWorkspace().

getCmdArrayForFlushWS (   $wsid,
  $flush = true,
  $pageId = 0,
  $language = null 
)

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

Parameters
intReal workspace ID, cannot be ONLINE (zero).
boolRun Flush (TRUE) or ClearWSID (FALSE) command
int$pageIdThe page id
int$languageSelect specific language only
Returns
array Command array for tcemain

Definition at line 162 of file WorkspaceService.php.

References WorkspaceService\selectVersionsInWorkspace().

getCmdArrayForPublishWS (   $wsid,
  $doSwap,
  $pageId = 0,
  $language = null 
)

Building tcemain CMD-array for swapping all versions in a workspace.

Parameters
intReal workspace ID, cannot be ONLINE (zero).
boolIf set, then the currently online versions are swapped into the workspace in exchange for the offline versions. Otherwise the workspace is emptied.
int$pageIdThe page id
int$languageSelect specific language only
Returns
array Command array for tcemain

Definition at line 127 of file WorkspaceService.php.

References BackendUtility\getRecord(), and WorkspaceService\selectVersionsInWorkspace().

getCurrentWorkspace ( )

Gets the current workspace ID.

Returns
int The current workspace ID

Definition at line 71 of file WorkspaceService.php.

References $GLOBALS, and WorkspaceService\getAvailableWorkspaces().

Referenced by WorkspaceService\generateWorkspacePreviewLink().

getDatabaseConnection ( )
protected
getLivePageUid (   $uid)

Find the Live-Uid for a given page, the results are cached at run-time to avoid too many database-queries

Exceptions
\InvalidArgumentException
Parameters
int$uid
Returns
int

Definition at line 708 of file WorkspaceService.php.

References BackendUtility\getRecord().

getMoveToPlaceHolderFromPages (   $table,
  $pageList,
  $wsid,
  $filter,
  $stage 
)
protected

Find all moved records at their new position.

Parameters
string$table
string$pageList
int$wsid
int$filter
int$stage
Returns
array

Definition at line 320 of file WorkspaceService.php.

References VersionState\DEFAULT_STATE, BackendUtility\deleteClause(), elseif, WorkspaceService\getDatabaseConnection(), VersionState\MOVE_PLACEHOLDER, and VersionState\MOVE_POINTER.

Referenced by WorkspaceService\selectVersionsInWorkspace().

getObjectManager ( )
protected
Returns

Definition at line 785 of file WorkspaceService.php.

References GeneralUtility\makeInstance().

static getWorkspaceTitle (   $wsId)
static

Find the title for the requested workspace.

Parameters
int$wsId
Returns
string
Exceptions
\InvalidArgumentException

Definition at line 98 of file WorkspaceService.php.

References $GLOBALS, and BackendUtility\getRecord().

Referenced by PageTreeNavigationController\getWorkspaceInfo(), ToolbarMenu\setWorkspace(), and AjaxController\switchWorkspaceAction().

hasPageRecordVersions (   $workspace,
  $pageId 
)

Checks if a page has record versions according to a given workspace

Parameters
int$workspace
int$pageId
Returns
bool

Definition at line 728 of file WorkspaceService.php.

References $GLOBALS, BackendUtility\deleteClause(), WorkspaceService\getDatabaseConnection(), and VersionState\MOVE_POINTER.

isLanguageAccessibleForCurrentUser (   $table,
array  $record 
)
protected

Check current be users language access on given record.

Parameters
string$tableName of the table
array$recordRecord row to be checked
Returns
bool

Definition at line 475 of file WorkspaceService.php.

References $GLOBALS, and BackendUtility\isTableLocalizable().

Referenced by WorkspaceService\filterPermittedElements().

static isNewPage (   $id,
  $language = 0 
)
static

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

Parameters
int$idPrimary key of the page to check
int$languageLanguage for which to check the page
Returns
bool

Definition at line 513 of file WorkspaceService.php.

References $GLOBALS, Enumeration\cast(), BackendUtility\deleteClause(), BackendUtility\getRecord(), and VersionState\NEW_PLACEHOLDER.

static isOldStyleWorkspaceUsed ( )
static

Trivial check to see if the user already migrated his workspaces to the new style (either manually or with the migrator scripts)

Returns
bool

Definition at line 491 of file WorkspaceService.php.

References $GLOBALS.

isPageAccessibleForCurrentUser (   $table,
array  $record 
)
protected

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

Parameters
string$tableName of the table
array$recordRecord row to be checked
Returns
bool

Definition at line 453 of file WorkspaceService.php.

References $GLOBALS, BackendUtility\getRecord(), and BackendUtility\isRootLevelRestrictionIgnored().

Referenced by WorkspaceService\filterPermittedElements().

selectAllVersionsFromPages (   $table,
  $pageList,
  $wsid,
  $filter,
  $stage,
  $language = null 
)
protected

Find all versionized elements except moved records.

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

Definition at line 250 of file WorkspaceService.php.

References $GLOBALS, MathUtility\canBeInterpretedAsInteger(), BackendUtility\deleteClause(), elseif, WorkspaceService\getDatabaseConnection(), BackendUtility\isRootLevelRestrictionIgnored(), BackendUtility\isTableLocalizable(), and VersionState\MOVE_POINTER.

Referenced by WorkspaceService\selectVersionsInWorkspace().

selectVersionsInWorkspace (   $wsid,
  $filter = 0,
  $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
intWorkspace ID. If -99, will select ALL versions from ANY workspace. If -98 will select all but ONLINE. >=-1 will select from the actual workspace
intLifecycle filter: 1 = select all drafts (never-published), 2 = select all published one or more times (archive/multiple), anything else selects all.
intStage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10
intPage id: Live page for which to find versions in workspace!
intRecursion Level - select versions recursive - parameter is only relevant if $pageId != -1
stringHow to collect records for "listing" or "modify" these tables. Support the permissions of each type of record, see ::check.
int$languageSelect 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 196 of file WorkspaceService.php.

References $GLOBALS, elseif, WorkspaceService\filterPermittedElements(), WorkspaceService\getMoveToPlaceHolderFromPages(), and WorkspaceService\selectAllVersionsFromPages().

Referenced by WorkspaceService\getCmdArrayForFlushWS(), and WorkspaceService\getCmdArrayForPublishWS().

static viewSingleRecord (   $table,
  $uid,
array  $liveRecord = null,
array  $versionRecord = null 
)
static

Generates a view link for a page.

Parameters
string$tableTable to be used
int$uidUid of the version(!) record
array$liveRecordOptional live record data
array$versionRecordOptional version record data
Returns
string

Definition at line 545 of file WorkspaceService.php.

References $GLOBALS, GeneralUtility\callUserFunction(), Enumeration\cast(), elseif, BackendUtility\getLiveVersionIdOfRecord(), BackendUtility\getLiveVersionOfRecord(), BackendUtility\getMovePlaceholder(), BackendUtility\getPagesTSconfig(), BackendUtility\getRecord(), BackendUtility\isTableLocalizable(), VersionState\MOVE_POINTER, and BackendUtility\viewOnClick().

Member Data Documentation

$pageCache = array()
protected

Definition at line 31 of file WorkspaceService.php.

$versionsOnPageCache = array()
protected

Definition at line 36 of file WorkspaceService.php.

const LIVE_WORKSPACE_ID = 0

Definition at line 40 of file WorkspaceService.php.

Referenced by MassActionHandler\getMassStageActions().

const SELECT_ALL_WORKSPACES = -98
const TABLE_WORKSPACE = 'sys_workspace'

Definition at line 38 of file WorkspaceService.php.