/**
  * @return void
  */
 public function initializeObject()
 {
     $this->settings = $this->configurationManager->getConfiguration('Settings', 'TYPO3.Media');
     $domain = $this->domainRepository->findOneByActiveRequest();
     // Set active asset collection to the current site's asset collection, if it has one, on the first view if a matching domain is found
     if ($domain !== null && !$this->browserState->get('activeAssetCollection') && $this->browserState->get('automaticAssetCollectionSelection') !== true && $domain->getSite()->getAssetCollection() !== null) {
         $this->browserState->set('activeAssetCollection', $domain->getSite()->getAssetCollection());
         $this->browserState->set('automaticAssetCollectionSelection', true);
     }
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * Create a Context for a workspace given by name to be used in this controller.
  *
  * @param string $workspaceName Name of the current workspace
  * @return \TYPO3\TYPO3CR\Domain\Service\Context
  */
 protected function createContext($workspaceName)
 {
     $contextProperties = array('workspaceName' => $workspaceName);
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     }
     return $this->contextFactory->create($contextProperties);
 }
 /**
  * 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);
 }
 /**
  * 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->findDefault();
     $this->view->assignMultiple(['styles' => array_filter($this->settings['userInterface']['backendLoginForm']['stylesheets']), 'username' => $username, 'site' => $currentSite]);
 }
 /**
  * @return string
  */
 public function render()
 {
     $configuration = array('window.T3Configuration = {};', 'window.T3Configuration.UserInterface = ' . json_encode($this->settings['userInterface']) . ';', 'window.T3Configuration.nodeTypes = {};', 'window.T3Configuration.nodeTypes.groups = ' . json_encode($this->getNodeTypeGroupsSettings()) . ';', 'window.T3Configuration.requirejs = {};', 'window.T3Configuration.neosStaticResourcesBaseUri = ' . json_encode($this->resourceManager->getPublicPackageResourceUri('TYPO3.Neos', '')) . ';', 'window.T3Configuration.requirejs.paths = ' . json_encode($this->getRequireJsPathMapping()) . ';', 'window.T3Configuration.maximumFileUploadSize = ' . $this->renderMaximumFileUploadSize());
     $neosJavaScriptBasePath = $this->getStaticResourceWebBaseUri('resource://TYPO3.Neos/Public/JavaScript');
     $configuration[] = 'window.T3Configuration.neosJavascriptBasePath = ' . json_encode($neosJavaScriptBasePath) . ';';
     if ($this->backendAssetsUtility->shouldLoadMinifiedJavascript()) {
         $configuration[] = 'window.T3Configuration.neosJavascriptVersion = ' . json_encode($this->backendAssetsUtility->getJavascriptBuiltVersion()) . ';';
     }
     if ($this->bootstrap->getContext()->isDevelopment()) {
         $configuration[] = 'window.T3Configuration.DevelopmentMode = true;';
     }
     if ($activeDomain = $this->domainRepository->findOneByActiveRequest()) {
         $configuration[] = 'window.T3Configuration.site = "' . $activeDomain->getSite()->getNodeName() . '";';
     }
     return implode("\n", $configuration);
 }
 /**
  * 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);
 }