TYPO3 CMS  TYPO3_6-2
ExtDirectServer.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
29  protected $gridDataService;
30 
34  protected $stagesService;
35 
42  public function checkIntegrity(\stdClass $parameters) {
43  $integrity = $this->createIntegrityService($this->getAffectedElements($parameters));
44  $integrity->check();
45  $response = array(
46  'result' => $integrity->getStatusRepresentation()
47  );
48  return $response;
49  }
50 
57  public function getWorkspaceInfos($parameter) {
58  // To avoid too much work we use -1 to indicate that every page is relevant
59  $pageId = $parameter->id > 0 ? $parameter->id : -1;
60  if (!isset($parameter->language) || !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($parameter->language)) {
61  $parameter->language = NULL;
62  }
63  $versions = $this->getWorkspaceService()->selectVersionsInWorkspace($this->getCurrentWorkspace(), 0, -99, $pageId, $parameter->depth, 'tables_select', $parameter->language);
64  $data = $this->getGridDataService()->generateGridListFromVersions($versions, $parameter, $this->getCurrentWorkspace());
65  return $data;
66  }
67 
74  public function getHistory($parameters) {
76  $historyService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\HistoryService');
77  $history = $historyService->getHistory($parameters->table, $parameters->liveId);
78  return array(
79  'data' => $history,
80  'total' => count($history)
81  );
82  }
83 
90  public function getStageActions($parameter) {
91  $currentWorkspace = $this->getCurrentWorkspace();
92  $stages = array();
93  if ($currentWorkspace != \TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES) {
94  $stages = $this->getStagesService()->getStagesForWSUser();
95  }
96  $data = array(
97  'total' => count($stages),
98  'data' => $stages
99  );
100  return $data;
101  }
102 
109  public function getRowDetails($parameter) {
110  $diffReturnArray = array();
111  $liveReturnArray = array();
113  $t3lib_diff = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
115  $parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser');
116  $liveRecord = BackendUtility::getRecord($parameter->table, $parameter->t3ver_oid);
117  $versionRecord = BackendUtility::getRecord($parameter->table, $parameter->uid);
118  $icon_Live = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($parameter->table, $liveRecord);
119  $icon_Workspace = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($parameter->table, $versionRecord);
120  $stagePosition = $this->getStagesService()->getPositionOfCurrentStage($parameter->stage);
121  $fieldsOfRecords = array_keys($liveRecord);
122  if ($GLOBALS['TCA'][$parameter->table]) {
123  if ($GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']) {
124  $fieldsOfRecords = $GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList'];
125  $fieldsOfRecords = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fieldsOfRecords, TRUE);
126  }
127  }
128  foreach ($fieldsOfRecords as $fieldName) {
129  // check for exclude fields
130  if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0 || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) {
131  // call diff class only if there is a difference
132  if ((string)$liveRecord[$fieldName] !== (string)$versionRecord[$fieldName]) {
133  // Select the human readable values before diff
134  $liveRecord[$fieldName] = BackendUtility::getProcessedValue(
135  $parameter->table,
136  $fieldName,
137  $liveRecord[$fieldName],
138  0,
139  1,
140  FALSE,
141  $liveRecord['uid']
142  );
143  $versionRecord[$fieldName] = BackendUtility::getProcessedValue(
144  $parameter->table,
145  $fieldName,
146  $versionRecord[$fieldName],
147  0,
148  1,
149  FALSE,
150  $versionRecord['uid']
151  );
152  // Get the field's label. If not available, use the field name
153  $fieldTitle = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($parameter->table, $fieldName));
154  if (empty($fieldTitle)) {
155  $fieldTitle = $fieldName;
156  }
157  if ($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['type'] == 'group' && $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['internal_type'] == 'file') {
158  $versionThumb = BackendUtility::thumbCode($versionRecord, $parameter->table, $fieldName, '');
159  $liveThumb = BackendUtility::thumbCode($liveRecord, $parameter->table, $fieldName, '');
160  $diffReturnArray[] = array(
161  'field' => $fieldName,
162  'label' => $fieldTitle,
163  'content' => $versionThumb
164  );
165  $liveReturnArray[] = array(
166  'field' => $fieldName,
167  'label' => $fieldTitle,
168  'content' => $liveThumb
169  );
170  } else {
171  $diffReturnArray[] = array(
172  'field' => $fieldName,
173  'label' => $fieldTitle,
174  'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName])
175  );
176  $liveReturnArray[] = array(
177  'field' => $fieldName,
178  'label' => $fieldTitle,
179  'content' => $parseObj->TS_images_rte($liveRecord[$fieldName])
180  );
181  }
182  }
183  }
184  }
185  // Hook for modifying the difference and live arrays
186  // (this may be used by custom or dynamically-defined fields)
187  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'])) {
188  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'] as $className) {
189  $hookObject =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($className);
190  $hookObject->modifyDifferenceArray($parameter, $diffReturnArray, $liveReturnArray, $t3lib_diff);
191  }
192  }
193  $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table);
194  return array(
195  'total' => 1,
196  'data' => array(
197  array(
198  // these parts contain HTML (don't escape)
199  'diff' => $diffReturnArray,
200  'live_record' => $liveReturnArray,
201  'icon_Live' => $icon_Live,
202  'icon_Workspace' => $icon_Workspace,
203  // this part is already escaped in getCommentsForRecord()
204  'comments' => $commentsForRecord,
205  // escape/santinize the others
206  'path_Live' => htmlspecialchars($parameter->path_Live),
207  'label_Stage' => htmlspecialchars($parameter->label_Stage),
208  'stage_position' => (int)$stagePosition['position'],
209  'stage_count' => (int)$stagePosition['count']
210  )
211  )
212  );
213  }
214 
222  public function getCommentsForRecord($uid, $table) {
223  $sysLogReturnArray = array();
224  $sysLogRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('log_data,tstamp,userid', 'sys_log', 'action=6 and details_nr=30
225  AND tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_log') . '
226  AND recuid=' . (int)$uid, '', 'tstamp DESC');
227  foreach ($sysLogRows as $sysLogRow) {
228  $sysLogEntry = array();
229  $data = unserialize($sysLogRow['log_data']);
230  $beUserRecord = BackendUtility::getRecord('be_users', $sysLogRow['userid']);
231  $sysLogEntry['stage_title'] = $this->getStagesService()->getStageTitle($data['stage']);
232  $sysLogEntry['user_uid'] = $sysLogRow['userid'];
233  $sysLogEntry['user_username'] = is_array($beUserRecord) ? $beUserRecord['username'] : '';
234  $sysLogEntry['tstamp'] = BackendUtility::datetime($sysLogRow['tstamp']);
235  $sysLogEntry['user_comment'] = $data['comment'];
236  $sysLogReturnArray[] = $sysLogEntry;
237  }
238  return $sysLogReturnArray;
239  }
240 
246  public function getSystemLanguages() {
247  $systemLanguages = array(
248  array(
249  'uid' => 'all',
250  'title' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('language.allLanguages', 'workspaces'),
251  'cls' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses('empty-empty')
252  )
253  );
254  foreach ($this->getGridDataService()->getSystemLanguages() as $id => $systemLanguage) {
255  if ($id < 0) {
256  continue;
257  }
258  $systemLanguages[] = array(
259  'uid' => $id,
260  'title' => htmlspecialchars($systemLanguage['title']),
261  'cls' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses($systemLanguage['flagIcon'])
262  );
263  }
264  $result = array(
265  'total' => count($systemLanguages),
266  'data' => $systemLanguages
267  );
268  return $result;
269  }
270 
276  protected function getGridDataService() {
277  if (!isset($this->gridDataService)) {
278  $this->gridDataService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\GridDataService');
279  }
280  return $this->gridDataService;
281  }
282 
288  protected function getStagesService() {
289  if (!isset($this->stagesService)) {
290  $this->stagesService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService');
291  }
292  return $this->stagesService;
293  }
294 
295 }
$parameters
Definition: FileDumpEID.php:15
static getItemLabel($table, $col, $printAllWrap='')
$uid
Definition: server.php:36
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static mapRecordTypeToSpriteIconClass($table, array $row)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]