/**
  * @test
  */
 public function renderCallsStandardWrapOnResultStringIfGivenInConfiguration()
 {
     $this->addMockViewToSubject();
     $configuration = array('stdWrap.' => array('foo' => 'bar'));
     $this->standaloneView->expects($this->any())->method('render')->will($this->returnValue('baz'));
     $this->contentObjectRenderer->expects($this->once())->method('stdWrap')->with('baz', array('foo' => 'bar'));
     $this->subject->render($configuration);
 }
Exemple #2
0
 /**
  * Renders an ajax-enabled text field. Also adds required JS
  *
  * @param string $fieldName The field name in the form
  * @param string $table The table we render this selector for
  * @param string $field The field we render this selector for
  * @param array $row The row which is currently edited
  * @param array $config The TSconfig of the field
  * @param array $flexFormConfig If field is within flex form, this is the TCA config of the flex field
  * @throws \RuntimeException for incomplete incoming arguments
  * @return string The HTML code for the selector
  */
 public function renderSuggestSelector($fieldName, $table, $field, array $row, array $config, array $flexFormConfig = [])
 {
     $dataStructureIdentifier = '';
     if (!empty($flexFormConfig) && $flexFormConfig['config']['type'] === 'flex') {
         $fieldPattern = 'data[' . $table . '][' . $row['uid'] . '][';
         $flexformField = str_replace($fieldPattern, '', $fieldName);
         $flexformField = substr($flexformField, 0, -1);
         $field = str_replace([']['], '|', $flexformField);
         if (!isset($flexFormConfig['config']['dataStructureIdentifier'])) {
             throw new \RuntimeException('A data structure identifier must be set in [\'config\'] part of a flex form.' . ' This is usually added by TcaFlexPrepare data processor', 1478604742);
         }
         $dataStructureIdentifier = $flexFormConfig['config']['dataStructureIdentifier'];
     }
     // Get minimumCharacters from TCA
     $minChars = 0;
     if (isset($config['fieldConf']['config']['wizards']['suggest']['default']['minimumCharacters'])) {
         $minChars = (int) $config['fieldConf']['config']['wizards']['suggest']['default']['minimumCharacters'];
     }
     // Overwrite it with minimumCharacters from TSConfig if given
     if (isset($config['fieldTSConfig']['suggest.']['default.']['minimumCharacters'])) {
         $minChars = (int) $config['fieldTSConfig']['suggest.']['default.']['minimumCharacters'];
     }
     $minChars = $minChars > 0 ? $minChars : 2;
     // fetch the TCA field type to hand it over to the JS class
     $type = '';
     if (isset($config['fieldConf']['config']['type'])) {
         $type = $config['fieldConf']['config']['type'];
     }
     // Sign those parameters that come back in an ajax request to configure the search in searchAction()
     $hmac = GeneralUtility::hmac((string) $table . (string) $field . (string) $row['uid'] . (string) $row['pid'] . (string) $dataStructureIdentifier, 'formEngineSuggest');
     $this->view->assignMultiple(['placeholder' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.findRecord', 'fieldname' => $fieldName, 'table' => $table, 'field' => $field, 'uid' => $row['uid'], 'pid' => (int) $row['pid'], 'dataStructureIdentifier' => $dataStructureIdentifier, 'fieldtype' => $type, 'minchars' => (int) $minChars, 'hmac' => $hmac]);
     return $this->view->render();
 }
 public function main()
 {
     $result = $error = $url = NULL;
     $this->view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($this->templatePath . 'Main.html'));
     if ($this->configuration->isValid()) {
         try {
             $this->checkPageId();
             $url = $this->urlService->getFullUrl($this->pageId, $this->pObj->MOD_SETTINGS);
             if (GeneralUtility::_GET('clear')) {
                 $this->pageSpeedRepository->clearByIdentifier($url);
                 $this->view->assign('cacheCleared', TRUE);
             }
             $result = $this->pageSpeedRepository->findByIdentifier($url);
         } catch (\HTTP_Request2_ConnectionException $e) {
             $error = 'error.http_request.connection';
             // todo add log
         } catch (\RuntimeException $e) {
             $error = $e->getMessage();
         }
     } else {
         $error = 'error.invalid.key';
     }
     $this->view->assignMultiple(array('lll' => 'LLL:EXT:page_speed/Resources/Private/Language/locallang.xlf:', 'menu' => $this->modifyFuncMenu(BackendUtility::getFuncMenu($this->pObj->id, 'SET[language]', $this->pObj->MOD_SETTINGS['language'], $this->pObj->MOD_MENU['language']), 'language'), 'configuration' => $this->configuration, 'result' => $result, 'url' => $url, 'error' => $error, 'pageId' => $this->pageId));
     return $this->view->render();
 }
 /**
  * @param string $viewHelperTemplate
  * @param string $expectedOutput
  *
  * @test
  * @dataProvider viewHelperTemplateSourcesDataProvider
  */
 public function renderingTest($viewHelperTemplate, $expectedOutput)
 {
     $view = new StandaloneView();
     $view->getRenderingContext()->getViewHelperResolver()->addNamespace('ft', 'TYPO3Fluid\\FluidTest\\ViewHelpers');
     $view->getRenderingContext()->getTemplatePaths()->setTemplateSource($viewHelperTemplate);
     $view->assign('settings', ['test' => '<strong>Bla</strong>']);
     $this->assertSame($expectedOutput, $view->render());
 }
Exemple #5
0
 /**
  * Initialize the handler
  *
  * @param AbstractLinkBrowserController $linkBrowser
  * @param string $identifier
  * @param array $configuration Page TSconfig
  *
  * @return void
  */
 public function initialize(AbstractLinkBrowserController $linkBrowser, $identifier, array $configuration)
 {
     $this->linkBrowser = $linkBrowser;
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $this->view = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
     $this->view->getRequest()->setControllerExtensionName('recordlist');
     $this->view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:recordlist/Resources/Private/Templates/LinkBrowser')]);
     $this->view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:recordlist/Resources/Private/Partials/LinkBrowser')]);
     $this->view->setLayoutRootPaths([GeneralUtility::getFileAbsFileName('EXT:recordlist/Resources/Private/Layouts/LinkBrowser')]);
 }
 /**
  * @param StandaloneView $view
  * @param PageRenderer $pageRenderer
  * @param LoginController $loginController
  * @throws \UnexpectedValueException
  */
 public function render(StandaloneView $view, PageRenderer $pageRenderer, LoginController $loginController)
 {
     GeneralUtility::makeInstance(ObjectManager::class)->get(Dispatcher::class)->dispatch(__CLASS__, self::SIGNAL_getPageRenderer, array($pageRenderer));
     $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/UserPassLogin');
     $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/UserPassLoginForm.html'));
     if (GeneralUtility::getIndpEnv('TYPO3_SSL')) {
         $view->assign('presetUsername', GeneralUtility::_GP('u'));
         $view->assign('presetPassword', GeneralUtility::_GP('p'));
     }
 }
 /**
  * Callback function for rendering quotes.
  *
  * @param string $matches PCRE matches.
  * @return string  The quote content.
  */
 protected function replaceCallback($matches)
 {
     $this->view->setControllerContext($this->controllerContext);
     $this->view->setTemplatePathAndFilename(File::replaceSiteRelPath($this->settings['template']));
     $tmp = $this->postRepository->findByUid((int) $matches[1]);
     if (!empty($tmp)) {
         $this->view->assign('post', $tmp);
     }
     $this->view->assign('quote', trim($matches[2]));
     return $this->view->render();
 }
 /**
  * @param string $templateName
  * @param string $appExtensionKey
  * @return string
  */
 public function loadTemplateAction($templateName, $appExtensionKey)
 {
     $appTemplatesPath = sprintf(RoutesFileGenerator::APP_TEMPLATES_FOLDER, ExtensionManagementUtility::extPath($appExtensionKey));
     $templateFilePath = $appTemplatesPath . '/' . $templateName;
     if (!file_exists($templateFilePath)) {
         return '';
     } else {
         $this->view->setTemplatePathAndFilename($templateFilePath);
         return $this->view->render();
     }
 }
Exemple #9
0
 /**
  * Initialize the handle action, sets up fluid stuff and assigns default variables.
  *
  * @return void
  */
 protected function initializeHandle()
 {
     // Context service distinguishes between standalone and backend context
     $contextService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\ContextService::class);
     $viewRootPath = GeneralUtility::getFileAbsFileName('EXT:install/Resources/Private/');
     $controllerActionDirectoryName = ucfirst($this->controller);
     $mainTemplate = ucfirst($this->action);
     $this->view = GeneralUtility::makeInstance(StandaloneView::class);
     $this->view->setTemplatePathAndFilename($viewRootPath . 'Templates/Action/' . $controllerActionDirectoryName . '/' . $mainTemplate . '.html');
     $this->view->setLayoutRootPaths([$viewRootPath . 'Layouts/']);
     $this->view->setPartialRootPaths([$viewRootPath . 'Partials/']);
     $this->view->assign('time', time())->assign('action', $this->action)->assign('controller', $this->controller)->assign('token', $this->token)->assign('context', $contextService->getContextString())->assign('contextService', $contextService)->assign('lastError', $this->lastError)->assign('messages', $this->messages)->assign('typo3Version', TYPO3_version)->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
 }
