/**
  * Additionally add the current site and domain to the Context properties.
  *
  * {@inheritdoc}
  */
 protected function prepareContextProperties($workspaceName, \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration = null, array $dimensions = null)
 {
     $contextProperties = parent::prepareContextProperties($workspaceName, $configuration, $dimensions);
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
     }
     return $contextProperties;
 }
 /**
  * Default action, displays the login screen
  *
  * @param string $username Optional: A username to pre-fill into the username field
  * @param boolean $unauthorized
  * @return void
  */
 public function indexAction($username = null, $unauthorized = false)
 {
     if ($this->securityContext->getInterceptedRequest() || $unauthorized) {
         $this->response->setStatus(401);
     }
     if ($this->authenticationManager->isAuthenticated()) {
         $this->redirect('index', 'Backend\\Backend');
     }
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     $currentSite = $currentDomain !== null ? $currentDomain->getSite() : $this->siteRepository->findFirstOnline();
     $this->view->assignMultiple(array('username' => $username, 'site' => $currentSite));
 }
 /**
  * Create a ContentContext based on the given workspace name
  *
  * @param string $workspaceName Name of the workspace to set for the context
  * @param array $dimensions Optional list of dimensions and their values which should be set
  * @return \TYPO3\Neos\Domain\Service\ContentContext
  */
 protected function createContentContext($workspaceName, array $dimensions = array())
 {
     $contextProperties = array('workspaceName' => $workspaceName, 'invisibleContentShown' => true, 'inaccessibleContentShown' => true);
     if ($dimensions !== array()) {
         $contextProperties['dimensions'] = $dimensions;
         $contextProperties['targetDimensions'] = array_map(function ($dimensionValues) {
             return array_shift($dimensionValues);
         }, $dimensions);
     }
     $currentDomain = $this->_domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $this->_siteRepository->findFirstOnline();
     }
     return $this->_contextFactory->create($contextProperties);
 }
 /**
  * @param ACLCheckerDto $dto
  * @return array
  */
 protected function getNodes(ACLCheckerDto $dto)
 {
     $context = $this->createContext();
     $site = $this->siteRepository->findFirstOnline();
     $startNode = $context->getNode('/sites/' . $site->getNodeName());
     $roles = $this->getRolesByDto($dto);
     $nodes = [];
     $this->getChildNodeData($nodes, $startNode, $roles, $dto->getNodeTreeLoadingDepth());
     return $nodes;
 }
 /**
  * Determines the current domain and site from the request and sets the resulting values as
  * as defaults.
  *
  * @param array $defaultContextProperties
  * @return array
  */
 protected function setDefaultSiteAndDomainFromCurrentRequest(array $defaultContextProperties)
 {
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $defaultContextProperties['currentSite'] = $currentDomain->getSite();
         $defaultContextProperties['currentDomain'] = $currentDomain;
     } else {
         $defaultContextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
     }
     return $defaultContextProperties;
 }
 /**
  * Sets context properties like "invisibleContentShown" according to the workspace (live or not) and returns a
  * ContentContext object.
  *
  * @param string $workspaceName Name of the workspace to use in the context
  * @param array $dimensionsAndDimensionValues An array of dimension names (index) and their values (array of strings). See also: ContextFactory
  * @return ContentContext
  */
 protected function buildContextFromWorkspaceNameAndDimensions($workspaceName, array $dimensionsAndDimensionValues)
 {
     $contextProperties = array('workspaceName' => $workspaceName, 'invisibleContentShown' => $workspaceName !== 'live', 'inaccessibleContentShown' => $workspaceName !== 'live', 'dimensions' => $dimensionsAndDimensionValues);
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== NULL) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
     }
     return $this->contextFactory->create($contextProperties);
 }
 /**
  * Create a ContentContext to be used for the backend redirects.
  *
  * @param string $workspaceName
  * @return ContentContext
  */
 protected function createContext($workspaceName)
 {
     $contextProperties = array('workspaceName' => $workspaceName, 'invisibleContentShown' => true, 'inaccessibleContentShown' => true);
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
     }
     return $this->contextFactory->create($contextProperties);
 }
 /**
  * Creates a new content context based on the given workspace and the NodeData object and additionally takes
  * the current site and current domain into account.
  *
  * @param Workspace $workspace Workspace for the new context
  * @param array $dimensionValues The dimension values for the new context
  * @param array $contextProperties Additional pre-defined context properties
  * @return Context
  */
 protected function createContext(Workspace $workspace, array $dimensionValues, array $contextProperties = array())
 {
     if ($this->currentDomain === false) {
         $this->currentDomain = $this->domainRepository->findOneByActiveRequest();
     }
     if ($this->currentDomain !== null) {
         $contextProperties['currentSite'] = $this->currentDomain->getSite();
         $contextProperties['currentDomain'] = $this->currentDomain;
     } else {
         if ($this->currentSite === false) {
             $this->currentSite = $this->siteRepository->findFirstOnline();
         }
         $contextProperties['currentSite'] = $this->currentSite;
     }
     return parent::createContext($workspace, $dimensionValues, $contextProperties);
 }
 /**
  * @param NodeType $nodetype
  * @return boolean
  */
 private function isNodeTypeInAllowedSite(NodeType $nodetype)
 {
     // dont restrict abstract nodes
     if ($nodetype->isAbstract()) {
         return true;
     }
     $deniedWilcard = false;
     $allowedSites = $nodetype->getConfiguration('allowedSites');
     if ($allowedSites) {
         $currentDomain = $this->domainRepository->findOneByActiveRequest();
         if ($currentDomain !== null) {
             $currentSite = $currentDomain->getSite();
         } else {
             $currentSite = $this->siteRepository->findFirstOnline();
         }
         if (!$currentSite) {
             return true;
         }
         foreach ($allowedSites as $siteName => $allowed) {
             if ($allowed == TRUE && $siteName == '*' | $currentSite->getSiteResourcesPackageKey() == $siteName) {
                 return true;
             }
             if ($allowed == FALSE && $currentSite->getSiteResourcesPackageKey() == $siteName) {
                 return false;
             }
             if ($allowed == TRUE && $siteName == '*') {
                 $deniedWilcard = false;
             }
             if ($allowed == FALSE && $siteName == '*') {
                 $deniedWilcard = true;
             }
         }
         if ($deniedWilcard == true) {
             return false;
         }
     }
     return true;
 }
 /**
  * @return void
  */
 protected function createContentContext()
 {
     $domain = $this->domainRepository->findOneByActiveRequest();
     $this->contentContext = new ContentContext('live', new \DateTime(), [], [], false, false, false, $domain ? $domain->getSite() : $this->siteRepository->findFirstOnline(), $domain);
 }