/** * Includes the locallang file for the 'formhandler' extension * * @return array The LOCAL_LANG array */ function includeLocalLang() { $llFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('formhandler') . 'Resources/Language/locallang_db.xml'; $parser = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Parser\\LocallangXmlParser'); $LOCAL_LANG = $parser->getParsedData($llFile, $GLOBALS['LANG']->lang, 'utf-8'); return $LOCAL_LANG; }
/** * Rebuild the class cache * * @param array $parameters * * @throws \Evoweb\Extender\Exception\FileNotFoundException * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException * @return void */ public function reBuild(array $parameters = array()) { if (empty($parameters) || !empty($parameters['cacheCmd']) && GeneralUtility::inList('all,system', $parameters['cacheCmd']) && isset($GLOBALS['BE_USER'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'] as $extensionKey => $extensionConfiguration) { if (!isset($extensionConfiguration['extender']) || !is_array($extensionConfiguration['extender'])) { continue; } foreach ($extensionConfiguration['extender'] as $entity => $entityConfiguration) { $key = 'Domain/Model/' . $entity; // Get the file to extend, this needs to be loaded as first $path = ExtensionManagementUtility::extPath($extensionKey) . 'Classes/' . $key . '.php'; if (!is_file($path)) { throw new \Evoweb\Extender\Exception\FileNotFoundException('given file "' . $path . '" does not exist'); } $code = $this->parseSingleFile($path, false); // Get the files from all other extensions that are extending this domain model if (is_array($entityConfiguration)) { foreach ($entityConfiguration as $extendingExtension => $extendingFilepath) { $path = GeneralUtility::getFileAbsFileName($extendingFilepath, false); if (!is_file($path) && !is_numeric($extendingExtension)) { $path = ExtensionManagementUtility::extPath($extendingExtension) . 'Classes/' . $key . '.php'; } $code .= $this->parseSingleFile($path); } } // Close the class definition $code = $this->closeClassDefinition($code); // Add the new file to the class cache $cacheEntryIdentifier = GeneralUtility::underscoredToLowerCamelCase($extensionKey) . '_' . str_replace('/', '', $key); $this->cacheInstance->set($cacheEntryIdentifier, $code); } } } }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
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()); } } } }
/** * Outputs a list view of address * * @return void */ public function listAction() { if ($this->request->hasArgument('zip') && $this->request->getArgument('zip') != '') { $zip = $this->request->getArgument('zip'); $isSearch = TRUE; } if ($zip == '' && $this->request->hasArgument('city') && $this->request->getArgument('city') != '') { $jsonFileName = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('hwt_address') . 'Resources/Private/Data/city-zip.json'; $dataArray = array_change_key_case(json_decode(file_get_contents($jsonFileName), true)); $city = strtolower($this->request->getArgument('city')); if (!empty($dataArray[$city])) { $zip = substr($dataArray[$city], 0, 5); } $isSearch = TRUE; } if ($this->settings['addressStoragePages'] && $this->settings['addressStoragePages'] != '') { $addressRecords = $this->addressRepository->findInPageIds($this->settings['addressStoragePages'], $this->settings['orderBy'], $this->settings['orderDirection']); } elseif ($this->settings['list']['displayPageRelated'] == 1) { $addressRecords = $this->addressRepository->findRelatedToPage($GLOBALS['TSFE']->id); } elseif ($this->settings['addressCategories'] || $zip) { $addressRecords = $this->addressRepository->findAllWithoutPidRestriction($this->settings['addressCategories'], $zip, $this->settings['orderBy'], $this->settings['orderDirection']); } if (count($addressRecords) == 0 && $this->settings['addressRecords']) { $addressRecords = $this->addressRepository->findByUidInList($this->settings['addressRecords'], $this->settings['orderBy'], $this->settings['orderDirection']); } $this->view->assign('addresses', $addressRecords); }
/** * Returns the flag icons path depending on the current core version * * @return string */ public static function getLanguageFlagIconPath() { if (TRUE === version_compare(TYPO3_version, '7.1', '<')) { return ExtensionManagementUtility::extPath('t3skin') . 'images/flags/'; } return ExtensionManagementUtility::extPath('core') . 'Resources/Public/Icons/Flags/'; }
/** * 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 */ function addFields_predefinedJS($config) { $newRecord = 'true'; if ($config['row']['pi_flexform'] != '') { $flexData = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($config['row']['pi_flexform']); if (isset($flexData['data']['sDEF']['lDEF']['predefined'])) { $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']; } //print_r($GLOBALS['SOBE']->elementsData[0]); $js = "<script>\n"; $js .= "/*<![CDATA[*/\n"; $divId = $GLOBALS['SOBE']->tceforms->dynNestedStack[0][1]; if (!$divId) { //$divId = 'DTM-' . $uid; $divId = "DIV.c-tablayer"; } else { $divId .= "-DIV"; } $js .= "var uid = '" . $uid . "'\n"; $js .= "var flexformBoxId = '" . $divId . "'\n"; //$js .= "var flexformBoxId = 'DIV.c-tablayer'\n"; $js .= "var newRecord = " . $newRecord . "\n"; $js .= file_get_contents(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('formhandler') . 'Resources/JS/addFields_predefinedJS.js'); $js .= "/*]]>*/\n"; $js .= "</script>\n"; return $js; }
/** * Do the language pack update * * @param string $extensionKey: extension key of the language pack * @return void */ public function doUpdate($extensionKey) { $extPath = ExtensionManagementUtility::extPath($extensionKey); $fileContent = explode(LF, GeneralUtility::getUrl($extPath . 'ext_tables_static+adt.sql')); // SQL parser was moved from core to dbal in TYPO3 CMS 7.5 if (is_object($GLOBALS['TYPO3_DB']->SQLparser)) { $sqlParser = $GLOBALS['TYPO3_DB']->SQLparser; } else { $sqlParser = $this->objectManager->get('SJBR\\StaticInfoTables\\Database\\SqlParser'); } foreach ($fileContent as $line) { $line = trim($line); if ($line && preg_match('#^UPDATE#i', $line)) { $parsedResult = $sqlParser->parseSQL($line); // WHERE clause $whereClause = $sqlParser->compileWhereClause($parsedResult['WHERE']); // Fields $fields = array(); foreach ($parsedResult['FIELDS'] as $fN => $fV) { $fields[$fN] = $fV[0]; } $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($parsedResult['TABLE'], $whereClause, $fields, TRUE); } } }
/** * Fetch the JavaScript to be rendered and replace the markers with "live" variables. * * @return string */ protected function getJavaScript() { // Get the base prefix. $basePrefix = $this->getBasePrefix($this->getPrefix()); $filePath = ExtensionManagementUtility::extPath('media') . 'Resources/Private/Backend/Standalone/FileUploadTceForms.js'; return sprintf(file_get_contents($filePath), $basePrefix, $this->elementId, $this->getModuleUrl(), $this->getAllowedExtension(), GeneralUtility::getMaxUploadFileSize() * 1024, $this->getValue()); }
/** * 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'); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); foreach ($slotClasses as $slot) { $slotClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Slots\\' . $slot; if (!$autoLoader->isInstantiableClass($slotClass)) { continue; } $methods = ReflectionUtility::getPublicMethods($slotClass); foreach ($methods as $methodReflection) { /** @var MethodReflection $methodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName']); foreach ($tagConfiguration['signalClass'] as $key => $signalClass) { if (!isset($tagConfiguration['signalName'][$key])) { continue; } $slots[] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()]; } } } return $slots; }
/** * Reads the [extDir]/locallang.xml and returns the \$LOCAL_LANG array found in that file. * * @return The array with language labels */ public function includeLocalLang() { $llFile = ExtensionManagementUtility::extPath('ke_search') . 'pi1/locallang.xml'; $xmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Parser\\LocallangXmlParser'); $LOCAL_LANG = $xmlParser->getParsedData($llFile, $GLOBALS['LANG']->lang); return $LOCAL_LANG; }
/** * Load the xclass template and cache it in a local property * * @return null */ protected function loadXclassTemplate() { if (!self::$xclassTemplate) { $xclassTemplatePath = ExtensionManagementUtility::extPath('autoloader') . 'Resources/Private/Templates/Xclass/Aspect.tmpl'; self::$xclassTemplate = GeneralUtility::getUrl($xclassTemplatePath); } }
/** * 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; }
/** * Registers exception handler to the Sentry. * * @return void */ function sentry_register() { $extConf = @unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sentry']); if (is_array($extConf) && isset($extConf['sentryDSN'])) { // Register Raven autoloader $ravenPhpAutoloaderPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sentry', 'lib/raven-php/lib/Raven/Autoloader.php'); /** @noinspection PhpIncludeInspection */ require_once $ravenPhpAutoloaderPath; Raven_Autoloader::register(); // Set error handler $GLOBALS['SENTRY_CLIENT'] = new Raven_Client($extConf['sentryDSN']); $ravenErrorHandler = new Raven_ErrorHandler($GLOBALS['SENTRY_CLIENT']); $errorMask = E_ALL & ~(E_DEPRECATED | E_NOTICE | E_STRICT); // Register handlers in case if we do not have to report to TYPO3. Otherwise we need to register those handlers first! if (!$extConf['passErrorsToTypo3']) { $ravenErrorHandler->registerErrorHandler(FALSE, $errorMask); $ravenErrorHandler->registerExceptionHandler(FALSE); } // Make sure that TYPO3 does not override our handler \DmitryDulepov\Sentry\ErrorHandlers\SentryErrorHandler::initialize($ravenErrorHandler, $errorMask); \DmitryDulepov\Sentry\ErrorHandlers\SentryExceptionHandler::initialize($ravenErrorHandler); // TYPO3 7.0 \DmitryDulepov\Sentry\ErrorHandlers\SentryExceptionHandlerFrontend::initialize($ravenErrorHandler); // Register test plugin if (is_array($extConf) && isset($extConf['enableTestPlugin']) && $extConf['enableTestPlugin']) { \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('DmitryDulepov.sentry', 'ErrorHandlerTest', array('ErrorHandlerTest' => 'index,phpWarning,phpError,phpException'), array('ErrorHandlerTest' => 'index,phpWarning,phpError,phpException')); } unset($extConf); // Fix TYPO3 7.0 hard-coded FE exception handler $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Frontend\\ContentObject\\Exception\\ProductionExceptionHandler'] = array('className' => 'DmitryDulepov\\Sentry\\ErrorHandlers\\SentryExceptionHandlerFrontend'); } }
/** * 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) { $grids = []; if (!ExtensionManagementUtility::isLoaded('gridelements')) { return $grids; } $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/Grids/'; $files = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt'); foreach ($files as $file) { $pathInfo = PathUtility::pathinfo($file); $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/Grids/' . $pathInfo['filename'] . '.'; $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); $translationKey = 'grid.' . $pathInfo['filename']; if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); } $path = 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Grids/' . $file; $icon = $extension ? $iconPath . $extension : false; $label = TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()); $content = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($path)); $flexForm = 'EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Grids/' . $pathInfo['filename'] . '.xml'; $flexFormFile = GeneralUtility::getFileAbsFileName($flexForm); $flexFormContent = is_file($flexFormFile) ? GeneralUtility::getUrl($flexFormFile) : false; $grids[] = $this->getPageTsConfig($pathInfo['filename'], $label, $content, $icon, $flexFormContent); } return $grids; }
public function init($PA, $fobj) { $GLOBALS['LANG']->includeLLFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cal') . 'Resources/Private/Language/locallang_db.xml'); $this->frequency = $PA['row']['freq']; if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7005000) { $this->frequency = $PA['row']['freq'][0]; } $this->uid = $PA['row']['uid']; $this->row = $PA['row']; $this->table = $PA['table']; $this->rdateType = $this->row['rdate_type']; $this->rdate = $this->row['rdate']; $this->rdateValues = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->row['rdate'], 1); if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7004000) { $this->garbageIcon = '<span class="t3-icon fa t3-icon fa fa-trash"> </span>'; $this->newIcon = '<span title="' . $GLOBALS['LANG']->getLL('tx_cal_event.add_recurrence') . '" class="t3-icon fa t3-icon fa fa-plus-square"> </span>'; } else { $this->garbageIcon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/garbage.gif') . ' title="' . $GLOBALS['LANG']->getLL('tx_cal_event.remove_recurrence') . '" alt="' . $GLOBALS['LANG']->getLL('tx_cal_event.delete_recurrence') . '" />'; $this->newIcon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/new_el.gif') . ' title="' . $GLOBALS['LANG']->getLL('tx_cal_event.add_recurrence') . '" alt="' . $GLOBALS['LANG']->getLL('tx_cal_event.add_recurrence') . '" />'; } $this->commonJS = ''; if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7004000) { $this->commonJS .= '<script src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('cal') . 'Resources/Public/js/recurui2.js" type="text/javascript"></script>' . chr(10) . '<script src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('cal') . 'Resources/Public/js/url2.js" type="text/javascript"></script>'; } else { $this->commonJS .= '<script src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('cal') . 'Resources/Public/js/recurui.js" type="text/javascript"></script>' . chr(10) . '<script src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('cal') . 'Resources/Public/js/url.js" type="text/javascript"></script>'; } $this->everyMonthText = $GLOBALS['LANG']->getLL('tx_cal_event.recurs_every_month'); $this->selectedMonthText = $GLOBALS['LANG']->getLL('tx_cal_event.recurs_selected_months'); $this->counts = $this->getCountsArray(); $startDay = $this->getWeekStartDay($PA); $this->weekdays = $this->getWeekDaysArray($startDay); $this->months = $this->getMonthsArray(); }
/** * 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; }
/** * Initializes the Module * * @return void */ public function initialize() { parent::init(); $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->setModuleTemplate(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('recycler') . 'mod1/mod_template.html'); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setExtDirectStateProvider(); $this->pageRenderer = $this->doc->getPageRenderer(); $this->relativePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('recycler'); $this->pageRecord = BackendUtility::readPageAccess($this->id, $this->perms_clause); $this->isAccessibleForCurrentUser = $this->id && is_array($this->pageRecord) || !$this->id && $this->isCurrentUserAdmin(); //don't access in workspace if ($GLOBALS['BE_USER']->workspace !== 0) { $this->isAccessibleForCurrentUser = FALSE; } //read configuration $modTS = $GLOBALS['BE_USER']->getTSConfig('mod.recycler'); if ($this->isCurrentUserAdmin()) { $this->allowDelete = TRUE; } else { $this->allowDelete = $modTS['properties']['allowDelete'] == '1'; } if (isset($modTS['properties']['recordsPageLimit']) && (int) $modTS['properties']['recordsPageLimit'] > 0) { $this->recordsPageLimit = (int) $modTS['properties']['recordsPageLimit']; } }
/** * 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); } }
/** * action index * * @return void */ public function indexAction() { $this->extKey = 'twitterbox'; $this->pluginKey = 'twitterbox'; $this->extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey); $this->extRelPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey); $this->config = $this->loadConfig(); $this->view->assign('config', $this->config); $headerData = array(); if ($this->config['includeCSS']) { $headerData[] = '<link rel="stylesheet" type="text/css" href="' . $this->extRelPath . 'Resources/Public/Css/' . $this->pluginKey . '.css" />'; } $GLOBALS['TSFE']->additionalHeaderData['tx_' . $this->extKey . '_' . $this->pluginKey] = implode('', $headerData); if ($this->config['templateDir'] !== false) { $this->view->setTemplateRootPath($this->config['templateDir']); } $tweets = array(); if ($this->config['consumerKey'] !== false && $this->config['consumerSecret']) { $tokenUrl = "https://api.twitter.com/oauth2/token"; $auth = base64_encode(urlencode($this->config['consumerKey']) . ':' . urlencode($this->config['consumerSecret'])); try { $getTokenCH = curl_init(); curl_setopt($getTokenCH, CURLOPT_URL, $tokenUrl); curl_setopt($getTokenCH, CURLOPT_POST, 1); curl_setopt($getTokenCH, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $auth)); curl_setopt($getTokenCH, CURLOPT_POSTFIELDS, "grant_type=client_credentials"); curl_setopt($getTokenCH, CURLOPT_RETURNTRANSFER, 1); $token = json_decode(curl_exec($getTokenCH)); curl_close($getTokenCH); if (isset($token->errors)) { throw new \Exception('Error ' . $token->errors[0]->code . ': ' . $token->errors[0]->message); } $token = $token->access_token; if ($this->settings['mode'] == 'user') { $quest = 'https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=' . urlencode($this->settings['filter']); } else { $quest = 'https://api.twitter.com/1.1/search/tweets.json?q=' . urlencode($this->settings['filter']) . '&result_type=recent'; } $quest .= '&count=' . $this->config['numTweets']; $questCH = curl_init(); curl_setopt($questCH, CURLOPT_URL, $quest); curl_setopt($questCH, CURLOPT_RETURNTRANSFER, 1); curl_setopt($questCH, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token)); $result = json_decode(curl_exec($questCH)); curl_close($questCH); if (isset($result->errors)) { throw new \Exception('Error ' . $token->errors[0]->code . ': ' . $token->errors[0]->message); } if (isset($result->statuses)) { $tweets = $result->statuses; } else { $tweets = $result; } } catch (\Exception $e) { echo $e->getMessage(); } } $this->view->assign('heading', array('mode' => $this->settings['mode'], 'filter' => $this->settings['filter'])); $this->view->assign('tweets', $tweets); }
/** * 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; }
/** * Initialize editor * * @param integer $pageId * @param integer $template_uid * @return integer * @todo Define visibility */ public function initialize_editor($pageId, $template_uid = 0) { // Initializes the module. Done in this function because we may need to re-initialize if data is submitted! global $tmpl, $tplRow, $theConstants; $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService'); // Defined global here! $tmpl->tt_track = 0; // Do not log time-performance information $tmpl->init(); $tmpl->ext_localGfxPrefix = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('tstemplate'); $tmpl->ext_localWebGfxPrefix = $GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('tstemplate') . 'Resources/Public/'; // Get the row of the first VISIBLE template of the page. whereclause like the frontend. $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid); // IF there was a template... if (is_array($tplRow)) { // Gets the rootLine $sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $rootLine = $sys_page->getRootLine($pageId); // This generates the constants/config + hierarchy info for the template. $tmpl->runThroughTemplates($rootLine, $template_uid); // The editable constants are returned in an array. $theConstants = $tmpl->generateConfig_constants(); // The returned constants are sorted in categories, that goes into the $tmpl->categories array $tmpl->ext_categorizeEditableConstants($theConstants); // This array will contain key=[expanded constantname], value=linenumber in template. (after edit_divider, if any) $tmpl->ext_regObjectPositions($tplRow['constants']); return 1; } }
/** * 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; }
/** * Init parameters. Reads TypoScript settings. * * @param array $conf: The PlugIn configuration * @return void */ protected function init($conf) { $this->db = $GLOBALS['TYPO3_DB']; // Process stdWrap properties $temp = $conf['scriptParams.']; unset($conf['scriptParams.']); $this->conf = $this->processStdWraps($conf); if (is_array($temp)) { $this->conf['scriptParams'] = $this->processStdWraps($temp); } $this->pi_setPiVarDefaults(); $this->scriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('webkitpdf') . 'res/'; if ($this->conf['customScriptPath']) { $this->scriptPath = $this->conf['customScriptPath']; } $this->outputPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'); if ($this->conf['customTempOutputPath']) { $this->outputPath .= tx_webkitpdf_utils::sanitizePath($this->conf['customTempOutputPath']); } else { $this->outputPath .= '/typo3temp/tx_webkitpdf/'; } $this->paramName = 'urls'; if ($this->conf['customParameterName']) { $this->paramName = $this->conf['customParameterName']; } $this->baseUrlToConvert = $this->piVars[$this->paramName][0]; $this->generateFileName(); $this->readScriptSettings(); $this->cacheManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Webkitpdf_CacheManager', $this->conf); $this->contentDisposition = 'attachment'; if (intval($this->conf['openFilesInline']) === 1) { $this->contentDisposition = 'inline'; } }
/** * 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; }
/** * Render the different elements and collect the single lines. * After the rendering the lines will be imploded. Notice: * All methods after this are CType rendering helper * * @param string $content * @param array $conf * * @return array */ public function render($content, $conf) { $lines = array(); $this->conf = $conf; $CType = (string) $this->cObj->data['CType']; if (isset($this->conf['forceCType']) && trim($this->conf['forceCType']) !== '') { $CType = trim($this->conf['forceCType']); } $renderer = array('html' => 'FRUIT\\Ink\\Rendering\\Html', 'header' => 'FRUIT\\Ink\\Rendering\\Header', 'table' => 'FRUIT\\Ink\\Rendering\\Table', 'menu' => 'FRUIT\\Ink\\Rendering\\Menu', 'text' => 'FRUIT\\Ink\\Rendering\\Text', 'image' => 'FRUIT\\Ink\\Rendering\\Image', 'textpic' => 'FRUIT\\Ink\\Rendering\\TextPicture', 'templavoila_pi1' => 'FRUIT\\Ink\\Rendering\\Templavoila', 'list' => 'FRUIT\\Ink\\Rendering\\Plugin'); GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Classes/Rendering/Plugin.php')); GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Classes/Rendering/Image.php')); GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Classes/Rendering/Menu.php')); $objectManager = new ObjectManager(); /** @var Dispatcher $signalSlot */ $signalSlot = $objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); $returnData = $signalSlot->dispatch(__CLASS__, 'renderer', array('renderer' => $renderer)); $renderer = $returnData['renderer']; if (isset($renderer[$CType])) { $className = $renderer[$CType]; /** @var RenderingInterface $renderObject */ $renderObject = $objectManager->get($className); $lines = $renderObject->render($this->cObj, $this->conf); } else { $lines[] = 'CType: ' . $CType . ' have no rendering definitions'; } $content = implode(LF, $lines); return trim($content, CRLF . TAB); }