/**
  * @return bool
  */
 public function isDevelopmentApplicationContext()
 {
     if (GeneralUtility::getApplicationContext()->isDevelopment()) {
         return TRUE;
     }
     return FALSE;
 }
 /**
  * Constructor
  *
  * @param \TYPO3\CMS\Backend\Controller\BackendController $backendReference TYPO3 backend object reference
  * @throws \UnexpectedValueException
  */
 public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL)
 {
     $this->backendReference = $backendReference;
     $this->cacheActions = array();
     $this->optionValues = array();
     $backendUser = $this->getBackendUser();
     // Clear all page-related caches
     if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.pages')) {
         $this->cacheActions[] = array('id' => 'pages', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesTitle', TRUE), 'description' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesDescription', TRUE), 'href' => $this->backPath . 'tce_db.php?vC=' . $backendUser->veriCode() . '&cacheCmd=pages&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-low'));
         $this->optionValues[] = 'pages';
     }
     // Clear cache for ALL tables!
     if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.all')) {
         $this->cacheActions[] = array('id' => 'all', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesTitle', TRUE), 'description' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesDescription', TRUE), 'href' => $this->backPath . 'tce_db.php?vC=' . $backendUser->veriCode() . '&cacheCmd=all&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-medium'));
         $this->optionValues[] = 'all';
     }
     // Clearing of system cache (core cache, class cache etc)
     // is only shown explicitly if activated for a BE-user (not activated for admins by default)
     // or if the system runs in development mode
     // or if $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] is set (only for admins)
     if ($backendUser->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === TRUE && $backendUser->isAdmin()) {
         $this->cacheActions[] = array('id' => 'system', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle', TRUE), 'description' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription', TRUE), 'href' => $this->backPath . 'tce_db.php?vC=' . $backendUser->veriCode() . '&cacheCmd=system&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-high'));
         $this->optionValues[] = 'system';
     }
     // Hook for manipulating cacheActions
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'] as $cacheAction) {
             $hookObject = GeneralUtility::getUserObj($cacheAction);
             if (!$hookObject instanceof \TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface) {
                 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\Toolbar\\ClearCacheActionsHookInterface', 1228262000);
             }
             $hookObject->manipulateCacheActions($this->cacheActions, $this->optionValues);
         }
     }
 }
 /**
  * Modifies CacheMenuItems array
  *
  * @param array $cacheActions Array of CacheMenuItems
  * @param array $optionValues Array of AccessConfigurations-identifiers (typically  used by userTS with options.clearCache.identifier)
  */
 public function manipulateCacheActions(&$cacheActions, &$optionValues)
 {
     if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === TRUE && $this->getBackendUser()->isAdmin()) {
         $cacheActions[] = array('id' => 'dyncss', 'title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle', TRUE), 'description' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription', TRUE), 'href' => BackendUtility::getModuleUrl('tce_db') . '&vC=' . $this->getBackendUser()->veriCode() . '&cacheCmd=dyncss&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-high'));
         $optionValues[] = 'dyncss';
     }
 }
 /**
  * @return bool
  */
 public function isDevelopmentApplicationContext()
 {
     if (GeneralUtility::getApplicationContext()->isDevelopment()) {
         return true;
     }
     return false;
 }
 /**
  * Modifies CacheMenuItems array
  *
  * @param array $cacheActions Array of CacheMenuItems
  * @param array $optionValues Array of AccessConfigurations-identifiers (typically  used by userTS with options.clearCache.identifier)
  *
  * @return void
  */
 public function manipulateCacheActions(&$cacheActions, &$optionValues)
 {
     if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === TRUE && $this->getBackendUser()->isAdmin()) {
         $cacheActions[] = array('id' => 'dyncss', 'title' => $this->getLanguageService()->sL('LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.title', TRUE), 'description' => $this->getLanguageService()->sL('LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.description', TRUE), 'href' => BackendUtility::getModuleUrl('tce_db') . '&vC=' . $this->getBackendUser()->veriCode() . '&cacheCmd=dyncss&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('extensions-dyncss-lightning-blue'));
         $optionValues[] = 'dyncss';
     }
 }
 /**
  * Constructor
  *
  * @throws \UnexpectedValueException
  */
 public function __construct()
 {
     $backendUser = $this->getBackendUser();
     $languageService = $this->getLanguageService();
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/ClearCacheMenu');
     // Clear all page-related caches
     if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.pages')) {
         $this->cacheActions[] = array('id' => 'pages', 'title' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesTitle', true), 'description' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesDescription', true), 'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'pages', 'ajaxCall' => 1]), 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-low', Icon::SIZE_SMALL)->render());
         $this->optionValues[] = 'pages';
     }
     // Clear cache for ALL tables!
     if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.all')) {
         $this->cacheActions[] = array('id' => 'all', 'title' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesTitle', true), 'description' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesDescription', true), 'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'all', 'ajaxCall' => 1]), 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-medium', Icon::SIZE_SMALL)->render());
         $this->optionValues[] = 'all';
     }
     // Clearing of system cache (core cache, class cache etc)
     // is only shown explicitly if activated for a BE-user (not activated for admins by default)
     // or if the system runs in development mode
     // or if $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] is set (only for admins)
     if ($backendUser->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $backendUser->isAdmin()) {
         $this->cacheActions[] = array('id' => 'system', 'title' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle', true), 'description' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription', true), 'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'system', 'ajaxCall' => 1]), 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-high', Icon::SIZE_SMALL)->render());
         $this->optionValues[] = 'system';
     }
     // Hook for manipulating cacheActions
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'] as $cacheAction) {
             $hookObject = GeneralUtility::getUserObj($cacheAction);
             if (!$hookObject instanceof ClearCacheActionsHookInterface) {
                 throw new \UnexpectedValueException('$hookObject must implement interface ' . ClearCacheActionsHookInterface::class, 1228262000);
             }
             $hookObject->manipulateCacheActions($this->cacheActions, $this->optionValues);
         }
     }
 }
