/** * Handler for unknown types. * * @return array As defined in initializeResultArray() of AbstractNode */ public function render() { $resultArray = $this->initializeResultArray(); $languageService = $this->getLanguageService(); $row = $this->data['databaseRow']; $parameterArray = $this->data['parameterArray']; // If ratios are set do not add default options if (isset($parameterArray['fieldConf']['config']['ratios'])) { unset($this->defaultConfig['ratios']); } $config = ArrayUtility::arrayMergeRecursiveOverrule($this->defaultConfig, $parameterArray['fieldConf']['config']); // By default we allow all image extensions that can be handled by the GFX functionality if ($config['allowedExtensions'] === null) { $config['allowedExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']; } if ($config['readOnly']) { $options = array(); $options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']); $options['renderType'] = 'none'; return $this->nodeFactory->create($options)->render(); } $file = $this->getFile($row, $config['file_field']); if (!$file) { return $resultArray; } $content = ''; $preview = ''; if (GeneralUtility::inList(mb_strtolower($config['allowedExtensions']), mb_strtolower($file->getExtension()))) { // Get preview $preview = $this->getPreview($file, $parameterArray['itemFormElValue']); // Check if ratio labels hold translation strings foreach ((array) $config['ratios'] as $ratio => $label) { $config['ratios'][$ratio] = $languageService->sL($label, true); } $formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-'); $wizardData = array('zoom' => $config['enableZoom'] ? '1' : '0', 'ratios' => json_encode($config['ratios']), 'file' => $file->getUid()); $wizardData['token'] = GeneralUtility::hmac(implode('|', $wizardData), 'ImageManipulationWizard'); $buttonAttributes = array('data-url' => BackendUtility::getAjaxUrl('wizard_image_manipulation', $wizardData), 'data-severity' => 'notice', 'data-image-name' => $file->getNameWithoutExtension(), 'data-image-uid' => $file->getUid(), 'data-file-field' => $config['file_field'], 'data-field' => $formFieldId); $button = '<button class="btn btn-default t3js-image-manipulation-trigger"'; foreach ($buttonAttributes as $key => $value) { $button .= ' ' . $key . '="' . htmlspecialchars($value) . '"'; } $button .= '><span class="t3-icon fa fa-crop"></span>'; $button .= $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.open-editor', true); $button .= '</button>'; $inputField = '<input type="hidden" ' . 'id="' . $formFieldId . '" ' . 'name="' . $parameterArray['itemFormElName'] . '" ' . 'value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />'; $content .= $inputField . $button; $content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']); $resultArray['requireJsModules'][] = array('TYPO3/CMS/Backend/ImageManipulation' => 'function(ImageManipulation){ImageManipulation.initializeTrigger()}'); } $content .= '<p class="text-muted"><em>' . $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.supported-types-message', true) . '<br />'; $content .= mb_strtoupper(implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions']))); $content .= '</em></p>'; $item = '<div class="media">'; $item .= $preview; $item .= '<div class="media-body">' . $content . '</div>'; $item .= '</div>'; $resultArray['html'] = $item; return $resultArray; }
/** * Modifies CacheMenuItems array * * @param array $cacheActions * @param array $optionValues * * @return void */ public function manipulateCacheActions(&$cacheActions, &$optionValues) { if ($this->isProduction() || !$this->isAdmin()) { return; } $cacheActions[] = ['id' => 'autoloader', 'title' => 'EXT:autoloader caches', 'href' => BackendUtility::getAjaxUrl('autoloader::clearCache'), 'icon' => '<img src="' . IconUtility::getByExtensionKey('autoloader') . '">']; }
/** * Return JS configuration of the htmlArea plugins registered by the extension * * @param integer Relative id of the RTE editing area in the form * @return string JS configuration for registered plugins */ public function buildJavascriptConfiguration($RTEcounter) { $button = 'spellcheck'; // Set the SpellChecker mode $spellCheckerMode = isset($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) ? trim($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) : 'normal'; if (!in_array($spellCheckerMode, $this->spellCheckerModes)) { $spellCheckerMode = 'normal'; } // Set the use of personal dictionary $enablePersonalDicts = $this->thisConfig['buttons.'][$button . '.']['enablePersonalDictionaries'] ? isset($GLOBALS['BE_USER']->userTS['options.']['enablePersonalDicts']) && $GLOBALS['BE_USER']->userTS['options.']['enablePersonalDicts'] ? TRUE : FALSE : FALSE; if ($this->htmlAreaRTE->is_FE()) { $enablePersonalDicts = FALSE; } $registerRTEinJavascriptString = ''; if (in_array($button, $this->toolbar)) { if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$button . '.'])) { $registerRTEinJavascriptString .= ' RTEarea[' . $RTEcounter . '].buttons.' . $button . ' = new Object();'; } $registerRTEinJavascriptString .= ' RTEarea[' . $RTEcounter . '].buttons.' . $button . '.contentTypo3Language = "' . $this->htmlAreaRTE->contentTypo3Language . '"; RTEarea[' . $RTEcounter . '].buttons.' . $button . '.contentISOLanguage = "' . $this->htmlAreaRTE->contentISOLanguage . '"; RTEarea[' . $RTEcounter . '].buttons.' . $button . '.contentCharset = "' . $this->htmlAreaRTE->contentCharset . '"; RTEarea[' . $RTEcounter . '].buttons.' . $button . '.spellCheckerMode = "' . $spellCheckerMode . '"; RTEarea[' . $RTEcounter . '].buttons.' . $button . '.enablePersonalDicts = ' . ($enablePersonalDicts ? 'true' : 'false') . ';'; $registerRTEinJavascriptString .= ' RTEarea[' . $RTEcounter . '].buttons.' . $button . '.path = "' . ($this->htmlAreaRTE->is_FE() || $this->htmlAreaRTE->isFrontendEditActive() ? ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . 'index.php?eID=rtehtmlarea_spellchecker' : $this->htmlAreaRTE->backPath . BackendUtility::getAjaxUrl('rtehtmlarea::spellchecker')) . '";'; } return $registerRTEinJavascriptString; }
/** * Generate public url for file * * @param Resource\ResourceStorage $storage * @param Resource\Driver\DriverInterface $driver * @param Resource\FileInterface $file * @param $relativeToCurrentScript * @param array $urlData * @return void */ public function generatePublicUrl(Resource\ResourceStorage $storage, Resource\Driver\DriverInterface $driver, Resource\FileInterface $file, $relativeToCurrentScript, array $urlData) { // We only render special links for non-public files if ($this->enabled && !$storage->isPublic()) { $queryParameterArray = array('eID' => 'dumpFile', 't' => ''); if ($file instanceof Resource\File) { $queryParameterArray['f'] = $file->getUid(); $queryParameterArray['t'] = 'f'; } elseif ($file instanceof Resource\ProcessedFile) { $queryParameterArray['p'] = $file->getUid(); $queryParameterArray['t'] = 'p'; } $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'BeResourceStorageDumpFile'); // $urlData['publicUrl'] is passed by reference, so we can change that here and the value will be taken into account $urlData['publicUrl'] = BackendUtility::getAjaxUrl('FalSecuredownload::publicUrl', $queryParameterArray); } }
/** * Return JS configuration of the htmlArea plugins registered by the extension * * @return string JS configuration for registered plugins */ public function buildJavascriptConfiguration() { $jsArray = array(); $button = 'spellcheck'; // Set the SpellChecker mode $spellCheckerMode = isset($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) ? trim($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) : 'normal'; if (!in_array($spellCheckerMode, $this->spellCheckerModes)) { $spellCheckerMode = 'normal'; } // Set the use of personal dictionary $enablePersonalDicts = $this->configuration['thisConfig']['buttons.'][$button . '.']['enablePersonalDictionaries'] && !empty($GLOBALS['BE_USER']->userTS['options.']['enablePersonalDicts']); if (in_array($button, $this->toolbar)) { if (!is_array($this->configuration['thisConfig']['buttons.']) || !is_array($this->configuration['thisConfig']['buttons.'][$button . '.'])) { $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . ' = new Object();'; } $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.contentTypo3Language = "' . $this->configuration['contentTypo3Language'] . '";'; $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.contentISOLanguage = "' . $this->configuration['contentISOLanguage'] . '";'; $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.spellCheckerMode = "' . $spellCheckerMode . '";'; $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.enablePersonalDicts = ' . ($enablePersonalDicts ? 'true' : 'false') . ';'; $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.path = "' . ($this->isFrontend() || $this->isFrontendEditActive() ? ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . 'index.php?eID=rtehtmlarea_spellchecker' : BackendUtility::getAjaxUrl('rtehtmlarea::spellchecker')) . '";'; } return implode(LF, $jsArray); }
/** * Make URLs to all backend ajax handlers available as inline setting. */ protected function addAjaxUrlsToInlineSettings() { $ajaxUrls = []; // Note: this method of adding Ajax URLs is @deprecated as of TYPO3 v8, and will be removed in TYPO3 v9 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'] as $ajaxHandler => $_) { $ajaxUrls[$ajaxHandler] = BackendUtility::getAjaxUrl($ajaxHandler); } // also add the ajax-based routes /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); /** @var Router $router */ $router = GeneralUtility::makeInstance(Router::class); $routes = $router->getRoutes(); foreach ($routes as $routeIdentifier => $route) { if ($route->getOption('ajax')) { $uri = (string) $uriBuilder->buildUriFromRoute($routeIdentifier); // use the shortened value in order to use this in JavaScript $routeIdentifier = str_replace('ajax_', '', $routeIdentifier); $ajaxUrls[$routeIdentifier] = $uri; } } $this->inlineSettings['ajaxUrls'] = $ajaxUrls; }
/** * Make URLs to all backend ajax handlers available as inline setting. */ protected function addAjaxUrlsToInlineSettings() { $ajaxUrls = array(); foreach (array_keys($GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']) as $ajaxHandler) { $ajaxUrls[$ajaxHandler] = BackendUtility::getAjaxUrl($ajaxHandler); } $this->inlineSettings['ajaxUrls'] = $ajaxUrls; }
/** * Adds a menu entry to the clear cache menu to detect Solr connections. * * @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 ($GLOBALS['BE_USER']->isAdmin()) { $title = 'Initialize Solr connections'; $cacheActions[] = array('id' => 'clearSolrConnectionCache', 'title' => $title, 'href' => BackendUtility::getAjaxUrl('solr::clearSolrConnectionCache'), 'icon' => IconUtility::getSpriteIcon('extensions-solr-InitSolrConnections')); $optionValues[] = 'clearSolrConnectionCache'; } }
/** * Adds a menu entry to the clear cache menu to detect Solr connections. * * @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 ($GLOBALS['BE_USER']->isAdmin()) { $title = 'Initialize Solr connections'; $iconFactory = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\IconFactory'); $cacheActions[] = array('id' => 'clearSolrConnectionCache', 'title' => $title, 'href' => BackendUtility::getAjaxUrl('solr::clearSolrConnectionCache'), 'icon' => $iconFactory->getIcon('extensions-solr-module-initsolrconnections', Icon::SIZE_SMALL)); $optionValues[] = 'clearSolrConnectionCache'; } }
/** * Returns the convenient path for the routing Urls based on the TYPO3 mode. * * @param string $namespace * @return string */ public function getRoutingUrl($namespace) { if (TYPO3_MODE === 'FE') { $url = GeneralUtility::locationHeaderUrl('?eID=ExtDirect&action=route&namespace=' . rawurlencode($namespace)); } else { $url = BackendUtility::getAjaxUrl('ext_direct_route', array('namespace' => $namespace)); } return $url; }
/** * Add new cache menu option. * * @param array $cacheActions * @param array $optionValues * @return void */ public function manipulateCacheActions(&$cacheActions, &$optionValues) { $cacheActions[] = array('id' => 'tev_cache_url', 'title' => 'Flush RealURL config', 'href' => BackendUtility::getAjaxUrl('TevTevAjax::clearRealurlConfig'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-low')); $optionValues[] = 'clearCacheTevUrl'; }