Example #1
0
 /**
  * Initializes the view before invoking an action method.
  *
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     if (isset($this->settings['templatePath']) && !empty($this->settings['templatePath'])) {
         /** @var $view \TYPO3\CMS\Fluid\View\TemplateView */
         $view->setTemplateRootPath(array_shift(explode(' ', $this->settings['templatePath'])));
     }
 }
 /**
  * Initializes the view before invoking an action method.
  *
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  * @api
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $this->contentObject = $this->configurationManager->getContentObject();
     $this->contentObjectData = $this->contentObject->data;
     $this->data['parent'] = $this->contentObjectData;
     $view->assign('data', $this->data);
     if ($this->settings['region']['htmlTag_langKey']) {
         $this->region = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('_', $this->settings['region']['htmlTag_langKey']);
         $this->region = $this->region[1];
     } else {
         $this->region = $this->settings['region']['default'];
     }
     $view->assign('region', $this->region);
     parent::initializeView($view);
     if (count($this->settings['javascript']['load']) > 0) {
         foreach ($this->settings['javascript']['load'] as $key => $value) {
             if ($value['enable']) {
                 $src = $value['src'];
                 if ($key == 'googleMapsApi') {
                     $src .= '&language=' . ($this->settings['region']['htmlTag_langKey'] ? $this->settings['region']['htmlTag_langKey'] : $this->settings['region']['default']);
                 }
                 if ($key == 'googleMapsApi' && '' != $this->settings['general']['google']['apikey']) {
                     $src .= '&key=' . $this->settings['general']['google']['apikey'];
                 }
                 $this->response->addAdditionalHeaderData($this->wrapJavascriptFile($src));
             }
         }
     }
 }
 /**
  * Initializes the view before invoking an action method.
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  * 
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $cObjData = $this->configurationManager->getContentObject()->data;
     $view->assign('newsItem', $cObjData);
     //$view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
     $view->assign('emConfiguration', EmConfiguration::getSettings());
     parent::initializeView($view);
 }
 /**
  * @param ViewInterface $view
  */
 protected function initializeView(ViewInterface $view)
 {
     // Set template
     if ($this->settings['templateFile']) {
         $templateFile = GeneralUtility::getFileAbsFileName($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sschhtml5videoplayer.']['view.']['templateRootPath'] . 'Audio/' . $this->settings['templateFile']);
         if (file_exists($templateFile)) {
             $view->setTemplatePathAndFilename($templateFile);
         }
     }
 }
 /**
  * Set up the view template configuration correctly for BackendTemplateView
  *
  * @param ViewInterface $view
  * @return void
  */
 protected function setViewConfiguration(ViewInterface $view)
 {
     if (class_exists('\\TYPO3\\CMS\\Backend\\View\\BackendTemplateView') && $view instanceof \TYPO3\CMS\Backend\View\BackendTemplateView) {
         /** @var \TYPO3\CMS\Fluid\View\TemplateView $_view */
         $_view = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\TemplateView');
         $this->setViewConfiguration($_view);
         $view->injectTemplateView($_view);
     } else {
         parent::setViewConfiguration($view);
     }
 }
Example #6
0
 /**
  * Allows the widget template root path to be overriden via the framework configuration,
  * e.g. plugin.tx_extension.view.widget.<WidgetViewHelperClassName>.templateRootPath
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  * @return void
  */
 protected function setViewConfiguration(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $widgetViewHelperClassName = $this->request->getWidgetContext()->getWidgetViewHelperClassName();
     $templatePaths = new TemplatePaths($this->controllerContext->getRequest()->getControllerExtensionKey());
     $widgetViewConfiguration = null;
     $parentConfiguration = $view->getTemplatePaths()->toArray();
     $rootConfiguration = $templatePaths->toArray();
     if (!isset($extbaseFrameworkConfiguration['view']['widget'][$widgetViewHelperClassName])) {
         $widgetViewConfiguration = array_merge_recursive($parentConfiguration, $rootConfiguration);
     } else {
         $widgetViewConfiguration = array_merge_recursive((array) $rootConfiguration, (array) $parentConfiguration, (array) $extbaseFrameworkConfiguration['view']['widget'][$widgetViewHelperClassName]);
     }
     $view->getTemplatePaths()->fillFromConfigurationArray($widgetViewConfiguration);
 }
Example #7
0
 /**
  * Calls the specified action method and passes the arguments.
  *
  * If the action returns a string, it is appended to the content in the
  * response object. If the action doesn't return anything and a valid
  * view exists, the view is rendered automatically.
  *
  * @return void
  * @api
  */
 protected function callActionMethod()
 {
     if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) {
         // enabled since Extbase 1.4.0.
         $preparedArguments = array();
         foreach ($this->arguments as $argument) {
             $preparedArguments[] = $argument->getValue();
         }
         $validationResult = $this->arguments->getValidationResults();
         if (!$validationResult->hasErrors()) {
             $this->emitBeforeCallActionMethodSignal($preparedArguments);
             $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
         } else {
             $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName);
             $ignoreValidationAnnotations = array();
             if (isset($methodTagsValues['ignorevalidation'])) {
                 $ignoreValidationAnnotations = $methodTagsValues['ignorevalidation'];
             }
             // if there exist errors which are not ignored with @ignorevalidation => call error method
             // else => call action method
             $shouldCallActionMethod = TRUE;
             foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
                 if (!$subValidationResult->hasErrors()) {
                     continue;
                 }
                 if (array_search('$' . $argumentName, $ignoreValidationAnnotations) !== FALSE) {
                     continue;
                 }
                 $shouldCallActionMethod = FALSE;
                 break;
             }
             if ($shouldCallActionMethod) {
                 $this->emitBeforeCallActionMethodSignal($preparedArguments);
                 $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
             } else {
                 $actionResult = call_user_func(array($this, $this->errorMethodName));
             }
         }
     } else {
         // @deprecated since Extbase 1.4.0, will be removed two versions after Extbase 6.1
         $preparedArguments = array();
         foreach ($this->arguments as $argument) {
             $preparedArguments[] = $argument->getValue();
         }
         if ($this->argumentsMappingResults->hasErrors()) {
             $actionResult = call_user_func(array($this, $this->errorMethodName));
         } else {
             $this->emitBeforeCallActionMethodSignal($preparedArguments);
             $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
         }
     }
     if ($actionResult === NULL && $this->view instanceof ViewInterface) {
         $this->response->appendContent($this->view->render());
     } elseif (is_string($actionResult) && strlen($actionResult) > 0) {
         $this->response->appendContent($actionResult);
     } elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) {
         $this->response->appendContent((string) $actionResult);
     }
 }
