Logo Search packages:      
Sourcecode: nagvis version File versions  Download package

GlobalLanguage::getText ( languagePath,
replace = '',
mergeWithGlobal = TRUE 
)

Gets the text of an id

Parameters:
String $languagePath Path to the Language String in the XML File
String $replace Strings to Replace
Boolean $mergeWithGlobal Merge with Global Type
Returns:
String String with Language String
Author:
Lars Michelsen <lars@vertical-visions.de>

Definition at line 307 of file GlobalLanguage.php.

                                                                        {
            if (DEBUG&&DEBUGLEVEL&1) debug('Start method GlobalLanguage::getText('.$languagePath.','.$replace.','.$mergeWithGlobal.')');
            $arrLang = Array();
            $strLang = '';
            $arrLanguagePath = explode(':',$languagePath);
            # DEBUG: print_r($arrLanguagePath);
            # [0] => backend
            # [1] => ndomy
            # [2] => messages
            # [3] => errorSelectingDb
            # [4] => title
            
            if($mergeWithGlobal && isset($this->lang['global']['global'][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]]) 
                    && $this->lang['global']['global'][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]] != '') {
                  $strLang = $this->lang['global']['global'][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]];
            } else {
                  if($mergeWithGlobal && isset($this->lang[$arrLanguagePath[0]]['global'][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]]) 
                          && $this->lang[$arrLanguagePath[0]]['global'][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]] != '') {
                        $strLang = $this->lang[$arrLanguagePath[0]]['global'][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]];
                  } else {
                        if(isset($this->lang[$arrLanguagePath[0]][$arrLanguagePath[1]][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]]) 
                                && $this->lang[$arrLanguagePath[0]][$arrLanguagePath[1]][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]] != '') {
                              $strLang = $this->lang[$arrLanguagePath[0]][$arrLanguagePath[1]][$arrLanguagePath[2]][$arrLanguagePath[3]][$arrLanguagePath[4]];
                        }
                  }
            }
            
            // filter type, messages/labels
            if($strLang != '') {
                  // Replace [i],[b] and their ending tags with HTML code
                  $strLang = preg_replace('/\[(\/|)(i|b)\]/i',"<$1$2>",$strLang);
                  
                  if($replace != '') {
                        $arrReplace = explode(',', $replace);
                        $size = count($arrReplace);
                        for($i=0;$i<$size;$i++) {
                              if(isset($arrReplace[$i])) {
                                    // If = are in the text, they'l be cut: $var = explode('=', str_replace('~','=',$arrReplace[$i]));
                                    $var = explode('~', $arrReplace[$i]);
                                    $strLang = str_replace('['.$var[0].']', $var[1], $strLang);
                              }
                        }
                        
                        if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalLanguage::getText(): '.$strLang);
                        // Return string with replaced text
                        return $strLang;
                  } else {
                        if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalLanguage::getText(): '.$strLang);
                        // Return without replacement
                        return $strLang;
                  }
            } else {
                  if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalLanguage::getText(): TranslationNotFound: '.$languagePath);
                  // Return Translation not Found error
                  return 'TranslationNotFound: '.$languagePath;
            }
      }


Generated by  Doxygen 1.6.0   Back to index