TYPO3 CMS  TYPO3_6-2
ExtDirectNode.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Tree;
3 
22 
28  protected $type = '';
29 
35  protected $leaf = TRUE;
36 
42  protected $expanded = FALSE;
43 
49  protected $expandable = FALSE;
50 
56  protected $draggable = TRUE;
57 
63  protected $isDropTarget = TRUE;
64 
70  protected $text = '';
71 
77  protected $editableText = '';
78 
84  protected $prefix = '';
85 
91  protected $suffix = '';
92 
98  protected $cls = '';
99 
105  protected $qtip = '';
106 
112  protected $spriteIconCode = '';
113 
119  protected $t3TextSourceField = '';
120 
126  protected $t3InCopyMode = FALSE;
127 
133  protected $t3InCutMode = FALSE;
134 
140  protected $record = array();
141 
147  protected $contextInfo = array();
148 
154  protected $labelIsEditable = TRUE;
155 
161  protected $allowChildren = TRUE;
162 
169  public function setType($type) {
170  $this->type = $type;
171  }
172 
178  public function getType() {
179  return $this->type;
180  }
181 
188  public function setLeaf($isLeaf) {
189  $this->leaf = $isLeaf == TRUE;
190  }
191 
197  public function isLeafNode() {
198  return $this->leaf;
199  }
200 
207  public function setExpandable($expandable) {
208  $this->expandable = $expandable == TRUE;
209  }
210 
216  public function isExpandable() {
217  return $this->expandable;
218  }
219 
226  public function setExpanded($expanded) {
227  $this->expanded = $expanded == TRUE;
228  }
229 
235  public function isExpanded() {
236  if ($this->isLeafNode()) {
237  return TRUE;
238  }
239  return $this->expanded;
240  }
241 
248  public function setDraggable($draggable) {
249  $this->draggable = $draggable == TRUE;
250  }
251 
257  public function isDraggable() {
258  return $this->draggable;
259  }
260 
267  public function setIsDropTarget($isDropTarget) {
268  $this->isDropTarget = $isDropTarget == TRUE;
269  }
270 
276  public function isDropTarget() {
277  return $this->isDropTarget;
278  }
279 
289  public function setText($text, $textSourceField = 'title', $prefix = '', $suffix = '') {
290  $this->text = $text;
291  $this->t3TextSourceField = $textSourceField;
292  $this->prefix = $prefix;
293  $this->suffix = $suffix;
294  }
295 
301  public function getText() {
302  return $this->text;
303  }
304 
311  public function setEditableText($editableText) {
312  $this->editableText = $editableText;
313  }
314 
320  public function getEditableText() {
321  return $this->editableText;
322  }
323 
329  public function getTextSourceField() {
331  }
332 
339  public function setInCopyMode($inCopyMode) {
340  $this->t3InCopyMode = $inCopyMode == TRUE;
341  }
342 
348  public function isInCopyMode() {
349  return $this->t3InCopyMode;
350  }
351 
358  public function setInCutMode($inCutMode) {
359  $this->t3InCutMode = $inCutMode == TRUE;
360  }
361 
367  public function isInCutMode() {
368  return $this->t3InCutMode;
369  }
370 
376  public function getPrefix() {
377  return $this->prefix;
378  }
379 
385  public function getSuffix() {
386  return $this->suffix;
387  }
388 
395  public function setCls($class) {
396  $this->cls = $class;
397  }
398 
404  public function getCls() {
405  return $this->cls;
406  }
407 
414  public function setQTip($qtip) {
415  $this->qtip = $qtip;
416  }
417 
423  public function getQTip() {
424  return $this->qtip;
425  }
426 
433  public function setSpriteIconCode($spriteIcon) {
434  $this->spriteIconCode = $spriteIcon;
435  }
436 
442  public function getSpriteIconCode() {
443  return $this->spriteIconCode;
444  }
445 
453  $this->labelIsEditable = $labelIsEditable == TRUE;
454  }
455 
461  public function isLabelEditable() {
462  return $this->labelIsEditable;
463  }
464 
471  public function setRecord($record) {
472  $this->record = (array) $record;
473  }
474 
480  public function getRecord() {
481  return $this->record;
482  }
483 
490  public function setContextInfo($contextInfo) {
491  $this->contextInfo = (array) $contextInfo;
492  }
493 
499  public function getContextInfo() {
500  return (array) $this->contextInfo;
501  }
502 
509  public function setChildNodes(\TYPO3\CMS\Backend\Tree\TreeNodeCollection $childNodes) {
510  parent::setChildNodes($childNodes);
511  if ($childNodes->count()) {
512  $this->setLeaf(FALSE);
513  }
514  }
515 
522  public function setAllowChildren($allowChildren) {
523  $this->allowChildren = $allowChildren == TRUE;
524  }
525 
531  public function canHaveChildren() {
532  return $this->allowChildren;
533  }
534 
541  public function toArray($addChildNodes = TRUE) {
542  $arrayRepresentation = array(
543  'serializeClassName' => get_class($this),
544  'id' => $this->getId(),
545  'type' => $this->getType(),
546  'editableText' => $this->getEditableText(),
547  'text' => $this->getPrefix() . $this->getText() . $this->getSuffix(),
548  'cls' => $this->getCls(),
549  'prefix' => $this->getPrefix(),
550  'suffix' => $this->getSuffix(),
551  'qtip' => $this->getQTip(),
552  'expanded' => $this->isExpanded(),
553  'expandable' => $this->isExpandable(),
554  'draggable' => $this->isDraggable(),
555  'isTarget' => $this->isDropTarget(),
556  'spriteIconCode' => $this->getSpriteIconCode(),
557  't3TextSourceField' => $this->getTextSourceField(),
558  't3InCopyMode' => $this->isInCopyMode(),
559  't3InCutMode' => $this->isInCutMode(),
560  't3ContextInfo' => $this->getContextInfo(),
561  'editable' => $this->isLabelEditable(),
562  'allowChildren' => $this->canHaveChildren()
563  );
564  // only set the leaf attribute if the node has children's,
565  // otherwise you cannot add child's to real leaf nodes
566  if (!$this->isLeafNode()) {
567  $arrayRepresentation['leaf'] = FALSE;
568  }
569  // Suhosin(?) or some other strange environment thingy prevents
570  // the direct copy of an array into an index of the same array
571  $copy = $arrayRepresentation;
572  $arrayRepresentation['nodeData'] = $copy;
573  if ($this->hasChildNodes()) {
574  $arrayRepresentation['children'] = $this->childNodes->toArray();
575  }
576  return $arrayRepresentation;
577  }
578 
585  public function dataFromArray($data) {
586  parent::dataFromArray($data);
587  $this->setType($data['type']);
588  $this->setText($data['label'], $data['t3TextSourceField'], $data['prefix'], $data['suffix']);
589  $this->setEditableText($data['editableText']);
590  $this->setCls($data['cls']);
591  $this->setQTip($data['qtip']);
592  $this->setExpanded($data['expanded']);
593  $this->setExpandable($data['expandable']);
594  $this->setDraggable($data['draggable']);
595  $this->setIsDropTarget($data['isTarget']);
596  $this->setSpriteIconCode($data['spriteIconCode']);
597  $this->setInCopyMode($data['t3InCopyMode']);
598  $this->setInCutMode($data['t3InCutMode']);
599  $this->setContextInfo($data['t3ContextInfo']);
600  $this->setLabelIsEditable($data['editable']);
601  $this->setAllowChildren($data['allowChildren']);
602  // only set the leaf attribute if it's applied
603  // otherwise you cannot insert nodes into this one
604  if (isset($data['leaf'])) {
605  $this->setLeaf(FALSE);
606  }
607  }
608 
609 }
setText($text, $textSourceField='title', $prefix='', $suffix='')
setChildNodes(\TYPO3\CMS\Backend\Tree\TreeNodeCollection $childNodes)