Example #8
0
 /**
  * Renders the content preview of a content element.
  *
  * The initial item content is passed as a reference like in the core's
  * PageLayoutViewDrawItemHookInterface. The implementation has to modify
  * the content.
  *
  * @param PageLayoutView $parentObject Calling parent object
  * @param string $itemContent Item content
  * @param array $row Record row of tt_content
  *
  * @return void
  */
 public function renderContent(PageLayoutView &$parentObject, &$itemContent, array &$row)
 {
     $this->view->assign('section', 'itemContent');
     $this->view->assign('uid', $row['uid']);
     $this->view->assign('code', $row['bodytext']);
     $this->view->assign('label', $row['subheader']);
     $itemContent .= $this->view->render();
 }
 /**
  * Renders the content preview of a content element.
  *
  * The initial item content is passed as a reference like in the core's
  * PageLayoutViewDrawItemHookInterface. The implementation has to modify
  * the content.
  *
  * @param PageLayoutView $parentObject Calling parent object
  * @param string $itemContent Item content
  * @param array $row Record row of tt_content
  *
  * @return void
  */
 public function renderContent(PageLayoutView &$parentObject, &$itemContent, array &$row)
 {
     $this->view->assign('section', 'itemContent');
     $pageType = Type::fromString($this->getFlexformValue($row['pi_flexform'], 'settings.pageType'));
     $offset = (int) $this->getFlexformValue($row['pi_flexform'], 'settings.offset');
     $limit = (int) $this->getFlexformValue($row['pi_flexform'], 'settings.limit');
     $this->view->assign('typeLabelReference', $this->getPageTypeLabelReference($pageType));
     $this->view->assign('offset', $offset);
     $this->view->assign('limit', $limit);
     $pages = $this->pageRepository->findLastUpdated($pageType, $offset - 1, $limit);
     $this->view->assign('pages', $pages);
     $itemContent .= $this->view->render();
 }
