/**
  * Build parser configuration
  *
  * @return \TYPO3\CMS\Fluid\Core\Parser\Configuration
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Parser\\Configuration');
     if ($this->controllerContext->getRequest()->getFormat() === 'html') {
         $parserConfiguration->addInterceptor($this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Parser\\Interceptor\\Escape'));
     }
     return $parserConfiguration;
 }
 /**
  * Sets the current controller context
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
  * @return void
  */
 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 {
     $request = $controllerContext->getRequest();
     $this->controllerContext = $controllerContext;
     $this->baseRenderingContext->getTemplatePaths()->fillDefaultsByPackageName($request->getControllerExtensionKey());
     $this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
     $this->baseRenderingContext->setControllerContext($controllerContext);
 }
 /**
  * Pre-processes class member values.
  */
 protected function preProcess()
 {
     $emptyGetVariables = count($this->getVariables) === 0;
     // Set default GET parameters
     if ($emptyGetVariables) {
         $this->getVariables = array('id', 'M');
     }
     // Automatically determine module name in Extbase context
     if ($this->controllerContext !== null) {
         $currentRequest = $this->controllerContext->getRequest();
         $extensionName = $currentRequest->getControllerExtensionName();
         $this->moduleName = $currentRequest->getPluginName();
         // Extend default GET parameters
         if ($emptyGetVariables) {
             $modulePrefix = strtolower('tx_' . $extensionName . '_' . $this->moduleName);
             $this->getVariables[] = $modulePrefix;
         }
     }
 }
