コード例 #1
0
 /**
  * Returns the specified node
  *
  * @param string $term
  * @param integer $requestIndex
  * @return void
  * @ExtDirect
  * @todo Improve this WIP search implementation
  */
 public function searchAction($term, $requestIndex)
 {
     $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext($this->securityContext->getParty()->getPreferences()->get('context.workspace'));
     $this->nodeRepository->setContext($contentContext);
     $searchContentGroups = array();
     $searchContentTypes = array();
     foreach (array('TYPO3.Phoenix.ContentTypes:Page', 'TYPO3.Phoenix.ContentTypes:ContentObject') as $contentType) {
         $searchContentGroups[$contentType] = $this->contentTypeManager->getContentType($contentType)->getConfiguration();
         array_push($searchContentTypes, $contentType);
         $subContentTypes = $this->contentTypeManager->getSubContentTypes($contentType);
         if (count($subContentTypes) > 0) {
             $searchContentGroups[$contentType]['subContentTypes'] = $subContentTypes;
             $searchContentTypes = array_merge($searchContentTypes, array_keys($subContentTypes));
         }
     }
     $staticWebBaseUri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/TYPO3.TYPO3/';
     $groups = array();
     foreach ($this->nodeSearchService->findByProperties($term, $searchContentTypes) as $result) {
         $contentType = $result->getContentType();
         if (array_key_exists($contentType->getName(), $searchContentGroups)) {
             $type = $contentType->getName();
         } else {
             foreach ($searchContentGroups as $searchContentGroup => $searchContentGroupConfiguration) {
                 if (isset($searchContentGroupConfiguration['subContentTypes']) && array_key_exists($contentType->getName(), $searchContentGroupConfiguration['subContentTypes'])) {
                     $type = $searchContentGroup;
                     break;
                 }
             }
         }
         if (!array_key_exists($type, $groups)) {
             $groups[$type] = array('type' => $contentType->getName(), 'label' => $searchContentGroups[$type]['search'], 'items' => array());
         }
         foreach ($contentType->getProperties() as $property => $configuration) {
             if ($property[0] !== '_') {
                 $labelProperty = $property;
                 break;
             }
         }
         $this->uriBuilder->reset();
         if ($result->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:Page')) {
             $pageNode = $result;
         } else {
             $pageNode = $this->findNextParentFolderNode($result);
             $this->uriBuilder->setSection('c' . $result->getIdentifier());
         }
         $searchResult = array('type' => $contentType->getName(), 'label' => substr(trim(strip_tags($result->getProperty($labelProperty))), 0, 50), 'action' => $this->uriBuilder->uriFor('show', array('node' => $pageNode), 'Frontend\\Node', 'TYPO3.TYPO3'), 'path' => $result->getPath());
         $contentTypeConfiguration = $contentType->getConfiguration();
         if (isset($contentTypeConfiguration['darkIcon'])) {
             $searchResult['icon'] = $staticWebBaseUri . $contentTypeConfiguration['darkIcon'];
         }
         array_push($groups[$type]['items'], $searchResult);
     }
     $data = array('requestIndex' => $requestIndex, 'actions' => array(array('label' => 'Clear all cache', 'command' => 'clear:cache:all'), array('label' => 'Clear page cache', 'command' => 'clear:cache:pages')), 'results' => array_values($groups));
     $this->view->assign('value', array('data' => $data, 'success' => TRUE));
 }
コード例 #2
0
 /**
  * @param string $workspaceName
  * @return void
  * @todo Pagination
  * @todo Tree filtering + level limit
  * @todo Search field
  * @todo Difference mechanism
  */
 public function indexAction($workspaceName = NULL)
 {
     if (is_null($workspaceName)) {
         $workspaceName = $this->securityContext->getParty()->getPreferences()->get('context.workspace');
     }
     $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext($workspaceName);
     $contentContext->setInvisibleContentShown(TRUE);
     $contentContext->setRemovedContentShown(TRUE);
     $contentContext->setInaccessibleContentShown(TRUE);
     $this->nodeRepository->setContext($contentContext);
     $sites = array();
     foreach ($this->workspacesService->getUnpublishedNodes($workspaceName) as $node) {
         if (!$node->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:Section')) {
             $pathParts = explode('/', $node->getPath());
             if (count($pathParts) > 2) {
                 $siteNodeName = $pathParts[2];
                 $folder = $this->findFolderNode($node);
                 $folderPath = implode('/', array_slice(explode('/', $folder->getPath()), 3));
                 $relativePath = str_replace(sprintf('/sites/%s/%s', $siteNodeName, $folderPath), '', $node->getPath());
                 if (!isset($sites[$siteNodeName]['siteNode'])) {
                     $sites[$siteNodeName]['siteNode'] = $this->siteRepository->findOneByNodeName($siteNodeName);
                 }
                 $sites[$siteNodeName]['folders'][$folderPath]['folderNode'] = $folder;
                 $change = array('node' => $node);
                 if ($node->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:AbstractNode')) {
                     $change['configuration'] = $node->getContentType()->getConfiguration();
                 }
                 $sites[$siteNodeName]['folders'][$folderPath]['changes'][$relativePath] = $change;
             }
         }
     }
     $liveWorkspace = $this->workspacesService->getWorkspace('live');
     ksort($sites);
     foreach ($sites as $siteKey => $site) {
         foreach ($site['folders'] as $folderKey => $folder) {
             foreach ($folder['changes'] as $changeKey => $change) {
                 $liveNode = $this->nodeRepository->findOneByIdentifier($change['node']->getIdentifier(), $liveWorkspace);
                 $sites[$siteKey]['folders'][$folderKey]['changes'][$changeKey]['isNew'] = is_null($liveNode);
                 $sites[$siteKey]['folders'][$folderKey]['changes'][$changeKey]['isMoved'] = $liveNode && $change['node']->getPath() !== $liveNode->getPath();
             }
         }
         ksort($sites[$siteKey]['folders']);
     }
     $workspaces = array();
     foreach ($this->workspacesService->getWorkspaces() as $workspace) {
         array_push($workspaces, array('workspaceNode' => $workspace, 'unpublishedNodesCount' => $this->workspacesService->getUnpublishedNodesCount($workspace->getName())));
     }
     $this->view->assignMultiple(array('workspaceName' => $workspaceName, 'workspaces' => $workspaces, 'sites' => $sites));
 }
