Пример #1
0
 /**
  * Set template
  *
  * @param array $conf With possibly set file resource
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function setTemplate(array $conf)
 {
     // Fetch the Fluid template by templateName
     if (!empty($conf['templateName']) && !empty($conf['templateRootPaths.']) && is_array($conf['templateRootPaths.'])) {
         $templateRootPaths = array();
         foreach ($conf['templateRootPaths.'] as $key => $path) {
             if (strpos($key, '.') === false) {
                 $templateRootPaths[$key] = isset($conf['templateRootPaths.'][$key . '.']) ? GeneralUtility::getFileAbsFileName($this->cObj->stdWrap($conf['templateRootPaths.'][$key], $conf['templateRootPaths.'][$key . '.'])) : GeneralUtility::getFileAbsFileName($path);
             }
         }
         $this->view->setTemplateRootPaths($templateRootPaths);
         $templateName = isset($conf['templateName.']) ? $this->cObj->stdWrap($conf['templateName'], $conf['templateName.']) : $conf['templateName'];
         $this->view->setTemplate($templateName);
         // Fetch the Fluid template by template cObject
     } elseif (!empty($conf['template']) && !empty($conf['template.'])) {
         $templateSource = $this->cObj->cObjGetSingle($conf['template'], $conf['template.']);
         $this->view->setTemplateSource($templateSource);
         // Fetch the Fluid template by file stdWrap
     } else {
         $file = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
         /** @var $templateService \TYPO3\CMS\Core\TypoScript\TemplateService */
         $templateService = $GLOBALS['TSFE']->tmpl;
         $templatePathAndFilename = $templateService->getFileName($file);
         $this->view->setTemplatePathAndFilename(PATH_site . $templatePathAndFilename);
     }
 }
Пример #2
0
 /**
  * @test
  */
 public function setTemplateWalksStringKeysInReversedOrder()
 {
     $this->view->setTemplateRootPaths(array('default' => 'some/Default/Directory', 'specific' => 'specific/Templates', 'verySpecific' => 'evenMore/Specific/Templates'));
     $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
     $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Templates/Template.html')->will($this->returnValue(false));
     $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Templates/Template')->will($this->returnValue(false));
     $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Templates/Template.html')->will($this->returnValue(false));
     $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Templates/Template')->will($this->returnValue(false));
     $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Template.html')->will($this->returnValue(false));
     $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Template')->will($this->returnValue(true));
     $this->view->setTemplate('Template');
     $this->assertEquals(PATH_site . 'some/Default/Directory/Template', $this->view->getTemplatePathAndFilename());
 }
Пример #3
0
 /**
  * Set template
  *
  * @param array $conf With possibly set file resource
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function setTemplate(array $conf)
 {
     // Fetch the Fluid template by templateName
     if ((!empty($conf['templateName']) || !empty($conf['templateName.'])) && !empty($conf['templateRootPaths.']) && is_array($conf['templateRootPaths.'])) {
         $templateRootPaths = $this->applyStandardWrapToFluidPaths($conf['templateRootPaths.']);
         $this->view->setTemplateRootPaths($templateRootPaths);
         $templateName = isset($conf['templateName.']) ? $this->cObj->stdWrap(isset($conf['templateName']) ? $conf['templateName'] : '', $conf['templateName.']) : $conf['templateName'];
         $this->view->setTemplate($templateName);
         // Fetch the Fluid template by template cObject
     } elseif (!empty($conf['template']) && !empty($conf['template.'])) {
         $templateSource = $this->cObj->cObjGetSingle($conf['template'], $conf['template.']);
         $this->view->setTemplateSource($templateSource);
         // Fetch the Fluid template by file stdWrap
     } else {
         $file = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
         /** @var $templateService \TYPO3\CMS\Core\TypoScript\TemplateService */
         $templateService = $GLOBALS['TSFE']->tmpl;
         $templatePathAndFilename = $templateService->getFileName($file);
         $this->view->setTemplatePathAndFilename(PATH_site . $templatePathAndFilename);
     }
 }
Пример #4
0
 /**
  * Class constructor
  * Sets up view and property objects
  *
  * @throws InvalidTemplateResourceException In case a template is invalid
  */
 public function __construct()
 {
     $this->view = GeneralUtility::makeInstance(StandaloneView::class);
     $this->view->setPartialRootPaths($this->partialRootPaths);
     $this->view->setTemplateRootPaths($this->templateRootPaths);
     $this->view->setLayoutRootPaths($this->layoutRootPaths);
     $this->view->setTemplate($this->templateFile);
     $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
     $this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
 }
Пример #5
0
 /**
  * Main module function
  *
  * @throws \BadFunctionCallException
  * @throws \InvalidArgumentException
  * @return void
  */
 public function main()
 {
     $this->lang->includeLLFile('EXT:impexp/Resources/Private/Language/locallang.xlf');
     // Start document template object:
     // We keep this here, in case somebody relies on the old doc being here
     $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
     $this->doc->bodyTagId = 'imp-exp-mod';
     $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
     if (is_array($this->pageinfo)) {
         $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
     }
     // Setting up the context sensitive menu:
     $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
     $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Impexp/ImportExport');
     $this->moduleTemplate->addJavaScriptCode('ImpexpInLineJS', 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . ';');
     // Input data grabbed:
     $inData = GeneralUtility::_GP('tx_impexp');
     $this->standaloneView->assign('moduleUrl', BackendUtility::getModuleUrl('xMOD_tximpexp'));
     $this->standaloneView->assign('id', $this->id);
     $this->standaloneView->assign('inData', $inData);
     switch ((string) $inData['action']) {
         case 'export':
             $this->shortcutName = $this->lang->getLL('title_export');
             // Call export interface
             $this->exportData($inData);
             $this->standaloneView->setTemplate('Export.html');
             break;
         case 'import':
             $this->shortcutName = $this->lang->getLL('title_import');
             if (GeneralUtility::_POST('_upload')) {
                 $this->checkUpload();
             }
             // Finally: If upload went well, set the new file as the import file:
             if (!empty($this->uploadedFiles[0])) {
                 // Only allowed extensions....
                 $extension = $this->uploadedFiles[0]->getExtension();
                 if ($extension === 't3d' || $extension === 'xml') {
                     $inData['file'] = $this->uploadedFiles[0]->getCombinedIdentifier();
                 }
             }
             // Call import interface:
             $this->importData($inData);
             $this->standaloneView->setTemplate('Import.html');
             break;
     }
     // Setting up the buttons and markers for docheader
     $this->getButtons();
 }
Пример #6
0
 /**
  * Render the warning markup when the page record has not been saved yet
  *
  * @return string The warning markup
  */
 protected function renderSaveWarning()
 {
     $this->view->setTemplate('SaveWarning');
     return $this->view->render();
 }