Exemple #10
0
 /**
  * Render avatar tag
  *
  * @param array $backendUser be_users record
  * @param int $size width and height of the image
  * @param bool $showIcon show the record icon
  * @return string
  */
 public function render(array $backendUser = null, int $size = 32, bool $showIcon = false)
 {
     if (!is_array($backendUser)) {
         $backendUser = $this->getBackendUser()->user;
     }
     // Icon
     $icon = '';
     if ($showIcon) {
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $icon = $iconFactory->getIconForRecord('be_users', $backendUser, Icon::SIZE_SMALL)->render();
     }
     $image = $this->getImgTag($backendUser, $size);
     $this->view->assignMultiple(['image' => $image, 'icon' => $icon]);
     return $this->view->render();
 }
 /**
  * @test
  */
 public function getPartialSourceReturnsContentOfDefaultPartialFileIfNoPartialExistsForTheSpecifiedFormat()
 {
     $partialRootPath = __DIR__ . '/Fixtures';
     $this->view->setPartialRootPath($partialRootPath);
     $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo'));
     $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture');
     $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
     $this->assertEquals($expectedResult, $actualResult);
 }
Exemple #12
0
 /**
  * Prints the clipboard
  *
  * @return string HTML output
  * @throws \BadFunctionCallException
  */
 public function printClipboard()
 {
     $languageService = $this->getLanguageService();
     $elementCount = count($this->elFromTable($this->fileMode ? '_FILE' : ''));
     // Copymode Selector menu
     $copymodeUrl = GeneralUtility::linkThisScript();
     $this->view->assign('actionCopyModeUrl', htmlspecialchars(GeneralUtility::quoteJSvalue($copymodeUrl . '&CB[setCopyMode]=')));
     $this->view->assign('actionCopyModeUrl1', htmlspecialchars(GeneralUtility::quoteJSvalue($copymodeUrl . '&CB[setCopyMode]=1')));
     $this->view->assign('currentMode', $this->currentMode());
     $this->view->assign('elementCount', $elementCount);
     if ($elementCount) {
         $removeAllUrl = GeneralUtility::linkThisScript(['CB' => ['removeAll' => $this->current]]);
         $this->view->assign('removeAllUrl', $removeAllUrl);
         // Selector menu + clear button
         $optionArray = [];
         // Import / Export link:
         if (ExtensionManagementUtility::isLoaded('impexp')) {
             $url = BackendUtility::getModuleUrl('xMOD_tximpexp', $this->exportClipElementParameters());
             $optionArray[] = ['label' => $this->clLabel('export', 'rm'), 'uri' => $url];
         }
         // Edit:
         if (!$this->fileMode) {
             $optionArray[] = ['label' => $this->clLabel('edit', 'rm'), 'uri' => '#', 'additionalAttributes' => ['onclick' => htmlspecialchars('window.location.href=' . GeneralUtility::quoteJSvalue($this->editUrl() . '&returnUrl=') . '+top.rawurlencode(window.location.href);')]];
         }
         // Delete referenced elements:
         $confirmationCheck = false;
         if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
             $confirmationCheck = true;
         }
         $confirmationMessage = sprintf($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.deleteClip'), $elementCount);
         $title = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clipboard.delete_elements');
         $returnUrl = $this->deleteUrl(1, $this->fileMode ? 1 : 0);
         $btnOkText = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf:buttons.confirm.delete_elements.yes');
         $btnCancelText = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf:buttons.confirm.delete_elements.no');
         $optionArray[] = ['label' => htmlspecialchars($title), 'uri' => $returnUrl, 'additionalAttributes' => ['class' => $confirmationCheck ? 't3js-modal-trigger' : ''], 'data' => ['severity' => 'warning', 'button-close-text' => htmlspecialchars($btnCancelText), 'button-ok-text' => htmlspecialchars($btnOkText), 'content' => htmlspecialchars($confirmationMessage), 'title' => htmlspecialchars($title)]];
         // Clear clipboard
         $optionArray[] = ['label' => $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clipboard.clear_clipboard', true), 'uri' => $removeAllUrl . '#clip_head'];
         $this->view->assign('optionArray', $optionArray);
     }
     // Print header and content for the NORMAL tab:
     $this->view->assign('current', $this->current);
     $tabArray = [];
     $tabArray['normal'] = ['id' => 'normal', 'number' => 0, 'url' => GeneralUtility::linkThisScript(['CB' => ['setP' => 'normal']]), 'description' => 'normal-description', 'label' => 'labels.normal', 'padding' => $this->padTitle('normal')];
     if ($this->current == 'normal') {
         $tabArray['normal']['content'] = $this->getContentFromTab('normal');
     }
     // Print header and content for the NUMERIC tabs:
     for ($a = 1; $a <= $this->numberTabs; $a++) {
         $tabArray['tab_' . $a] = ['id' => 'tab_' . $a, 'number' => $a, 'url' => GeneralUtility::linkThisScript(['CB' => ['setP' => 'tab_' . $a]]), 'description' => 'cliptabs-description', 'label' => 'labels.cliptabs-name', 'padding' => $this->padTitle('tab_' . $a)];
         if ($this->current === 'tab_' . $a) {
             $tabArray['tab_' . $a]['content'] = $this->getContentFromTab('tab_' . $a);
         }
     }
     $this->view->assign('clipboardHeader', BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_clipboard', $this->clLabel('clipboard', 'buttons')));
     $this->view->assign('tabArray', $tabArray);
     return $this->view->render();
 }
 /**
  * Render drop down
  *
  * @return string Drop down HTML
  */
 public function getDropDown()
 {
     if (!$this->checkAccess()) {
         return '';
     }
     $request = $this->standaloneView->getRequest();
     $request->setControllerExtensionName('backend');
     $this->standaloneView->assignMultiple(array('installToolUrl' => BackendUtility::getModuleUrl('system_extinstall'), 'messages' => $this->systemMessages, 'count' => $this->totalCount > $this->maximumCountInBadge ? $this->maximumCountInBadge . '+' : $this->totalCount, 'severityBadgeClass' => $this->severityBadgeClass, 'systemInformation' => $this->systemInformation));
     return $this->standaloneView->render();
 }
Exemple #14
0
 /**
  * Show list references
  *
  * @return void
  */
 public function func_relations()
 {
     $admin = GeneralUtility::makeInstance(DatabaseIntegrityCheck::class);
     $fkey_arrays = $admin->getGroupFields('');
     $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
     $fileTest = $admin->testFileRefs();
     if (is_array($fileTest['noFile'])) {
         ksort($fileTest['noFile']);
     }
     $this->view->assignMultiple(['files' => $fileTest, 'select_db' => $admin->testDBRefs($admin->checkSelectDBRefs), 'group_db' => $admin->testDBRefs($admin->checkGroupDBRefs)]);
 }
 /**
  * inits the standalone fluid template
  */
 public function initFluidTemplate()
 {
     $this->resultListView = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $this->resultListView->setPartialRootPaths([$this->conf['partialRootPath']]);
     $this->resultListView->setLayoutRootPaths([$this->conf['layoutRootPath']]);
     $this->resultListView->setTemplatePathAndFilename($this->conf['templateRootPath'] . 'ResultList.html');
     // make settings available in fluid template
     $this->resultListView->assign('conf', $this->conf);
     $this->resultListView->assign('extConf', $this->extConf);
     $this->resultListView->assign('extConfPremium', $this->extConfPremium);
 }
 /**
  * @test
  */
 public function getLayoutPathAndFilenameWalksStringKeysInReversedOrder()
 {
     $this->view->setLayoutRootPaths(array('default' => 'some/Default/Directory', 'specific' => 'specific/Layout', 'verySpecific' => 'evenMore/Specific/Layout'));
     $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
     $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layout/Default.html')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layout/Default')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layout/Default.html')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layout/Default')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE));
     $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
 }
 /**
  * renderContent renders sie given Fluidtemplate an adds the given data to the view helper.
  * Your templates have to be in "Resources/Private/Html/Content/"
  *
  * @param array  $data Daten für das Fluid-Template
  * @param string $templateFile
  *
  * @return string Content
  */
 public function renderContent($data, $templateFile)
 {
     if (file_exists($templateFile)) {
         $this->view->getRequest()->setControllerExtensionName($this->extKey);
         $this->view->setTemplatePathAndFilename($templateFile);
         $this->view->assign('data', $data);
         $content = $this->view->render();
     } else {
         $content = 'Could not load template!';
     }
     return $content;
 }
 /**
  * @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());
 }
 /**
  * Making interface selector:
  *
  * @return void
  */
 public function makeInterfaceSelectorBox()
 {
     // If interfaces are defined AND no input redirect URL in GET vars:
     if ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] && ($this->isLoginInProgress() || !$this->redirectUrl)) {
         $parts = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']);
         if (count($parts) > 1) {
             // Only if more than one interface is defined we will show the selector
             $interfaces = array('backend' => array('label' => $this->getLanguageService()->getLL('interface.backend'), 'jumpScript' => BackendUtility::getModuleUrl('main'), 'interface' => 'backend'), 'frontend' => array('label' => $this->getLanguageService()->getLL('interface.frontend'), 'jumpScript' => '../', 'interface' => 'frontend'));
             $this->view->assign('showInterfaceSelector', true);
             $this->view->assign('interfaces', $interfaces);
         } elseif (!$this->redirectUrl) {
             // If there is only ONE interface value set and no redirect_url is present
             $this->view->assign('showInterfaceSelector', false);
             $this->view->assign('interface', $parts[0]);
         }
     }
 }
