Esempio n. 1
0
function shGetActiveLanguages()
{
    global $mainframe;
    static $shActiveLanguages = null;
    // cache this, to reduce DB queries
    if (!is_null($shActiveLanguages)) {
        return $shActiveLanguages;
    }
    $shKind = shIsMultilingual();
    if ($shKind == 'joomfish') {
        $tempList = JoomFishManager::getActiveLanguages();
        if (!empty($tempList)) {
            foreach ($tempList as $language) {
                $shLang = null;
                $shLang->code = $language->code;
                $shLang->iso = $language->shortcode;
                $shActiveLanguages[] = $shLang;
            }
        } else {
            $shKind = '';
        }
    }
    if (empty($shKind)) {
        // not multilingual
        $shActiveLanguages = shGetFrontEndActiveLanguages();
    }
    return $shActiveLanguages;
}
function shGetActiveLanguages() {

  $mainframe = JFactory::getApplication();

  static $shActiveLanguages = null;  // cache this, to reduce DB queries
  if (!is_null($shActiveLanguages))
  return $shActiveLanguages;
   
  $shKind = shIsMultilingual();
  switch ($shKind) {
    case 'joomfish':
      $languages = JoomFishManager::getActiveLanguages();
      if (!empty($languages)) {
        foreach ($languages as $language) {
          $shLang = null;
          $shLang->code = $language->code;
          $shLang->iso = $language->shortcode;
          $shActiveLanguages[] = $shLang;
        }
      } else $shKind = '';
      break;
    case 'joomla':
      jimport('joomla.language.helper');
      $languages	= JLanguageHelper::getLanguages();
      if (!empty($languages)) {
        foreach ($languages as $language) {
          $shLang = null;
          $shLang->code = $language->lang_code;
          $shLang->iso = $language->sef;
          if(empty($shLang->iso)) {
            $shLang->iso = substr( $language->lang_code, 0, 2);
          }
          $shActiveLanguages[] = $shLang;
        }
      } else $shKind = '';
      break;
  }
  if (empty($shKind)) {
    // not multilingual
    $shActiveLanguages = shGetFrontEndActiveLanguages();
  }
  return $shActiveLanguages;
}