/** * Return the mime type of a file. * * @return string|bool Returns the mime type or FALSE if the mime type could not be discovered */ public function getMimeType() { $mimeType = FALSE; if ($this->isFile()) { $fileExtensionToMimeTypeMapping = $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']; $lowercaseFileExtension = strtolower($this->getExtension()); if (!empty($fileExtensionToMimeTypeMapping[$lowercaseFileExtension])) { $mimeType = $fileExtensionToMimeTypeMapping[$lowercaseFileExtension]; } else { if (function_exists('finfo_file')) { $fileInfo = new \finfo(); $mimeType = $fileInfo->file($this->getPathname(), FILEINFO_MIME_TYPE); } elseif (function_exists('mime_content_type')) { $mimeType = mime_content_type($this->getPathname()); } } } if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuessers']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuesser'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuesser'] as $mimeTypeGuesser) { $hookParameters = array('mimeType' => &$mimeType); \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($mimeTypeGuesser, $hookParameters, $this); } } return $mimeType; }
/** * Enrich the processed record information with the resolved title * * @param array $result Incoming result array * @return array Modified array */ public function addData(array $result) { if (!isset($result['processedTca']['ctrl']['label'])) { throw new \UnexpectedValueException('TCA of table ' . $result['tableName'] . ' misses required [\'ctrl\'][\'label\'] definition.', 1443706103); } if ($result['isInlineChild'] && isset($result['processedTca']['ctrl']['formattedLabel_userFunc'])) { // inline child with formatted user func is first $parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'isOnSymmetricSide' => $result['isOnSymmetricSide'], 'options' => isset($result['processedTca']['ctrl']['formattedLabel_userFunc_options']) ? $result['processedTca']['ctrl']['formattedLabel_userFunc_options'] : [], 'parent' => ['uid' => $result['databaseRow']['uid'], 'config' => $result['inlineParentConfig']]]; // callUserFunction requires a third parameter, but we don't want to give $this as reference! $null = null; GeneralUtility::callUserFunction($result['processedTca']['ctrl']['formattedLabel_userFunc'], $parameters, $null); $result['recordTitle'] = $parameters['title']; } elseif ($result['isInlineChild'] && (isset($result['inlineParentConfig']['foreign_label']) || isset($result['inlineParentConfig']['symmetric_label']))) { // inline child with foreign label or symmetric inline child with symmetric_label $fieldName = $result['isOnSymmetricSide'] ? $result['inlineParentConfig']['symmetric_label'] : $result['inlineParentConfig']['foreign_label']; // @todo: this is a mixup here. problem is the prep method cuts the string, but also hsc's the thing. // @todo: this is uncool for the userfuncs, so it is applied only here. however, the OuterWrapContainer // @todo: also prep()'s the title created by the else patch below ... find a better separation and clean this up! $result['recordTitle'] = BackendUtility::getRecordTitlePrep($this->getRecordTitleForField($fieldName, $result)); } elseif (isset($result['processedTca']['ctrl']['label_userFunc'])) { // userFunc takes precedence over everything else $parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'options' => isset($result['processedTca']['ctrl']['label_userFunc_options']) ? $result['processedTca']['ctrl']['label_userFunc_options'] : []]; $null = null; GeneralUtility::callUserFunction($result['processedTca']['ctrl']['label_userFunc'], $parameters, $null); $result['recordTitle'] = $parameters['title']; } else { // standard record $result = $this->getRecordTitleByLabelProperties($result); } return $result; }
/** * Resolve "itemProcFunc" of elements. * * @param array $result Main result array * @param string $fieldName Field name to handle item list for * @param array $items Existing items array * @return array New list of item elements */ protected function resolveItemProcessorFunction(array $result, $fieldName, array $items) { $table = $result['tableName']; $config = $result['processedTca']['columns'][$fieldName]['config']; $pageTsProcessorParameters = null; if (!empty($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['itemsProcFunc.'])) { $pageTsProcessorParameters = $result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['itemsProcFunc.']; } $processorParameters = ['items' => &$items, 'config' => $config, 'TSconfig' => $pageTsProcessorParameters, 'table' => $table, 'row' => $result['databaseRow'], 'field' => $fieldName]; try { GeneralUtility::callUserFunction($config['itemsProcFunc'], $processorParameters, $this); } catch (\Exception $exception) { // The itemsProcFunc method may throw an exception, create a flash message if so $languageService = $this->getLanguageService(); $fieldLabel = $fieldName; if (!empty($result['processedTca']['columns'][$fieldName]['label'])) { $fieldLabel = $languageService->sL($result['processedTca']['columns'][$fieldName]['label']); } $message = sprintf($languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.items_proc_func_error'), $fieldLabel, $exception->getMessage()); /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, '', FlashMessage::ERROR, true); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } return $items; }
function execute($commands_array) { // init cObj so that the template parser works inside the cli /* @var $cObj tslib_cObj */ chdir(PATH_site); if (!$GLOBALS['TSFE'] instanceof tslib_fe) { $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], 0, 0); $GLOBALS['TSFE']->config['config']['language'] = null; $GLOBALS['TSFE']->initTemplate(); } if (!isset($GLOBALS['TT'])) { $GLOBALS['TT'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TimeTrackNull'); } $GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site; $this->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj'); switch ($commands_array['action']) { case 'rebuild_flat_database': mslib_befe::rebuildFlatDatabase(); break; } // hook if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/cli/multishop.php']['cli_cron'])) { $params = array('commands_array' => &$commands_array); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/cli/multishop.php']['cli_cron'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } }
/** * Executes an itemsProcFunc if defined in TCA and returns the combined result (predefined + processed items) * * @param string $table * @param int $pageId * @param string $field * @param array $row * @param array $tcaConfig The TCA configuration of $field * @param array $selectedItems The items already defined in the TCA configuration * @return array The processed items (including the predefined items) */ public function getProcessingItems($table, $pageId, $field, $row, $tcaConfig, $selectedItems) { $pageId = $table === 'pages' ? $row['uid'] : $row['pid']; $TSconfig = BackendUtility::getPagesTSconfig($pageId); $fieldTSconfig = $TSconfig['TCEFORM.'][$table . '.'][$field . '.']; $params = []; $params['items'] =& $selectedItems; $params['config'] = $tcaConfig; $params['TSconfig'] = $fieldTSconfig['itemsProcFunc.']; $params['table'] = $table; $params['row'] = $row; $params['field'] = $field; // The itemsProcFunc method may throw an exception. // If it does display an error message and return items unchanged. try { GeneralUtility::callUserFunction($tcaConfig['itemsProcFunc'], $params, $this); } catch (\Exception $exception) { $languageService = $this->getLanguageService(); $fieldLabel = $field; if (isset($GLOBALS['TCA'][$table]['columns'][$field]['label'])) { $fieldLabel = $languageService->sL($GLOBALS['TCA'][$table]['columns'][$field]['label']); } $message = sprintf($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:error.items_proc_func_error'), $fieldLabel, $exception->getMessage()); /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, '', FlashMessage::ERROR, true); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } return $selectedItems; }
/** * Enrich the processed record information with the resolved title * * @param array $result Incoming result array * @return array Modified array */ public function addData(array $result) { if (!isset($result['processedTca']['ctrl']['label'])) { throw new \UnexpectedValueException('TCA of table ' . $result['tableName'] . ' misses required [\'ctrl\'][\'label\'] definition.', 1443706103); } if ($result['isInlineChild'] && isset($result['processedTca']['ctrl']['formattedLabel_userFunc'])) { // inline child with formatted user func is first $parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'isOnSymmetricSide' => $result['isOnSymmetricSide'], 'options' => isset($result['processedTca']['ctrl']['formattedLabel_userFunc_options']) ? $result['processedTca']['ctrl']['formattedLabel_userFunc_options'] : [], 'parent' => ['uid' => $result['databaseRow']['uid'], 'config' => $result['inlineParentConfig']]]; // callUserFunction requires a third parameter, but we don't want to give $this as reference! $null = null; GeneralUtility::callUserFunction($result['processedTca']['ctrl']['formattedLabel_userFunc'], $parameters, $null); $result['recordTitle'] = $parameters['title']; } elseif ($result['isInlineChild'] && (isset($result['inlineParentConfig']['foreign_label']) || isset($result['inlineParentConfig']['symmetric_label']))) { // inline child with foreign label or symmetric inline child with symmetric_label $fieldName = $result['isOnSymmetricSide'] ? $result['inlineParentConfig']['symmetric_label'] : $result['inlineParentConfig']['foreign_label']; $result['recordTitle'] = $this->getRecordTitleForField($fieldName, $result); } elseif (isset($result['processedTca']['ctrl']['label_userFunc'])) { // userFunc takes precedence over everything else $parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'options' => isset($result['processedTca']['ctrl']['label_userFunc_options']) ? $result['processedTca']['ctrl']['label_userFunc_options'] : []]; $null = null; GeneralUtility::callUserFunction($result['processedTca']['ctrl']['label_userFunc'], $parameters, $null); $result['recordTitle'] = $parameters['title']; } else { // standard record $result = $this->getRecordTitleByLabelProperties($result); } return $result; }
/** * creates the repo * * @return void * @todo missing detailed description */ public function __construct() { /** * @var \TYPO3\CMS\Core\Log\LogManager $logger */ $logger = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\LogManager'); // hook to recognize themes, this is the magic point, why it's possible to support so many theme formats and types :D if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Tx_Themes_Domain_Repository_ThemeRepository']['init'])) { if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Tx_Themes_Domain_Repository_ThemeRepository']['init'])) { $hookParameters = array(); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Tx_Themes_Domain_Repository_ThemeRepository']['init'] as $hookFunction) { $logger->getLogger()->warning('Theme loader found ' . $hookFunction . ' - sadly this loader uses the old hook, please fix this, should be KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository nowThem'); GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository']['init'])) { if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository']['init'])) { $hookParameters = array(); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository']['init'] as $hookFunction) { $logger->getLogger()->warning('Theme loader found ' . $hookFunction); GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } }
/** * Handles a frontend request based on the _GP "eID" variable. * * @return void */ public function handleRequest() { // Timetracking started $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']); if (empty($configuredCookieName)) { $configuredCookieName = 'be_typo_user'; } if ($_COOKIE[$configuredCookieName]) { $GLOBALS['TT'] = new TimeTracker(); } else { $GLOBALS['TT'] = new NullTimeTracker(); } $GLOBALS['TT']->start(); // Hook to preprocess the current request if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) { $hookParameters = array(); GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters); } unset($hookFunction); unset($hookParameters); } // Remove any output produced until now $this->bootstrap->endOutputBufferingAndCleanPreviousOutput(); require EidUtility::getEidScriptPath(); $this->bootstrap->shutdown(); exit; }
/** * Evaluates via the referenced user-defined method * * @param string $condition * @return bool */ protected function matchUserCondition($condition) { $conditionParameters = explode(':', $condition); $userFunction = array_shift($conditionParameters); $parameter = array('record' => $this->record, 'flexformValueKey' => $this->flexformValueKey, 'conditionParameters' => $conditionParameters); return (bool) GeneralUtility::callUserFunction($userFunction, $parameter, $this); }
/** * MAIN function for page information display * * @return string Output HTML for the module. * @todo Define visibility */ public function main() { global $BACK_PATH, $LANG, $SOBE; $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView'); $dblist->descrTable = '_MOD_' . $GLOBALS['MCONF']['name']; $dblist->backPath = $BACK_PATH; $dblist->thumbs = 0; $dblist->script = 'index.php'; $dblist->showIcon = 0; $dblist->setLMargin = 0; $dblist->agePrefixes = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'); $dblist->pI_showUser = 1; // PAGES: $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth']; // ONLY for the sake of dblist module which uses this value. $h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth'], 'index.php'); $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages'], 'index.php'); $dblist->start($this->pObj->id, 'pages', 0); $dblist->generateList(); // CSH $theOutput .= $this->pObj->doc->header($LANG->getLL('page_title')); $theOutput .= $this->pObj->doc->section('', \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', $GLOBALS['BACK_PATH'], '|<br />') . $h_func . $dblist->HTMLcode, 0, 1); // Additional footer content $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook']; if (is_array($footerContentHook)) { foreach ($footerContentHook as $hook) { $params = array(); $theOutput .= \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hook, $params, $this); } } return $theOutput; }
/** * MAIN function for page information display * * @return string Output HTML for the module. */ public function main() { $theOutput = $this->pObj->doc->header($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title')); $dblist = GeneralUtility::makeInstance(PageLayoutView::class); $dblist->descrTable = '_MOD_web_info'; $dblist->thumbs = 0; $dblist->script = BackendUtility::getModuleUrl('web_info'); $dblist->showIcon = 0; $dblist->setLMargin = 0; $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears'); $dblist->pI_showUser = 1; // PAGES: $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth']; // ONLY for the sake of dblist module which uses this value. $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']); $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']); $dblist->start($this->pObj->id, 'pages', 0); $dblist->generateList(); // CSH $theOutput .= $this->pObj->doc->section('', BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', null, '|<br />') . '<div class="form-inline form-inline-spaced">' . $h_func . '</div>' . $dblist->HTMLcode, 0, 1); // Additional footer content $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook']; if (is_array($footerContentHook)) { foreach ($footerContentHook as $hook) { $params = array(); $theOutput .= GeneralUtility::callUserFunction($hook, $params, $this); } } return $theOutput; }
/** * @test */ public function supportsExceptionAsParameter() { $userFunctionReference = $this->getClassName() . '->' . $this->methodName; $parameters = $this->getParameters(); $parameters['fieldConf']['config']['arguments'] = array(new \Exception(self::FAKE_MESSAGE, self::FAKE_CODE)); $output = GeneralUtility::callUserFunction($userFunctionReference, $parameters, $this->getCallerInstance()); $this->assertOutputContainsExpectedMessageAndCode($output); }
/** * Routes the given eID action to the related ExtDirect method with the necessary * ajax object. * * @param string $ajaxID * @return void */ protected function routeAction($ajaxID) { EidUtility::initLanguage(); $ajaxScript = $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['ExtDirect::' . $ajaxID]['callbackMethod']; $this->ajaxObject = GeneralUtility::makeInstance(AjaxRequestHandler::class, 'ExtDirect::' . $ajaxID); $parameters = array(); GeneralUtility::callUserFunction($ajaxScript, $parameters, $this->ajaxObject, false, true); }
/** * Routes the given eID action to the related ExtDirect method with the necessary * ajax object. * * @return void */ public function routeAction() { \TYPO3\CMS\Frontend\Utility\EidUtility::initLanguage(); $ajaxID = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action'); $ajaxScript = $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['ExtDirect::' . $ajaxID]['callbackMethod']; $this->ajaxObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Http\\AjaxRequestHandler', 'ExtDirect::' . $ajaxID); $parameters = array(); \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($ajaxScript, $parameters, $this->ajaxObject, FALSE, TRUE); }
public function dispatchUserFunction($requestArguments) { $result = []; list($className) = GeneralUtility::trimExplode('->', $requestArguments['function']); if (class_exists($className) && in_array(AjaxInterface::class, class_implements($className))) { $parameters = true === isset($requestArguments['arguments']) ? $requestArguments['arguments'] : []; $result = GeneralUtility::callUserFunction($requestArguments['function'], $parameters, $this); } return $result; }
/** * @test */ public function leavesRecordsWhichAreNotRootsUntouched() { \FluidTYPO3\Flux\Core::addStaticTypoScript(self::FIXTURE_TYPOSCRIPT_DIR); $function = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSources']['flux']; $template = $this->objectManager->get('t3lib_TStemplate'); $parameters = array('row' => \FluidTYPO3\Flux\Tests\Fixtures\Data\Records::$sysTemplateRoot); $parameters['row']['root'] = 0; GeneralUtility::callUserFunction($function, $parameters, $template); $this->assertNotContains(self::FIXTURE_TYPOSCRIPT_DIR, $parameters['row']['include_static_file']); $this->assertSame(\FluidTYPO3\Flux\Tests\Fixtures\Data\Records::$sysTemplateRoot['include_static_file'], $parameters['row']['include_static_file']); }
/** * @test */ public function leavesRecordsWhichAreNotRootsUntouched() { Core::addStaticTypoScript(self::FIXTURE_TYPOSCRIPT_DIR); $function = 'FluidTYPO3\\Flux\\Backend\\TypoScriptTemplate->preprocessIncludeStaticTypoScriptSources'; $template = $this->objectManager->get('TYPO3\\CMS\\Core\\TypoScript\\TemplateService'); $parameters = array('row' => Records::$sysTemplateRoot); $parameters['row']['root'] = 0; GeneralUtility::callUserFunction($function, $parameters, $template); $this->assertNotContains(self::FIXTURE_TYPOSCRIPT_DIR, $parameters['row']['include_static_file']); $this->assertSame(Records::$sysTemplateRoot['include_static_file'], $parameters['row']['include_static_file']); }
/** * User defined field type * * @return array As defined in initializeResultArray() of AbstractNode */ public function render() { $parameterArray = $this->data['parameterArray']; $parameterArray['table'] = $this->data['tableName']; $parameterArray['field'] = $this->data['fieldName']; $parameterArray['row'] = $this->data['databaseRow']; $parameterArray['parameters'] = isset($parameterArray['fieldConf']['config']['parameters']) ? $parameterArray['fieldConf']['config']['parameters'] : array(); $resultArray = $this->initializeResultArray(); $resultArray['html'] = GeneralUtility::callUserFunction($parameterArray['fieldConf']['config']['userFunc'], $parameterArray, $this); return $resultArray; }
/** * @return array The options of the field. */ public function getOptions() { if (!is_array($this->options)) { $params = array(); $options = GeneralUtility::callUserFunction($this->options, $params, $this); if ($options) { $this->options = (array) $options; } } return $this->options; }
/** * Main function of the class. Outputs sitemap. * * @return void */ public function main() { $sitemapType = $this->getSitemapType(); if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dd_googlesitemap']['sitemap'][$sitemapType])) { $userFuncRef = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dd_googlesitemap']['sitemap'][$sitemapType]; $params = array(); GeneralUtility::callUserFunction($userFuncRef, $params, $this); } else { header('HTTP/1.0 400 Bad request', true, 400); header('Content-type: text/plain'); echo 'No generator found for type \'' . $sitemapType . '\''; } }
/** * Gets additional code for login forms based on the * TYPO3_CONF_VARS/EXTCONF/felogin/loginFormOnSubmitFuncs hook * * Will be invoked just before the render method. * * @return void */ public function initialize() { parent::initialize(); if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['loginFormOnSubmitFuncs'])) { $parameters = array(); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['loginFormOnSubmitFuncs'] as $callback) { $result = GeneralUtility::callUserFunction($callback, $parameters, $this); if (isset($result[0])) { $this->submitJavaScriptCode[] = $result[0]; } if (isset($result[1])) { $this->additionalHiddenFields[] = $result[1]; } } } }
/** * Enrich the processed record information with the resolved title * * @param array $result Incoming result array * @return array Modified array */ public function addData(array $result) { if (!isset($result['processedTca']['ctrl']['label'])) { throw new \UnexpectedValueException('TCA of table ' . $result['tableName'] . ' misses required [\'ctrl\'][\'label\'] definition.', 1443706103); } if (isset($result['processedTca']['ctrl']['label_userFunc'])) { // userFunc takes precedence over everything $parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'options' => isset($result['processedTca']['ctrl']['label_userFunc_options']) ? $result['processedTca']['ctrl']['label_userFunc_options'] : []]; $null = null; GeneralUtility::callUserFunction($result['processedTca']['ctrl']['label_userFunc'], $parameters, $null); $result['recordTitle'] = $parameters['title']; } else { $result = $this->getRecordTitleByLabelProperties($result); } return $result; }
/** * * * @return string */ public function run() { $cObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $gp = GeneralUtility::_GP('jh_magnificpopup'); //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($GLOBALS['TSFE']->tmpl->setup['tt_content.']); //http://lists.typo3.org/pipermail/typo3-german/2011-July/079128.html switch ($gp['type']) { case 'inline': $cObjConfig = array('name' => 'CONTENT', 'conf' => array('table' => 'tt_content', 'select.' => array('where' => 'tx_jhmagnificpopup_irre_parentid=' . $gp['irre_parrentid'], 'pidInList' => GeneralUtility::_GP('id') ?: $GLOBALS["TSFE"]->id, 'languageField' => 'sys_language_uid', 'orderBy' => 'sorting'), 'wrap' => '<div class="white-popup-block">|</div>', 'renderObj' => $GLOBALS['TSFE']->tmpl->setup['tt_content'], 'renderObj.' => $GLOBALS['TSFE']->tmpl->setup['tt_content.'])); break; case 'reference': $pid = isset($gp['pid']) && !empty($gp['pid']) ? $gp['pid'] : $GLOBALS["TSFE"]->id; $cObjConfig = array('name' => 'CONTENT', 'conf' => array('table' => 'tt_content', 'select.' => array('uidInList' => $gp['uid'], 'pidInList' => $pid, 'orderBy' => 'sorting', 'languageField' => 'sys_language_uid'), 'wrap' => '<div class="white-popup-block">|</div>', 'renderObj' => $GLOBALS['TSFE']->tmpl->setup['tt_content'], 'renderObj.' => $GLOBALS['TSFE']->tmpl->setup['tt_content.'])); break; default: if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['jh_magnificpopup']['EidTypeHook']) { if (!isset($gp['hookConf'])) { $gp['hookConf'] = ''; } $params = array('type' => $gp['type'], 'hookConf' => $gp['hookConf']); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['jh_magnificpopup']['EidTypeHook'] as $_funcRef) { if ($_funcRef) { $cObjConfig = GeneralUtility::callUserFunction($_funcRef, $params, $this); if (isset($cObjConfig['matchedType']) && $cObjConfig['matchedType'] === true) { break; } } } if (isset($cObjConfig['matchedType']) && $cObjConfig['matchedType'] === false) { $cObjConfig = null; } } } if (!empty($cObjConfig) && is_array($cObjConfig)) { $this->typoScriptFrontendController->content = $cObject->getContentObject($cObjConfig['name'])->render($cObjConfig['conf']); } else { $this->typoScriptFrontendController->content = 'ERROR - no (or wrong) configuration'; } if ($GLOBALS['TSFE']->isINTincScript()) { $GLOBALS['TSFE']->INTincScript(); } if (isset($cObjConfig['wrap']) && !empty($cObjConfig['wrap'])) { $this->typoScriptFrontendController->content = $cObject->wrap($this->typoScriptFrontendController->content, $cObjConfig['wrap']); } return $this->typoScriptFrontendController->content; }
/** * Saves the value of a PHP variable in the cache. Note that the variable * will be serialized if necessary. * * @param string $entryIdentifier An identifier used for this cache entry * @param mixed $variable The variable to cache * @param array $tags Tags to associate with this cache entry * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited liftime. * @return void * @throws \InvalidArgumentException if the identifier or tag is not valid * @api */ public function set($entryIdentifier, $variable, array $tags = array(), $lifetime = null) { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058264); } foreach ($tags as $tag) { if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058269); } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php']['set'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php']['set'] as $_funcRef) { $params = array('entryIdentifier' => &$entryIdentifier, 'variable' => &$variable, 'tags' => &$tags, 'lifetime' => &$lifetime); GeneralUtility::callUserFunction($_funcRef, $params, $this); } } $this->backend->set($entryIdentifier, serialize($variable), $tags, $lifetime); }
/** * Handles a frontend request based on the _GP "eID" variable. * * @param ServerRequestInterface $request * @return NULL|\Psr\Http\Message\ResponseInterface */ public function handleRequest(ServerRequestInterface $request) { // Starting time tracking $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']) ?: 'be_typo_user'; $GLOBALS['TT'] = new TimeTracker($request->getCookieParams()[$configuredCookieName] ? true : false); $GLOBALS['TT']->start(); // Hook to preprocess the current request if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) { $hookParameters = array(); GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters); } unset($hookFunction); unset($hookParameters); } // Remove any output produced until now $this->bootstrap->endOutputBufferingAndCleanPreviousOutput(); return $this->dispatch($request); }
/** * User defined field type * * @return array As defined in initializeResultArray() of AbstractNode */ public function render() { $parameterArray = $this->globalOptions['parameterArray']; $parameterArray['table'] = $this->globalOptions['table']; $parameterArray['field'] = $this->globalOptions['fieldName']; $parameterArray['row'] = $this->globalOptions['databaseRow']; $parameterArray['parameters'] = isset($parameterArray['fieldConf']['config']['parameters']) ? $parameterArray['fieldConf']['config']['parameters'] : array(); // Instance of FormEngine is kept here for backwards compatibility - but it is a dummy only $dummyFormEngine = new FormEngine; $parameterArray['pObj'] = $dummyFormEngine; $resultArray = $this->initializeResultArray(); $resultArray['html'] = GeneralUtility::callUserFunction( $parameterArray['fieldConf']['config']['userFunc'], $parameterArray, $dummyFormEngine ); return $resultArray; }
/** * MAIN function for page information display * * @return string Output HTML for the module. */ public function main() { $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title')) . '</h1>'; $dblist = GeneralUtility::makeInstance(PageLayoutView::class); $dblist->descrTable = '_MOD_web_info'; $dblist->thumbs = 0; $dblist->script = BackendUtility::getModuleUrl('web_info'); $dblist->showIcon = 0; $dblist->setLMargin = 0; $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears'); $dblist->pI_showUser = 1; switch ((int) $this->pObj->MOD_SETTINGS['pages']) { case 1: $dblist->fieldArray = ['title', 'uid'] + array_keys($this->cleanTableNames()); break; case 2: $dblist->fieldArray = ['title', 'uid', 'lastUpdated', 'newUntil', 'no_cache', 'cache_timeout', 'php_tree_stop', 'TSconfig', 'is_siteroot', 'fe_login_mode']; break; default: $dblist->fieldArray = ['title', 'uid', 'alias', 'starttime', 'endtime', 'fe_group', 'target', 'url', 'shortcut', 'shortcut_mode']; } // PAGES: $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth']; // ONLY for the sake of dblist module which uses this value. $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']); $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']); $dblist->start($this->pObj->id, 'pages', 0); $dblist->generateList(); // CSH $theOutput .= '<div>'; $theOutput .= BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', null, '<span class="btn btn-default btn-sm">|</span><br />') . '<div class="form-inline form-inline-spaced">' . $h_func . '</div>' . $dblist->HTMLcode; $theOutput .= '</div>'; // Additional footer content $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook']; if (is_array($footerContentHook)) { foreach ($footerContentHook as $hook) { $params = []; $theOutput .= GeneralUtility::callUserFunction($hook, $params, $this); } } return $theOutput; }
/** * Includes static template records (from static_template table) and static template files (from extensions) for the input template record row. * * @param array Array of parameters from the parent class. Includes idList, templateId, pid, and row. * @param \TYPO3\CMS\Core\TypoScript\TemplateService Reference back to parent object, t3lib_tstemplate or one of its subclasses. * * @return void */ public static function main(&$params, \TYPO3\CMS\Core\TypoScript\TemplateService &$pObj) { $idList = $params['idList']; $templateId = $params['templateId']; $pid = $params['pid']; $row = $params['row']; if ($templateId === $idList) { $tRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_template', 'pid=' . (int) $pid); $themeIdentifier = $tRow['tx_themes_skin']; // Call hook for possible manipulation of current skin. if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/themes/Classes/Hooks/T3libTstemplateIncludeStaticTypoScriptSourcesAtEndHook.php']['setTheme'])) { $tempParamsForHook = ['theme' => $themeIdentifier]; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/themes/Classes/Hooks/T3libTstemplateIncludeStaticTypoScriptSourcesAtEndHook.php']['setTheme'] as $userFunc) { $themeIdentifier = GeneralUtility::callUserFunction($userFunc, $tempParamsForHook, $ref = null); } } if (empty($themeIdentifier)) { $themeIdentifier = $tRow['tx_themes_skin']; } /** * @var \KayStrobach\Themes\Domain\Repository\ThemeRepository */ $themeRepository = GeneralUtility::makeInstance('KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository'); $theme = $themeRepository->findByUid($themeIdentifier); if ($theme === null) { // fallback if the hook returns a undefined theme $theme = $themeRepository->findByUid($tRow['tx_themes_skin']); } if ($theme !== null) { $theme->addTypoScriptForFe($params, $pObj); } // @todo add hook to inject template overlays, e.g. for previewed constants before save ... // Call hook for possible manipulation of current skin. constants if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/themes/Classes/Hooks/T3libTstemplateIncludeStaticTypoScriptSourcesAtEndHook.php']['modifyTS'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/themes/Classes/Hooks/T3libTstemplateIncludeStaticTypoScriptSourcesAtEndHook.php']['modifyTS'] as $userFunc) { $themeItem = GeneralUtility::callUserFunction($userFunc, $tempParamsForHook, $pObj); $pObj->processTemplate($themeItem, $params['idList'] . ',themes_modifyTsOverlay', $params['pid'], 'themes_themes_modifyTsOverlay', $params['templateId']); } } } }
/** * Gets the selected backend layout * * @param int $id : The uid of the page we are currently working on * * @return array|null $backendLayout : An array containing the data of the selected backend layout as well as a parsed version of the layout configuration */ public function getSelectedBackendLayout($id) { $backendLayoutData = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', $id, $this); // add allowed CTypes to the columns, since this is not done by the native core methods if (count($backendLayoutData['__items']) > 0) { if (!empty($backendLayoutData['__config']['backend_layout.']['rows.'])) { foreach ($backendLayoutData['__config']['backend_layout.']['rows.'] as $row) { if (!empty($row['columns.'])) { foreach ($row['columns.'] as $column) { $backendLayoutData['columns'][$column['colPos']] = $column['allowed'] ? $column['allowed'] : '*'; $backendLayoutData['columns']['allowed'] .= $backendLayoutData['columns']['allowed'] ? ',' . $backendLayoutData['columns'][$column['colPos']] : $backendLayoutData['columns'][$column['colPos']]; } } } } foreach ($backendLayoutData['__items'] as $key => $item) { $backendLayoutData['__items'][$key][3] = $backendLayoutData['columns'][$item[1]]; } } return $backendLayoutData; }
function init($ref) { mslib_fe::init($ref); $this->initLanguage($ref->LOCAL_LANG); static $installedPaymentMethods; // custom hook for loading the installed payment methods if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_payment'])) { $params = array('installedPaymentMethods' => &$installedPaymentMethods); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_payment'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $ref); } } // custom hook for manipulating the installed payment methods if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_paymentPostProc'])) { $params = array('installedPaymentMethods' => &$installedPaymentMethods); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_payment.php']['mslib_paymentPostProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $ref); } } $this->installedPaymentMethods = $params['installedPaymentMethods']; // custom hook for loading the installed payment methods eof // load enabled payment methods $filter = array(); if (!$include_hidden_items) { $filter[] = 's.status=1'; } $filter[] = 'd.language_id=\'' . $this->sys_language_uid . '\''; $filter[] = 's.id=d.id'; $filter[] = '(s.page_uid=' . $this->shop_pid . ' or s.page_uid=0)'; $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_payment_methods s, tx_multishop_payment_methods_description d', implode(' AND ', $filter), '', 's.sort_order', ''); $qry = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) { $array = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) { $array[$row['code']] = $row; } $this->enabledPaymentMethods = $array; } // load enabled payment methods eof }