/** * Render a node label * * @param \TYPO3\TYPO3CR\Domain\Model\AbstractNodeData $nodeData * @param boolean $crop This argument is deprecated as of Neos 1.2 and will be removed. Don't rely on this behavior and crop labels in the view. * @return string */ public function getLabel(AbstractNodeData $nodeData, $crop = true) { if ($nodeData->hasProperty('title') === true && $nodeData->getProperty('title') !== '') { $label = strip_tags($nodeData->getProperty('title')); } elseif ($nodeData->hasProperty('text') === true && $nodeData->getProperty('text') !== '') { $label = strip_tags($nodeData->getProperty('text')); } else { $label = ($nodeData->getNodeType()->getLabel() ?: $nodeData->getNodeType()->getName()) . ' (' . $nodeData->getName() . ')'; } if ($crop === false) { return $label; } $croppedLabel = \TYPO3\Flow\Utility\Unicode\Functions::substr($label, 0, 30); return $croppedLabel . (strlen($croppedLabel) < strlen($label) ? ' …' : ''); }
/** * Render a node label * * @param \TYPO3\TYPO3CR\Domain\Model\AbstractNodeData $nodeData * @param boolean $crop * @return string */ public function getLabel(AbstractNodeData $nodeData, $crop = TRUE) { if ($nodeData->hasProperty('title') === TRUE && $nodeData->getProperty('title') !== '') { $label = strip_tags($nodeData->getProperty('title')); } elseif ($nodeData->hasProperty('text') === TRUE && $nodeData->getProperty('text') !== '') { $label = strip_tags($nodeData->getProperty('text')); } else { $label = ($nodeData->getNodeType()->getLabel() ?: $nodeData->getNodeType()->getName()) . ' (' . $nodeData->getName() . ')'; } if ($crop === FALSE) { return $label; } $croppedLabel = \TYPO3\Flow\Utility\Unicode\Functions::substr($label, 0, NodeInterface::LABEL_MAXIMUM_CHARACTERS); return $croppedLabel . (strlen($croppedLabel) < strlen($label) ? ' …' : ''); }
/** * Make the node "similar" to the given source node. That means, * - all properties * - index * - node type * - content object * will be set to the same values as in the source node. * * @param \TYPO3\TYPO3CR\Domain\Model\AbstractNodeData $sourceNode * @param boolean $isCopy * @return void */ public function similarize(AbstractNodeData $sourceNode, $isCopy = false) { $this->properties = array(); foreach ($sourceNode->getProperties() as $propertyName => $propertyValue) { $this->setProperty($propertyName, $propertyValue); } $propertyNames = array('nodeType', 'hidden', 'hiddenAfterDateTime', 'hiddenBeforeDateTime', 'hiddenInIndex', 'accessRoles'); if (!$isCopy) { $propertyNames[] = 'creationDateTime'; $propertyNames[] = 'lastModificationDateTime'; } if ($sourceNode instanceof NodeData) { $propertyNames[] = 'index'; } foreach ($propertyNames as $propertyName) { ObjectAccess::setProperty($this, $propertyName, ObjectAccess::getProperty($sourceNode, $propertyName)); } $contentObject = $sourceNode->getContentObject(); if ($contentObject !== null) { $this->setContentObject($contentObject); } }
/** * @param AbstractNodeData $nodeData * @param NodeType $nodeType * @param MetaDataCollection $metaDataCollection * @throws \TYPO3\Eel\Exception */ protected function mapMetaDataToNodeData(AbstractNodeData $nodeData, NodeType $nodeType, MetaDataCollection $metaDataCollection) { if ($this->defaultContextVariables === NULL) { $this->defaultContextVariables = EelUtility::getDefaultContextVariables($this->settings['defaultEelContext']); } foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) { $contextVariables = array_merge($this->defaultContextVariables, $metaDataCollection->toArray()); if (isset($propertyConfiguration['mapping'])) { $nodeData->setProperty($propertyName, EelUtility::evaluateEelExpression($propertyConfiguration['mapping'], $this->eelEvaluator, $contextVariables)); } } }