_debug = @DEBUG == '1' || $mosConfig_debug == '1'; } /** * Translator function * @param string Name of the Class Variable * @param boolean Encode String to HTML entities? * @return string The value of $var (as an HTML Entitiy-encoded string if $htmlentities) */ function _( $var, $htmlentities=true ) { $key = strtoupper( $var ); if (isset($this->$key)) { if( $htmlentities ) return htmlentities( $this->$key, ENT_QUOTES, 'utf-8' ); else return $this->$key; } elseif( $this->_debug ) return "$var is missing in language file."; } /** * Merges the class vars of another class * @param string The name of the class to merge * @return boolean True if successful, false is failed */ function merge( $classname ) { if (class_exists( $classname )) { foreach (get_class_vars( $classname ) as $k=>$v) { if (is_string( $v )) { if ($k[0] != '_') { $this->$k = $v; } } } } else { return false; } } /** * This safely converts an iso-8859 string into an utf-8 encoded * string. It does not convert when the string is already utf-8 encoded * * @param string $text iso-8859 encoded text * @param string $charset This is a k.o.-Argument. If it is NOT equal to 'utf-8', no conversion will take place * @return unknown */ function safe_utf8_encode( $text, $charset ) { if( strtolower($charset) == 'utf-8') { // when the supacart language file is not // utf-8_encoded, we must encode it if( !vmAbstractLanguage::seems_utf8($text)) { $text = utf8_encode($text); } } // This converts the currency symbol from HTML entity to the utf-8 symbol // example: € => € $text = vmHtmlEntityDecode( $text, null, 'utf-8' ); return $text; } /** * a simple function that can help, if you want to know * if a string could be UTF-8 or not * @author bmorel at ssi dot fr * @param unknown_type $Str * @return unknown */ function seems_utf8($Str) { for ($i=0; $i