Example #7
0
 /**
  * JavaScript file to load
  *
  * @param string $file
  * @param bool $canBeMinified
  */
 public function render($file, $canBeMinified = false)
 {
     // Sipped minified file in Production context.
     if ($canBeMinified && (string) GeneralUtility::getApplicationContext() === 'Production') {
         $file = str_replace('.js', '.min.js', $file);
     }
     $this->getPageRenderer()->addJsFooterFile($file);
 }
Example #8
0
 /**
  * Get a body message when email is not in production.
  *
  * @param string $messageBody
  * @return string
  */
 protected function addDebugInfoToBody($messageBody)
 {
     $to = $this->getTo();
     $cc = $this->getCc();
     $bcc = $this->getBcc();
     $messageBody = sprintf("%s CONTEXT: this message is for testing purposes. In Production, it will be sent as follows. \nto: %s\n%s%s\n%s", strtoupper((string) GeneralUtility::getApplicationContext()), implode(',', array_keys($to)), empty($cc) ? '' : sprintf("cc: %s \n", implode(',', array_keys($cc))), empty($bbc) ? '' : sprintf("bcc: %s \n", implode(',', array_keys($bcc))), $messageBody);
     return $messageBody;
 }
 /**
  * Set up
  */
 protected function setUp()
 {
     require_once 'Fixtures/ConditionMatcherUserFuncs.php';
     $this->backupApplicationContext = GeneralUtility::getApplicationContext();
     $this->conditionMatcher = $this->getMockForAbstractClass(AbstractConditionMatcher::class);
     $this->evaluateConditionCommonMethod = new \ReflectionMethod(AbstractConditionMatcher::class, 'evaluateConditionCommon');
     $this->evaluateConditionCommonMethod->setAccessible(TRUE);
 }
Example #10
0
 /**
  * Set up
  *
  * This setUp() does not call its parent implementation to avoid database cleaning
  *
  * @return void
  */
 protected function setUp()
 {
     if (!(in_array(GeneralUtility::getApplicationContext(), $this->allowedApplicationContexts) || in_array($_SERVER['HOSTNAME'], $this->allowedDomains) || in_array($_SERVER['HTTP_HOST'], $this->allowedDomains))) {
         $this->markTestSkipped(sprintf('This test is only allowed in contexts "%s" or on domains "%s"', implode(', ', $this->allowedApplicationContexts), implode(', ', $this->allowedDomains)));
     }
     $fixtureImporter = GeneralUtility::makeInstance('Tx_PtExtbase_Testing_FixtureFramework_FixtureImporter');
     /** @var Tx_PtExtbase_Testing_FixtureFramework_FixtureImporter $fixtureImporter */
     $fixtureImporter->import($this->getFixtures());
 }
 public static function configureAll()
 {
     if (!preg_match('#/Heroku$#', GeneralUtility::getApplicationContext())) {
         return;
     }
     static::configureDatabase();
     static::configureSessionStorage();
     static::relaxBackendIpRestriction();
 }