Exemple #20
0
 /**
  * Init some values
  * 
  * @param array $data
  */
 protected function init($data)
 {
     $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:yag/Resources/Private/Templates/Backend/PluginInfo.html');
     // Extbase
     $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $configuration['extensionName'] = self::EXTENSION_NAME;
     $configuration['pluginName'] = self::PLUGIN_NAME;
     $bootstrap = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Core\\Bootstrap');
     $bootstrap->initialize($configuration);
     // Fluid
     $this->fluidRenderer = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $this->fluidRenderer->setTemplatePathAndFilename($templatePathAndFilename);
     // PluginMode
     if (is_array($data)) {
         $firstControllerAction = array_shift(explode(';', $this->getDataValue($data, 'switchableControllerActions', 'sDefault')));
         $this->pluginMode = str_replace('->', '_', $firstControllerAction);
         // Theme
         $this->theme = $this->getDataValue($data, 'settings.theme', 'sDefault');
     }
 }
Exemple #21
0
 /**
  * Initialize module header etc and call extObjContent function
  *
  * @return void
  */
 public function main()
 {
     // Access check...
     // The page will show only if there is a valid page and if this page may be viewed by the user
     $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
     if ($this->pageinfo) {
         $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
     }
     $access = is_array($this->pageinfo);
     // We keep this here, in case somebody relies on the old doc being here
     $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
     // Main
     if ($this->id && $access) {
         // JavaScript
         $this->moduleTemplate->addJavaScriptCode('WebFuncInLineJS', 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . ';');
         // Setting up the context sensitive menu:
         $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
         $this->view = $this->getFluidTemplateObject('func', 'func');
         $this->view->assign('moduleName', BackendUtility::getModuleUrl('web_func'));
         $this->view->assign('id', $this->id);
         $this->view->assign('versionSelector', $this->moduleTemplate->getVersionSelector($this->id, true));
         $this->view->assign('functionMenuModuleContent', $this->getExtObjContent());
         // Setting up the buttons and markers for docheader
         $this->getButtons();
         $this->generateMenu();
         $this->content .= $this->view->render();
     } else {
         // If no access or if ID == zero
         $title = $this->getLanguageService()->getLL('title');
         $message = $this->getLanguageService()->getLL('clickAPage_content');
         $this->view = $this->getFluidTemplateObject('func', 'func', 'InfoBox');
         $this->view->assignMultiple(['title' => $title, 'message' => $message, 'state' => InfoboxViewHelper::STATE_INFO]);
         $this->content = $this->view->render();
         // Setting up the buttons and markers for docheader
         $this->getButtons();
     }
 }