Example #10
0
 /**
  * Calls the specified action method and passes the arguments.
  *
  * If the action returns a string, it is appended to the content in the
  * response object. If the action doesn't return anything and a valid
  * view exists, the view is rendered automatically.
  *
  * @return void
  * @api
  */
 protected function callActionMethod()
 {
     $preparedArguments = array();
     /** @var \TYPO3\CMS\Extbase\Mvc\Controller\Argument $argument */
     foreach ($this->arguments as $argument) {
         $preparedArguments[] = $argument->getValue();
     }
     $validationResult = $this->arguments->getValidationResults();
     if (!$validationResult->hasErrors()) {
         $this->emitBeforeCallActionMethodSignal($preparedArguments);
         $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
     } else {
         $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName);
         $ignoreValidationAnnotations = array();
         if (isset($methodTagsValues['ignorevalidation'])) {
             $ignoreValidationAnnotations = $methodTagsValues['ignorevalidation'];
         }
         // if there exist errors which are not ignored with @ignorevalidation => call error method
         // else => call action method
         $shouldCallActionMethod = true;
         foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
             if (!$subValidationResult->hasErrors()) {
                 continue;
             }
             if (array_search('$' . $argumentName, $ignoreValidationAnnotations) !== false) {
                 continue;
             }
             $shouldCallActionMethod = false;
             break;
         }
         if ($shouldCallActionMethod) {
             $this->emitBeforeCallActionMethodSignal($preparedArguments);
             $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments);
         } else {
             $actionResult = call_user_func(array($this, $this->errorMethodName));
         }
     }
     if ($actionResult === null && $this->view instanceof ViewInterface) {
         $this->response->appendContent($this->view->render());
     } elseif (is_string($actionResult) && $actionResult !== '') {
         $this->response->appendContent($actionResult);
     } elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) {
         $this->response->appendContent((string) $actionResult);
     }
 }
Example #11
0
 /**
  * Set the TS defined custom paths in view
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  * @throws Exception
  */
 protected function setCustomPathsInView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $templatePathAndFilename = null;
     // We can overwrite a template via TS using plugin.yag.settings.controller.<ControllerName>.<actionName>.template
     if ($this->configurationBuilder) {
         $templatePathAndFilename = $this->configurationBuilder->buildThemeConfiguration()->getTemplate($this->request->getControllerName(), $this->request->getControllerActionName());
         $this->objectManager->get('Tx_Yag_Utility_HeaderInclusion')->includeThemeDefinedHeader($this->configurationBuilder->buildThemeConfiguration());
     }
     if (!$templatePathAndFilename) {
         $templatePathAndFilename = $this->settings['controller'][$this->request->getControllerName()][$this->request->getControllerActionName()]['template'];
     }
     if (isset($templatePathAndFilename) && strlen($templatePathAndFilename) > 0) {
         /**
          * Format Overlay
          */
         if ($this->request->getFormat() && strtolower($this->request->getFormat()) !== 'html') {
             $templatePathAndFilename = Tx_Yag_Domain_FileSystem_Div::concatenatePaths(array(dirname($templatePathAndFilename), basename($templatePathAndFilename, '.html') . '.' . $this->request->getFormat()));
         }
         if (file_exists(GeneralUtility::getFileAbsFileName($templatePathAndFilename))) {
             $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templatePathAndFilename));
         } else {
             throw new Exception('Given template path and filename could not be found or resolved: ' . $templatePathAndFilename . ' 1284655109');
         }
     }
 }
 /**
  * Initialize all views
  *
  * @param ViewInterface $view
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $view->assignMultiple(array('formData' => $this->request->getArgument('formData'), 'storagePid' => $frameworkConfiguration['persistence']['storagePid']));
 }
 /**
  * Initializes view
  *
  * @param ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     $view->assign('previewUrl', BackendUtility::viewonclick($this->pageInfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageInfo['uid'])));
 }
 /**
  * Set the TS defined custom paths in view
  * 
  * Template path can be configured in TS via
  * plugin.<plugin_key>.settings.controller.<Controller_Name_Without_Controller>.<action_name_without_action>.template = full_path_to_template_with.html
  * 
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  * @throws Exception
  */
 protected function setCustomPathsInView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     // We use template method here to enable adding further informations in extending controllers
     $templatePathAndFilename = $this->getTsTemplatePathAndFilename();
     // We have no template path set by TS --> fallback
     if (!$templatePathAndFilename) {
         $templatePathAndFilename = $this->templatePathAndFileName;
     }
     if (isset($templatePathAndFilename) && strlen($templatePathAndFilename) > 0) {
         // We enable FILE: and EXT: prefix for template path
         if (file_exists(GeneralUtility::getFileAbsFileName($templatePathAndFilename))) {
             $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templatePathAndFilename));
         } else {
             throw new Exception('Given template path and filename could not be found or resolved: ' . GeneralUtility::getFileAbsFileName($templatePathAndFilename), 1284655109);
         }
     }
 }
