TYPO3 CMS  TYPO3_7-6
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 
80  {
81  $this->backgroundColor = $backgroundColor;
82  }
83 
89  public function getBackgroundColor()
90  {
92  }
93 
100  public function setWorkspaceId($workspaceId)
101  {
102  $this->workspaceId = (int)$workspaceId;
103  }
104 
110  public function getWorkspaceId()
111  {
112  return $this->workspaceId;
113  }
114 
121  {
122  $this->stopPageTree = (bool)$stopPageTree;
123  }
124 
130  public function getStopPageTree()
131  {
132  return $this->stopPageTree;
133  }
134 
141  public function setMountPoint($mountPoint)
142  {
143  $this->mountPoint = (int)$mountPoint;
144  }
145 
151  public function getMountPoint()
152  {
153  return $this->mountPoint;
154  }
155 
163  {
164  $this->isMountPoint = $isMountPoint == true;
165  }
166 
172  public function isMountPoint()
173  {
174  return $this->isMountPoint;
175  }
176 
183  public function setReadableRootline($rootline)
184  {
185  $this->readableRootline = $rootline;
186  }
187 
193  public function getReadableRootline()
194  {
196  }
197 
203  protected function canCreate()
204  {
205  if (!isset($this->cachedAccessRights['create'])) {
206  $this->cachedAccessRights['create'] = $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 8);
207  }
208  return $this->cachedAccessRights['create'];
209  }
210 
216  protected function canEdit()
217  {
218  if (!isset($this->cachedAccessRights['edit'])) {
219  $this->cachedAccessRights['edit'] =
220  $GLOBALS['BE_USER']->isAdmin()
221  || (
222  (int)$this->record['editlock'] === 0
223  && $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 2)
224  );
225  }
226  return $this->cachedAccessRights['edit'];
227  }
228 
234  protected function canRemove()
235  {
236  if (!isset($this->cachedAccessRights['remove'])) {
237  $this->cachedAccessRights['remove'] =
238  $GLOBALS['BE_USER']->isAdmin()
239  || (
240  (int)$this->record['editlock'] === 0
241  && $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 4)
242  );
243  if (!$this->isLeafNode() && !$GLOBALS['BE_USER']->uc['recursiveDelete']) {
244  $this->cachedAccessRights['remove'] = false;
245  }
246  }
247  return $this->cachedAccessRights['remove'];
248  }
249 
255  public function canBeDisabledAndEnabled()
256  {
257  return $this->canEdit($this->record) && $GLOBALS['BE_USER']->checkLanguageAccess(0);
258  }
259 
265  public function canBeCut()
266  {
267  return
268  $this->canEdit($this->record)
269  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
270  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
271  ;
272  }
273 
279  public function canBeEdited()
280  {
281  return $this->canEdit($this->record) && $GLOBALS['BE_USER']->checkLanguageAccess(0);
282  }
283 
289  public function canBeCopied()
290  {
291  return
292  $GLOBALS['BE_USER']->doesUserHaveAccess($this->record, 1)
293  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
294  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
295  ;
296  }
297 
303  public function canCreateNewPages()
304  {
305  return $this->canCreate($this->record) && $GLOBALS['BE_USER']->checkLanguageAccess(0);
306  }
307 
313  public function canBeRemoved()
314  {
315  return
316  $this->canRemove($this->record)
317  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
318  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
319  ;
320  }
321 
327  public function canBePastedInto()
328  {
329  return
330  $this->canCreate($this->record)
331  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
332  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
333  ;
334  }
335 
341  public function canBePastedAfter()
342  {
343  return
344  $this->canCreate($this->record)
345  && !VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
346  && $GLOBALS['BE_USER']->checkLanguageAccess(0)
347  ;
348  }
349 
355  public function canShowHistory()
356  {
357  return $GLOBALS['BE_USER']->checkLanguageAccess(0);
358  }
359 
365  public function canBeViewed()
366  {
367  return !$this->isDeleted();
368  }
369 
375  public function canShowInfo()
376  {
377  return true;
378  }
379 
385  public function canBeTemporaryMountPoint()
386  {
387  return true;
388  }
389 
395  public function isDeleted()
396  {
397  return
398  !empty($this->record['deleted'])
399  || VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)
400  ;
401  }
402 
409  public function calculateNodeId($prefix = 'p')
410  {
411  return $prefix . dechex($this->getId()) . ($this->getMountPoint() ? '-' . dechex($this->getMountPoint()) : '');
412  }
413 
420  public function toArray($addChildNodes = true)
421  {
422  $arrayRepresentation = parent::toArray();
423  $arrayRepresentation['id'] = $this->calculateNodeId();
424  $arrayRepresentation['realId'] = $this->getId();
425  $arrayRepresentation['nodeData']['id'] = $this->getId();
426  $arrayRepresentation['readableRootline'] = $this->getReadableRootline();
427  $arrayRepresentation['canBeRemoved'] = $this->canBeRemoved();
428  $arrayRepresentation['nodeData']['readableRootline'] = $this->getReadableRootline();
429  $arrayRepresentation['nodeData']['mountPoint'] = $this->getMountPoint();
430  $arrayRepresentation['nodeData']['workspaceId'] = $this->getWorkspaceId();
431  $arrayRepresentation['nodeData']['isMountPoint'] = $this->isMountPoint();
432  $arrayRepresentation['nodeData']['backgroundColor'] = htmlspecialchars($this->getBackgroundColor());
433  $arrayRepresentation['nodeData']['stopPageTree'] = $this->getStopPageTree();
434  $arrayRepresentation['nodeData']['serializeClassName'] = get_class($this);
435  return $arrayRepresentation;
436  }
437 
444  public function dataFromArray($data)
445  {
446  parent::dataFromArray($data);
447  $this->setWorkspaceId($data['workspaceId']);
448  $this->setMountPoint($data['mountPoint']);
449  $this->setReadableRootline($data['readableRootline']);
450  $this->setIsMountPoint($data['isMountPoint']);
451  $this->setBackgroundColor($data['backgroundColor']);
452  }
453 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']