/** * Gets the localized name of the entity * * @return string */ public function getNameLocalized() { $language = LocalizationUtility::getCurrentLanguage(); $labelFields = LocalizationUtility::getLabelFields($this->tableName, $language); foreach ($labelFields as $labelField) { if ($this->_hasProperty($this->columnsMapping[$labelField]['mapOnProperty'])) { $value = $this->_getProperty($this->columnsMapping[$labelField]['mapOnProperty']); if ($value) { $this->nameLocalized = $value; break; } } } return $this->nameLocalized; }
/** * Initialize action. Called before every action method */ public function initializeAction() { $this->settings['baseUrl'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $mediaElementJsFolder = $this->getFileAbsFileName($this->settings['mediaelementjsFolder']); $this->settings['mediaelementjsFolderRelative'] = $mediaElementJsFolder; if ($this->settings['addHeaderData']) { if ($this->settings['addJQueryLibrary']) { $jQueryLibrary = $mediaElementJsFolder . 'build/jquery.js'; $this->addHeaderData($jQueryLibrary, 'js'); } if ($this->settings['addMediaElementJs']) { $locale = strtolower(LocalizationUtility::getCurrentLanguage()); if ($locale) { $localeFile = $mediaElementJsFolder . sprintf('src/js/me-i18n-locale-%s.js', $locale); if (file_exists($localeFile)) { $this->addHeaderData('var mejs = mejs || {}; (function () { mejs.i18n = { locale: { language: "' . $locale . '", strings: { } } }; })();', 'script'); $this->addHeaderData($localeFile, 'js'); } } $mediaElementJsJavascript = $mediaElementJsFolder . 'build/mediaelement-and-player.min.js'; $this->addHeaderData($mediaElementJsJavascript, 'js'); $mediaElementJsCss = $mediaElementJsFolder . 'build/mediaelementplayer.min.css'; $this->addHeaderData($mediaElementJsCss); if ($this->settings['skin']) { $mediaElementSkinCss = $mediaElementJsFolder . 'build/mejs-skins.css'; $this->addHeaderData($mediaElementSkinCss); } } if ($this->settings['addMediaElementJsInitialization'] && !$this->settings['addMediaElementJsInitializationFile']) { $this->addHeaderData('(function($) { $(document).ready(function() { $(\'video,audio\').mediaelementplayer(); });})(jQuery);', 'script'); } elseif ($this->settings['addMediaElementJsInitializationFile']) { $initializationFile = $this->getFileAbsFileName($this->settings['addMediaElementJsInitializationFile']); $fluidView = $this->objectManager->get(StandaloneView::class); /* @var $fluidView \TYPO3\CMS\Fluid\View\StandaloneView */ $fluidView->assign('settings', $this->settings); $fluidView->setTemplatePathAndFilename($initializationFile); $fluidView->setPartialRootPath(dirname($initializationFile)); $this->addHeaderData($fluidView->render(), 'none'); } } }
/** * Getting all languages into an array * where the key is the ISO alpha-2 code of the language * and where the value are the name of the language in the current language * Note: we exclude sacred and constructed languages * * @return array An array of names of languages */ protected function getLanguages() { $databaseConnection = $this->getDatabaseConnection(); $nameArray = array(); if (ExtensionManagementUtility::isLoaded('static_info_tables')) { $where = '1=1'; $table = 'static_languages'; $lang = LocalizationUtility::getCurrentLanguage(); $titleFields = LocalizationUtility::getLabelFields($table, $lang); $prefixedTitleFields = array(); foreach ($titleFields as $titleField) { $prefixedTitleFields[] = $table . '.' . $titleField; } $labelFields = implode(',', $prefixedTitleFields); // Restrict to certain languages if (is_array($this->configuration['thisConfig']['buttons.']) && is_array($this->configuration['thisConfig']['buttons.']['language.']) && isset($this->configuration['thisConfig']['buttons.']['language.']['restrictToItems'])) { $languageList = implode('\',\'', GeneralUtility::trimExplode(',', $databaseConnection->fullQuoteStr(strtoupper($this->configuration['thisConfig']['buttons.']['language.']['restrictToItems']), $table))); $where .= ' AND ' . $table . '.lg_iso_2 IN (' . $languageList . ')'; } $res = $databaseConnection->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_constructed = 0 ' . BackendUtility::BEenableFields($table) . BackendUtility::deleteClause($table)); $prefixLabelWithCode = (bool) $this->configuration['thisConfig']['buttons.']['language.']['prefixLabelWithCode']; $postfixLabelWithCode = (bool) $this->configuration['thisConfig']['buttons.']['language.']['postfixLabelWithCode']; while ($row = $databaseConnection->sql_fetch_assoc($res)) { $code = strtolower($row['lg_iso_2']) . ($row['lg_country_iso_2'] ? '-' . strtoupper($row['lg_country_iso_2']) : ''); foreach ($titleFields as $titleField) { if ($row[$titleField]) { $nameArray[$code] = $prefixLabelWithCode ? $code . ' - ' . $row[$titleField] : ($postfixLabelWithCode ? $row[$titleField] . ' - ' . $code : $row[$titleField]); break; } } } $databaseConnection->sql_free_result($res); uasort($nameArray, 'strcoll'); } return $nameArray; }
/** * Getting all languages into an array * where the key is the ISO alpha-2 code of the language * and where the value are the name of the language in the current language * Note: we exclude sacred and constructed languages * * @return array An array of names of languages * @todo Define visibility */ public function getLanguages() { $nameArray = array(); if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) { $where = '1=1'; $table = 'static_languages'; $lang = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getCurrentLanguage(); $titleFields = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFields($table, $lang); $prefixedTitleFields = array(); foreach ($titleFields as $titleField) { $prefixedTitleFields[] = $table . '.' . $titleField; } $labelFields = implode(',', $prefixedTitleFields); // Restrict to certain languages if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) { $languageList = implode('\',\'', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $table))); $where .= ' AND ' . $table . '.lg_iso_2 IN (' . $languageList . ')'; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_constructed = 0 ' . ($this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->sys_page->enableFields($table) : \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table))); $prefixLabelWithCode = (bool) $this->thisConfig['buttons.']['language.']['prefixLabelWithCode']; $postfixLabelWithCode = (bool) $this->thisConfig['buttons.']['language.']['postfixLabelWithCode']; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $code = strtolower($row['lg_iso_2']) . ($row['lg_country_iso_2'] ? '-' . strtoupper($row['lg_country_iso_2']) : ''); foreach ($titleFields as $titleField) { if ($row[$titleField]) { $nameArray[$code] = $prefixLabelWithCode ? $code . ' - ' . $row[$titleField] : ($postfixLabelWithCode ? $row[$titleField] . ' - ' . $code : $row[$titleField]); break; } } } $GLOBALS['TYPO3_DB']->sql_free_result($res); uasort($nameArray, 'strcoll'); } return $nameArray; }
/** * Getting all languages into an array * where the key is the ISO alpha-2 code of the language * and where the value are the name of the language in the current language * Note: we exclude sacred and constructed languages * * @return array An array of names of languages */ protected function getLanguages() { $nameArray = []; if (ExtensionManagementUtility::isLoaded('static_info_tables')) { $table = 'static_languages'; $lang = LocalizationUtility::getCurrentLanguage(); $titleFields = LocalizationUtility::getLabelFields($table, $lang); $labelFields = []; foreach ($titleFields as $titleField) { $labelFields[] = $table . '.' . $titleField; } $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); $queryBuilder->select($table . '.lg_iso_2', $table . '.lg_country_iso_2')->addSelect(...$labelFields)->from($table)->where($queryBuilder->expr()->eq('lg_constructed', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))); // Restrict to certain languages if (is_array($this->configuration['thisConfig']['buttons.']) && is_array($this->configuration['thisConfig']['buttons.']['language.']) && isset($this->configuration['thisConfig']['buttons.']['language.']['restrictToItems'])) { $languageList = GeneralUtility::trimExplode(',', strtoupper($this->configuration['thisConfig']['buttons.']['language.']['restrictToItems'])); $queryBuilder->andWhere($queryBuilder->expr()->in($table . '.lg_iso_2', $queryBuilder->createNamedParameter($languageList, Connection::PARAM_STR_ARRAY))); } $result = $queryBuilder->execute(); $prefixLabelWithCode = (bool) $this->configuration['thisConfig']['buttons.']['language.']['prefixLabelWithCode']; $postfixLabelWithCode = (bool) $this->configuration['thisConfig']['buttons.']['language.']['postfixLabelWithCode']; while ($row = $result->fetch()) { $code = strtolower($row['lg_iso_2']) . ($row['lg_country_iso_2'] ? '-' . strtoupper($row['lg_country_iso_2']) : ''); foreach ($titleFields as $titleField) { if ($row[$titleField]) { $nameArray[$code] = $prefixLabelWithCode ? $code . ' - ' . $row[$titleField] : ($postfixLabelWithCode ? $row[$titleField] . ' - ' . $code : $row[$titleField]); break; } } } uasort($nameArray, 'strcoll'); } return $nameArray; }
/** * Prepares the clause by which the result elements are sorted. See description of ORDER BY in * SQL standard for reference. * * @return void */ protected function prepareOrderByStatement() { if ($GLOBALS['TCA'][$this->table]['ctrl']['label']) { $this->orderByStatement = $GLOBALS['TCA'][$this->table]['ctrl']['label']; } // Get the label field for the current language, if any is available $lang = LocalizationUtility::getCurrentLanguage(); $lang = LocalizationUtility::getIsoLanguageKey($lang); $labelFields = LocalizationUtility::getLabelFields($this->table, $lang); $this->orderByStatement = implode(',', $labelFields); }
/** * Getting all languages into an array * where the key is the ISO alpha-2 code of the language * and where the value are the name of the language in the current language * Note: we exclude sacred and constructed languages * * @param string additional WHERE clause * @return array An array of names of languages */ public function initLanguages($addWhere = '') { $where = '1=1' . ($addWhere ? ' AND ' . $addWhere : ''); $table = $this->tables['LANGUAGES']; $lang = LocalizationUtility::getCurrentLanguage(); $lang = LocalizationUtility::getIsoLanguageKey($lang); $nameArray = array(); $titleFields = LocalizationUtility::getLabelFields($table, $lang); $prefixedTitleFields = array(); foreach ($titleFields as $titleField) { $prefixedTitleFields[] = $table . '.' . $titleField; } $labelFields = implode(',', $prefixedTitleFields); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_sacred = 0 AND lg_constructed = 0 ' . \SJBR\StaticInfoTables\Utility\TcaUtility::getEnableFields($table)); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $code = $row['lg_iso_2'] . ($row['lg_country_iso_2'] ? '_' . $row['lg_country_iso_2'] : ''); foreach ($titleFields as $titleField) { if ($row[$titleField]) { $nameArray[$code] = $row[$titleField]; break; } } } $GLOBALS['TYPO3_DB']->sql_free_result($res); uasort($nameArray, 'strcoll'); return $nameArray; }