Exemple #22
0
    /**
     * Initialize module header etc and call extObjContent function
     *
     * @return void
     */
    public function main()
    {
        // We leave this here because of dependencies to submodules
        $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
        // The page will show only if there is a valid page and if this page
        // may be viewed by the user
        $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
        if ($this->pageinfo) {
            $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
        }
        $access = is_array($this->pageinfo);
        if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) {
            if ($this->backendUser->user['admin'] && !$this->id) {
                $this->pageinfo = ['title' => '[root-level]', 'uid' => 0, 'pid' => 0];
            }
            // JavaScript
            $this->moduleTemplate->addJavaScriptCode('WebFuncInLineJS', 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . ';
				function jumpToUrl(URL) {
					window.location.href = URL;
					return false;
				}
				');
            // Setting up the context sensitive menu:
            $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
            $this->view = $this->getFluidTemplateObject();
            $this->view->assign('moduleName', BackendUtility::getModuleUrl($this->moduleName));
            $this->view->assign('versionSelector', $this->moduleTemplate->getVersionSelector($this->id, 1));
            $this->view->assign('functionMenuModuleContent', $this->getExtObjContent());
            // Setting up the buttons and markers for docheader
            $this->getButtons();
            $this->generateMenu();
            $this->content .= $this->view->render();
        } else {
            // If no access or if ID == zero
            $this->content = $this->moduleTemplate->header($this->languageService->getLL('title'));
        }
    }
