Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * 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;
 }