/** * Returns information about this extension plugin * * @param array $params Parameters to the hook * * @return string Information about pi1 plugin * @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar */ public function getExtensionSummary(array $params) { $relIconPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ExtensionManagementUtility::siteRelPath('calendarize') . 'ext_icon.png'; $this->flexFormService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\FlexFormService'); $this->layoutService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\ContentElementLayoutService'); $this->layoutService->setTitle('<img src="' . $relIconPath . '" /> Calendarize'); if ($params['row']['list_type'] != 'calendarize_calendar') { return ''; } $this->flexFormService->load($params['row']['pi_flexform']); if (!$this->flexFormService->isValid()) { return ''; } $actions = $this->flexFormService->get('switchableControllerActions', 'main'); $parts = GeneralUtility::trimExplode(';', $actions, true); $parts = array_map(function ($element) { $split = explode('->', $element); return ucfirst($split[1]); }, $parts); $actionKey = lcfirst(implode('', $parts)); $this->layoutService->addRow(LocalizationUtility::translate('mode', 'calendarize'), LocalizationUtility::translate('mode.' . $actionKey, 'calendarize')); $this->layoutService->addRow(LocalizationUtility::translate('configuration', 'calendarize'), $this->flexFormService->get('settings.configuration', 'main')); if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) { $this->layoutService->addRow(LocalizationUtility::translate('hide.pagination.teaser', 'calendarize'), '!!!'); } $this->addPageIdsToTable(); return $this->layoutService->render(); }
/** * Initializes the controller before invoking an action method. * * @return void */ protected function initializeAction() { $this->id = intval(GeneralUtility::_GET('id')); $this->tsParser = new TsParserUtility(); // Get extension configuration /** @var \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility */ $configurationUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility'); $extensionConfiguration = $configurationUtility->getCurrentConfiguration('themes'); // Initially, get configuration from extension manager! $extensionConfiguration['categoriesToShow'] = GeneralUtility::trimExplode(',', $extensionConfiguration['categoriesToShow']['value']); $extensionConfiguration['constantsToHide'] = GeneralUtility::trimExplode(',', $extensionConfiguration['constantsToHide']['value']); // mod.tx_themes.constantCategoriesToShow.value // Get value from page/user typoscript $externalConstantCategoriesToShow = $this->getBackendUser()->getTSConfig('mod.tx_themes.constantCategoriesToShow', BackendUtility::getPagesTSconfig($this->id)); if ($externalConstantCategoriesToShow['value']) { $this->externalConfig['constantCategoriesToShow'] = GeneralUtility::trimExplode(',', $externalConstantCategoriesToShow['value']); $extensionConfiguration['categoriesToShow'] = array_merge($extensionConfiguration['categoriesToShow'], $this->externalConfig['constantCategoriesToShow']); } // mod.tx_themes.constantsToHide.value // Get value from page/user typoscript $externalConstantsToHide = $this->getBackendUser()->getTSConfig('mod.tx_themes.constantsToHide', BackendUtility::getPagesTSconfig($this->id)); if ($externalConstantsToHide['value']) { $this->externalConfig['constantsToHide'] = GeneralUtility::trimExplode(',', $externalConstantsToHide['value']); $extensionConfiguration['constantsToHide'] = array_merge($extensionConfiguration['constantsToHide'], $this->externalConfig['constantsToHide']); } $this->allowedCategories = $extensionConfiguration['categoriesToShow']; $this->deniedFields = $extensionConfiguration['constantsToHide']; // initialize normally used values }
/** * @param $uidList * * @return array|NULL */ protected function loadSlides($uidList) { /** @var \WMDB\WmdbBaseEwh\DatabaseLayer\Tables\tx_wmdbbaseewh_slide $table */ $table = DatabaseFactory::getTable('tx_wmdbbaseewh_slide', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\'); $items = $table->findByUidList($uidList); foreach ($items as &$item) { $item['image'] = $this->pObj->loadFalData($item, 'image', 'tx_wmdbbaseewh_slide'); if ($item['style'] == 2) { $descriptionParts = GeneralUtility::trimExplode(LF, $item['description'], 1); $tmp = array(); $leftCnt = $rightCnt = 190; $itemOffset = 800; foreach ($descriptionParts as $key => $part) { $tmp[$key % 2 == 0 ? 'left' : 'right'][] = array('text' => $part, 'offset' => $key % 2 == 0 ? $leftCnt : $rightCnt, 'timeOffset' => $itemOffset); if ($key % 2 == 0) { $leftCnt += 55; } else { $rightCnt += 55; } $itemOffset += 150; } $item['split'] = $tmp; } } return $items; }
/** * 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; }
/** * Remove values of a comma separated list from another comma separated list * * @param string $result string comma separated list * @param $toBeRemoved string comma separated list * @return string */ public static function removeValuesFromString($result, $toBeRemoved) { $resultAsArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $result, TRUE); $idListAsArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $toBeRemoved, TRUE); $result = implode(',', array_diff($resultAsArray, $idListAsArray)); return $result; }
/** * Rendering preview output of a field value which is not shown as a form field but just outputted. * * @param string $value The value to output * @param array $config Configuration for field. * @param string $field Name of field. * @return string HTML formatted output */ protected function previewFieldValue($value, $config, $field = '') { if ($config['config']['type'] === 'group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) { // Ignore upload folder if internal_type is file_reference if ($config['config']['internal_type'] === 'file_reference') { $config['config']['uploadfolder'] = ''; } $table = 'tt_content'; // Making the array of file items: $itemArray = GeneralUtility::trimExplode(',', $value, true); // Showing thumbnails: $thumbnail = ''; $imgs = array(); $iconFactory = GeneralUtility::makeInstance(IconFactory::class); foreach ($itemArray as $imgRead) { $imgParts = explode('|', $imgRead); $imgPath = rawurldecode($imgParts[0]); $rowCopy = array(); $rowCopy[$field] = $imgPath; // Icon + click menu: $absFilePath = GeneralUtility::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath); $fileInformation = pathinfo($imgPath); $title = $fileInformation['basename'] . ($absFilePath && @is_file($absFilePath)) ? ' (' . GeneralUtility::formatSize(filesize($absFilePath)) . ')' : ' - FILE NOT FOUND!'; $fileIcon = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForFileExtension($fileInformation['extension'], Icon::SIZE_SMALL)->render() . '</span>'; $imgs[] = '<span class="text-nowrap">' . BackendUtility::thumbCode($rowCopy, $table, $field, '', 'thumbs.php', $config['config']['uploadfolder'], 0, ' align="middle"') . ($absFilePath ? $this->getControllerDocumentTemplate()->wrapClickMenuOnIcon($fileIcon, $absFilePath, 0, 1, '', '+copy,info,edit,view') : $fileIcon) . $imgPath . '</span>'; } return implode('<br />', $imgs); } else { return nl2br(htmlspecialchars($value)); } }
/** * Update language file for each extension * * @param string $localesToUpdate Comma separated list of locales that needs to be updated * @return void */ public function updateCommand($localesToUpdate = '') { /** @var $translationService \TYPO3\CMS\Lang\Service\TranslationService */ $translationService = $this->objectManager->get(\TYPO3\CMS\Lang\Service\TranslationService::class); /** @var $languageRepository \TYPO3\CMS\Lang\Domain\Repository\LanguageRepository */ $languageRepository = $this->objectManager->get(\TYPO3\CMS\Lang\Domain\Repository\LanguageRepository::class); $locales = array(); if (!empty($localesToUpdate)) { $locales = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $localesToUpdate, TRUE); } else { $languages = $languageRepository->findSelected(); foreach ($languages as $language) { /** @var $language \TYPO3\CMS\Lang\Domain\Model\Language */ $locales[] = $language->getLocale(); } } /** @var PackageManager $packageManager */ $packageManager = $this->objectManager->get(\TYPO3\CMS\Core\Package\PackageManager::class); $this->emitPackagesMayHaveChangedSignal(); $packages = $packageManager->getAvailablePackages(); $this->outputLine(sprintf('Updating language packs of all activated extensions for locales "%s"', implode(', ', $locales))); $this->output->progressStart(count($locales) * count($packages)); foreach ($locales as $locale) { /** @var PackageInterface $package */ foreach ($packages as $package) { $extensionKey = $package->getPackageKey(); $result = $translationService->updateTranslation($extensionKey, $locale); if (empty($result[$extensionKey][$locale]['error'])) { $this->registryService->set($locale, $GLOBALS['EXEC_TIME']); } $this->output->progressAdvance(); } } $this->output->progressFinish(); }
/** * Registers a command and its command class for several plugins * * @param string $plugins comma separated list of plugin names (without pi_ prefix) * @param string $commandName command name * @param string $commandClass name of the class implementing the command * @param integer $requirements Bitmask of which requirements need to be met for a command to be executed */ public static function registerPluginCommand($plugins, $commandName, $commandClass, $requirements = Tx_Solr_PluginCommand::REQUIREMENT_HAS_SEARCHED) { if (!array_key_exists($commandName, self::$commands)) { $plugins = GeneralUtility::trimExplode(',', $plugins, TRUE); self::$commands[$commandName] = array('plugins' => $plugins, 'commandName' => $commandName, 'commandClass' => $commandClass, 'requirements' => $requirements); } }
protected function getSortingLinks() { $sortHelper = GeneralUtility::makeInstance('Tx_Solr_Sorting', $this->configuration['search.']['sorting.']['options.']); $query = $this->search->getQuery(); $queryLinkBuilder = GeneralUtility::makeInstance('Tx_Solr_Query_LinkBuilder', $query); $queryLinkBuilder->setLinkTargetPageId($this->parentPlugin->getLinkTargetPageId()); $sortOptions = array(); $urlParameters = GeneralUtility::_GP('tx_solr'); $urlSortParameters = GeneralUtility::trimExplode(',', $urlParameters['sort']); $configuredSortOptions = $sortHelper->getSortOptions(); foreach ($configuredSortOptions as $sortOptionName => $sortOption) { $sortDirection = $this->configuration['search.']['sorting.']['defaultOrder']; if (!empty($this->configuration['search.']['sorting.']['options.'][$sortOptionName . '.']['defaultOrder'])) { $sortDirection = $this->configuration['search.']['sorting.']['options.'][$sortOptionName . '.']['defaultOrder']; } $sortIndicator = $sortDirection; $currentSortOption = ''; $currentSortDirection = ''; foreach ($urlSortParameters as $urlSortParameter) { $explodedUrlSortParameter = explode(' ', $urlSortParameter); if ($explodedUrlSortParameter[0] == $sortOptionName) { list($currentSortOption, $currentSortDirection) = $explodedUrlSortParameter; break; } } // toggle sorting direction for the current sorting field if ($currentSortOption == $sortOptionName) { switch ($currentSortDirection) { case 'asc': $sortDirection = 'desc'; $sortIndicator = 'asc'; break; case 'desc': $sortDirection = 'asc'; $sortIndicator = 'desc'; break; } } if (!empty($this->configuration['search.']['sorting.']['options.'][$sortOptionName . '.']['fixedOrder'])) { $sortDirection = $this->configuration['search.']['sorting.']['options.'][$sortOptionName . '.']['fixedOrder']; } $sortParameter = $sortOptionName . ' ' . $sortDirection; $temp = array('link' => $queryLinkBuilder->getQueryLink($sortOption['label'], array('sort' => $sortParameter)), 'url' => $queryLinkBuilder->getQueryUrl(array('sort' => $sortParameter)), 'optionName' => $sortOptionName, 'field' => $sortOption['field'], 'label' => $sortOption['label'], 'is_current' => '0', 'direction' => $sortDirection, 'indicator' => $sortIndicator, 'current_direction' => ' '); // set sort indicator for the current sorting field if ($currentSortOption == $sortOptionName) { $temp['selected'] = 'selected="selected"'; $temp['current'] = 'current'; $temp['is_current'] = '1'; $temp['current_direction'] = $sortIndicator; } // special case relevance: just reset the search to normal behavior if ($sortOptionName == 'relevance') { $temp['link'] = $queryLinkBuilder->getQueryLink($sortOption['label'], array('sort' => NULL)); $temp['url'] = $queryLinkBuilder->getQueryUrl(array('sort' => NULL)); unset($temp['direction'], $temp['indicator']); } $sortOptions[] = $temp; } return $sortOptions; }
/** * Entry method * * @return array As defined in initializeResultArray() of AbstractNode */ public function render() { $table = $this->data['tableName']; $fieldToRender = $this->data['singleFieldToRender']; $recordTypeValue = $this->data['recordTypeValue']; $resultArray = $this->initializeResultArray(); // Load the description content for the table if requested if ($GLOBALS['TCA'][$table]['interface']['always_description']) { $languageService = $this->getLanguageService(); $languageService->loadSingleTableDescription($table); } $itemList = $this->data['processedTca']['types'][$recordTypeValue]['showitem']; $fields = GeneralUtility::trimExplode(',', $itemList, true); foreach ($fields as $fieldString) { $fieldConfiguration = $this->explodeSingleFieldShowItemConfiguration($fieldString); $fieldName = $fieldConfiguration['fieldName']; if ((string) $fieldName === (string) $fieldToRender) { // Field is in showitem configuration // @todo: This field is not rendered if it is "hidden" in a palette! if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) { $options = $this->data; $options['fieldName'] = $fieldName; $options['renderType'] = 'singleFieldContainer'; $resultArray = $this->nodeFactory->create($options)->render(); } } } return $resultArray; }
/** * Error handling if no news entry is found * * @param string $configuration configuration what will be done * @throws \InvalidArgumentException * @return void */ protected function handleNoNewsFoundError($configuration) { if (empty($configuration)) { return; } $configuration = GeneralUtility::trimExplode(',', $configuration, true); switch ($configuration[0]) { case 'redirectToListView': $this->redirect('list'); break; case 'redirectToPage': if (count($configuration) === 1 || count($configuration) > 3) { $msg = sprintf('If error handling "%s" is used, either 2 or 3 arguments, split by "," must be used', $configuration[0]); throw new \InvalidArgumentException($msg); } $this->uriBuilder->reset(); $this->uriBuilder->setTargetPageUid($configuration[1]); $this->uriBuilder->setCreateAbsoluteUri(true); if (GeneralUtility::getIndpEnv('TYPO3_SSL')) { $this->uriBuilder->setAbsoluteUriScheme('https'); } $url = $this->uriBuilder->build(); if (isset($configuration[2])) { $this->redirectToUri($url, 0, (int) $configuration[2]); } else { $this->redirectToUri($url); } break; case 'pageNotFoundHandler': $GLOBALS['TSFE']->pageNotFoundAndExit('No news entry found.'); break; default: // Do nothing, it might be handled in the view. } }
/** * @return string */ public function render() { if ('BE' === TYPO3_MODE) { return; } $languages = $this->arguments['languages']; if (TRUE === $languages instanceof \Traversable) { $languages = iterator_to_array($languages); } elseif (TRUE === is_string($languages)) { $languages = GeneralUtility::trimExplode(',', $languages, TRUE); } else { $languages = (array) $languages; } $pageUid = intval($this->arguments['pageUid']); $normalWhenNoLanguage = $this->arguments['normalWhenNoLanguage']; if (0 === $pageUid) { $pageUid = $GLOBALS['TSFE']->id; } $currentLanguageUid = $GLOBALS['TSFE']->sys_language_uid; $languageUid = 0; if (FALSE === $this->pageSelect->hidePageForLanguageUid($pageUid, $currentLanguageUid, $normalWhenNoLanguage)) { $languageUid = $currentLanguageUid; } elseif (0 !== $currentLanguageUid) { if (TRUE === $this->pageSelect->hidePageForLanguageUid($pageUid, 0, $normalWhenNoLanguage)) { return; } } if (FALSE === empty($languages[$languageUid])) { return $languages[$languageUid]; } return $languageUid; }
/** * Process the link generation * * @param string $linkText * @param array $typoLinkConfiguration TypoLink Configuration array * @param string $linkHandlerKeyword Define the identifier that an record is given * @param string $linkHandlerValue Table and uid of the requested record like "tt_news:2" * @param string $linkParameters Full link params like "record:tt_news:2" * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer * @return string */ public function main($linkText, array $typoLinkConfiguration, $linkHandlerKeyword, $linkHandlerValue, $linkParameters, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer) { $typoScriptConfiguration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_linkhandler.']; $generatedLink = $linkText; // extract link params like "target", "css-class" or "title" $additionalLinkParameters = str_replace('"' . $linkHandlerKeyword . ':' . $linkHandlerValue . '"', '', $linkParameters); $additionalLinkParameters = str_replace($linkHandlerKeyword . ':' . $linkHandlerValue, '', $additionalLinkParameters); list($recordTableName, $recordUid) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $linkHandlerValue); $recordArray = $this->getCurrentRecord($recordTableName, $recordUid); if ($recordArray && $this->isRecordLinkable($recordTableName, $typoScriptConfiguration, $recordArray)) { $this->localContentObject = clone $contentObjectRenderer; $this->localContentObject->start($recordArray, ''); unset($typoLinkConfiguration['parameter']); $typoScriptConfiguration[$recordTableName . '.']['parameter'] .= $additionalLinkParameters; $currentLinkConfigurationArray = $this->mergeTypoScript($typoScriptConfiguration, $typoLinkConfiguration, $recordTableName); if (isset($currentLinkConfigurationArray['storagePidParameterOverride.'])) { if (array_key_exists($recordArray['pid'], $currentLinkConfigurationArray['storagePidParameterOverride.'])) { $currentLinkConfigurationArray['parameter'] = $currentLinkConfigurationArray['storagePidParameterOverride.'][$recordArray['pid']]; } } // build the full link to the record $generatedLink = $this->localContentObject->typoLink($linkText, $currentLinkConfigurationArray); $this->updateParentLastTypoLinkMember($contentObjectRenderer); } return $generatedLink; }
/** * Initialize actions. These actions are meant to be called by an logged-in FE User. */ public function initializeAction() { // Perhaps it should go into a validator? // Check permission before executing any action. $allowedFrontendGroups = trim($this->settings['allowedFrontendGroups']); if ($allowedFrontendGroups === '*') { if (empty($this->getFrontendUser()->user)) { throw new Exception('FE User must be logged-in.', 1387696171); } } elseif (!empty($allowedFrontendGroups)) { $isAllowed = FALSE; $frontendGroups = GeneralUtility::trimExplode(',', $allowedFrontendGroups, TRUE); foreach ($frontendGroups as $frontendGroup) { if (GeneralUtility::inList($this->getFrontendUser()->user['usergroup'], $frontendGroup)) { $isAllowed = TRUE; break; } } // Throw exception if not allowed if (!$isAllowed) { throw new Exception('FE User does not have enough permission.', 1415211931); } } $this->emitBeforeHandleUploadSignal(); }
/** * Returns information about this extension's pi1 plugin * * @param array $params Parameters to the hook * @param object $pObj A reference to calling object * @return string Information about pi1 plugin */ function getExtensionSummary($params, &$pObj) { $languageService = $this->getLanguageService(); $result = ''; if ($params['row']['list_type'] == 'irfaq_pi1') { $data = GeneralUtility::xml2array($params['row']['pi_flexform']); if (is_array($data)) { $modes = array(); foreach (GeneralUtility::trimExplode(',', $data['data']['sDEF']['lDEF']['what_to_display']['vDEF'], true) as $mode) { switch ($mode) { case 'DYNAMIC': $modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_dynamic'); break; case 'STATIC': $modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_static'); break; case 'STATIC_SEPARATE': $modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_static_separate'); break; case 'SEARCH': $modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_search'); break; } } $result = implode(', ', $modes); } if (!$result) { $result = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.no_view'); } } return $result; }
/** * Return markers from TypoScript * plugin.tx_powermail.settings.setup.excludeFromPowermailAllMarker { * submitPage.excludeFromMarkerNames = marker1, marker2 * submitPage.excludeFromFieldTypes = marker1, marker2 * } * * @param string $type * @param array $settings * @param string $configurationType * @return array */ protected function getExcludedValues($type, $settings, $configurationType = 'excludeFromFieldTypes') { if (!empty($settings['excludeFromPowermailAllMarker'][$this->typeToTypoScriptType[$type]][$configurationType])) { return GeneralUtility::trimExplode(',', $settings['excludeFromPowermailAllMarker'][$this->typeToTypoScriptType[$type]][$configurationType], TRUE); } return array(); }
/** * Manipulating the input array, $params, adding new selectorbox items. * * @param array array of select field options (reference) * @param object parent object (reference) * @return void */ function main(&$params, &$pObj) { if (version_compare(TYPO3_branch, '6.1', '<')) { GeneralUtility::loadTCA('tt_address'); } // TODO consolidate with list in pi1 $coreSortFields = 'gender, first_name, middle_name, last_name, title, company, ' . 'address, building, room, birthday, zip, city, region, country, email, www, phone, mobile, ' . 'fax'; $sortFields = GeneralUtility::trimExplode(',', $coreSortFields); $selectOptions = array(); foreach ($sortFields as $field) { $label = $GLOBALS['LANG']->sL($GLOBALS['TCA']['tt_address']['columns'][$field]['label']); $label = substr($label, 0, -1); $selectOptions[] = array('field' => $field, 'label' => $label); } // add sorting by order of single selection $selectOptions[] = array('field' => 'singleSelection', 'label' => $GLOBALS['LANG']->sL('LLL:EXT:tt_address/pi1/locallang_ff.xml:pi1_flexform.sortBy.singleSelection')); // sort by labels $labels = array(); foreach ($selectOptions as $key => $v) { $labels[$key] = $v['label']; } $labels = array_map('strtolower', $labels); array_multisort($labels, SORT_ASC, $selectOptions); // add fields to <select> foreach ($selectOptions as $option) { $params['items'][] = array($option['label'], $option['field']); } }
/** * Fetches the items that should be disabled from the context menu * * @return array */ protected function getDisableActions() { $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.' . $this->getContextMenuType() . '.disableItems'); $disableItems = array(); if (trim($tsConfig['value']) !== '') { $disableItems = GeneralUtility::trimExplode(',', $tsConfig['value']); } $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.pageTree.disableItems'); $oldDisableItems = array(); if (trim($tsConfig['value']) !== '') { $oldDisableItems = GeneralUtility::trimExplode(',', $tsConfig['value']); } $additionalItems = array(); foreach ($oldDisableItems as $item) { if (!isset($this->legacyContextMenuMapping[$item])) { $additionalItems[] = $item; continue; } if (strpos($this->legacyContextMenuMapping[$item], ',')) { $actions = GeneralUtility::trimExplode(',', $this->legacyContextMenuMapping[$item]); $additionalItems = array_merge($additionalItems, $actions); } else { $additionalItems[] = $item; } } return array_merge($disableItems, $additionalItems); }
/** * @return array */ public function getItems() { $items = array(); if (TRUE === $this->items instanceof QueryInterface) { $items = $this->addOptionsFromResults($this->items); } elseif (TRUE === is_string($this->items)) { $itemNames = GeneralUtility::trimExplode(',', $this->items); foreach ($itemNames as $itemName) { array_push($items, array($itemName, $itemName)); } } elseif (TRUE === is_array($this->items) || TRUE === $this->items instanceof \Traversable) { foreach ($this->items as $itemIndex => $itemValue) { if (TRUE === is_array($itemValue) || TRUE === $itemValue instanceof \ArrayObject) { array_push($items, $itemValue); } else { array_push($items, array($itemValue, $itemIndex)); } } } $emptyOption = $this->getEmptyOption(); if (FALSE !== $emptyOption) { array_unshift($items, array($emptyOption, '')); } return $items; }
/** * Init the dataProvider by TS-conifg * * @param array $filterSettings */ protected function initDataProviderByTsConfig($filterSettings) { if (array_key_exists('excludeFilters', $filterSettings) && trim($filterSettings['excludeFilters'])) { $this->excludeFilters = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $filterSettings['excludeFilters']); } $this->buildDateFieldConfigArray(); }
/** * Parse the sorting config string and build sorting config objects * * @param string $sortingSettings * @return Tx_PtExtlist_Domain_Configuration_Columns_SortingConfigCollection */ public static function getInstanceBySortingSettings($sortingSettings) { $nameToConstantMapping = array('asc' => Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_ASC, 'desc' => Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_DESC); // We create new sortingConfigCollection for column that can only be sorted as a whole $sortingConfigCollection = new Tx_PtExtlist_Domain_Configuration_Columns_SortingConfigCollection(true); $sortingFields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $sortingSettings); foreach ($sortingFields as $sortingField) { $sortingFieldOptions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $sortingField); $fieldName = $sortingFieldOptions[0]; if ($fieldName) { $tempSortingDir = strtolower($sortingFieldOptions[1]); $sortingDir = Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_ASC; $forceSortingDir = false; if (in_array($tempSortingDir, array('asc', 'desc'))) { $sortingDir = $nameToConstantMapping[$tempSortingDir]; } elseif (in_array($tempSortingDir, array('!asc', '!desc'))) { $forceSortingDir = true; $sortingDir = $nameToConstantMapping[substr($tempSortingDir, 1)]; } $sortingConfig = new Tx_PtExtlist_Domain_Configuration_Columns_SortingConfig($fieldName, $sortingDir, $forceSortingDir); $sortingConfigCollection->addSortingField($sortingConfig, $fieldName); } } return $sortingConfigCollection; }
/** * @param string $listenerId * @return object */ public function findById($listenerId) { if ($listenerId) { $object = parent::findById($listenerId); if (!$object) { list($table, $uid, $rawListenerId) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('-', $listenerId, false, 3); // try to generate the listener cache if ($table == 'tt_content' && $uid) { $object = $this->serviceContent->generateListenerCacheForContentElement($table, $uid); } elseif ($table == 'h' || $table == 'hInt') { $settingsHash = $uid; $encodedSettings = $rawListenerId; if (\TYPO3\CMS\Core\Utility\GeneralUtility::hmac($encodedSettings) == $settingsHash) { $loadContentFromTypoScript = str_replace('---', '.', $encodedSettings); $eventsToListen = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('e'); $object = $this->serviceContent->generateListenerCacheForHijaxPi1($loadContentFromTypoScript, $eventsToListen[$listenerId], $table == 'h'); } } if ($table == 'f') { $settingsHash = $uid; $encodedSettings = $rawListenerId; if (\TYPO3\CMS\Core\Utility\GeneralUtility::hmac($encodedSettings) == $settingsHash) { $fallbackTypoScriptConfiguration = str_replace('---', '.', $encodedSettings); $object = $this->serviceContent->generateListenerCacheForTypoScriptFallback($fallbackTypoScriptConfiguration); } } } return $object; } else { return null; } }
/** * 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; }
/** * @return string */ public function render() { $value = $this->configurationManager->getContentObject() ? $this->configurationManager->getContentObject()->data : array(); if ($this->arguments['as']) { $variableNameArr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('.', $this->arguments['as'], TRUE, 2); $variableName = $variableNameArr[0]; $attributePath = $variableNameArr[1]; if ($this->templateVariableContainer->exists($variableName)) { $oldValue = $this->templateVariableContainer->get($variableName); $this->templateVariableContainer->remove($variableName); } if ($attributePath) { if ($oldValue && is_array($oldValue)) { $templateValue = $oldValue; $templateValue[$attributePath] = $value; } else { $templateValue = array($attributePath => $value); } } else { $templateValue = $value; } $this->templateVariableContainer->add($variableName, $templateValue); return ''; } else { return $value; } }
/** * Main function, rendering the element browser in RTE mode. * * @return void * @todo Define visibility */ public function main() { // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only") $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints')); if ($altMountPoints) { $altMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $altMountPoints); foreach ($altMountPoints as $filePathRelativeToFileadmindir) { $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly'); } $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts(); } // Rendering type by user function $browserRendered = FALSE; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'] as $classRef) { $browserRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) { if ($browserRenderObj->isValid($this->mode, $this)) { $this->content .= $browserRenderObj->render($this->mode, $this); $browserRendered = TRUE; break; } } } } // If type was not rendered, use default rendering functions if (!$browserRendered) { $GLOBALS['SOBE']->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Rtehtmlarea\\SelectImage'); $GLOBALS['SOBE']->browser->init(); $modData = $GLOBALS['BE_USER']->getModuleData('select_image.php', 'ses'); list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData); $GLOBALS['BE_USER']->pushModuleData('select_image.php', $modData); $this->content = $GLOBALS['SOBE']->browser->main_rte(); } }
/** * Get the base pages * * @return array */ protected function getBasePages() { $startPage = intval($this->settings['startpoint']); $depth = intval($this->settings['depth']); $pages = $this->configurationManager->getContentObject()->getTreeList($startPage, $depth, 0, TRUE); return \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $startPage . ',' . $pages, TRUE); }
/** * Saves the edited stop word list to Solr * * @return void */ public function saveStopWordsAction() { $solrConnection = $this->getSelectedCoreSolrConnection(); $postParameters = GeneralUtility::_POST('tx_solr_tools_solradministration'); // lowercase stopword before saving because terms get lowercased before stopword filtering $newStopWords = $this->stringUtility->toLower($postParameters['stopWords']); $newStopWords = GeneralUtility::trimExplode("\n", $newStopWords, true); $oldStopWords = $solrConnection->getStopWords(); $wordsRemoved = true; $removedStopWords = array_diff($oldStopWords, $newStopWords); foreach ($removedStopWords as $word) { $response = $solrConnection->deleteStopWord($word); if ($response->getHttpStatus() != 200) { $wordsRemoved = false; $this->addFlashMessage('Failed to remove stop word "' . $word . '".', 'An error occurred', FlashMessage::ERROR); break; } } $wordsAdded = true; $addedStopWords = array_diff($newStopWords, $oldStopWords); if (!empty($addedStopWords)) { $wordsAddedResponse = $solrConnection->addStopWords($addedStopWords); $wordsAdded = $wordsAddedResponse->getHttpStatus() == 200; } $reloadResponse = $solrConnection->reloadCore(); if ($wordsRemoved && $wordsAdded && $reloadResponse->getHttpStatus() == 200) { $this->addFlashMessage('Stop Words Updated.'); } $this->forwardToIndex(); }
/** * Process data for the Themes variants. * * @param ContentObjectRenderer $cObj The content object renderer, which contains data of the content element * @param array $contentObjectConfiguration The configuration of Content Object * @param array $processorConfiguration The configuration of this processor * @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View) * * @throws ContentRenderingException * * @return array the processed data as key/value store */ public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData) { $keys = GeneralUtility::trimExplode(',', $processedData['data']['tx_themes_responsive'], true); $processedData['themes']['responsive']['keys'] = $keys; $processedData['themes']['responsive']['css'] = []; if (!empty($keys)) { $setup = $this->getFrontendController()->tmpl->setup; foreach ($keys as $key) { if (isset($setup['lib.']['content.']['cssMap.']['responsive.'][$key])) { // Special handling for column width if (strstr($key, '-column-width-')) { $keyParts = explode('-', $key); $columns = array_slice($keyParts, 3); if (!empty($columns)) { foreach ($columns as $no => $column) { $cssClass = trim($setup['lib.']['content.']['cssMap.']['responsive.'][$key]); $value = sprintf($cssClass, $column); $processedData['themes']['responsive']['column'][$no]['css'][$value] = $value; if (isset($processedData['themes']['responsive']['column'][$no]['css'])) { $processedData['themes']['responsive']['column'][$no]['cssClasses'] = implode(' ', $processedData['themes']['responsive']['column'][$no]['css']); } } } } else { $cssClass = trim($setup['lib.']['content.']['cssMap.']['responsive.'][$key]); if ($cssClass !== '') { $processedData['themes']['responsive']['css'][$cssClass] = $cssClass; } } } } $processedData['themes']['responsive']['cssClasses'] = implode(' ', $processedData['themes']['responsive']['css']); } return $processedData; }
public function check() { $checkFailed = ''; $formValue = trim($this->gp[$this->formFieldName]); if (strlen($formValue) > 0) { $checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words'); if (!is_array($checkValue)) { $checkValue = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $checkValue); } $error = FALSE; $array = preg_split('//', $formValue, -1, PREG_SPLIT_NO_EMPTY); foreach ($array as $idx => $char) { if (!in_array($char, $checkValue)) { $error = TRUE; } } if ($error) { //remove userfunc settings and only store comma seperated words $this->settings['params']['words'] = implode(',', $checkValue); unset($this->settings['params']['words.']); $checkFailed = $this->getCheckFailed(); } } return $checkFailed; }
/** * Remove values of a comma separated list from another comma separated list * * @param string $result string comma separated list * @param $toBeRemoved string comma separated list * @return string */ public static function removeValuesFromString($result, $toBeRemoved) { $resultAsArray = GeneralUtility::trimExplode(',', $result, true); $idListAsArray = GeneralUtility::trimExplode(',', $toBeRemoved, true); $result = implode(',', array_diff($resultAsArray, $idListAsArray)); return $result; }