aaa87a8ec32fa97f3359e4b57bd182904c2fc7d0
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Service / Befunc.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
30 * @package Workspaces
31 * @subpackage Service
32 */
33 class tx_Workspaces_Service_Befunc {
34
35 /**
36 * Hooks into the t3lib_beFunc::viewOnClick and redirects to the workspace preview
37 * only if we're in a workspace and if the frontend-preview is disabled.
38 *
39 * @param $pageUid
40 * @param $backPath
41 * @param $rootLine
42 * @param $anchorSection
43 * @param $viewScript
44 * @param $additionalGetVars
45 * @param $switchFocus
46 * @return void
47 */
48 public function preProcess(&$pageUid, $backPath, $rootLine, $anchorSection, &$viewScript, $additionalGetVars, $switchFocus) {
49 if ($GLOBALS['BE_USER']->workspace !== 0) {
50 $viewScript = $this->getWorkspaceService()->generateWorkspaceSplittedPreviewLink($pageUid);
51 }
52 }
53
54 /**
55 * Find the Live-Uid for a given page,
56 * the results are cached at run-time to avoid too many database-queries
57 *
58 * @throws InvalidArgumentException
59 * @param integer $uid
60 * @return integer
61 * @deprecated since TYPO3 4.6 - use tx_Workspaces_Service_Workspaces::getLivePageUid() instead
62 */
63 protected function getLivePageUid($uid) {
64 t3lib_div::deprecationLog(__METHOD__ . ' is deprected since TYPO3 4.6 - use tx_Workspaces_Service_Workspaces::getLivePageUid() instead');
65 return $this->getWorkspaceService()->getLivePageUid($uid);
66 }
67
68 /**
69 * Gets an instance of the workspaces service.
70 *
71 * @return tx_Workspaces_Service_Workspaces
72 */
73 protected function getWorkspaceService() {
74 return t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
75 }
76
77 /**
78 * Use that hook to show a info message in case someone starts editing
79 * a staged element
80 *
81 * @param $params
82 * @param $form
83 * @return boolean
84 */
85 public function makeEditForm_accessCheck($params, &$form) {
86 if ($GLOBALS['BE_USER']->workspace !== 0 && $GLOBALS['TCA'][$params['table']]['ctrl']['versioningWS']) {
87 $record = t3lib_BEfunc::getRecordWSOL($params['table'], $params['uid']);
88 if (abs($record['t3ver_stage']) > Tx_Workspaces_Service_Stages::STAGE_EDIT_ID) {
89 $stages = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
90 $stageName = $stages->getStageTitle($record['t3ver_stage']);
91 $editingName = $stages->getStageTitle(Tx_Workspaces_Service_Stages::STAGE_EDIT_ID);
92 $message = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified');
93 $flashMessage = t3lib_div::makeInstance(
94 't3lib_FlashMessage',
95 sprintf($message, $stageName, $editingName),
96 '',
97 t3lib_FlashMessage::INFO,
98 TRUE
99 );
100 t3lib_FlashMessageQueue::addMessage($flashMessage);
101 }
102 }
103 return $params['hasAccess'];
104 }
105 }
106
107 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Befunc.php'])) {
108 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Befunc.php']);
109 }
110 ?>