Exemple #1
0
 /**
  * Event "onMageBridgeValidate"
  * 
  * @access public
  * @param array $actions
  * @param object $condition
  * @return bool
  */
 public function onMageBridgeValidate($actions = null, $condition = null)
 {
     // Make sure this plugin is enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Make sure to check upon the $actions array to see if it contains what we need
     if (empty($actions['joomfish_language'])) {
         return false;
     }
     // Fetch the current language
     $language = JFactory::getLanguage();
     // Fetch the languages
     $languages = JoomfishManager::getInstance()->getActiveLanguages();
     if (!empty($languages)) {
         foreach ($languages as $l) {
             if ($language->getTag() == $l->code || $language->getTag() == $l->lang_code) {
                 if (!empty($l->shortcode)) {
                     $language_code = $l->shortcode;
                     break;
                 } else {
                     if (!empty($l->sef)) {
                         $language_code = $l->sef;
                         break;
                     }
                 }
             }
         }
     } else {
         $language_code = JFactory::getApplication()->input->getCmd('lang');
     }
     // Check if the condition applies
     if ($actions['joomfish_language'] == $language_code) {
         return true;
     }
     // Return false by default
     return false;
 }
 /**
  * returns the default language of the frontend
  * @return object	instance of the default language
  */
 public function getDefaultLanguage()
 {
     return JoomfishManager::getDefaultLanguage();
 }
Exemple #3
0
 function getLangLongCode($lang_code = null)
 {
     static $codes;
     // Get current language code
     if (is_null($lang_code)) {
         $lang = JFactory::getLanguage();
         return $lang->getTag();
     }
     if (is_null($codes)) {
         $codes = array();
         if (Mijosef::get('utility')->JoomfishInstalled() || Mijosef::get('utility')->FalangInstalled()) {
             if (Mijosef::get('utility')->JoomfishInstalled()) {
                 $jfm = JoomfishManager::getInstance();
             } else {
                 $jfm = FalangManager::getInstance();
             }
             $langs =& $jfm->getLanguages(false);
             if (!empty($langs)) {
                 foreach ($langs as $lang) {
                     $codes[$lang->shortcode] = $lang->code;
                 }
             }
         } else {
             // Only one language
             $lang =& JFactory::getLanguage();
             $tag = $lang->getTag();
             $parts = explode('-', $tag);
             $iso = $parts[0];
             $codes[$iso] = $tag;
         }
     }
     if (isset($codes[$lang_code])) {
         return $codes[$lang_code];
     }
     return null;
 }