/**
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @param $targetWorkspaceName
  * @return void
  */
 public function publishNode(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, $targetWorkspaceName = 'live')
 {
     $nodes = array($node);
     $contentType = $node->getContentType();
     if ($contentType->isOfType('TYPO3.Phoenix.ContentTypes:Page') || $contentType->hasStructure()) {
         foreach ($node->getChildNodes('TYPO3.Phoenix.ContentTypes:Section') as $sectionNode) {
             array_push($nodes, $sectionNode);
         }
     }
     $sourceWorkspace = $node->getWorkspace();
     $sourceWorkspace->publishNodes($nodes, $targetWorkspaceName);
 }
Exemple #2
0
 /**
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @param boolean $expand
  * @param array $children
  * @param string $contentTypeFilter
  * @return array
  */
 public function collectTreeNodeData(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, $expand = TRUE, array $children = array())
 {
     $contentType = $node->getContentType()->getName();
     $classes = array(strtolower(str_replace(array('.', ':'), array('_', '-'), $contentType)));
     if ($node->isHidden() === TRUE) {
         array_push($classes, 'hidden');
     }
     if ($node->isHiddenInIndex() === TRUE) {
         array_push($classes, 'hiddenInIndex');
     }
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $hasChildNodes = $children !== array() ? TRUE : FALSE;
     $contentType = $node->getContentType()->getName();
     $treeNode = array('key' => $node->getContextPath(), 'title' => $node->getContentType() === 'TYPO3.Phoenix.ContentTypes:Page' ? $node->getProperty('title') : $node->getLabel(), 'href' => $uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(TRUE)->uriFor('show', array('node' => $node), 'Frontend\\Node', 'TYPO3.TYPO3', ''), 'isFolder' => $hasChildNodes, 'isLazy' => $hasChildNodes && !$expand, 'contentType' => $contentType, 'expand' => $expand, 'addClass' => implode(' ', $classes), 'name' => $node->getName());
     if ($hasChildNodes) {
         $treeNode['children'] = $children;
     }
     return $treeNode;
 }
 /**
  * Finds the nearest parent folder node of the provided node by looping recursively trough
  * the node and it's parent nodes and checking if they are a sub content type of TYPO3.TYPO3CR:Folder
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return \TYPO3\TYPO3CR\Domain\Model\NodeInterface|NULL
  */
 protected function findFolderNode(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     while ($node) {
         if ($node->getContentType()->isOfType('TYPO3.TYPO3CR:Folder')) {
             return $node;
         }
         $node = $node->getParent();
     }
     return NULL;
 }
 /**
  * Wrap the $content identified by $node with the needed markup for
  * the backend.
  * $parameters can be used to further pass parameters to the content element.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @param string $typoscriptPath
  * @param string $content
  * @param boolean $isPage
  * @return string
  */
 public function wrapContentObject(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, $typoscriptPath, $content, $isPage = FALSE)
 {
     $contentType = $node->getContentType();
     $tagBuilder = new \TYPO3\Fluid\Core\ViewHelper\TagBuilder('div');
     $tagBuilder->forceClosingTag(TRUE);
     if (!$node->isRemoved()) {
         $tagBuilder->setContent($content);
     }
     if (!$isPage) {
         $cssClasses = array('t3-contentelement');
         $cssClasses[] = str_replace(array(':', '.'), '-', strtolower($contentType->getName()));
         if ($node->isHidden()) {
             $cssClasses[] = 't3-contentelement-hidden';
         }
         if ($node->isRemoved()) {
             $cssClasses[] = 't3-contentelement-removed';
         }
         $tagBuilder->addAttribute('class', implode(' ', $cssClasses));
         $tagBuilder->addAttribute('id', 'c' . $node->getIdentifier());
     }
     try {
         $this->accessDecisionManager->decideOnResource('TYPO3_TYPO3_Backend_BackendController');
     } catch (\TYPO3\FLOW3\Security\Exception\AccessDeniedException $e) {
         return $tagBuilder->render();
     }
     $tagBuilder->addAttribute('typeof', 'typo3:' . $contentType->getName());
     $tagBuilder->addAttribute('about', $node->getContextPath());
     $this->addScriptTag($tagBuilder, '__workspacename', $node->getWorkspace()->getName());
     $this->addScriptTag($tagBuilder, '_removed', $node->isRemoved() ? 'true' : 'false', 'boolean');
     $this->addScriptTag($tagBuilder, '_typoscriptPath', $typoscriptPath);
     foreach ($contentType->getProperties() as $propertyName => $propertyConfiguration) {
         $dataType = isset($propertyConfiguration['type']) ? $propertyConfiguration['type'] : 'string';
         if ($propertyName[0] === '_') {
             $propertyValue = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($node, substr($propertyName, 1));
         } else {
             $propertyValue = $node->getProperty($propertyName);
         }
         // Serialize boolean values to String
         if (isset($propertyConfiguration['type']) && $propertyConfiguration['type'] === 'boolean') {
             $propertyValue = $propertyValue ? 'true' : 'false';
         }
         // Serialize date values to String
         if ($propertyValue !== NULL && isset($propertyConfiguration['type']) && $propertyConfiguration['type'] === 'date') {
             $propertyValue = $propertyValue->format('Y-m-d');
         }
         // Serialize objects to JSON strings
         if (is_object($propertyValue) && $propertyValue !== NULL && isset($propertyConfiguration['type']) && $this->objectManager->isRegistered($propertyConfiguration['type'])) {
             $gettableProperties = \TYPO3\FLOW3\Reflection\ObjectAccess::getGettableProperties($propertyValue);
             $convertedProperties = array();
             foreach ($gettableProperties as $key => $value) {
                 if (is_object($value)) {
                     $entityIdentifier = $this->persistenceManager->getIdentifierByObject($value);
                     if ($entityIdentifier !== NULL) {
                         $value = $entityIdentifier;
                     }
                 }
                 $convertedProperties[$key] = $value;
             }
             $propertyValue = json_encode($convertedProperties);
             $dataType = 'jsonEncoded';
         }
         $this->addScriptTag($tagBuilder, $propertyName, $propertyValue, $dataType);
     }
     if (!$isPage) {
         // add CSS classes
         $this->addScriptTag($tagBuilder, '__contenttype', $contentType->getName());
     } else {
         $tagBuilder->addAttribute('id', 't3-page-metainformation');
         $tagBuilder->addAttribute('data-__sitename', $this->nodeRepository->getContext()->getCurrentSite()->getName());
         $tagBuilder->addAttribute('data-__siteroot', sprintf('/sites/%s@%s', $this->nodeRepository->getContext()->getCurrentSite()->getNodeName(), $this->nodeRepository->getContext()->getWorkspace()->getName()));
     }
     return $tagBuilder->render();
 }
 /**
  * Shows the specified node and takes visibility and access restrictions into
  * account.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return string View output for the specified node
  */
 public function showWireframeAction(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     if (!$node->isAccessible()) {
         try {
             $this->authenticationManager->authenticate();
         } catch (\Exception $exception) {
         }
     }
     if (!$node->isAccessible() && !$this->nodeRepository->getContext()->isInaccessibleContentShown()) {
         $this->throwStatus(403);
     }
     if (!$node->isVisible() && !$this->nodeRepository->getContext()->isInvisibleContentShown()) {
         $this->throwStatus(404);
     }
     if ($node->getContentType() === 'TYPO3.Phoenix.ContentTypes:Shortcut') {
         $this->view->assign('wireframeMode', $node);
     }
     $this->nodeRepository->getContext()->setCurrentNode($node);
     $this->view->assign('value', $node);
     $this->view->setTypoScriptPath('wireframeMode');
     $this->response->setHeader('Cache-Control', 'public, s-maxage=600', FALSE);
 }