Example #12
0
 /**
  * If context is set to production, priority
  * of this preset is raised.
  *
  * @return int Priority of preset
  */
 public function getPriority()
 {
     $context = \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext();
     $priority = $this->priority;
     if ($context->isProduction()) {
         $priority = $priority + 20;
     }
     return $priority;
 }
 protected function connect()
 {
     // Load system specific configuration for Apache mode
     $dpppConfiguration = __DIR__ . '/../../../../../../configurations/' . GeneralUtility::getApplicationContext() . '/AdditionalConfiguration.php';
     if (file_exists($dpppConfiguration)) {
         @(include $dpppConfiguration);
     }
     $credentials = $GLOBALS['TYPO3_CONF_VARS']['DB'];
     $this->mySQLConnection = new \PDO('mysql:host=' . $credentials['host'] . ';dbname=' . $credentials['database'], $credentials['username'], $credentials['password']);
 }
Example #14
0
 /**
  * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
  * @return string
  */
 public function render()
 {
     $redirectTo = $this->getRedirectService()->redirectionForCurrentContext();
     $output = '';
     // Means we want to redirect email.
     if (!empty($redirectTo)) {
         $contentElement = $this->templateVariableContainer->get('contentElement');
         $settings = $this->getFlexFormService()->extractSettings($contentElement['pi_flexform']);
         $to = $this->getEmailAddressService()->parse($settings['emailAdminTo']);
         #$cc = $this->getEmailAddressService()->parse($settings['emailAdminCc']);
         #$bcc = $this->getEmailAddressService()->parse($settings['emailAdminBcc']);
         $templateService = $this->getTemplateService($settings['template']);
         $output = sprintf("<pre style='clear: both'>%s CONTEXT<br /> %s %s %s %s %s</pre>", strtoupper((string) GeneralUtility::getApplicationContext()), $this->hasEmails($settings) ? '<br />- All emails will be redirected to ' . implode(', ', array_keys($redirectTo)) . '.' : '', empty($to) ? '' : '<br />- Admin email will be sent to: ' . implode(', ', array_keys($to)), empty($settings['emailUserTo']) ? '' : '<br/>- User email will be sent using the field "' . $settings['emailUserTo'] . '"', $this->isSenderOk($settings) ? '' : '<br/>- ATTENTION! No sender could be found. This will be a problem when sending emails.', $templateService->hasPersistingTable() ? '<br/>- Submitted data will be persisted into "' . $templateService->getPersistingTable() . '"' : '');
     }
     return $output;
 }
Example #15
0
 /**
  * @param $subject
  * @param $message
  */
 public static function sendMailToWinkel($subject, $message)
 {
     $isDev = GeneralUtility::getApplicationContext()->isDevelopment();
     if ($isDev === false) {
         /* @var \TYPO3\CMS\Core\Mail\MailMessage */
         $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
         $mail->setFrom(array('*****@*****.**' => 'WINKEL GmbH'));
         $mail->setTo(array('*****@*****.**' => 'Produktanfrage'));
         $mail->setSubject($subject);
         $mail->setBody($message);
         //        if ($_FILES['tx_winkelproducts_pi1']['name']['flangeplate-pdf'] != '') {
         //            $attachment = Swift_Attachment::fromPath($fileName, $mimeType);
         //            $attachment->setFilename($_FILES['tx_winkelproducts_pi1']['name']['flangeplate-pdf']);
         //            $mail->attach($attachment);
         //        }
         $mail->send();
     }
 }
Example #16
0
 /**
  * Run the server
  */
 public function runServer()
 {
     $pdo = $this->getPdoConnection();
     $principalBackend = new PrincipalBackendTypo3($pdo);
     $tree = [new Collection($principalBackend), new CalendarRoot($principalBackend, new BackendTypo3($pdo))];
     $server = new Server($tree);
     $server->setBaseUri('/CalDav/');
     /* Server Plugins */
     $authPlugin = new AuthPlugin(new AuthBackendTypo3($pdo));
     $server->addPlugin($authPlugin);
     #$aclPlugin = new \Sabre\DAVACL\Plugin();
     #$server->addPlugin($aclPlugin);
     $caldavPlugin = new Plugin();
     $server->addPlugin($caldavPlugin);
     if (GeneralUtility::getApplicationContext()->isDevelopment()) {
         $server->addPlugin(new BrowserPlugin());
     }
     $server->exec();
 }
