/** * Initialize, setting what is necessary for browsing pages. * Using the current user. * * @param string $clause Additional clause for selecting pages. * @param string $orderByFields record ORDER BY field * @return void * @todo Define visibility */ public function init($clause = '', $orderByFields = '') { // This will hide records from display - it has nothing todo with user rights!! $clauseExcludePidList = ''; if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) { if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) { $clauseExcludePidList = ' AND pages.uid NOT IN (' . $pidList . ')'; } } // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly: parent::init(' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1) . ' ' . $clause . $clauseExcludePidList, 'sorting'); $this->table = 'pages'; $this->setTreeName('browsePages'); $this->domIdPrefix = 'pages'; $this->iconName = ''; $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; $this->MOUNTS = $GLOBALS['WEBMOUNTS']; if ($pidList) { // Remove mountpoint if explicitly set in options.hideRecords.pages (see above) $hideList = explode(',', $pidList); $this->MOUNTS = array_diff($this->MOUNTS, $hideList); } $this->fieldArray = array_merge($this->fieldArray, array('doktype', 'php_tree_stop', 't3ver_id', 't3ver_state', 't3ver_wsid', 't3ver_state', 't3ver_move_id')); if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) { $this->fieldArray = array_merge($this->fieldArray, array('hidden', 'starttime', 'endtime', 'fe_group', 'module', 'extendToSubpages', 'is_siteroot', 'nav_hide')); } }
/** * Render the captcha image html * * @param string suffix to be appended to the extenstion key when forming css class names * @return string The html used to render the captcha image */ public function render($suffix = '') { $value = ''; // Include the required JavaScript $GLOBALS['TSFE']->additionalHeaderData[$this->extensionKey . '_freeCap'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(ExtensionManagementUtility::siteRelPath($this->extensionKey) . 'Resources/Public/JavaScript/freeCap.js') . '"></script>'; // Disable caching $GLOBALS['TSFE']->no_cache = 1; // Get the plugin configuration $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $this->extensionName); // Get the translation view helper $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $translator = $objectManager->get('SJBR\\SrFreecap\\ViewHelpers\\TranslateViewHelper'); $translator->injectConfigurationManager($this->configurationManager); // Generate the image url $fakeId = GeneralUtility::shortMD5(uniqid(rand()), 5); $siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $L = GeneralUtility::_GP('L'); $urlParams = array('eID' => 'sr_freecap_EidDispatcher', 'id' => $GLOBALS['TSFE']->id, 'vendorName' => 'SJBR', 'extensionName' => 'SrFreecap', 'pluginName' => 'ImageGenerator', 'controllerName' => 'ImageGenerator', 'actionName' => 'show', 'formatName' => 'png', 'L' => $GLOBALS['TSFE']->sys_language_uid); if ($GLOBALS['TSFE']->MP) { $urlParams['MP'] = $GLOBALS['TSFE']->MP; } $urlParams['set'] = $fakeId; $imageUrl = $siteURL . 'index.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParams), '&'); // Generate the html text $value = '<img' . $this->getClassAttribute('image', $suffix) . ' id="tx_srfreecap_captcha_image_' . $fakeId . '"' . ' src="' . htmlspecialchars($imageUrl) . '"' . ' alt="' . $translator->render('altText') . ' "/>' . '<span' . $this->getClassAttribute('cant-read', $suffix) . '>' . $translator->render('cant_read1') . ' <a href="#" onclick="this.blur();' . $this->extensionName . '.newImage(\'' . $fakeId . '\', \'' . $translator->render('noImageMessage') . '\');return false;">' . $translator->render('click_here') . '</a>' . $translator->render('cant_read2') . '</span>'; return $value; }
/** * Returns information about this extension plugin * * @param array $params Parameters to the hook * * @return string Information about pi1 plugin * @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar */ public function getExtensionSummary(array $params) { $relIconPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ExtensionManagementUtility::siteRelPath('calendarize') . 'ext_icon.png'; $this->flexFormService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\FlexFormService'); $this->layoutService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\ContentElementLayoutService'); $this->layoutService->setTitle('<img src="' . $relIconPath . '" /> Calendarize'); if ($params['row']['list_type'] != 'calendarize_calendar') { return ''; } $this->flexFormService->load($params['row']['pi_flexform']); if (!$this->flexFormService->isValid()) { return ''; } $actions = $this->flexFormService->get('switchableControllerActions', 'main'); $parts = GeneralUtility::trimExplode(';', $actions, true); $parts = array_map(function ($element) { $split = explode('->', $element); return ucfirst($split[1]); }, $parts); $actionKey = lcfirst(implode('', $parts)); $this->layoutService->addRow(LocalizationUtility::translate('mode', 'calendarize'), LocalizationUtility::translate('mode.' . $actionKey, 'calendarize')); $this->layoutService->addRow(LocalizationUtility::translate('configuration', 'calendarize'), $this->flexFormService->get('settings.configuration', 'main')); if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) { $this->layoutService->addRow(LocalizationUtility::translate('hide.pagination.teaser', 'calendarize'), '!!!'); } $this->addPageIdsToTable(); return $this->layoutService->render(); }
/** * Parses the extension settings. * * @return Tx_MooxNews_Domain_Model_Dto_EmConfiguration * @throws Exception If the configuration is invalid. */ public static function getSettings() { $configuration = self::parseSettings(); \TYPO3\CMS\Core\Utility\GeneralUtility::requireOnce(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('moox_news') . 'Classes/Domain/Model/Dto/EmConfiguration.php'); $settings = new Tx_MooxNews_Domain_Model_Dto_EmConfiguration($configuration); return $settings; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $languageOverride = []; if ($type === LoaderInterface::EXT_TABLES) { return $languageOverride; } $languageOverridePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Resources/Private/Language/Overrides/'; if (!is_dir($languageOverridePath)) { return $languageOverride; } $files = GeneralUtility::getAllFilesAndFoldersInPath([], $languageOverridePath, 'xlf,php,xml', false, 99); foreach ($files as $file) { $file = str_replace($languageOverridePath, '', $file); $parts = GeneralUtility::trimExplode('/', $file, true); $extension = GeneralUtility::camelCaseToLowerCaseUnderscored($parts[0]); unset($parts[0]); $parts = array_values($parts); // language $language = 'default'; $fileParts = GeneralUtility::trimExplode('.', PathUtility::basename($file), true); if (strlen($fileParts[0]) === 2) { $language = $fileParts[0]; unset($fileParts[0]); $parts[sizeof($parts) - 1] = implode('.', $fileParts); } $languageOverride[] = ['language' => $language, 'original' => 'EXT:' . $extension . '/' . implode('/', $parts), 'override' => 'EXT:' . $autoLoader->getExtensionKey() . '/Resources/Private/Language/Overrides/' . $file]; } return $languageOverride; }
/** * Call this function at the end of your ext_tables.php to autoregister the flexforms * of the extension to the given plugins. * * @return void */ public static function flexFormAutoLoader() { global $TCA, $_EXTKEY; $_extConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['nn_address']); $FlexFormPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/FlexForms/'; $extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY); $FlexForms = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($FlexFormPath, 'xml'); foreach ($FlexForms as $FlexForm) { if (preg_match("/^Model_(.*)\$/", $FlexForm)) { continue; } $fileKey = str_replace('.xml', '', $FlexForm); $pluginSignature = strtolower($extensionName . '_' . $fileKey); #$TCA['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout,select_key,recursive'; $TCA['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'select_key,recursive'; $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; $fileFlexForm = 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/' . $fileKey . '.xml'; // Any flexform dir in extension config set? if ($_extConfig['flexFormPlugin'] != '') { if (is_dir(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($_extConfig['flexFormPlugin']))) { // modify the relative path $path = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($_extConfig['flexFormPlugin']); $path = preg_match('/^(.*)\\/$/', $path) ? $path : $path . '/'; $fileFlexForm = 'FILE:' . $path . $fileKey . '.xml'; } } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, $fileFlexForm); } }
/** * Return TRUE if dbal and adodb extension is loaded * * @return bool TRUE if dbal and adodb is loaded */ protected function isDbalEnabled() { if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('adodb') && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal')) { return true; } return false; }
public function initializeAction() { //parent::initializeAction(); // TODO: Change the autogenerated stub $css = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->request->getControllerExtensionKey()) . 'Resources/Public/Css/bjrfreizeitfeadmin.css'; /** */ $GLOBALS['TSFE']->getPageRenderer()->addCssFile($css); }
/** * Provides form code and javascript for the user setup. * * @param array $parameters Parameters to the script * @param \TYPO3\CMS\Setup\Controller\SetupModuleController $userSetupObject Calling object: user setup module * @return string The code for the user setup */ public function getLoginScripts(array $parameters, \TYPO3\CMS\Setup\Controller\SetupModuleController $userSetupObject) { $content = ''; if ($this->isRsaAvailable()) { // If we can get the backend, we can proceed $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend(); $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/'; $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js'); $content = ''; foreach ($files as $file) { $content .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>'; } // Generate a new key pair $keyPair = $backend->createNewKeyPair(); // Save private key $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage(); /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */ $storage->put($keyPair->getPrivateKey()); // Add form tag $form = '<form action="' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded" onsubmit="tx_rsaauth_encryptUserSetup();">'; // Add RSA hidden fields $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; $userSetupObject->doc->form = $form; } return $content; }
/** * Main function, adding the item to input menuItems array * * @param ClickMenu $backRef References to parent clickmenu objects. * @param array $menuItems Array of existing menu items accumulated. New element added to this. * @param string $table Table name of the element * @param int $uid Record UID of the element * @return array Modified menuItems array */ public function main(&$backRef, $menuItems, $table, $uid) { $localItems = array(); if (!$backRef->cmLevel && $uid > 0 && $GLOBALS['BE_USER']->check('modules', 'web_txversionM1')) { // Returns directly, because the clicked item was not from the pages table if (in_array('versioning', $backRef->disabledItems) || !$GLOBALS['TCA'][$table] || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { return $menuItems; } // Adds the regular item $LL = $this->includeLL(); // "Versioning" element added: $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', array('table' => $table, 'uid' => $uid)); $localItems[] = $backRef->linkItem($GLOBALS['LANG']->getLLL('title', $LL), $backRef->excludeIcon('<img src="' . $backRef->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('version') . 'Resources/Public/Icons/module-version.png" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url), TRUE); // Find position of "delete" element: $c = 0; foreach ($menuItems as $k => $value) { $c++; if ($k === 'delete') { break; } } // .. subtract two (delete item + divider line) $c -= 2; // ... and insert the items just before the delete element. array_splice($menuItems, $c, 0, $localItems); } return $menuItems; }
public function reBuild() { $classPath = 'Classes/'; foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes'] as $key => $extensionsWithThisClass) { $extendingClassFound = false; $path = ExtensionManagementUtility::extPath('news') . $classPath . $key . '.php'; if (!is_file($path)) { throw new \Exception('Given file "' . $path . '" does not exist'); } $code = $this->parseSingleFile($path, true); // Get the files from all other extensions foreach ($extensionsWithThisClass as $extensionKey) { $path = ExtensionManagementUtility::extPath($extensionKey) . $classPath . $key . '.php'; if (is_file($path)) { $extendingClassFound = true; $code .= $this->parseSingleFile($path, false); } } $code = $this->closeClassDefinition($code); // If an extending class is found, the file is written and // added to the autoloader info if ($extendingClassFound) { $cacheEntryIdentifier = 'tx_news_' . strtolower(str_replace('/', '_', $key)); try { $this->cacheInstance->set($cacheEntryIdentifier, $code); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } } } }
/** * Get the localization of the select field items (right-hand part of form) * Referenced by TCA * * @param array $params Array of searched translation * * @return void */ function get_localized_categories(array $params) { global $LANG; /* $params['items'] = &$items; $params['config'] = $config; $params['TSconfig'] = $iArray; $params['table'] = $table; $params['row'] = $row; $params['field'] = $field; */ $config = $params['config']; $table = $config['itemsProcFunc_config']['table']; // initialize backend user language if ($LANG->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) { $sysPage = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode = static_languages.uid', 'static_languages.lg_typo3 = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($LANG->lang, 'static_languages') . $sysPage->enableFields('sys_language') . $sysPage->enableFields('static_languages')); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->sys_language_uid = $row['uid']; $this->collate_locale = $row['lg_collate_locale']; } $GLOBALS['TYPO3_DB']->sql_free_result($res); } if (is_array($params['items']) && !empty($params['items'])) { foreach ($params['items'] as $k => $item) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid=' . intval($item[1])); while ($rowCat = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { if ($localizedRowCat = DirectMailUtility::getRecordOverlay($table, $rowCat, $this->sys_language_uid, '')) { $params['items'][$k][0] = $localizedRowCat['category']; } } $GLOBALS['TYPO3_DB']->sql_free_result($res); } } }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $slots = []; $slotPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Slots/'; $slotClasses = FileUtility::getBaseFilesInDir($slotPath, 'php'); foreach ($slotClasses as $slot) { $slotClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Slots/' . $slot); if (!$autoLoader->isInstantiableClass($slotClass)) { continue; } $methods = ReflectionUtility::getPublicMethods($slotClass); foreach ($methods as $methodReflection) { /** @var MethodReflection $methodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName', 'signalPriority']); foreach ($tagConfiguration['signalClass'] as $key => $signalClass) { if (!isset($tagConfiguration['signalName'][$key])) { continue; } $priority = isset($tagConfiguration['signalPriority'][$key]) ? $tagConfiguration['signalPriority'][$key] : 0; $priority = MathUtility::forceIntegerInRange($priority, 0, 100); $slots[$priority][] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()]; } } } $slots = $this->flattenSlotsByPriority($slots); return $slots; }
/** * Returns the default markers for the template, with some additional parameters for the error page. * * @return array */ protected function getDefaultMarkers() { $defaultMarkers = parent::getDefaultMarkers(); $defaultMarkers['###EXTPATH_CORE###'] = ExtensionManagementUtility::siteRelPath('core'); $defaultMarkers['###EXTPATH_BACKEND###'] = ExtensionManagementUtility::siteRelPath('backend'); return $defaultMarkers; }
/** * Calls addJsFile for each file in the given folder on the Instance of TYPO3\CMS\Core\Page\PageRenderer. * * @param string $name the file to include * @param string $extKey the extension, where the file is located * @param string $pathInsideExt the path to the file relative to the ext-folder * @param bool $recursive */ public function render($name = null, $extKey = null, $pathInsideExt = 'Resources/Public/JavaScript/', $recursive = false) { if ($extKey == null) { $extKey = $this->controllerContext->getRequest()->getControllerExtensionKey(); } $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey); if (TYPO3_MODE === 'FE') { $extRelPath = substr($extPath, strlen(PATH_site)); } else { $extRelPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($extKey); } $absFolderPath = $extPath . $pathInsideExt . $name; // $files will include all files relative to $pathInsideExt if ($recursive === false) { $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($absFolderPath); foreach ($files as $hash => $filename) { $files[$hash] = $name . $filename; } } else { $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath([], $absFolderPath, '', 0, 99, '\\.svn'); foreach ($files as $hash => $absPath) { $files[$hash] = str_replace($extPath . $pathInsideExt, '', $absPath); } } foreach ($files as $name) { $this->pageRenderer->addJsFile($extRelPath . $pathInsideExt . $name); } }
/** * Parses the extension settings. * * @return \GeorgRinger\News\Domain\Model\Dto\EmConfiguration * @throws \Exception If the configuration is invalid. */ public static function getSettings() { $configuration = self::parseSettings(); GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('news') . 'Classes/Domain/Model/Dto/EmConfiguration.php'); $settings = new \GeorgRinger\News\Domain\Model\Dto\EmConfiguration($configuration); return $settings; }
/** * Load all necessary Javascript files * * @param bool $useRequireJsModule */ public function enableRsaEncryption($useRequireJsModule = false) { if ($this->moduleLoaded || !$this->isAvailable()) { return; } $this->moduleLoaded = true; $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); // Include necessary javascript files if ($useRequireJsModule) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Rsaauth/RsaEncryptionModule'); } else { // Register ajax handler url $code = 'var TYPO3RsaEncryptionPublicKeyUrl = ' . GeneralUtility::quoteJSvalue(GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php?eID=RsaPublicKeyGenerationController') . ';'; $pageRenderer->addJsInlineCode('TYPO3RsaEncryptionPublicKeyUrl', $code); $javascriptPath = ExtensionManagementUtility::siteRelPath('rsaauth') . 'Resources/Public/JavaScript/'; if (!$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['debug']) { $files = array('RsaEncryptionWithLib.min.js'); } else { $files = array('RsaLibrary.js', 'RsaEncryption.js'); } foreach ($files as $file) { $pageRenderer->addJsFile($javascriptPath . $file); } } }
/** * Override the initialize method to load all available country * zones for a given parent country before rendering * * @return void */ public function initialize() { parent::initialize(); if ($this->hasArgument('parent') && $this->arguments['parent'] != '' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) { $this->arguments['options'] = $this->countryZonesRepository->findAllByIso2($this->arguments['parent']); } }
/** * Get the Records * * @param integer $startPage * @param array $basePages * @param Tx_GoogleServices_Controller_SitemapController $obj * * @throws Exception * @return Tx_GoogleServices_Domain_Model_Node */ public function getRecords($startPage, $basePages, Tx_GoogleServices_Controller_SitemapController $obj) { $nodes = array(); if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tt_news')) { return $nodes; } if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_news.']['singlePid'])) { throw new Exception('You have to set tt_news singlePid.'); } $singlePid = intval($GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_news.']['singlePid']); $news = $this->getRecordsByField('tt_news', 'pid', implode(',', $basePages)); foreach ($news as $record) { // Alternative Single PID $alternativeSinglePid = $this->alternativeSinglePid($record['uid']); $linkPid = $alternativeSinglePid ? $alternativeSinglePid : $singlePid; // Build URL $url = $obj->getUriBuilder()->setArguments(array('tx_ttnews' => array('tt_news' => $record['uid'])))->setTargetPageUid($linkPid)->build(); // can't generate a valid url if (!strlen($url)) { continue; } // Build Node $node = new Tx_GoogleServices_Domain_Model_Node(); $node->setLoc($url); $node->setPriority($this->getPriority($record)); $node->setChangefreq('monthly'); $node->setLastmod($this->getModifiedDate($record)); $nodes[] = $node; } return $nodes; }
/** * Hooks to the felogin extension to provide additional code for FE login * * @return array 0 => onSubmit function, 1 => extra fields and required files */ public function loginFormHook() { $result = array(0 => '', 1 => ''); if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') { $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend(); if ($backend) { $result[0] = 'tx_rsaauth_feencrypt(this);'; $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/'; $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js'); foreach ($files as $file) { $result[1] .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>'; } // Generate a new key pair $keyPair = $backend->createNewKeyPair(); // Save private key $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage(); /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */ $storage->put($keyPair->getPrivateKey()); // Add RSA hidden fields $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; } } return $result; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $icons = []; if (!class_exists('TYPO3\\CMS\\Core\\Imaging\\IconRegistry')) { return $icons; } $iconFolder = 'Resources/Public/Icon/'; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . $iconFolder; $extensionPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()); $files = GeneralUtility::getAllFilesAndFoldersInPath([], $folder, '', false, true); if (!sizeof($files)) { return $icons; } foreach ($files as $path) { $provider = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\BitmapIconProvider'; if (substr(strtolower($path), -3) === 'svg') { $provider = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\SvgIconProvider'; } $relativePath = str_replace($extensionPath, '', $path); $iconPath = str_replace($iconFolder, '', $relativePath); $pathElements = PathUtility::pathinfo(strtolower(str_replace('/', '-', $iconPath))); $icons[] = ['provider' => $provider, 'path' => 'EXT:' . $loader->getExtensionKey() . '/' . $relativePath, 'identifier' => str_replace('_', '-', $loader->getExtensionKey()) . '-' . $pathElements['filename']]; } return $icons; }
/** * Synchronizes backend users. * * @param array $users */ protected function synchronizeUsers(array $users) { /** @var \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface $instance */ $instance = null; if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords')) { $instance = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(null, 'BE'); } $authorizedKeys = array_flip(array('username', 'admin', 'disable', 'realName', 'email', 'TSconfig', 'starttime', 'endtime', 'lang', 'tx_openid_openid', 'deleted')); foreach ($users as $user) { $user = array_intersect_key($user, $authorizedKeys); if (empty($this->config['synchronizeDeletedAccounts']) || !$this->config['synchronizeDeletedAccounts']) { if (isset($user['deleted']) && $user['deleted']) { // We do not authorize deleted user accounts to be synchronized // on this website continue; } } else { $user['deleted'] = $user['deleted'] ? 1 : 0; } // Generate a random password $password = GeneralUtility::generateRandomBytes(16); $user['password'] = $instance ? $instance->getHashedPassword($password) : md5($password); $localUser = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', 'be_users', 'username='******'username'], 'be_users')); if ($localUser) { // Update existing user $this->getDatabaseConnection()->exec_UPDATEquery('be_users', 'uid=' . $localUser['uid'], $user); } else { // Create new user $this->getDatabaseConnection()->exec_INSERTquery('be_users', $user); } } }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $hooks = []; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Hooks/'; $files = FileUtility::getBaseFilesInDir($folder, 'php'); foreach ($files as $hookFile) { $hookClass = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Hooks/' . $hookFile); if (!$loader->isInstantiableClass($hookClass)) { continue; } $classReflection = ReflectionUtility::createReflectionClass($hookClass); // add class hook $tagConfiguration = ReflectionUtility::getTagConfiguration($classReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass]; } // add method hooks foreach ($classReflection->getMethods(MethodReflection::IS_PUBLIC) as $methodReflection) { /** @var $methodReflection \TYPO3\CMS\Extbase\Reflection\MethodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass . '->' . $methodReflection->getName()]; } } } return $hooks; }
/** * Adds onchange listener on the drop down menu "predefined". * If the event is fired and old value was ".default", then empty some fields. * * @param array $config * @return string the javascript * @author Fabien Udriot */ public function addFields_predefinedJS($config) { $newRecord = 'true'; if (is_array($GLOBALS['SOBE']->editconf['tt_content']) && reset($GLOBALS['SOBE']->editconf['tt_content']) === 'edit') { $newRecord = 'false'; } $uid = NULL; if (is_array($GLOBALS['SOBE']->editconf['tt_content'])) { $uid = key($GLOBALS['SOBE']->editconf['tt_content']); } if ($uid < 0 || empty($uid) || !strstr($uid, 'NEW')) { $uid = $GLOBALS['SOBE']->elementsData[0]['uid']; } $js = "<script>\n"; $js .= "/*<![CDATA[*/\n"; $divId = $GLOBALS['SOBE']->tceforms->dynNestedStack[0][1]; if (!$divId) { $divId = "DIV.c-tablayer"; } else { $divId .= "-DIV"; } $js .= "var uid = '" . $uid . "'\n"; $js .= "var flexformBoxId = '" . $divId . "'\n"; $js .= "var newRecord = " . $newRecord . "\n"; $js .= file_get_contents(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('formhandler') . 'Resources/Public/JavaScript/addFields_predefinedJS.js'); $js .= "/*]]>*/\n"; $js .= "</script>\n"; return $js; }
/** * Constructor */ public function __construct() { $this->defaultIcon = '../' . ExtensionManagementUtility::siteRelPath('fluidcontent') . 'Resources/Public/Icons/Plugin.png'; $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['fluidcontent']); $this->extConf['iconWidth'] = $this->extConf['iconWidth'] ?: self::ICON_WIDTH; $this->extConf['iconHeight'] = $this->extConf['iconHeight'] ?: self::ICON_HEIGHT; }
/** * This method renders the report * * @return string The status report as HTML */ public function getReport() { $this->setCss(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('additional_reports') . 'Resources/Public/Shadowbox/shadowbox.css'); $this->setJs(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('additional_reports') . 'Resources/Public/Shadowbox/shadowbox.js'); $content = tx_additionalreports_main::displayExtensions(); return $content; }
/** * Initialize editor * * Initializes the module. * Done in this function because we may need to re-initialize if data is submitted! * * @param int $pageId * @param int $template_uid * @return bool */ public function initialize_editor($pageId, $template_uid = 0) { $templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class); $GLOBALS['tmpl'] = $templateService; // Do not log time-performance information $templateService->tt_track = false; $templateService->init(); $templateService->ext_localGfxPrefix = ExtensionManagementUtility::extPath('tstemplate'); $templateService->ext_localWebGfxPrefix = ExtensionManagementUtility::extRelPath('tstemplate') . 'Resources/Public/'; // Get the row of the first VISIBLE template of the page. whereclause like the frontend. $GLOBALS['tplRow'] = $templateService->ext_getFirstTemplate($pageId, $template_uid); // IF there was a template... if (is_array($GLOBALS['tplRow'])) { // Gets the rootLine $sys_page = GeneralUtility::makeInstance(PageRepository::class); $rootLine = $sys_page->getRootLine($pageId); // This generates the constants/config + hierarchy info for the template. $templateService->runThroughTemplates($rootLine, $template_uid); // The editable constants are returned in an array. $GLOBALS['theConstants'] = $templateService->generateConfig_constants(); // The returned constants are sorted in categories, that goes into the $tmpl->categories array $templateService->ext_categorizeEditableConstants($GLOBALS['theConstants']); // This array will contain key=[expanded constant name], value=line number in template. (after edit_divider, if any) $templateService->ext_regObjectPositions($GLOBALS['tplRow']['constants']); return true; } return false; }
/** * Main function * * @param [type] $$backRef: ... * @param [type] $menuItems: ... * @param [type] $table: ... * @param [type] $uid: ... * @return [type] ... */ function main(&$backRef, $menuItems, $table, $uid) { global $BE_USER, $TCA, $LANG; $localItems = array(); if (!$backRef->cmLevel) { // Returns directly, because the clicked item was not from the pages table if ($table == "tx_l10nmgr_cfg") { // Adds the regular item: $LL = $this->includeLL(); // Repeat this (below) for as many items you want to add! // Remember to add entries in the localconf.php file for additional titles. $url = ExtensionManagementUtility::extRelPath("l10nmgr") . "cm1/index.php?id=" . $uid; $localItems[] = $backRef->linkItem($GLOBALS["LANG"]->getLLL("cm1_title", $LL), $backRef->excludeIcon('<img src="' . ExtensionManagementUtility::extRelPath("l10nmgr") . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" />'), $backRef->urlRefForCM($url), 1); } $localItems["moreoptions_tx_l10nmgr_cm3"] = $backRef->linkItem('L10Nmgr tools', '', "top.loadTopMenu('" . GeneralUtility::linkThisScript() . "&cmLevel=1&subname=moreoptions_tx_l10nmgrXX_cm3');return false;", 0, 1); // Simply merges the two arrays together and returns ... $menuItems = array_merge($menuItems, $localItems); } elseif (GeneralUtility::_GET('subname') == 'moreoptions_tx_l10nmgrXX_cm3') { $url = ExtensionManagementUtility::extRelPath("l10nmgr") . "cm3/index.php?id=" . $uid . '&table=' . $table; $localItems[] = $backRef->linkItem('Create priority', '', $backRef->urlRefForCM($url . '&cmd=createPriority'), 1); $localItems[] = $backRef->linkItem('Manage priorities', '', $backRef->urlRefForCM($url . '&cmd=managePriorities'), 1); $localItems[] = $backRef->linkItem('Update Index', '', $backRef->urlRefForCM($url . '&cmd=updateIndex'), 1); $localItems[] = $backRef->linkItem('Flush Translations', '', $backRef->urlRefForCM($url . '&cmd=flushTranslations'), 1); $menuItems = array_merge($menuItems, $localItems); } return $menuItems; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $pluginInformation = []; $controllerPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Controller/'; $controllers = FileUtility::getBaseFilesRecursivelyInDir($controllerPath, 'php'); foreach ($controllers as $controller) { $controllerName = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Controller/' . $controller); if (!$loader->isInstantiableClass($controllerName)) { continue; } $controllerKey = str_replace('/', '\\', $controller); $controllerKey = str_replace('Controller', '', $controllerKey); $methods = ReflectionUtility::getPublicMethods($controllerName); foreach ($methods as $method) { /** @var $method \TYPO3\CMS\Extbase\Reflection\MethodReflection */ if ($method->isTaggedWith('plugin')) { $pluginKeys = GeneralUtility::trimExplode(' ', implode(' ', $method->getTagValues('plugin')), true); $actionName = str_replace('Action', '', $method->getName()); foreach ($pluginKeys as $pluginKey) { $pluginInformation = $this->addPluginInformation($pluginInformation, $pluginKey, $controllerKey, $actionName, $method->isTaggedWith('noCache')); } } } } return $pluginInformation; }
/** * Renders the application defined cObject FORM * which overrides the TYPO3 default cObject FORM * * Convert FORM to COA_INT - COA_INT.10 = FORM_INT * If FORM_INT is also dedected by the ContentObjectRenderer, and now * the Extbaseplugin "Form" is initalized. At this time the * controller "Frontend" action "execute" do the rest. * * @param string $typoScriptObjectName Name of the object * @param array $typoScript TS configuration for this cObject * @param string $typoScriptKey A string label used for the internal debugging tracking. * @param ContentObjectRenderer $contentObject reference * @return string HTML output */ public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject) { $content = ''; if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject']) && ExtensionManagementUtility::isLoaded('compatibility6')) { $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript); } elseif ($typoScriptObjectName === 'FORM') { $mergedTypoScript = null; if ($contentObject->data['CType'] === 'mailform') { $bodytext = $contentObject->data['bodytext']; /** @var $typoScriptParser TypoScriptParser */ $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class); $typoScriptParser->parse($bodytext); $mergedTypoScript = (array) $typoScriptParser->setup; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); // Disables content elements since TypoScript is handled that could contain insecure settings: $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true; } $newTypoScript = array('10' => 'FORM_INT', '10.' => is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript); $content = $contentObject->cObjGetSingle('COA_INT', $newTypoScript); // Only apply stdWrap to TypoScript that was NOT created by the wizard: if (isset($typoScript['stdWrap.'])) { $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']); } } elseif ($typoScriptObjectName === 'FORM_INT') { $extbase = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class); $content = $extbase->run('', array('pluginName' => 'Form', 'extensionName' => 'Form', 'vendorName' => 'TYPO3\\CMS', 'controller' => 'Frontend', 'action' => 'show', 'settings' => array('typoscript' => $typoScript), 'persistence' => array(), 'view' => array())); } return $content; }