public getPreparedExposedTemplateView ( FluidTYPO3\Flux\View\ViewContext $viewContext ) : |
||
$viewContext | FluidTYPO3\Flux\View\ViewContext | |
return |
/** * @return void */ protected function initializeViewObject() { $row = $this->getRecord(); $viewContext = $this->provider->getViewContext($row, $this->request); $controllerActionName = $this->provider->getControllerActionFromRecord($row); $this->view = $this->configurationService->getPreparedExposedTemplateView($viewContext); }
/** * @param ProviderInterface $provider * @param array $row * @param Form $form * @return string|NULL */ protected function renderPreviewSection(ProviderInterface $provider, array $row, Form $form = NULL) { $templatePathAndFilename = $provider->getTemplatePathAndFilename($row); if (NULL === $templatePathAndFilename) { return NULL; } $extensionKey = $provider->getExtensionKey($row); $paths = $provider->getTemplatePaths($row); $flexformVariables = $provider->getFlexFormValues($row); $templateVariables = $provider->getTemplateVariables($row); $variables = RecursiveArrayUtility::merge($templateVariables, $flexformVariables); $variables['row'] = $row; $variables['record'] = $row; if (TRUE === is_object($form)) { $formLabel = $form->getLabel(); $label = LocalizationUtility::translate($formLabel, $extensionKey); $variables['label'] = $label; } $templatePaths = new TemplatePaths($paths); $viewContext = new ViewContext($templatePathAndFilename, $extensionKey, self::CONTROLLER_NAME); $viewContext->setTemplatePaths($templatePaths); $viewContext->setVariables($variables); $view = $this->configurationService->getPreparedExposedTemplateView($viewContext); $existingContentObject = $this->configurationManager->getContentObject(); $contentObject = new ContentObjectRenderer(); $contentObject->start($row, $provider->getTableName($row)); $this->configurationManager->setContentObject($contentObject); $previewContent = $view->renderStandaloneSection(self::PREVIEW_SECTION, $variables, TRUE); $this->configurationManager->setContentObject($existingContentObject); $previewContent = trim($previewContent); return $previewContent; }
/** * @return void */ protected function initializeViewObject() { $row = $this->getRecord(); $templatePathAndFilename = $this->provider->getTemplatePathAndFilename($row); $extensionKey = $this->provider->getExtensionKey($row); $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey); $controller = $this->request->getControllerName(); $this->view = $this->configurationService->getPreparedExposedTemplateView($extensionKey, $controller, $this->setup, $this->data); $this->request->setControllerExtensionName($extensionName); $this->view->setControllerContext($this->controllerContext); if (FALSE === empty($templatePathAndFilename)) { $this->view->setTemplatePathAndFilename($templatePathAndFilename); } }
/** * @param array $row * @return Form|NULL */ public function getForm(array $row) { if (NULL !== $this->form) { return $this->form; } $formName = 'form'; $cacheKey = $this->getCacheKeyForStoredVariable($row, $formName); if (FALSE === array_key_exists($cacheKey, self::$cache)) { $formClassName = $this->resolveFormClassName($row); if (NULL !== $formClassName) { $form = call_user_func_array(array($formClassName, 'create'), array($row)); } else { $viewContext = $this->getViewContext($row); if (NULL !== $viewContext->getTemplatePathAndFilename()) { $view = $this->configurationService->getPreparedExposedTemplateView($viewContext); $form = $view->getForm($viewContext->getSectionName(), $formName); } } if (NULL !== $form) { $form->setOption(Form::OPTION_RECORD, $row); $form->setOption(Form::OPTION_RECORD_TABLE, $this->getTableName($row)); $form->setOption(Form::OPTION_RECORD_FIELD, $this->getFieldName($row)); } self::$cache[$cacheKey] = $form; } return self::$cache[$cacheKey]; }
/** * Get preview chunks - header and content - as * array(string $headerContent, string $previewContent, boolean $continueRendering) * * Default implementation renders the Preview section from the template * file that the actual Provider returns for $row, using paths also * determined by $row. Example: fluidcontent's Provider returns files * and paths based on selected "Fluid Content type" and inherits and * uses this method to render a Preview from the template file in the * specific path. This default implementation expects the TYPO3 core * to render the default header, so it returns NULL as $headerContent. * * @param array $row The record data to be analysed for variables to use in a rendered preview * @return array */ public function getPreview(array $row) { $templateSource = $this->getTemplateSource($row); if (TRUE === empty($templateSource)) { return array(NULL, NULL, TRUE); } $extensionKey = $this->getExtensionKey($row); $flexformVariables = $this->getFlexFormValues($row); $templateVariables = $this->getTemplateVariables($row); $variables = RecursiveArrayUtility::merge($templateVariables, $flexformVariables); $paths = $this->getTemplatePaths($row); $form = $this->getForm($row); $formLabel = $form->getLabel(); $label = LocalizationUtility::translate($formLabel, $extensionKey); $variables['label'] = $label; $variables['row'] = $row; $variables['record'] = $row; $view = $this->configurationService->getPreparedExposedTemplateView($extensionKey, 'Content', $paths, $variables); $view->setTemplateSource($templateSource); $existingContentObject = $this->configurationManager->getContentObject(); $contentObject = new ContentObjectRenderer(); $contentObject->start($row, $this->getTableName($row)); $this->configurationManager->setContentObject($contentObject); $previewContent = $view->renderStandaloneSection('Preview', $variables); $this->configurationManager->setContentObject($existingContentObject); $previewContent = trim($previewContent); $headerContent = NULL; return array($headerContent, $previewContent, empty($previewContent)); }
/** * @param array $row * @return Form|NULL */ public function getForm(array $row) { if (NULL !== $this->form) { return $this->form; } $formName = 'form'; $cacheKey = $this->getCacheKeyForStoredVariable($row, $formName); if (FALSE === isset(self::$cache[$cacheKey])) { $formClassName = $this->resolveFormClassName($row); if (NULL !== $formClassName) { $form = call_user_func_array(array($formClassName, 'create'), array($row)); } else { $templatePathAndFilename = $this->getTemplatePathAndFilename($row); if (NULL !== $templatePathAndFilename) { $class = get_class($this); $controllerName = substr(substr($class, strrpos($class, '\\')), -8); $section = $this->getConfigurationSectionName($row); $paths = $this->getTemplatePaths($row); $extensionKey = $this->getExtensionKey($row); $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey); $templatePaths = new TemplatePaths($paths); $viewContext = new ViewContext($templatePathAndFilename, $extensionName, $controllerName); $viewContext->setTemplatePaths($templatePaths); $variables = $this->getViewVariables($row); $viewContext->setVariables($variables); $view = $this->configurationService->getPreparedExposedTemplateView($viewContext); $form = $view->getForm($section, $formName); } } if (NULL !== $form) { $form->setOption(Form::OPTION_RECORD, $row); $form->setOption(Form::OPTION_RECORD_TABLE, $this->getTableName($row)); $form->setOption(Form::OPTION_RECORD_FIELD, $this->getFieldName($row)); } self::$cache[$cacheKey] = $form; } return self::$cache[$cacheKey]; }