Example #17
0
 /**
  * Get possible redirect recipients.
  *
  * @return array
  */
 public function redirectionForCurrentContext()
 {
     // Fetch email from PHP configuration array at first.
     $applicationContext = (string) GeneralUtility::getApplicationContext()->getParent();
     if (empty($applicationContext)) {
         $applicationContext = (string) GeneralUtility::getApplicationContext();
     }
     $applicationContext = strtolower($applicationContext);
     $key = $applicationContext . '_redirect_to';
     if (isset($GLOBALS['TYPO3_CONF_VARS']['MAIL'][$key])) {
         $recipientList = $GLOBALS['TYPO3_CONF_VARS']['MAIL'][$key];
     } else {
         $recipientList = ConfigurationUtility::getInstance()->get($key);
     }
     $recipients = array();
     if (strlen(trim($recipientList)) > 0) {
         $emails = GeneralUtility::trimExplode(',', $recipientList);
         foreach ($emails as $email) {
             $recipients[$email] = $email;
         }
         $this->getEmailAddressService()->validate($recipients);
     }
     return $recipients;
 }
Example #18
0
 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     if (!empty($this->requireJsConfig)) {
         return;
     }
     $this->addRequireJs = true;
     $loadedExtensions = ExtensionManagementUtility::getLoadedExtensionListArray();
     $isDevelopment = GeneralUtility::getApplicationContext()->isDevelopment();
     $cacheIdentifier = 'requireJS_' . md5(implode(',', $loadedExtensions) . ($isDevelopment ? ':dev' : ''));
     /** @var VariableFrontend $cache */
     $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('assets');
     $this->requireJsConfig = $cache->get($cacheIdentifier);
     // if we did not get a configuration from the cache, compute and store it in the cache
     if (empty($this->requireJsConfig)) {
         $this->requireJsConfig = $this->computeRequireJsConfig($isDevelopment, $loadedExtensions);
         $cache->set($cacheIdentifier, $this->requireJsConfig);
     }
 }
 /**
  * Determine exception handler class name from global and content object configuration
  *
  * @param array $configuration
  * @return string|NULL
  */
 protected function determineExceptionHandlerClassName($configuration)
 {
     $exceptionHandlerClassName = null;
     $tsfe = $this->getTypoScriptFrontendController();
     if (!isset($tsfe->config['config']['contentObjectExceptionHandler'])) {
         if (GeneralUtility::getApplicationContext()->isProduction()) {
             $exceptionHandlerClassName = '1';
         }
     } else {
         $exceptionHandlerClassName = $tsfe->config['config']['contentObjectExceptionHandler'];
     }
     if (isset($configuration['exceptionHandler'])) {
         $exceptionHandlerClassName = $configuration['exceptionHandler'];
     }
     if ($exceptionHandlerClassName === '1') {
         $exceptionHandlerClassName = ProductionExceptionHandler::class;
     }
     return $exceptionHandlerClassName;
 }
 /**
  * This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
  *
  * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
  * @return bool
  */
 protected static function evaluateCondition($arguments = NULL)
 {
     return GeneralUtility::getApplicationContext()->isProduction();
 }
 /**
  * Gets the application context
  *
  * @return void
  */
 protected function getApplicationContext()
 {
     $applicationContext = GeneralUtility::getApplicationContext();
     $this->systemInformation[] = array('title' => htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.sysinfo.applicationcontext')), 'value' => (string) $applicationContext, 'status' => $applicationContext->isProduction() ? InformationStatus::STATUS_OK : InformationStatus::STATUS_WARNING, 'icon' => $this->iconFactory->getIcon('sysinfo-application-context', Icon::SIZE_SMALL)->render());
 }
Example #22
0
 /**
  * Call function if you need the requireJS library
  * this automatically adds the JavaScript path of all loaded extensions in the requireJS path option
  * so it resolves names like TYPO3/CMS/MyExtension/MyJsFile to EXT:MyExtension/Resources/Public/JavaScript/MyJsFile.js
  * when using requireJS
  *
  * @return void
  */
 public function loadRequireJs()
 {
     // load all paths to map to package names / namespaces
     if (empty($this->requireJsConfig)) {
         // In order to avoid browser caching of JS files, adding a GET parameter to the files loaded via requireJS
         if (GeneralUtility::getApplicationContext()->isDevelopment()) {
             $this->requireJsConfig['urlArgs'] = 'bust=' . $GLOBALS['EXEC_TIME'];
         } else {
             $this->requireJsConfig['urlArgs'] = 'bust=' . GeneralUtility::hmac(TYPO3_version . PATH_site);
         }
         // first, load all paths for the namespaces, and configure contrib libs.
         $this->requireJsConfig['paths'] = array('jquery-ui' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery-ui', 'datatables' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.dataTables', 'nprogress' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/nprogress', 'moment' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/moment', 'cropper' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/cropper.min', 'imagesloaded' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/imagesloaded.pkgd.min', 'bootstrap' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap', 'twbs/bootstrap-datetimepicker' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-datetimepicker', 'autosize' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/autosize', 'taboverride' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/taboverride.min', 'twbs/bootstrap-slider' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap-slider.min', 'jquery/autocomplete' => $this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.autocomplete');
         // get all extensions that are loaded
         $loadedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
         foreach ($loadedExtensions as $packageName) {
             $fullJsPath = 'EXT:' . $packageName . '/Resources/Public/JavaScript/';
             $fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
             $fullJsPath = \TYPO3\CMS\Core\Utility\PathUtility::getRelativePath(PATH_typo3, $fullJsPath);
             $fullJsPath = rtrim($fullJsPath, '/');
             if ($fullJsPath) {
                 $this->requireJsConfig['paths']['TYPO3/CMS/' . GeneralUtility::underscoredToUpperCamelCase($packageName)] = $this->backPath . $fullJsPath;
             }
         }
         // check if additional AMD modules need to be loaded if a single AMD module is initialized
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules'])) {
             $this->addInlineSettingArray('RequireJS.PostInitializationModules', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['RequireJS']['postInitializationModules']);
         }
     }
     $this->addRequireJs = true;
 }
 /**
  * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
  *
  * @param string $key The condition to match against its criterias.
  * @param string $value
  * @return NULL|boolean Result of the evaluation; NULL if condition could not be evaluated
  */
 protected function evaluateConditionCommon($key, $value)
 {
     if (GeneralUtility::inList('browser,version,system,useragent', strtolower($key))) {
         $browserInfo = $this->getBrowserInfo(GeneralUtility::getIndpEnv('HTTP_USER_AGENT'));
     }
     $keyParts = GeneralUtility::trimExplode('|', $key);
     switch ($keyParts[0]) {
         case 'applicationContext':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             $currentApplicationContext = GeneralUtility::getApplicationContext();
             foreach ($values as $applicationContext) {
                 if ($this->searchStringWildcard($currentApplicationContext, $applicationContext)) {
                     return TRUE;
                 }
             }
             break;
         case 'browser':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             // take all identified browsers into account, eg chrome deliver
             // webkit=>532.5, chrome=>4.1, safari=>532.5
             // so comparing string will be
             // "webkit532.5 chrome4.1 safari532.5"
             $all = '';
             foreach ($browserInfo['all'] as $key => $value) {
                 $all .= $key . $value . ' ';
             }
             foreach ($values as $test) {
                 if (stripos($all, $test) !== FALSE) {
                     return TRUE;
                 }
             }
             break;
         case 'version':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             foreach ($values as $test) {
                 if (strcspn($test, '=<>') == 0) {
                     switch ($test[0]) {
                         case '=':
                             if (doubleval(substr($test, 1)) == $browserInfo['version']) {
                                 return TRUE;
                             }
                             break;
                         case '<':
                             if (doubleval(substr($test, 1)) > $browserInfo['version']) {
                                 return TRUE;
                             }
                             break;
                         case '>':
                             if (doubleval(substr($test, 1)) < $browserInfo['version']) {
                                 return TRUE;
                             }
                             break;
                     }
                 } elseif (strpos(' ' . $browserInfo['version'], $test) == 1) {
                     return TRUE;
                 }
             }
             break;
         case 'system':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             // Take all identified systems into account, e.g. mac for iOS, Linux
             // for android and Windows NT for Windows XP
             $allSystems = ' ' . implode(' ', $browserInfo['all_systems']);
             foreach ($values as $test) {
                 if (stripos($allSystems, $test) !== FALSE) {
                     return TRUE;
                 }
             }
             break;
         case 'device':
             if (!isset($this->deviceInfo)) {
                 $this->deviceInfo = $this->getDeviceType(GeneralUtility::getIndpEnv('HTTP_USER_AGENT'));
             }
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             foreach ($values as $test) {
                 if ($this->deviceInfo == $test) {
                     return TRUE;
                 }
             }
             break;
         case 'useragent':
             $test = trim($value);
             if ($test !== '') {
                 return $this->searchStringWildcard((string) $browserInfo['useragent'], $test);
             }
             break;
         case 'language':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             foreach ($values as $test) {
                 if (preg_match('/^\\*.+\\*$/', $test)) {
                     $allLanguages = preg_split('/[,;]/', GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
                     if (in_array(substr($test, 1, -1), $allLanguages)) {
                         return TRUE;
                     }
                 } elseif (GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test) {
                     return TRUE;
                 }
             }
             break;
         case 'IP':
             if ($value === 'devIP') {
                 $value = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
             }
             if (GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $value)) {
                 return TRUE;
             }
             break;
         case 'hostname':
             if (GeneralUtility::cmpFQDN(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $value)) {
                 return TRUE;
             }
             break;
         case 'hour':
         case 'minute':
         case 'month':
         case 'year':
         case 'dayofweek':
         case 'dayofmonth':
         case 'dayofyear':
             // In order to simulate time properly in templates.
             $theEvalTime = $GLOBALS['SIM_EXEC_TIME'];
             switch ($key) {
                 case 'hour':
                     $theTestValue = date('H', $theEvalTime);
                     break;
                 case 'minute':
                     $theTestValue = date('i', $theEvalTime);
                     break;
                 case 'month':
                     $theTestValue = date('m', $theEvalTime);
                     break;
                 case 'year':
                     $theTestValue = date('Y', $theEvalTime);
                     break;
                 case 'dayofweek':
                     $theTestValue = date('w', $theEvalTime);
                     break;
                 case 'dayofmonth':
                     $theTestValue = date('d', $theEvalTime);
                     break;
                 case 'dayofyear':
                     $theTestValue = date('z', $theEvalTime);
                     break;
             }
             $theTestValue = (int) $theTestValue;
             // comp
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             foreach ($values as $test) {
                 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($test)) {
                     $test = '=' . $test;
                 }
                 if ($this->compareNumber($test, $theTestValue)) {
                     return TRUE;
                 }
             }
             break;
         case 'compatVersion':
             return GeneralUtility::compat_version($value);
             break;
         case 'loginUser':
             if ($this->isUserLoggedIn()) {
                 $values = GeneralUtility::trimExplode(',', $value, TRUE);
                 foreach ($values as $test) {
                     if ($test == '*' || (string) $this->getUserId() === (string) $test) {
                         return TRUE;
                     }
                 }
             } elseif ($value === '') {
                 return TRUE;
             }
             break;
         case 'page':
             if ($keyParts[1]) {
                 $page = $this->getPage();
                 $property = $keyParts[1];
                 if (!empty($page) && isset($page[$property]) && (string) $page[$property] === (string) $value) {
                     return TRUE;
                 }
             }
             break;
         case 'globalVar':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             foreach ($values as $test) {
                 $point = strcspn($test, '!=<>');
                 $theVarName = substr($test, 0, $point);
                 $nv = $this->getVariable(trim($theVarName));
                 $testValue = substr($test, $point);
                 if ($this->compareNumber($testValue, $nv)) {
                     return TRUE;
                 }
             }
             break;
         case 'globalString':
             $values = GeneralUtility::trimExplode(',', $value, TRUE);
             foreach ($values as $test) {
                 $point = strcspn($test, '=');
                 $theVarName = substr($test, 0, $point);
                 $nv = (string) $this->getVariable(trim($theVarName));
                 $testValue = substr($test, $point + 1);
                 if ($this->searchStringWildcard($nv, trim($testValue))) {
                     return TRUE;
                 }
             }
             break;
         case 'userFunc':
             $matches = array();
             preg_match_all('/^\\s*([^\\(\\s]+)\\s*(?:\\((.*)\\))?\\s*$/', $value, $matches);
             $funcName = $matches[1][0];
             $funcValues = $matches[2][0] ? $this->parseUserFuncArguments($matches[2][0]) : array();
             if (function_exists($funcName) && call_user_func_array($funcName, $funcValues)) {
                 return TRUE;
             }
             break;
     }
     return NULL;
 }
 /**
  * Check if Development context is active
  *
  * @return bool
  */
 public function render()
 {
     return GeneralUtility::getApplicationContext()->isDevelopment();
 }