Example #15
0
 /**
  * Initializes the view before invoking an action method.
  * Add content object data to view
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
     parent::initializeView($view);
 }
Example #16
0
 /**
  * @test
  */
 public function showMiniCartPassesCartToView()
 {
     $cart = new \Extcode\Cart\Domain\Model\Cart\Cart([], 0);
     $this->view->expects(self::once())->method('assign')->with('cart', $cart);
     $this->subject->showMiniCartAction();
 }
 /**
  * Set the TS defined custom paths in view
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  * @throws Exception
  */
 protected function setCustomPathsInView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     // TODO we do not get global settings from pt_extlist merged into list_identifier settings here. fix this.
     // Get template for current action from settings for list identifier
     $templatePathAndFilename = $this->settings['listConfig'][$this->listIdentifier]['controller'][$this->request->getControllerName()][$this->request->getControllerActionName()]['template'];
     // Get template for current action from global settings (e.g. flexform)
     if (!$templatePathAndFilename) {
         $templatePathAndFilename = $this->settings['controller'][$this->request->getControllerName()][$this->request->getControllerActionName()]['template'];
     }
     // If no template is given before, take default one
     if (!$templatePathAndFilename) {
         $templatePathAndFilename = $this->templatePathAndFileName;
     }
     if (isset($templatePathAndFilename) && strlen($templatePathAndFilename) > 0) {
         if (file_exists(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($templatePathAndFilename))) {
             /* @var $view Tx_PtExtlist_View_BaseView */
             $view->setTemplatePathAndFilename(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($templatePathAndFilename));
         } else {
             throw new Exception('Given template path and filename could not be found or resolved: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($templatePathAndFilename), 1284655110);
         }
     }
 }
 /**
  * Initializes the view before invoking an action method.
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
     $view->assign('emConfiguration', Tx_MooxNews_Utility_EmConfiguration::getSettings());
 }
 /**
  * @param ViewInterface $view
  */
 public function initializeView(ViewInterface $view)
 {
     $view->assign('backendUserData', $this->backendUser->user);
     $view->assign('configuration', $this->configuration);
 }
Example #20
0
 /**
  * Initializes the view before invoking an action method.
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
     $view->assign('emConfiguration', EmConfiguration::getSettings());
     $view->assign('isVersion7Compatible', GeneralUtility::compat_version('7.0'));
 }
 /**
  * [initializeView description]
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view [description]
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $view->assign('layout', $this->isAjax ? 'Ajax' : 'Default');
     $view->assign('setup', $this->setup);
     $view->assign('data', $this->data);
 }
 /**
  * Initializes the title for the RSS feed of the current action consisting
  * of the page title and the content element header.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  */
 protected function initializeRssTitle(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     if (!empty($this->settings['list']['rss']['channel']['title'])) {
         $view->assign('rssTitle', $this->settings['list']['rss']['channel']['title']);
         return;
     }
     $rssTitle = $this->configurationManager->getContentObject()->data['header'];
     \TYPO3\CMS\Frontend\Page\PageGenerator::generatePageTitle();
     $rssTitle .= ' - ' . $this->getTypoScriptFrontendController()->getPageRenderer()->getTitle();
     $view->assign('rssTitle', $rssTitle);
 }
Example #23
0
 /**
  * Initializes the view before invoking an action method.
  *
  * Assigns the current module to the view
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     $view->assign('module', $this);
 }
 /**
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
  * @throws \Exception
  * @return string
  */
 protected function renderView(ViewInterface $view)
 {
     try {
         $content = $view->render();
     } catch (\Exception $error) {
         if (!$this->arguments['graceful']) {
             throw $error;
         }
         $content = $error->getMessage() . ' (' . $error->getCode() . ')';
     }
     return $content;
 }