/** * The main method of the PlugIn * @param string $content : The PlugIn content * @param array $conf : The PlugIn configuration * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->ms = GeneralUtility::milliseconds(); $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_loadLL(); // Configuring so caching is not expected. This value means that no cHash params are ever set. // We do this, because it's a USER_INT object! $this->pi_USER_INT_obj = 1; // initializes plugin configuration $this->init(); // init template for pi1 $this->initFluidTemplate(); // hook for initials if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $_procObj->addInitials($this); } } // get content for searchbox $this->getSearchboxContent(); // assign variables and do the rendering $this->searchFormView->assignMultiple($this->fluidTemplateVariables); $htmlOutput = $this->searchFormView->render(); return $htmlOutput; }
/** * 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(); }
/** * 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(); }
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(); }
/** * The main method of the PlugIn * @param string $content : The PlugIn content * @param array $conf : The PlugIn configuration * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->ms = GeneralUtility::milliseconds(); $this->conf = $conf; $this->pi_setPiVarDefaults(); // use pi1 locallang values, since all the frontend locallang values for // pi1, pi2 and pi3 are set in pi1 language file $this->pi_loadLL('EXT:ke_search/pi1/locallang.xml'); // Configuring so caching is not expected. This value means that no cHash params are ever set. // We do this, because it's a USER_INT object! $this->pi_USER_INT_obj = 1; // initializes plugin configuration $this->init(); if ($this->conf['resultPage'] != $GLOBALS['TSFE']->id) { $content = '<div id="textmessage">' . $this->pi_getLL('error_resultPage') . '</div>'; return $this->pi_wrapInBaseClass($content); } // init template $this->initFluidTemplate(); // hook for initials if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $_procObj->addInitials($this); } } // assign isEmptySearch to fluid templates $this->fluidTemplateVariables['isEmptySearch'] = $this->isEmptySearch; // render "no results"-message, "too short words"-message and finally the result list $this->getSearchResults(); // number of results $this->fluidTemplateVariables['numberofresults'] = $this->numberOfResults; // render links for sorting, fluid template variables are filled in class tx_kesearch_lib_sorting $this->renderOrdering(); // process query time $queryTime = GeneralUtility::milliseconds() - $GLOBALS['TSFE']->register['ke_search_queryStartTime']; $this->fluidTemplateVariables['queryTime'] = $queryTime; $this->fluidTemplateVariables['queryTimeText'] = sprintf($this->pi_getLL('query_time'), $queryTime); // render pagebrowser if ($GLOBALS['TSFE']->id == $this->conf['resultPage']) { if ($this->conf['pagebrowserOnTop'] || $this->conf['pagebrowserAtBottom']) { $this->renderPagebrowser(); } } // hook: modifyResultList if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyResultList'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyResultList'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $_procObj->modifyResultList($this->fluidTemplateVariables, $this); } } // generate HTML output $this->resultListView->assignMultiple($this->fluidTemplateVariables); $htmlOutput = $this->resultListView->render(); return $htmlOutput; }
/** * 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(); }
/** * 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)]); }
/** * Rendering the cObject, FLUIDTEMPLATE * * Configuration properties: * - file string+stdWrap The FLUID template file * - layoutRootPaths array of filepath+stdWrap Root paths to layouts (fallback) * - partialRootPaths array of filepath+stdWrap Root paths to partials (fallback) * - variable array of cObjects, the keys are the variable names in fluid * - dataProcessing array of data processors which are classes to manipulate $data * - extbase.pluginName * - extbase.controllerExtensionName * - extbase.controllerName * - extbase.controllerActionName * * Example: * 10 = FLUIDTEMPLATE * 10.templateName = MyTemplate * 10.templateRootPaths.10 = EXT:site_configuration/Resources/Private/Templates/ * 10.partialRootPaths.10 = EXT:site_configuration/Resources/Private/Patials/ * 10.layoutRootPaths.10 = EXT:site_configuration/Resources/Private/Layouts/ * 10.variables { * mylabel = TEXT * mylabel.value = Label from TypoScript coming * } * * @param array $conf Array of TypoScript properties * @return string The HTML output */ public function render($conf = array()) { $parentView = $this->view; $this->initializeStandaloneViewInstance(); if (!is_array($conf)) { $conf = array(); } $this->setFormat($conf); $this->setTemplate($conf); $this->setLayoutRootPath($conf); $this->setPartialRootPath($conf); $this->setExtbaseVariables($conf); $this->assignSettings($conf); $variables = $this->getContentObjectVariables($conf); $variables = $this->processData($conf, $variables); $this->view->assignMultiple($variables); $content = $this->renderFluidView(); $content = $this->applyStandardWrapToRenderedContent($content, $conf); $this->view = $parentView; return $content; }
/** * 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(); } }
/** * 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 - creating the login/logout form * * @throws Exception * @return string The content to output */ public function main() { /** @var $pageRenderer PageRenderer */ $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Login'); // support placeholders for IE9 and lower $clientInfo = GeneralUtility::clientInfo(); if ($clientInfo['BROWSER'] === 'msie' && $clientInfo['VERSION'] <= 9) { $pageRenderer->addJsLibrary('placeholders', 'sysext/core/Resources/Public/JavaScript/Contrib/placeholders.jquery.min.js'); } // Checking, if we should make a redirect. // Might set JavaScript in the header to close window. $this->checkRedirect(); // Extension Configuration $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']); // Background Image if (!empty($extConf['loginBackgroundImage'])) { $backgroundImage = $this->getUriForFileName($extConf['loginBackgroundImage']); $this->getDocumentTemplate()->inDocStylesArray[] = ' @media (min-width: 768px){ .typo3-login-carousel-control.right, .typo3-login-carousel-control.left, .panel-login { border: 0; } .typo3-login { background-image: url("' . $backgroundImage . '"); } } '; } // Add additional css to use the highlight color in the login screen if (!empty($extConf['loginHighlightColor'])) { $this->getDocumentTemplate()->inDocStylesArray[] = ' .btn-login.disabled, .btn-login[disabled], fieldset[disabled] .btn-login, .btn-login.disabled:hover, .btn-login[disabled]:hover, fieldset[disabled] .btn-login:hover, .btn-login.disabled:focus, .btn-login[disabled]:focus, fieldset[disabled] .btn-login:focus, .btn-login.disabled.focus, .btn-login[disabled].focus, fieldset[disabled] .btn-login.focus, .btn-login.disabled:active, .btn-login[disabled]:active, fieldset[disabled] .btn-login:active, .btn-login.disabled.active, .btn-login[disabled].active, fieldset[disabled] .btn-login.active, .btn-login:hover, .btn-login:focus, .btn-login:active, .btn-login:active:hover, .btn-login:active:focus, .btn-login { background-color: ' . $extConf['loginHighlightColor'] . '; } .panel-login .panel-body { border-color: ' . $extConf['loginHighlightColor'] . '; } '; } // Logo if (!empty($extConf['loginLogo'])) { $logo = $extConf['loginLogo']; } elseif (!empty($GLOBALS['TBE_STYLES']['logo_login'])) { // Fallback to old TBE_STYLES login logo $logo = $GLOBALS['TBE_STYLES']['logo_login']; GeneralUtility::deprecationLog('$GLOBALS["TBE_STYLES"]["logo_login"] is deprecated since TYPO3 CMS 7 and will be removed in TYPO3 CMS 8, please use the backend extension\'s configuration instead.'); } else { // Use TYPO3 logo depending on highlight color if (!empty($extConf['loginHighlightColor'])) { $logo = 'EXT:backend/Resources/Public/Images/typo3_black.svg'; } else { $logo = 'EXT:backend/Resources/Public/Images/typo3_orange.svg'; } $this->getDocumentTemplate()->inDocStylesArray[] = ' .typo3-login-logo .typo3-login-image { max-width: 150px; } '; } $logo = $this->getUriForFileName($logo); // Start form $formType = empty($this->getBackendUserAuthentication()->user['uid']) ? 'LoginForm' : 'LogoutForm'; $this->view->assignMultiple(array('backendUser' => $this->getBackendUserAuthentication()->user, 'hasLoginError' => $this->isLoginInProgress(), 'formType' => $formType, 'logo' => $logo, 'images' => array('capslock' => $this->getUriForFileName('EXT:backend/Resources/Public/Images/icon_capslock.svg'), 'typo3' => $this->getUriForFileName('EXT:backend/Resources/Public/Images/typo3_orange.svg')), 'copyright' => BackendUtility::TYPO3_copyRightNotice(), 'loginNewsItems' => $this->getSystemNews(), 'loginProviderIdentifier' => $this->loginProviderIdentifier, 'loginProviders' => $this->loginProviders)); // Initialize interface selectors: $this->makeInterfaceSelectorBox(); /** @var LoginProviderInterface $loginProvider */ $loginProvider = GeneralUtility::makeInstance($this->loginProviders[$this->loginProviderIdentifier]['provider']); $loginProvider->render($this->view, $pageRenderer, $this); $content = $this->getDocumentTemplate()->startPage('TYPO3 CMS Login: '******'TYPO3_CONF_VARS']['SYS']['sitename']); $content .= $this->view->render(); $content .= $this->getDocumentTemplate()->endPage(); return $content; }
/** * Creating the module output. * * @throws \UnexpectedValueException * @return void */ public function main() { $hasAccess = true; if ($this->id && $this->access) { // Init position map object: $posMap = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap::class); $posMap->cur_sys_language = $this->sys_language; // If a column is pre-set: if (isset($this->colPos)) { if ($this->uid_pid < 0) { $row = []; $row['uid'] = abs($this->uid_pid); } else { $row = ''; } $this->onClickEvent = $posMap->onClickInsertRecord($row, $this->colPos, '', $this->uid_pid, $this->sys_language); } else { $this->onClickEvent = ''; } // *************************** // Creating content // *************************** // Wizard $wizardItems = $this->wizardArray(); // Wrapper for wizards // Hook for manipulating wizardItems, wrapper, onClickEvent etc. if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof NewContentElementWizardHookInterface) { throw new \UnexpectedValueException($classData . ' must implement interface ' . NewContentElementWizardHookInterface::class, 1227834741); } $hookObject->manipulateWizardItems($wizardItems, $this); } } // Add document inline javascript $this->moduleTemplate->addJavaScriptCode('NewContentElementWizardInlineJavascript', ' function goToalt_doc() { ' . $this->onClickEvent . ' }'); // Traverse items for the wizard. // An item is either a header or an item rendered with a radio button and title/description and icon: $cc = $key = 0; $menuItems = []; $this->view->assign('onClickEvent', $this->onClickEvent); foreach ($wizardItems as $wizardKey => $wInfo) { $wizardOnClick = ''; if ($wInfo['header']) { $menuItems[] = ['label' => htmlspecialchars($wInfo['header']), 'content' => '']; $key = count($menuItems) - 1; } else { if (!$this->onClickEvent) { // Radio button: $wizardOnClick = 'document.editForm.defValues.value=unescape(' . GeneralUtility::quoteJSvalue(rawurlencode($wInfo['params'])) . ');goToalt_doc();' . (!$this->onClickEvent ? 'window.location.hash=\'#sel2\';' : ''); // Onclick action for icon/title: $aOnClick = 'document.getElementsByName(\'tempB\')[' . $cc . '].checked=1;' . $wizardOnClick . 'return false;'; } else { $aOnClick = "document.editForm.defValues.value=unescape('" . rawurlencode($wInfo['params']) . "');goToalt_doc();" . (!$this->onClickEvent ? "window.location.hash='#sel2';" : ''); } $icon = $this->moduleTemplate->getIconFactory()->getIcon($wInfo['iconIdentifier'])->render(); $this->menuItemView->assignMultiple(['onClickEvent' => $this->onClickEvent, 'aOnClick' => $aOnClick, 'wizardInformation' => $wInfo, 'icon' => $icon, 'wizardOnClick' => $wizardOnClick, 'wizardKey' => $wizardKey]); $menuItems[$key]['content'] .= $this->menuItemView->render(); $cc++; } } $this->view->assign('renderedTabs', $this->moduleTemplate->getDynamicTabMenu($menuItems, 'new-content-element-wizard')); // If the user must also select a column: if (!$this->onClickEvent) { // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable: $colPosArray = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getColPosListItemsParsed', $this->id, $this); $colPosIds = array_column($colPosArray, 1); // Removing duplicates, if any $colPosList = implode(',', array_unique(array_map('intval', $colPosIds))); // Finally, add the content of the column selector to the content: $this->view->assign('posMap', $posMap->printContentElementColumns($this->id, 0, $colPosList, 1, $this->R_URI)); } } else { // In case of no access: $hasAccess = false; } $this->view->assign('hasAccess', $hasAccess); $this->content = $this->view->render(); // Setting up the buttons and markers for docheader $this->getButtons(); }