Beispiel #4
0
 /**
  * Renders a given section.
  *
  * @param string $sectionName Name of section to render
  * @param array $variables The variables to use
  * @param boolean $ignoreUnknown Ignore an unknown section and just return an empty string
  * @return string rendered template for the section
  * @throws \TYPO3\Fluid\View\Exception\InvalidSectionException
  */
 public function renderSection($sectionName, array $variables, $ignoreUnknown = FALSE)
 {
     $renderingContext = $this->getCurrentRenderingContext();
     if ($this->getCurrentRenderingType() === self::RENDERING_LAYOUT) {
         // in case we render a layout right now, we will render a section inside a TEMPLATE.
         $renderingTypeOnNextLevel = self::RENDERING_TEMPLATE;
     } else {
         $variableContainer = $this->objectManager->create('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', $variables);
         $renderingContext = clone $renderingContext;
         $renderingContext->injectTemplateVariableContainer($variableContainer);
         $renderingTypeOnNextLevel = $this->getCurrentRenderingType();
     }
     $parsedTemplate = $this->getCurrentParsedTemplate();
     if ($parsedTemplate->isCompiled()) {
         $methodNameOfSection = 'section_' . sha1($sectionName);
         if ($ignoreUnknown && !method_exists($parsedTemplate, $methodNameOfSection)) {
             return '';
         }
         $this->startRendering($renderingTypeOnNextLevel, $parsedTemplate, $renderingContext);
         $output = $parsedTemplate->{$methodNameOfSection}($renderingContext);
         $this->stopRendering();
     } else {
         $sections = $parsedTemplate->getVariableContainer()->get('sections');
         if (!array_key_exists($sectionName, $sections)) {
             $controllerObjectName = $this->controllerContext->getRequest()->getControllerObjectName();
             if ($ignoreUnknown) {
                 return '';
             } else {
                 throw new \TYPO3\Fluid\View\Exception\InvalidSectionException(sprintf('Could not render unknown section "%s" in %s used by %s.', $sectionName, get_class($this), $controllerObjectName), 1227108982);
             }
         }
         $section = $sections[$sectionName];
         $renderingContext->getViewHelperVariableContainer()->add('TYPO3\\Fluid\\ViewHelpers\\SectionViewHelper', 'isCurrentlyRenderingSection', 'TRUE');
         $this->startRendering($renderingTypeOnNextLevel, $parsedTemplate, $renderingContext);
         $output = $section->evaluate($renderingContext);
         $this->stopRendering();
     }
     return $output;
 }
 /**
  * Set the controller context which will be passed to the ViewHelper
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext The controller context to set
  */
 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 {
     $request = $controllerContext->getRequest();
     $this->controllerContext = $controllerContext;
     $this->setControllerAction($request->getControllerActionName());
     // Check if Request is using a sub-package key; in which case we translate this
     // for our RenderingContext as an emulated plain old sub-namespace controller.
     $controllerName = $request->getControllerName();
     if ($request->getControllerSubpackageKey() && !strpos($controllerName, '\\')) {
         $this->setControllerName($request->getControllerSubpackageKey() . '\\' . $controllerName);
     } else {
         $this->setControllerName($controllerName);
     }
 }
 /**
  * Init
  *
  * @return void
  */
 public function initializeAction()
 {
     $this->controllerContext = $this->buildControllerContext();
     $this->user = $this->div->getCurrentUser();
     $this->cObj = $this->configurationManager->getContentObject();
     $this->pluginVariables = $this->request->getArguments();
     $this->allConfig = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $this->config = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $this->config = $this->config['plugin.']['tx_femanager.']['settings.'];
     $controllerName = strtolower($this->controllerContext->getRequest()->getControllerName());
     $removeFromUserGroupSelection = $this->settings[$controllerName]['misc']['removeFromUserGroupSelection'];
     $this->allUserGroups = $this->userGroupRepository->findAllForFrontendSelection($removeFromUserGroupSelection);
     if (isset($this->arguments['user'])) {
         $this->arguments['user']->getPropertyMappingConfiguration()->forProperty('dateOfBirth')->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, LocalizationUtility::translate('tx_femanager_domain_model_user.dateFormat', 'femanager'));
     }
     // check if ts is included
     if ($this->settings['_TypoScriptIncluded'] != 1 && !GeneralUtility::_GP('eID') && TYPO3_MODE !== 'BE') {
         $this->flashMessageContainer->add(LocalizationUtility::translate('error_no_typoscript', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     }
     // check if storage pid was set
     if (intval($this->allConfig['persistence']['storagePid']) === 0 && !GeneralUtility::_GP('eID') && TYPO3_MODE !== 'BE') {
         $this->flashMessageContainer->add(LocalizationUtility::translate('error_no_storagepid', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     }
 }
 /**
  * Checks whether a template can be resolved for the current request context.
  *
  * @param ControllerContext $controllerContext Controller context which is available inside the view
  * @return bool
  * @api
  */
 public function canRender(ControllerContext $controllerContext)
 {
     try {
         $request = $controllerContext->getRequest();
         $this->setControllerContext($controllerContext);
         $this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
         $this->baseRenderingContext->getTemplatePaths()->getTemplateSource($request->getControllerName(), $request->getControllerActionName());
         return true;
     } catch (InvalidTemplateResourceException $e) {
         return false;
     }
 }
Beispiel #8
0
 protected function getViewFileName(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 {
     // try to get the view name based upon the controller/action
     $controller = $controllerContext->getRequest()->getControllerName();
     $action = $controllerContext->getRequest()->getControllerActionName();
     $file = $controller . '/' . ucfirst($action) . '.tpl';
     $paths = $this->getTemplateRootPaths();
     $paths = \TYPO3\CMS\Extbase\Utility\ArrayUtility::sortArrayWithIntegerKeys($paths);
     $paths = array_reverse($paths, true);
     foreach ($paths as $rootPath) {
         $fileName = GeneralUtility::fixWindowsFilePath($rootPath . '/' . $file);
         $fileName = GeneralUtility::getFileAbsFileName($fileName);
         if (file_exists($fileName)) {
             return $fileName;
         }
     }
     // no view found
     throw new \Exception('Template not found for ' . $controller . '->' . $action);
 }