<?php

use TYPO3\CMS\Core\Utility\GeneralUtility;
defined('TYPO3_MODE') || die('Access denied.');
// get complete context
$context = GeneralUtility::getApplicationContext()->__toString();
// alternative: set $context (please keep in mind that you also have to set the correct context for cli tasks)
//$context = 'Development/Production';
// check for "Production/Live/Server123" etc
if ($context) {
    list($contextMainPart, $contextSubPart1, $contextSubPart2) = explode('/', $context);
}
// project specific configuration
$customChanges = ['BE' => ['sessionTimeout' => 3600, 'versionNumberInFilename' => 0], 'EXT' => ['extConf' => ['news' => serialize(['removeListActionFromFlexforms' => 2, 'archiveDate' => 'date', 'pageModuleFieldsCategory' => 'title,description', 'pageModuleFieldsNews' => 'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pagemodule_simple=title,datetime;LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pagemodule_advanced=title,datetime,teaser,categories;LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:pagemodule_complex=title,datetime,teaser,categories,archive;', 'showMediaDescriptionField' => 0, 'rteForTeaser' => 0, 'tagPid' => 1, 'prependAtCopy' => 0, 'categoryRestriction' => 'none', 'categoryBeGroupTceFormsRestriction' => 0, 'contentElementRelation' => 1, 'manualSorting' => 0, 'useFal' => 1, 'showAdministrationModule' => 0, 'showImporter' => 1, 'storageUidImporter' => '1', 'resourceFolderImporter' => '/news_import']), 'realurl' => serialize(['configFile' => 'typo3conf/ext/theme/Resources/Private/Extensions/Realurl/ManualConfiguration.php', 'enableAutoConf' => 1, 'enableDevLog' => 0, 'enableChashUrlDebug' => 0]), 'rtehtmlarea' => serialize(['defaultConfiguration' => 'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)', 'enableImages' => 0, 'enableInlineElements' => 0, 'allowStyleAttribute' => 0, 'enableAccessibilityIcons' => 0, 'forceCommandMode' => 0, 'noSpellCheckLanguages' => 'ja,km,ko,lo,th,zh,b5,gb', 'AspellDirectory' => '/usr/bin/aspell']), 'scheduler' => serialize(['maxLifetime' => 1440, 'enableBELog' => 1, 'showSampleTasks' => 1, 'useAtDaemon' => 0])]], 'FE' => ['disableNoCacheParameter' => true, 'hidePagesIfNotTranslatedByDefault' => true], 'GFX' => ['jpg_quality' => 86], 'SYS' => ['sitename' => 'TYPO3 community website' . ' [' . ($context ?: 'No applicationContext') . ']', 'curlUse' => true, 'devIPmask' => '', 'textfile_ext' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'] . ',setupts,constantsts,ts1,tsc,tsconfig', 'UTF8filesystem' => true, 'systemLocale' => 'en_US.utf8', 'defaultCategorizedTables' => 'pages', 'clearCacheSystem' => true, 't3lib_cs_convMethod' => 'mbstring', 't3lib_cs_utils' => 'mbstring'], 'MAIL' => ['defaultMailFromAddress' => '*****@*****.**', 'defaultMailFromName' => 'TYPO3']];
$GLOBALS['TYPO3_CONF_VARS'] = array_replace_recursive($GLOBALS['TYPO3_CONF_VARS'], (array) $customChanges);
/*
 * include the most general file e.g. "AdditionalConfiguration_Staging.php
 */
$file = realpath(__DIR__) . '/AdditionalConfiguration_' . $contextMainPart . '.php';
if (is_file($file)) {
    include_once $file;
    $GLOBALS['TYPO3_CONF_VARS'] = array_replace_recursive($GLOBALS['TYPO3_CONF_VARS'], (array) $customChanges);
}
/*
 * check for a more specific configuration as well e.g. "AdditionalConfiguration_Development_Profiling.php"
 */
$file = realpath(__DIR__) . '/AdditionalConfiguration_' . $contextMainPart . '_' . $contextSubPart1 . '.php';
if (is_file($file)) {
    include_once $file;
    $GLOBALS['TYPO3_CONF_VARS'] = array_replace_recursive($GLOBALS['TYPO3_CONF_VARS'], (array) $customChanges);
}
<?php

namespace Instruccionesaldorso\TYPO3\CMS\Base\Distribution;

use TYPO3\CMS\Core\Utility\GeneralUtility;
if (!function_exists('Instruccionesaldorso\\TYPO3\\CMS\\Base\\Distribution\\includeIfExists')) {
    function includeIfExists($file)
    {
        file_exists($file) && (include $file);
    }
}
includeIfExists(__DIR__ . '/../../Configuration/' . GeneralUtility::getApplicationContext() . '/Settings.php');
 /**
  * @test
  */
 public function exceptionHandlerIsEnabledByDefaultInProductionContext()
 {
     $backupApplicationContext = GeneralUtility::getApplicationContext();
     Fixtures\GeneralUtilityFixture::setApplicationContext(new ApplicationContext('Production'));
     $contentObjectFixture = $this->createContentObjectThrowingExceptionFixture();
     $this->subject->render($contentObjectFixture, array());
     Fixtures\GeneralUtilityFixture::setApplicationContext($backupApplicationContext);
 }
 /**
  * Call the render() method and handle errors.
  *
  * @return string the rendered ViewHelper
  * @throws Exception
  */
 protected function callRenderMethod()
 {
     $renderMethodParameters = array();
     foreach ($this->argumentDefinitions as $argumentName => $argumentDefinition) {
         if ($argumentDefinition->isMethodParameter()) {
             $renderMethodParameters[$argumentName] = $this->arguments[$argumentName];
         }
     }
     try {
         return call_user_func_array(array($this, 'render'), $renderMethodParameters);
     } catch (Exception $exception) {
         if (GeneralUtility::getApplicationContext()->isProduction()) {
             $this->getLogger()->error('A Fluid ViewHelper Exception was captured: ' . $exception->getMessage() . ' (' . $exception->getCode() . ')', array('exception' => $exception));
             return '';
         } else {
             throw $exception;
         }
     }
 }
Example #29
0
 /**
  * @param MailMessage $message
  * @throws \UnexpectedValueException
  * @throws \BadFunctionCallException
  */
 public function log(MailMessage $message)
 {
     $tableName = ExtensionManagementUtility::isLoaded('messenger') ? 'tx_messenger_domain_model_sentmessage' : 'tx_formule_domain_model_sentmessage';
     $values = ['pid' => (int) $this->getFrontendObject()->id, 'sender' => $this->formatEmails($message->getFrom()), 'recipient' => $this->formatEmails($message->getTo()), 'recipient_cc' => $this->formatEmails($message->getCc()), 'recipient_bcc' => $this->formatEmails($message->getBcc()), 'subject' => $this->getDatabaseConnection()->quoteStr($message->getSubject(), $tableName), 'body' => $this->getDatabaseConnection()->quoteStr($message->getBody(), $tableName), 'context' => (string) GeneralUtility::getApplicationContext(), 'is_sent' => (int) $message->isSent(), 'sent_time' => time(), 'ip' => GeneralUtility::getIndpEnv('REMOTE_ADDR'), 'crdate' => time()];
     $this->getDatabaseConnection()->exec_INSERTquery($tableName, $values);
 }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
/**
 * Development environment
 * TYPO3_CONTEXT Development
 */
if (\TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext()->isDevelopment()) {
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = '[DEV] Dumfart Shop';
    $GLOBALS['TYPO3_CONF_VARS']['DB']['database'] = 'typo3-cms';
    $GLOBALS['TYPO3_CONF_VARS']['DB']['host'] = '127.0.0.1';
    $GLOBALS['TYPO3_CONF_VARS']['DB']['password'] = '******';
    $GLOBALS['TYPO3_CONF_VARS']['DB']['port'] = 3306;
    $GLOBALS['TYPO3_CONF_VARS']['DB']['username'] = '******';
    $GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword'] = '******';
}