TYPO3 CMS  TYPO3_8-7
PagetreeNode.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
29  protected $cachedAccessRights = [];
30 
36  protected $workspaceId = 0;
37 
43  protected $mountPoint = 0;
44 
50  protected $readableRootline = '';
51 
57  protected $isMountPoint = false;
58 
64  protected $stopPageTree = false;
65 
71  protected $backgroundColor = '';
72 
79  {
80  $this->backgroundColor = $backgroundColor;
81  }
82 
88  public function getBackgroundColor()
89  {
91  }
92 
98  public function setWorkspaceId($workspaceId)
99  {
100  $this->workspaceId = (int)$workspaceId;
101  }
102 
108  public function getWorkspaceId()
109  {
110  return $this->workspaceId;
111  }
112 
119  {
120  $this->stopPageTree = (bool)$stopPageTree;
121  }
122 
128  public function getStopPageTree()
129  {
130  return $this->stopPageTree;
131  }
132 
138  public function setMountPoint($mountPoint)
139  {
140  $this->mountPoint = (int)$mountPoint;
141  }
142 
148  public function getMountPoint()
149  {
150  return $this->mountPoint;
151  }
152 
159  {
160  $this->isMountPoint = $isMountPoint == true;
161  }
162 
168  public function isMountPoint()
169  {
170  return $this->isMountPoint;
171  }
172 
178  public function setReadableRootline($rootline)
179  {
180  $this->readableRootline = $rootline;
181  }
182 
188  public function getReadableRootline()
189  {
191  }
192 
198  protected function canCreate()
199  {
200  if (!isset($this->cachedAccessRights['create'])) {
201  $this->cachedAccessRights['create'] = $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 8);
202  }
203  return $this->cachedAccessRights['create'];
204  }
205 
211  protected function canEdit()
212  {
213  if (!isset($this->cachedAccessRights['edit'])) {
214  $this->cachedAccessRights['edit'] =
215  $GLOBALS['BE_USER']->isAdmin()
216  || (
217  (int)$this->record['editlock'] === 0
218  && $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 2)
219  );
220  }
221  return $this->cachedAccessRights['edit'];
222  }
223 
229  protected function canRemove()
230  {
231  if (!isset($this->cachedAccessRights['remove'])) {
232  $this->cachedAccessRights['remove'] =
233  $GLOBALS['BE_USER']->isAdmin()
234  || (
235  (int)$this->record['editlock'] === 0
236  && $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 4)
237  );
238  if (!$this->isLeafNode() && !$GLOBALS['BE_USER']->uc['recursiveDelete']) {
239  $this->cachedAccessRights['remove'] = false;
240  }
241  }
242  return $this->cachedAccessRights['remove'];
243  }
244 
250  public function canBeDisabledAndEnabled()
251  {
252  return $this->canEdit() && $GLOBALS['BE_USER']->checkLanguageAccess(0);
253  }
254 
260  public function canBeCut()
261  {
262  return
263  $this->canEdit()
264  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
265  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
266  ;
267  }
268 
274  public function canBeEdited()
275  {
276  return $this->canEdit() && $GLOBALS['BE_USER']->checkLanguageAccess(0);
277  }
278 
284  public function canBeCopied()
285  {
286  return
287  $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 1)
288  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
289  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
290  ;
291  }
292 
298  public function canCreateNewPages()
299  {
300  return $this->canCreate() && $GLOBALS['BE_USER']->checkLanguageAccess(0);
301  }
302 
308  public function canBeRemoved()
309  {
310  return
311  $this->canRemove()
312  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
313  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
314  ;
315  }
316 
322  public function canBePastedInto()
323  {
324  return
325  $this->canCreate()
326  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
327  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
328  ;
329  }
330 
336  public function canBePastedAfter()
337  {
338  return
339  $this->canCreate()
340  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
341  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
342  ;
343  }
344 
350  public function canShowHistory()
351  {
352  return $GLOBALS['BE_USER']->checkLanguageAccess(0);
353  }
354 
360  public function canBeViewed()
361  {
362  return !$this->isDeleted();
363  }
364 
370  public function canShowInfo()
371  {
372  return true;
373  }
374 
380  public function canBeTemporaryMountPoint()
381  {
382  return true;
383  }
384 
390  public function isDeleted()
391  {
392  return
393  !empty($this->record['deleted'])
394  || VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
395  ;
396  }
397 
404  public function calculateNodeId($prefix = 'p')
405  {
406  return $prefix . dechex($this->getId()) . ($this->getMountPoint() ? '-' . dechex($this->getMountPoint()) : '');
407  }
408 
415  public function toArray($addChildNodes = true)
416  {
417  $arrayRepresentation = parent::toArray();
418  $arrayRepresentation['id'] = $this->calculateNodeId();
419  $arrayRepresentation['realId'] = $this->getId();
420  $arrayRepresentation['nodeData']['id'] = $this->getId();
421  $arrayRepresentation['readableRootline'] = $this->getReadableRootline();
422  $arrayRepresentation['canBeRemoved'] = $this->canBeRemoved();
423  $arrayRepresentation['nodeData']['readableRootline'] = $this->getReadableRootline();
424  $arrayRepresentation['nodeData']['mountPoint'] = $this->getMountPoint();
425  $arrayRepresentation['nodeData']['workspaceId'] = $this->getWorkspaceId();
426  $arrayRepresentation['nodeData']['isMountPoint'] = $this->isMountPoint();
427  $arrayRepresentation['nodeData']['backgroundColor'] = htmlspecialchars($this->getBackgroundColor());
428  $arrayRepresentation['nodeData']['stopPageTree'] = $this->getStopPageTree();
429  $arrayRepresentation['nodeData']['serializeClassName'] = get_class($this);
430  return $arrayRepresentation;
431  }
432 
438  public function dataFromArray($data)
439  {
440  parent::dataFromArray($data);
441  $this->setWorkspaceId($data['workspaceId']);
442  $this->setMountPoint($data['mountPoint']);
443  $this->setReadableRootline($data['readableRootline']);
444  $this->setIsMountPoint($data['isMountPoint']);
445  $this->setBackgroundColor($data['backgroundColor']);
446  }
447 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']