コード例 #3
0
 /**
  * Default action of the backend controller.
  *
  * @return void
  * @FLOW3\SkipCsrfProtection
  */
 public function indexAction()
 {
     $workspaceName = $this->securityContext->getParty()->getPreferences()->get('context.workspace');
     // Hack: Create the workspace if it does not exist yet.
     $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext($workspaceName);
     $contentContext->getWorkspace();
     if (isset($_COOKIE['TYPO3_lastVisitedUri'])) {
         $redirectUri = $_COOKIE['TYPO3_lastVisitedUri'];
         $appendHtml = !strpos($redirectUri, '.html') ? FALSE : TRUE;
         if (!strpos($redirectUri, '@')) {
             $redirectUri = str_replace('.html', '', $redirectUri);
         } else {
             $redirectUri = substr($redirectUri, 0, strpos($redirectUri, '@'));
         }
         $redirectUri .= '@' . $workspaceName . ($appendHtml === TRUE ? '.html' : '');
         $this->redirectToUri($redirectUri);
     } else {
         $this->redirectToUri('/@' . $workspaceName . '.html');
     }
 }
コード例 #4
0
 /**
  * Default action of this controller.
  *
  * @return void
  */
 public function indexAction()
 {
     if ($this->exception !== NULL) {
         $this->view->assign('errorMessage', $this->exception->getMessage());
     }
     $httpRequest = $this->request->getHttpRequest();
     $uriPath = $httpRequest->getUri()->getPath();
     $uriPathWithoutFormat = substr($uriPath, 0, strrpos($uriPath, '.'));
     preg_match(\TYPO3\TYPO3CR\Domain\Model\NodeInterface::MATCH_PATTERN_CONTEXTPATH, $uriPathWithoutFormat, $matches);
     if (isset($matches['WorkspaceName'])) {
         $uri = $httpRequest->getBaseUri() . '@' . $matches['WorkspaceName'];
     } elseif ($this->securityContext->getParty() instanceof \TYPO3\TYPO3\Domain\Model\User) {
         $uri = $httpRequest->getBaseUri() . '@' . $this->securityContext->getParty()->getPreferences()->get('context.workspace');
     } else {
         $uri = $httpRequest->getBaseUri();
     }
     $this->view->assign('pageTitle', '404 Not Found');
     $this->view->assign('errorTitle', 'Page Not Found');
     $this->view->assign('errorDescription', 'Sorry, we could not find any page at this URL.<br />Please visit the <a href="' . $uri . '">homepage</a> to get back on the path.');
     $this->response->setStatus(404);
 }
コード例 #5
0
 /**
  * Decide if wireframe mode should be enabled.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 protected function isWireframeModeEnabled(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     if ($this->securityContext->getParty() !== NULL) {
         try {
             $this->accessDecisionManager->decideOnResource('TYPO3_TYPO3_Backend_BackendController');
             if (!$this->view->canRenderWithNodeAndPath($node, $this->view->getTypoScriptPath())) {
                 return TRUE;
             }
             return $this->securityContext->getParty()->getPreferences()->get('contentEditing.wireframeMode') ? TRUE : FALSE;
         } catch (\Exception $e) {
         }
     }
     return FALSE;
 }
コード例 #6
0
 /**
  * Get a user preference.
  *
  * @param string $preferencePath The preference key / path
  * @return void
  * @ExtDirect
  */
 public function getPreferenceAction($preferencePath)
 {
     $value = $this->securityContext->getParty()->getPreferences()->get($preferencePath);
     $this->view->setConfiguration(array('value' => array('data' => array('_descendAll' => array()))));
     $this->view->assign('value', array('data' => $value, 'success' => TRUE));
 }