Exemple #23
0
 /**
  * Add sys_notes as additional content to the footer of the page module
  *
  * @param array $params
  * @param PageLayoutController $parentObject
  * @return string
  */
 public function render(array $params = array(), PageLayoutController $parentObject)
 {
     if ($parentObject->MOD_SETTINGS['function'] == 1) {
         $pageInfo = $parentObject->pageinfo;
         if ($this->pageCanBeIndexed($pageInfo)) {
             // template
             $this->loadCss();
             $this->loadJavascript();
             //load partial paths info from typoscript
             $this->view = GeneralUtility::makeInstance(StandaloneView::class);
             $this->view->setFormat('html');
             $this->view->getRequest()->setControllerExtensionName('cs_seo');
             $absoluteResourcesPath = ExtensionManagementUtility::extPath('cs_seo') . 'Resources/';
             $layoutPaths = [$absoluteResourcesPath . 'Private/Layouts/'];
             $partialPaths = [$absoluteResourcesPath . 'Private/Partials/'];
             // load partial paths info from TypoScript
             if ($this->isTYPO3VersionGreather6) {
                 /** @var ObjectManager $objectManager */
                 $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
                 /** @var ConfigurationManagerInterface $configurationManager */
                 $configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
                 $tsSetup = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'csseo');
                 $layoutPaths = $tsSetup["view"]["layoutRootPaths"] ?: $layoutPaths;
                 $partialPaths = $tsSetup["view"]["partialRootPaths"] ?: $partialPaths;
             }
             $this->view->setLayoutRootPaths($layoutPaths);
             $this->view->setPartialRootPaths($partialPaths);
             $this->view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('cs_seo') . 'Resources/Private/Templates/PageHook.html');
             $results = $this->getResults($pageInfo, $parentObject->current_sys_language);
             $score = $results['Percentage'];
             unset($results['Percentage']);
             $this->view->assignMultiple(['score' => $score, 'results' => $results, 'page' => $parentObject->pageinfo]);
             return $this->view->render();
         }
     }
 }
 /**
  * Main function of class
  *
  * @return string HTML output
  */
 public function main()
 {
     $pageId = (int) GeneralUtility::_GP('id');
     if ($pageId === 0) {
         $this->view->assign('pageZero', 1);
         $this->view->assign('overviewOfPagesUsingTSConfig', $this->getOverviewOfPagesUsingTSConfig());
     } else {
         if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
             $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, null, true);
             $lines = array();
             $pUids = array();
             foreach ($TSparts as $k => $v) {
                 if ($k != 'uid_0') {
                     $line = array();
                     if ($k == 'defaultPageTSconfig') {
                         $line['defaultPageTSconfig'] = 1;
                     } else {
                         $pUids[] = substr($k, 4);
                         $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
                         $icon = $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL);
                         $editIdList = substr($k, 4);
                         $urlParameters = ['edit' => ['pages' => [$editIdList => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                         $line['editIcon'] = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                         $line['editTitle'] = 'editTSconfig';
                         $line['title'] = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']) . ' ' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $row));
                     }
                     $tsparser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
                     $tsparser->lineNumberOffset = 0;
                     $line['content'] = $tsparser->doSyntaxHighlight(trim($v) . LF);
                     $lines[] = $line;
                 }
             }
             if (!empty($pUids)) {
                 $urlParameters = ['edit' => ['pages' => [implode(',', $pUids) => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                 $editIcon = htmlspecialchars($url);
                 $editTitle = 'editTSconfig_all';
             } else {
                 $editIcon = '';
                 $editTitle = '';
             }
             $this->view->assign('tsconfParts99', 1);
             $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', null, '|'));
             $this->view->assign('lines', $lines);
             $this->view->assign('editIcon', $editIcon);
             $this->view->assign('editTitle', $editTitle);
         } else {
             $this->view->assign('tsconfParts99', 0);
             // Defined global here!
             $tmpl = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
             // Do not log time-performance information
             $tmpl->tt_track = 0;
             $tmpl->fixedLgd = 0;
             $tmpl->linkObjects = 0;
             $tmpl->bType = '';
             $tmpl->ext_expandAllNotes = 1;
             $tmpl->ext_noPMicons = 1;
             $beUser = $this->getBackendUser();
             switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
                 case '1':
                     $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
                     break;
                 case '1a':
                     $modTSconfig = $beUser->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1b':
                     $modTSconfig = $beUser->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1c':
                     $modTSconfig = $beUser->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1d':
                     $modTSconfig = $beUser->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1e':
                     $modTSconfig = $beUser->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1f':
                     $modTSconfig = $beUser->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1g':
                     $modTSconfig = $beUser->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '2':
                     $modTSconfig = $beUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '5':
                     $modTSconfig = $beUser->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '6':
                     $modTSconfig = $beUser->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '3':
                     $modTSconfig = $beUser->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '4':
                     $modTSconfig = $beUser->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 default:
                     $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
             }
             $modTSconfig = $modTSconfig['properties'];
             if (!is_array($modTSconfig)) {
                 $modTSconfig = array();
             }
             $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', null, '|'));
             $this->view->assign('tree', $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']));
         }
         $this->view->assign('alphaSort', BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"'));
         $this->view->assign('dropdownMenu', BackendUtility::getDropdownMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']));
     }
     return $this->view->render();
 }
 /**
  * Render fluid standalone view
  *
  * @return string
  */
 protected function renderFluidView()
 {
     return $this->view->render();
 }
 /**
  * Main function
  *
  * @return void
  */
 public function main()
 {
     /** @var ArrayBrowser $arrayBrowser */
     $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
     $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
     $search_field = GeneralUtility::_GP('search_field');
     $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
     $this->view->setTemplatePathAndFilename($templatePathAndFilename);
     $this->view->assign('label', $label);
     $this->view->assign('search_field', $search_field);
     $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
     switch ($this->MOD_SETTINGS['function']) {
         case 0:
             $theVar = $GLOBALS['TYPO3_CONF_VARS'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TYPO3_CONF_VARS';
             break;
         case 1:
             $theVar = $GLOBALS['TCA'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TCA';
             break;
         case 2:
             $theVar = $GLOBALS['TCA_DESCR'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TCA_DESCR';
             break;
         case 3:
             $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
             break;
         case 4:
             $theVar = $GLOBALS['T3_SERVICES'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$T3_SERVICES';
             break;
         case 5:
             $theVar = $GLOBALS['TBE_MODULES'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TBE_MODULES';
             break;
         case 6:
             $theVar = $GLOBALS['TBE_MODULES_EXT'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TBE_MODULES_EXT';
             break;
         case 7:
             $theVar = $GLOBALS['TBE_STYLES'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TBE_STYLES';
             break;
         case 8:
             $theVar = $GLOBALS['BE_USER']->uc;
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$BE_USER->uc';
             break;
         case 9:
             $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
             ArrayUtility::naturalKeySortRecursive($theVar);
             $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
             break;
         default:
             $theVar = array();
     }
     // Update node:
     $update = 0;
     $node = GeneralUtility::_GET('node');
     // If any plus-signs were clicked, it's registered.
     if (is_array($node)) {
         $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
         $update = 1;
     }
     if ($update) {
         $this->getBackendUser()->pushModuleData($this->moduleName, $this->MOD_SETTINGS);
     }
     $arrayBrowser->dontLinkVar = true;
     $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
     $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
     $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
     $arrayBrowser->searchKeysToo = true;
     // If any POST-vars are send, update the condition array
     if (GeneralUtility::_POST('search') && trim($search_field)) {
         $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
     }
     // mask sensitive information
     $varName = trim($arrayBrowser->varName, '$');
     if (isset($this->blindedConfigurationOptions[$varName])) {
         ArrayUtility::mergeRecursiveWithOverrule($theVar, $this->blindedConfigurationOptions[$varName]);
     }
     $tree = $arrayBrowser->tree($theVar, '', '');
     $this->view->assign('tree', $tree);
     // Setting up the shortcut button for docheader
     $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
     // Shortcut
     $shortcutButton = $buttonBar->makeShortcutButton()->setModuleName($this->moduleName)->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])->setSetVariables(['function']);
     $buttonBar->addButton($shortcutButton);
     $this->getModuleMenu();
     $this->content = '<form action="" id="ConfigurationView" method="post">';
     $this->content .= $this->view->render();
     $this->content .= '</form>';
 }
Exemple #27
0
 /**
  * Set form tag
  *
  * @param string $formTag Form tag to add
  *
  * @return void
  */
 public function setForm($formTag = '')
 {
     $this->view->assign('formTag', $formTag);
 }
 /**
  * Assemble display of list of scheduled tasks
  *
  * @return string Table of pending tasks
  */
 protected function listTasksAction()
 {
     $this->view->setTemplatePathAndFilename($this->backendTemplatePath . 'ListTasks.html');
     // Define display format for dates
     $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
     // Get list of registered classes
     $registeredClasses = $this->getRegisteredClasses();
     // Get list of registered task groups
     $registeredTaskGroups = $this->getRegisteredTaskGroups();
     // add an empty entry for non-grouped tasks
     // add in front of list
     array_unshift($registeredTaskGroups, array('uid' => 0, 'groupName' => ''));
     // Get all registered tasks
     // Just to get the number of entries
     $query = array('SELECT' => '
             tx_scheduler_task.*,
             tx_scheduler_task_group.groupName as taskGroupName,
             tx_scheduler_task_group.description as taskGroupDescription,
             tx_scheduler_task_group.deleted as isTaskGroupDeleted
             ', 'FROM' => '
             tx_scheduler_task
             LEFT JOIN tx_scheduler_task_group ON tx_scheduler_task_group.uid = tx_scheduler_task.task_group
             ', 'WHERE' => '1=1', 'ORDERBY' => 'tx_scheduler_task_group.sorting');
     $res = $this->getDatabaseConnection()->exec_SELECT_queryArray($query);
     $numRows = $this->getDatabaseConnection()->sql_num_rows($res);
     // No tasks defined, display information message
     if ($numRows == 0) {
         $this->view->setTemplatePathAndFilename($this->backendTemplatePath . 'ListTasksNoTasks.html');
         return $this->view->render();
     } else {
         $this->getPageRenderer()->loadJquery();
         $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Scheduler/Scheduler');
         $table = array();
         // Header row
         $table[] = '<thead><tr>' . '<th><a href="#" id="checkall" title="' . $this->getLanguageService()->getLL('label.checkAll', true) . '" class="icon">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-select', Icon::SIZE_SMALL)->render() . '</a></th>' . '<th>' . $this->getLanguageService()->getLL('label.id', true) . '</th>' . '<th>' . $this->getLanguageService()->getLL('task', true) . '</th>' . '<th>' . $this->getLanguageService()->getLL('label.type', true) . '</th>' . '<th>' . $this->getLanguageService()->getLL('label.frequency', true) . '</th>' . '<th>' . $this->getLanguageService()->getLL('label.parallel', true) . '</th>' . '<th>' . $this->getLanguageService()->getLL('label.lastExecution', true) . '</th>' . '<th>' . $this->getLanguageService()->getLL('label.nextExecution', true) . '</th>' . '<th></th>' . '</tr></thead>';
         // Loop on all tasks
         $temporaryResult = array();
         while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
             if ($row['taskGroupName'] === null || $row['isTaskGroupDeleted'] === '1') {
                 $row['taskGroupName'] = '';
                 $row['taskGroupDescription'] = '';
                 $row['task_group'] = 0;
             }
             $temporaryResult[$row['task_group']]['groupName'] = $row['taskGroupName'];
             $temporaryResult[$row['task_group']]['groupDescription'] = $row['taskGroupDescription'];
             $temporaryResult[$row['task_group']]['tasks'][] = $row;
         }
         $registeredClasses = $this->getRegisteredClasses();
         foreach ($temporaryResult as $taskGroup) {
             if (!empty($taskGroup['groupName'])) {
                 $groupText = '<strong>' . htmlspecialchars($taskGroup['groupName']) . '</strong>';
                 if (!empty($taskGroup['groupDescription'])) {
                     $groupText .= '<br>' . nl2br(htmlspecialchars($taskGroup['groupDescription']));
                 }
                 $table[] = '<tr><td colspan="9">' . $groupText . '</td></tr>';
             }
             foreach ($taskGroup['tasks'] as $schedulerRecord) {
                 // Define action icons
                 $link = htmlspecialchars($this->moduleUri . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid']);
                 $editAction = '<a class="btn btn-default" href="' . $link . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:edit', true) . '" class="icon">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
                 if ((int) $schedulerRecord['disable'] === 1) {
                     $translationKey = 'enable';
                     $icon = $this->moduleTemplate->getIconFactory()->getIcon('actions-edit-unhide', Icon::SIZE_SMALL);
                 } else {
                     $translationKey = 'disable';
                     $icon = $this->moduleTemplate->getIconFactory()->getIcon('actions-edit-hide', Icon::SIZE_SMALL);
                 }
                 $toggleHiddenAction = '<a class="btn btn-default" href="' . htmlspecialchars($this->moduleUri . '&CMD=toggleHidden&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:' . $translationKey, true) . '" class="icon">' . $icon->render() . '</a>';
                 $deleteAction = '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars($this->moduleUri . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" ' . ' data-severity="warning"' . ' data-title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:delete', true) . '"' . ' data-button-close-text="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel', true) . '"' . ' data-content="' . $this->getLanguageService()->getLL('msg.delete', true) . '"' . ' title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:delete', true) . '" class="icon">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
                 $stopAction = '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars($this->moduleUri . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" ' . ' data-severity="warning"' . ' data-title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:stop', true) . '"' . ' data-button-close-text="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel', true) . '"' . ' data-content="' . $this->getLanguageService()->getLL('msg.stop', true) . '"' . ' title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:stop', true) . '" class="icon">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-close', Icon::SIZE_SMALL)->render() . '</a>';
                 $runAction = '<a class="btn btn-default" href="' . htmlspecialchars($this->moduleUri . '&tx_scheduler[execute][]=' . $schedulerRecord['uid']) . '" title="' . $this->getLanguageService()->getLL('action.run_task', true) . '" class="icon">' . $this->moduleTemplate->getIconFactory()->getIcon('extensions-scheduler-run-task', Icon::SIZE_SMALL)->render() . '</a>';
                 // Define some default values
                 $lastExecution = '-';
                 $isRunning = false;
                 $showAsDisabled = false;
                 $startExecutionElement = '<span class="btn btn-default disabled">' . $this->moduleTemplate->getIconFactory()->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
                 // Restore the serialized task and pass it a reference to the scheduler object
                 /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask|\TYPO3\CMS\Scheduler\ProgressProviderInterface */
                 $task = unserialize($schedulerRecord['serialized_task_object']);
                 $class = get_class($task);
                 if ($class === '__PHP_Incomplete_Class' && preg_match('/^O:[0-9]+:"(?P<classname>.+?)"/', $schedulerRecord['serialized_task_object'], $matches) === 1) {
                     $class = $matches['classname'];
                 }
                 // Assemble information about last execution
                 if (!empty($schedulerRecord['lastexecution_time'])) {
                     $lastExecution = date($dateFormat, $schedulerRecord['lastexecution_time']);
                     if ($schedulerRecord['lastexecution_context'] == 'CLI') {
                         $context = $this->getLanguageService()->getLL('label.cron');
                     } else {
                         $context = $this->getLanguageService()->getLL('label.manual');
                     }
                     $lastExecution .= ' (' . $context . ')';
                 }
                 if (isset($registeredClasses[get_class($task)]) && $this->scheduler->isValidTaskObject($task)) {
                     // The task object is valid
                     $labels = array();
                     $name = htmlspecialchars($registeredClasses[$class]['title'] . ' (' . $registeredClasses[$class]['extension'] . ')');
                     $additionalInformation = $task->getAdditionalInformation();
                     if ($task instanceof \TYPO3\CMS\Scheduler\ProgressProviderInterface) {
                         $progress = round(floatval($task->getProgress()), 2);
                         $name .= $this->renderTaskProgressBar($progress);
                     }
                     if (!empty($additionalInformation)) {
                         $name .= '<div class="additional-information">' . nl2br(htmlspecialchars($additionalInformation)) . '</div>';
                     }
                     // Check if task currently has a running execution
                     if (!empty($schedulerRecord['serialized_executions'])) {
                         $labels[] = array('class' => 'success', 'text' => $this->getLanguageService()->getLL('status.running'));
                         $isRunning = true;
                     }
                     // Prepare display of next execution date
                     // If task is currently running, date is not displayed (as next hasn't been calculated yet)
                     // Also hide the date if task is disabled (the information doesn't make sense, as it will not run anyway)
                     if ($isRunning || $schedulerRecord['disable']) {
                         $nextDate = '-';
                     } else {
                         $nextDate = date($dateFormat, $schedulerRecord['nextexecution']);
                         if (empty($schedulerRecord['nextexecution'])) {
                             $nextDate = $this->getLanguageService()->getLL('none');
                         } elseif ($schedulerRecord['nextexecution'] < $GLOBALS['EXEC_TIME']) {
                             $labels[] = array('class' => 'warning', 'text' => $this->getLanguageService()->getLL('status.late'), 'description' => $this->getLanguageService()->getLL('status.legend.scheduled'));
                         }
                     }
                     // Get execution type
                     if ($task->getType() === AbstractTask::TYPE_SINGLE) {
                         $execType = $this->getLanguageService()->getLL('label.type.single');
                         $frequency = '-';
                     } else {
                         $execType = $this->getLanguageService()->getLL('label.type.recurring');
                         if ($task->getExecution()->getCronCmd() == '') {
                             $frequency = $task->getExecution()->getInterval();
                         } else {
                             $frequency = $task->getExecution()->getCronCmd();
                         }
                     }
                     // Get multiple executions setting
                     if ($task->getExecution()->getMultiple()) {
                         $multiple = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:yes');
                     } else {
                         $multiple = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:no');
                     }
                     // Define checkbox
                     $startExecutionElement = '<label class="btn btn-default btn-checkbox"><input type="checkbox" name="tx_scheduler[execute][]" value="' . $schedulerRecord['uid'] . '" id="task_' . $schedulerRecord['uid'] . '"><span class="t3-icon fa"></span></label>';
                     $actions = $editAction . $toggleHiddenAction . $deleteAction;
                     // Check the disable status
                     // Row is shown dimmed if task is disabled, unless it is still running
                     if ($schedulerRecord['disable'] && !$isRunning) {
                         $labels[] = array('class' => 'default', 'text' => $this->getLanguageService()->getLL('status.disabled'));
                         $showAsDisabled = true;
                     }
                     // Show no action links (edit, delete) if task is running
                     if ($isRunning) {
                         $actions = $stopAction;
                     } else {
                         $actions .= $runAction;
                     }
                     // Check if the last run failed
                     if (!empty($schedulerRecord['lastexecution_failure'])) {
                         // Try to get the stored exception array
                         /** @var $exceptionArray array */
                         $exceptionArray = @unserialize($schedulerRecord['lastexecution_failure']);
                         // If the exception could not be unserialized, issue a default error message
                         if (!is_array($exceptionArray) || empty($exceptionArray)) {
                             $labelDescription = $this->getLanguageService()->getLL('msg.executionFailureDefault');
                         } else {
                             $labelDescription = sprintf($this->getLanguageService()->getLL('msg.executionFailureReport'), $exceptionArray['code'], $exceptionArray['message']);
                         }
                         $labels[] = array('class' => 'danger', 'text' => $this->getLanguageService()->getLL('status.failure'), 'description' => $labelDescription);
                     }
                     // Format the execution status,
                     // including failure feedback, if any
                     $taskDesc = '';
                     if ($schedulerRecord['description'] !== '') {
                         $taskDesc = '<span class="description">' . nl2br(htmlspecialchars($schedulerRecord['description'])) . '</span>';
                     }
                     $taskName = '<span class="name"><a href="' . $link . '">' . $name . '</a></span>';
                     $table[] = '<tr class="' . ($showAsDisabled ? 'disabled' : '') . '">' . '<td>' . $startExecutionElement . '</td>' . '<td class="right">' . $schedulerRecord['uid'] . '</td>' . '<td>' . $this->makeStatusLabel($labels) . $taskName . $taskDesc . '</td>' . '<td>' . $execType . '</td>' . '<td>' . $frequency . '</td>' . '<td>' . $multiple . '</td>' . '<td>' . $lastExecution . '</td>' . '<td>' . $nextDate . '</td>' . '<td nowrap="nowrap"><div class="btn-group" role="group">' . $actions . '</div></td>' . '</tr>';
                 } else {
                     // The task object is not valid
                     // Prepare to issue an error
                     $executionStatusOutput = '<span class="label label-danger">' . htmlspecialchars(sprintf($this->getLanguageService()->getLL('msg.invalidTaskClass'), $class)) . '</span>';
                     $table[] = '<tr>' . '<td>' . $startExecutionElement . '</td>' . '<td class="right">' . $schedulerRecord['uid'] . '</td>' . '<td colspan="6">' . $executionStatusOutput . '</td>' . '<td nowrap="nowrap"><div class="btn-group" role="group">' . '<span class="btn btn-default disabled">' . $this->moduleTemplate->getIconFactory()->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>' . '<span class="btn btn-default disabled">' . $this->moduleTemplate->getIconFactory()->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>' . $deleteAction . '<span class="btn btn-default disabled">' . $this->moduleTemplate->getIconFactory()->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>' . '</div></td>' . '</tr>';
                 }
             }
         }
         $this->getDatabaseConnection()->sql_free_result($res);
         $this->view->assign('table', '<table class="table table-striped table-hover">' . implode(LF, $table) . '</table>');
         // Server date time
         $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ' T (e';
         $this->view->assign('now', date($dateFormat) . ', GMT ' . date('P') . ')');
     }
     return $this->view->render();
 }
 /**
  * @test
  */
 public function setFormatSetsRequestFormat()
 {
     $this->mockRequest->expects($this->once())->method('setFormat')->with('xml');
     $this->view->setFormat('xml');
 }
 /**
  * Displays a diff over multiple fields including rollback links
  *
  * @param array $diff Difference array
  */
 public function displayMultipleDiff($diff)
 {
     // Get all array keys needed
     $arrayKeys = array_merge(array_keys($diff['newData']), array_keys($diff['insertsDeletes']), array_keys($diff['oldData']));
     $arrayKeys = array_unique($arrayKeys);
     $languageService = $this->getLanguageService();
     if ($arrayKeys) {
         $lines = array();
         foreach ($arrayKeys as $key) {
             $singleLine = array();
             $elParts = explode(':', $key);
             // Turn around diff because it should be a "rollback preview"
             if ((int) $diff['insertsDeletes'][$key] === 1) {
                 // insert
                 $singleLine['insertDelete'] = 'delete';
             } elseif ((int) $diff['insertsDeletes'][$key] === -1) {
                 $singleLine['insertDelete'] = 'insert';
             }
             // Build up temporary diff array
             // turn around diff because it should be a "rollback preview"
             if ($diff['newData'][$key]) {
                 $tmpArr['newRecord'] = $diff['oldData'][$key];
                 $tmpArr['oldRecord'] = $diff['newData'][$key];
                 $singleLine['differences'] = $this->renderDiff($tmpArr, $elParts[0], $elParts[1]);
             }
             $elParts = explode(':', $key);
             $singleLine['revertRecordLink'] = $this->createRollbackLink($key, $languageService->getLL('revertRecord', true), 1);
             $singleLine['title'] = $this->generateTitle($elParts[0], $elParts[1]);
             $lines[] = $singleLine;
         }
         $this->view->assign('revertAllLink', $this->createRollbackLink('ALL', $languageService->getLL('revertAll', true), 0));
         $this->view->assign('multipleDiff', $lines);
     }
 }