Changeset 1441

Show
Ignore:
Timestamp:
12/10/07 10:01:38 (10 months ago)
Author:
misja
Message:

Misja Hoebe <misja@curverider.co.uk> Merge r1440 in 0.9 branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • releases/0.9/lib/typo3/class.t3lib_cs.php

    r269 r1441  
    33*  Copyright notice 
    44* 
    5 *  (c) 2003-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 
     5*  (c) 2003-2006 Kasper Skaarhoj (kasperYYYY@typo3.com) 
    66*  All rights reserved 
    77* 
     
    2525 * Class for conversion between charsets. 
    2626 * 
    27  * $Id: class.t3lib_cs.php,v 1.54 2005/12/12 21:47:50 masi Exp $ 
     27 *    Typo Id: class.t3lib_cs.php,v 1.56 2006/05/03 08:47:30 masi Exp $ 
     28 * Moodle $Id: class.t3lib_cs.php,v 1.7 2006/08/11 09:48:35 stronk7 Exp $ 
    2829 * 
    2930 * @author      Kasper Skaarhoj <kasperYYYY@typo3.com> 
     
    3637 * 
    3738 *  136: class t3lib_cs 
    38  *  503:     function parse_charset($charset) 
    39  *  522:     function get_locale_charset($locale) 
     39 *  488:     function parse_charset($charset) 
     40 *  507:     function get_locale_charset($locale) 
    4041 * 
    4142 *              SECTION: Charset Conversion functions 
    42  *  575:     function conv($str,$fromCS,$toCS,$useEntityForNoChar=0) 
    43  *  615:     function convArray(&$array,$fromCS,$toCS,$useEntityForNoChar=0) 
    44  *  632:     function utf8_encode($str,$charset) 
    45  *  678:     function utf8_decode($str,$charset,$useEntityForNoChar=0) 
    46  *  721:     function utf8_to_entities($str) 
    47  *  754:     function entities_to_utf8($str,$alsoStdHtmlEnt=0) 
    48  *  788:     function utf8_to_numberarray($str,$convEntities=0,$retChar=0) 
    49  *  838:     function UnumberToChar($cbyte) 
    50  *  883:     function utf8CharToUnumber($str,$hex=0) 
     43 *  560:     function conv($str,$fromCS,$toCS,$useEntityForNoChar=0) 
     44 *  600:     function convArray(&$array,$fromCS,$toCS,$useEntityForNoChar=0) 
     45 *  617:     function utf8_encode($str,$charset) 
     46 *  663:     function utf8_decode($str,$charset,$useEntityForNoChar=0) 
     47 *  706:     function utf8_to_entities($str) 
     48 *  739:     function entities_to_utf8($str,$alsoStdHtmlEnt=0) 
     49 *  773:     function utf8_to_numberarray($str,$convEntities=0,$retChar=0) 
     50 *  823:     function UnumberToChar($cbyte) 
     51 *  868:     function utf8CharToUnumber($str,$hex=0) 
    5152 * 
    5253 *              SECTION: Init functions 
    53  *  926:     function initCharset($charset) 
    54  *  988:     function initUnicodeData($mode=null) 
    55  * 1213:     function initCaseFolding($charset) 
    56  * 1275:     function initToASCII($charset) 
     54 *  911:     function initCharset($charset) 
     55 *  973:     function initUnicodeData($mode=null) 
     56 * 1198:     function initCaseFolding($charset) 
     57 * 1260:     function initToASCII($charset) 
    5758 * 
    5859 *              SECTION: String operation functions 
    59  * 1346:     function substr($charset,$string,$start,$len=null) 
     60 * 1331:     function substr($charset,$string,$start,$len=null) 
    6061 * 1384:     function strlen($charset,$string) 
    61  * 1412:     function crop($charset,$string,$len,$crop='') 
    62  * 1465:     function strtrunc($charset,$string,$len) 
    63  * 1499:     function conv_case($charset,$string,$case) 
    64  * 1525:     function specCharsToASCII($charset,$string) 
     62 * 1414:     function crop($charset,$string,$len,$crop='') 
     63 * 1467:     function strtrunc($charset,$string,$len) 
     64 * 1501:     function conv_case($charset,$string,$case) 
     65 * 1527:     function specCharsToASCII($charset,$string) 
    6566 * 
    6667 *              SECTION: Internal string operation functions 
    67  * 1565:     function sb_char_mapping($str,$charset,$mode,$opt='') 
     68 * 1567:     function sb_char_mapping($str,$charset,$mode,$opt='') 
    6869 * 
    6970 *              SECTION: Internal UTF-8 string operation functions 
    70  * 1620:     function utf8_substr($str,$start,$len=null) 
    71  * 1653:     function utf8_strlen($str) 
    72  * 1674:     function utf8_strtrunc($str,$len) 
    73  * 1696:     function utf8_strpos($haystack,$needle,$offset=0) 
    74  * 1719:     function utf8_strrpos($haystack,$needle) 
    75  * 1739:     function utf8_char2byte_pos($str,$pos) 
    76  * 1780:     function utf8_byte2char_pos($str,$pos) 
    77  * 1803:     function utf8_char_mapping($str,$mode,$opt='') 
     71 * 1622:     function utf8_substr($str,$start,$len=null) 
     72 * 1655:     function utf8_strlen($str) 
     73 * 1676:     function utf8_strtrunc($str,$len) 
     74 * 1698:     function utf8_strpos($haystack,$needle,$offset=0) 
     75 * 1723:     function utf8_strrpos($haystack,$needle) 
     76 * 1745:     function utf8_char2byte_pos($str,$pos) 
     77 * 1786:     function utf8_byte2char_pos($str,$pos) 
     78 * 1809:     function utf8_char_mapping($str,$mode,$opt='') 
    7879 * 
    7980 *              SECTION: Internal EUC string operation functions 
    80  * 1879:     function euc_strtrunc($str,$len,$charset) 
    81  * 1908:     function euc_substr($str,$start,$charset,$len=null) 
    82  * 1933:     function euc_strlen($str,$charset) 
    83  * 1960:     function euc_char2byte_pos($str,$pos,$charset) 
    84  * 2001:     function euc_char_mapping($str,$charset,$mode,$opt='') 
     81 * 1885:     function euc_strtrunc($str,$len,$charset) 
     82 * 1914:     function euc_substr($str,$start,$charset,$len=null) 
     83 * 1939:     function euc_strlen($str,$charset) 
     84 * 1966:     function euc_char2byte_pos($str,$pos,$charset) 
     85 * 2007:     function euc_char_mapping($str,$charset,$mode,$opt='') 
    8586 * 
    8687 * TOTAL FUNCTIONS: 35 
     
    245246        ); 
    246247 
    247                 // mapping of iso-639:2 language codes to language (family) names 
    248         var $lang_to_langfamily=array( 
     248                // mapping of iso-639:2 language codes to script names 
     249        var $lang_to_script=array( 
    249250                        // iso-639:2 language codes, see: 
    250251                        //  http://www.w3.org/WAI/ER/IG/ert/iso639.htm 
     252                        //  http://www.loc.gov/standards/iso639-2/langcodes.html 
    251253                        //  http://www.unicode.org/onlinedat/languages.html 
    252254                'ar' => 'arabic', 
    253                 'bg' => 'cyrillic', 
    254                 'cs' => 'east_european', 
    255                 'da' => 'west_european', 
    256                 'de' => 'west_european', 
    257                 'es' => 'west_european', 
     255                'bg' => 'cyrillic',             // Bulgarian 
     256                'bs' => 'east_european',        // Bosnian 
     257                'cs' => 'east_european',        // Czech 
     258                'da' => 'west_european',        // Danish 
     259                'de' => 'west_european',        // German 
     260                'es' => 'west_european',        // Spanish 
    258261                'et' => 'estonian', 
    259                 'eu' => 'west_european', 
    260                 'fi' => 'west_european', 
    261                 'fr' => 'west_european', 
     262                'eo' => 'unicode',              // Esperanto 
     263                'eu' => 'west_european',        // Basque 
     264                'fa' => 'arabic',       // Persian 
     265                'fi' => 'west_european',        // Finish 
     266                'fo' => 'west_european',        // Faroese 
     267                'fr' => 'west_european',        // French 
    262268                'gr' => 'greek', 
    263                 'hr' => 'east_european', 
    264                 'hu' => 'east_european', 
    265                 'iw' => 'hebrew', 
    266                 'is' => 'west_european', 
    267                 'it' => 'west_european', 
     269                'he' => 'hebrew',               // Hebrew (since 1998) 
     270                'hi' => 'unicode',              // Hindi 
     271                'hr' => 'east_european',        // Croatian 
     272                'hu' => 'east_european',        // Hungarian 
     273                'iw' => 'hebrew',               // Hebrew (til 1998) 
     274                'is' => 'west_european',        // Icelandic 
     275                'it' => 'west_european',        // Italian 
    268276                'ja' => 'japanese', 
    269                 'kl' => 'west_european', 
     277                'kl' => 'west_european',       // Greenlandic 
    270278                'ko' => 'korean', 
    271279                'lt' => 'lithuanian', 
    272                 'lv' => 'west_european', // Latvian/Lettish 
    273                 'nl' => 'west_european', 
    274                 'no' => 'west_european', 
    275                 'pl' => 'east_european', 
    276                 'pt' => 'west_european', 
    277                 'ro' => 'east_european', 
    278                 'ru' => 'cyrillic', 
    279                 'sk' => 'east_european', 
    280                 'sl' => 'east_european', 
    281                 'sv' => 'west_european', 
     280                'lv' => 'west_european',        // Latvian/Lettish 
     281                'nl' => 'west_european',        // Dutch 
     282                'no' => 'west_european',        // Norwegian 
     283                'pl' => 'east_european',        // Polish 
     284                'pt' => 'west_european',        // Portuguese 
     285                'ro' => 'east_european',        // Romanian 
     286                'ru' => 'cyrillic',             // Russian 
     287                'sk' => 'east_european',        // Slovak 
     288                'sl' => 'east_european',        // Slovenian 
     289                'sr' => 'cyrillic',             // Serbian 
     290                'sv' => 'west_european',        // Swedish 
    282291                'th' => 'thai', 
    283                 'uk' => 'cyrillic', 
     292                'uk' => 'cyrillic',            // Ukranian 
    284293                'vi' => 'vietnamese', 
    285294                'zh' => 'chinese', 
    286295                        // MS language codes, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_language_strings.asp 
     296                        // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceinternational5/html/wce50conLanguageIdentifiersandLocales.asp 
     297                'ara' => 'arabic', 
     298                'bgr' => 'cyrillic',            // Bulgarian 
     299                'cat' => 'west_european',       // Catalan 
    287300                'chs' => 'simpl_chinese', 
    288301                'cht' => 'trad_chinese', 
    289                 'csy' => 'east_european', 
    290                 'dan' => 'west_european', 
    291                 'deu' => 'west_european', 
    292                 'dea' => 'west_european', 
    293                 'des' => 'west_european', 
    294                 'ena' => 'west_european', 
    295                 'enc' => 'west_european', 
    296                 'eng' => 'west_european', 
    297                 'enz' => 'west_european', 
    298                 'enu' => 'west_european', 
    299                 'nld' => 'west_european', 
    300                 'nlb' => 'west_european', 
    301                 'fin' => 'west_european', 
    302                 'fra' => 'west_european', 
    303                 'frb' => 'west_european', 
    304                 'frc' => 'west_european', 
    305                 'frs' => 'west_european', 
     302                'csy' => 'east_european',       // Czech 
     303                'dan' => 'west_european',       // Danisch 
     304                'deu' => 'west_european',       // German 
     305                'dea' => 'west_european',       // German (Austrian) 
     306                'des' => 'west_european',       // German (Swiss) 
     307                'ena' => 'west_european',       // English (Australian) 
     308                'enc' => 'west_european',       // English (Canadian) 
     309                'eng' => 'west_european',       // English 
     310                'enz' => 'west_european',       // English (New Zealand) 
     311                'enu' => 'west_european',       // English (United States) 
     312                'euq' => 'west_european',       // Basque 
     313                'fos' => 'west_european',       // Faroese 
     314                'far' => 'arabic',      // Persian 
     315                'fin' => 'west_european',       // Finish 
     316                'fra' => 'west_european',       // French 
     317                'frb' => 'west_european',       // French (Belgian) 
     318                'frc' => 'west_european',       // French (Canadian) 
     319                'frs' => 'west_european',       // French (Swiss) 
    306320                'ell' => 'greek', 
    307                 'hun' => 'east_european', 
    308                 'isl' => 'west_euorpean', 
    309                 'ita' => 'west_european', 
    310                 'its' => 'west_european', 
     321                'heb' => 'hebrew', 
     322                'hin' => 'unicode',     // Hindi 
     323                'hun' => 'east_european',       // Hungarian 
     324                'isl' => 'west_euorpean',       // Icelandic 
     325                'ita' => 'west_european',       // Italian 
     326                'its' => 'west_european',       // Italian (Swiss) 
    311327                'jpn' => 'japanese', 
    312328                'kor' => 'korean', 
    313                 'nor' => 'west_european', 
    314                 'non' => 'west_european', 
    315                 'plk' => 'east_european', 
    316                 'ptg' => 'west_european', 
    317                 'ptb' => 'west_european', 
    318                 'rus' => 'east_european', 
    319                 'sky' => 'east_european', 
    320                 'esp' => 'west_european', 
    321                 'esm' => 'west_european', 
    322                 'esn' => 'west_european', 
    323                 'sve' => 'west_european', 
     329                'lth' => 'lithuanian', 
     330                'lvi' => 'west_european',       // Latvian/Lettish 
     331                'msl' => 'west_european',       // Malay 
     332                'nlb' => 'west_european',       // Dutch (Belgian) 
     333                'nld' => 'west_european',       // Dutch 
     334                'nor' => 'west_european',       // Norwegian (bokmal) 
     335                'non' => 'west_european',       // Norwegian (nynorsk) 
     336                'plk' => 'east_european',       // Polish 
     337                'ptg' => 'west_european',       // Portuguese 
     338                'ptb' => 'west_european',       // Portuguese (Brazil) 
     339                'rom' => 'east_european',       // Romanian 
     340                'rus' => 'cyrillic',            // Russian 
     341                'slv' => 'east_european',       // Slovenian 
     342                'sky' => 'east_european',       // Slovak 
     343                'srl' => 'east_european',       // Serbian (Latin) 
     344                'srb' => 'cyrillic',            // Serbian (Cyrillic) 
     345                'esp' => 'west_european',       // Spanish (trad. sort) 
     346                'esm' => 'west_european',       // Spanish (Mexican) 
     347                'esn' => 'west_european',       // Spanish (internat. sort) 
     348                'sve' => 'west_european',       // Swedish 
     349                'tha' => 'thai', 
    324350                'trk' => 'turkish', 
     351                'ukr' => 'cyrillic',    // Ukrainian 
    325352                        // English language names 
     353                'arabic' => 'arabic', 
     354                'basque' => 'west_european', 
     355                'bosnian' => 'east_european', 
    326356                'bulgarian' => 'east_european', 
    327357                'catalan' => 'west_european', 
     
    331361                'dutch' => 'west_european', 
    332362                'english' => 'west_european', 
     363                'esperanto' => 'unicode', 
     364                'estonian' => 'estonian', 
     365                'faroese' => 'west_european', 
     366                'farsi' => 'arabic', 
    333367                'finnish' => 'west_european', 
    334368                'french' => 'west_european', 
    335369                'galician' => 'west_european', 
    336370                'german' => 'west_european', 
     371                'greek' => 'greek', 
     372                'greenlandic' => 'west_european', 
     373                'hebrew' => 'hebrew', 
     374                'hindi' => 'unicode', 
    337375                'hungarian' => 'east_european', 
    338376                'icelandic' => 'west_european', 
     
    340378                'latvian' => 'west_european', 
    341379                'lettish' => 'west_european', 
     380                'lithuanian' => 'lithuanian', 
     381                'malay' => 'west_european', 
    342382                'norwegian' => 'west_european', 
     383                'persian' => 'arabic', 
    343384                'polish' => 'east_european', 
    344385                'portuguese' => 'west_european', 
    345386                'russian' => 'cyrillic', 
    346387                'romanian' => 'east_european', 
     388                'serbian' => 'cyrillic', 
    347389                'slovak' => 'east_european', 
    348390                'slovenian' => 'east_european', 
    349391                'spanish' => 'west_european', 
    350392                'svedish' => 'west_european', 
    351                 'turkish' => 'east_european', 
     393                'that' => 'thai', 
     394                'turkish' => 'turkish', 
    352395                'ukrainian' => 'cyrillic', 
    353396        ); 
    354397 
    355398                // mapping of language (family) names to charsets on Unix 
    356         var $lang_to_charset_unix=array( 
     399        var $script_to_charset_unix=array( 
    357400                'west_european' => 'iso-8859-1', 
    358401                'estonian' => 'iso-8859-1', 
     
    372415                'trad_chinese' => 'big5', 
    373416                'vietnamese' => '', 
     417                'unicode' => 'utf-8', 
    374418        ); 
    375419 
    376420                // mapping of language (family) names to charsets on Windows 
    377         var $lang_to_charset_windows=array( 
     421        var $script_to_charset_windows=array( 
    378422                'east_european' => 'windows-1250', 
    379423                'cyrillic' => 'windows-1251', 
     
    400444                'ja_jp.ujis' => 'euc-jp', 
    401445                'korean.euc' => 'euc-kr', 
     446                'sr@Latn' => 'iso-8859-2', 
    402447                'zh_cn' => 'gb2312', 
    403448                'zh_hk' => 'big5', 
     
    450495                'my' => '', 
    451496                'hi' => 'utf-8', 
     497                'fo' => 'utf-8', 
     498                'fa' => 'utf-8', 
     499                'sr' => 'utf-8' 
    452500        ); 
    453501 
    454502                // TYPO3 specific: Array with the iso names used for each system language in TYPO3: 
    455                 // Empty values means sames as Typo3 
     503                // Missing keys means: same as Typo3 
    456504        var $isoArray = array( 
     505                'ba' => 'bs', 
     506                'br' => 'pt_BR', 
     507                'ch' => 'zh_CN', 
     508                'cz' => 'cs', 
    457509                'dk' => 'da', 
    458                 'de' => '', 
    459                 'no' => '', 
    460                 'it' => '', 
    461                 'fr' => '', 
    462                 'es' => '', 
    463                 'nl' => '', 
    464                 'cz' => 'cs', 
    465                 'pl' => '', 
    466510                'si' => 'sl', 
    467                 'fi' => '', 
    468                 'tr' => '', 
    469511                'se' => 'sv', 
    470                 'pt' => '', 
    471                 'ru' => '', 
    472                 'ro' => '', 
    473                 'ch' => 'zh_CN', 
    474                 'sk' => '', 
    475                 'lt' => '', 
    476                 'is' => '', 
    477                 'hr' => '', 
    478                 'hu' => '', 
    479                 'gl' => '', // Greenlandic 
    480                 'th' => '', 
     512                'gl' => 'kl', 
    481513                'gr' => 'el', 
    482514                'hk' => 'zh_HK', 
    483                 'eu' => '', 
    484                 'bg' => '', 
    485                 'br' => 'pt_BR', 
    486                 'et' => '', 
    487                 'ar' => '', 
    488                 'he' => 'iw', 
     515                'kr' => 'ko', 
    489516                'ua' => 'uk', 
    490517                'jp' => 'ja', 
    491                 'lv' => '', 
    492518                'vn' => 'vi', 
    493                 'ca' => '', 
    494                 'ba' => '', // Bosnian 
    495                 'kr' => '', 
    496519        ); 
    497520 
     
    540563                        // get language 
    541564                list($language,$country) = explode('_',$locale); 
    542                 if (isset($this->lang_to_langfamily[$language]))       $language = $this->lang_to_langfamily[$language]; 
     565                if (isset($this->lang_to_script[$language]))   $script = $this->lang_to_script[$language]; 
    543566 
    544567                if (TYPO3_OS == 'WIN')  { 
    545                         $cs = $this->lang_to_charset_windows[$language]
     568                        $cs = $this->script_to_charset_windows[$script] ? $this->script_to_charset_windows[$script] : 'window-1252'
    546569                } else { 
    547                         $cs = $this->lang_to_charset_unix[$language]
    548                 } 
    549  
    550                 return $cs ? $cs : 'iso-8859-1'
     570                        $cs = $this->script_to_charset_unix[$script] ? $this->script_to_charset_unix[$script] : 'iso-8859-1'
     571                } 
     572 
     573                return $cs
    551574        } 
    552575 
     
    587610 
    588611                        case 'iconv': 
    589                                 $conv_str = iconv($fromCS,$toCS.'//TRANSLIT',$str); 
     612                                $conv_str = iconv($fromCS,$toCS.'//IGNORE',$str); 
    590613                                if (false !== $conv_str)        return $conv_str; 
    591614                                break; 
     
    646669                                if (isset($this->twoByteSets[$charset]))        {       // If the charset has two bytes per char 
    647670                                        $ord2 = ord($str{$a+1}); 
    648                                         $ord = $ord<<8 & $ord2; // assume big endian 
     671                                        $ord = $ord<<8 | $ord2; // assume big endian 
    649672 
    650673                                        if (isset($this->parsedCharsets[$charset]['local'][$ord]))      {       // If the local char-number was found in parsed conv. table then we use that, otherwise 127 (no char?) 
     
    15191542                if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] == 'mbstring' && (float)phpversion() >= 4.3)   { 
    15201543                        if ($case == 'toLower') { 
    1521                                 return mb_strtolower($string,$charset); 
     1544                                $string = mb_strtolower($string,$charset); 
    15221545                        } else { 
    1523                                 return mb_strtoupper($string,$charset); 
     1546                                $string = mb_strtoupper($string,$charset); 
    15241547                        } 
    15251548                } elseif ($charset == 'utf-8')  { 
    1526                         return $this->utf8_char_mapping($string,'case',$case); 
     1549                        $string = $this->utf8_char_mapping($string,'case',$case); 
    15271550                } elseif (isset($this->eucBasedSets[$charset])) { 
    1528                         return $this->euc_char_mapping($string,$charset,'case',$case); 
     1551                        $string = $this->euc_char_mapping($string,$charset,'case',$case); 
    15291552                } else { 
    15301553                                // treat everything else as single-byte encoding 
    1531                         return $this->sb_char_mapping($string,$charset,'case',$case); 
     1554                        $string = $this->sb_char_mapping($string,$charset,'case',$case); 
    15321555                } 
    15331556 
     
    15441567        function specCharsToASCII($charset,$string)     { 
    15451568                if ($charset == 'utf-8')        { 
    1546                         return $this->utf8_char_mapping($string,'ascii'); 
     1569                        $string = $this->utf8_char_mapping($string,'ascii'); 
    15471570                } elseif (isset($this->eucBasedSets[$charset])) { 
    1548                         return $this->euc_char_mapping($string,$charset,'ascii'); 
     1571                        $string = $this->euc_char_mapping($string,$charset,'ascii'); 
    15491572                } else { 
    15501573                                // treat everything else as single-byte encoding 
    1551                         return $this->sb_char_mapping($string,$charset,'ascii'); 
     1574                        $string = $this->sb_char_mapping($string,$charset,'ascii'); 
    15521575                } 
    15531576 
     
    17421765                        return mb_strrpos($haystack,$needle,'utf-8'); 
    17431766                } elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] == 'iconv')      { 
    1744                         return iconv_strrpos($haystack,$needle,$offset,'utf-8'); 
     1767                        return iconv_strrpos($haystack,$needle,'utf-8'); 
    17451768                } 
    17461769 
  • releases/0.9/lib/typo3/class.t3lib_div.php

    r269 r1441  
    2828 * Contains the reknown class "t3lib_div" with general purpose functions 
    2929 * 
    30  * $Id: class.t3lib_div.php,v 1.93 2005/12/26 23:59:37 kurfuerst Exp $ 
     30 * $Id: class.t3lib_div.php,v 1.2 2005/10/17 15:48:29 stronk7 Exp $ 
    3131 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj 
    3232 * XHTML compliant 
     
    467467         * Returns a new string of max. $chars length. 
    468468         * If the string is longer, it will be truncated and appended with '...'. 
    469          * DEPRECATED. Works ONLY for single-byte charsets! USE t3lib_div::fixed_lgd_cs() instead 
     469         * DEPRECIATED. Works ONLY for single-byte charsets! USE t3lib_div::fixed_lgd_cs() instead 
    470470         * Usage: 39 
    471471         * 
    472          * @param       string          string to truncate 
    473          * @param       integer         must be an integer with an absolute value of at least 4. if negative the string is cropped from the right end. 
     472         * @param       string          $string        string to truncate 
     473         * @param       integer         $chars         must be an integer with an absolute value of at least 4. if negative the string is cropped from the right end. 
    474474         * @param       string          String to append to the output if it is truncated, default is '...' 
    475475         * @return      string          new string 
     
    493493         * If the string is longer, it will be truncated and prepended with '...'. 
    494494         * This works like fixed_lgd, but is truncated in the start of the string instead of the end 
    495          * DEPRECATED. Use either fixed_lgd() or fixed_lgd_cs() (with negative input value for $chars) 
     495         * DEPRECIATED. Use either fixed_lgd() or fixed_lgd_cs() (with negative input value for $chars) 
    496496         * Usage: 6 
    497497         * 
    498          * @param       string          string to truncate 
    499          * @param       integer         must be an integer of at least 4 
     498         * @param       string          $string        string to truncate 
     499         * @param       integer         $chars         must be an integer of at least 4 
    500500         * @return      string          new string 
    501501         * @see fixed_lgd() 
     
    510510         * Usage: 75 
    511511         * 
    512          * @param       string          string to truncate 
    513          * @param       integer         must be an integer with an absolute value of at least 4. if negative the string is cropped from the right end. 
     512         * @param       string          $string        string to truncate 
     513         * @param       integer         $chars         must be an integer with an absolute value of at least 4. if negative the string is cropped from the right end. 
    514514         * @return      string          New string 
    515515         * @see fixed_lgd() 
     
    624624         * Match fully qualified domain name with list of strings with wildcard 
    625625         * 
    626          * @param       string          The current remote IP address for instance, typ. REMOTE_ADDR 
    627          * @param       string          A comma-list of domain names to match with. *-wildcard allowed but cannot be part of a string, so it must match the full host name (eg. myhost.*.com => correct, myhost.*domain.com => wrong) 
     626         * @param       string          $baseIP is the current remote IP address for instance, typ. REMOTE_ADDR 
     627         * @param       string          $list is a comma-list of domain names to match with. *-wildcard allowed but cannot be part of a string, so it must match the full host name (eg. myhost.*.com => correct, myhost.*domain.com => wrong) 
    628628         * @return      boolean         True if a domain name mask from $list matches $baseIP 
    629629         */ 
     
    666666         * Usage: 1 
    667667         * 
    668          * @param       string          element to remove 
    669          * @param       string          comma-separated list of items (string) 
     668         * @param       string          $element       element to remove 
     669         * @param       string          $list  comma-separated list of items (string) 
    670670         * @return      string          new comma-separated list of items 
    671671         */ 
     
    682682         * Ranges are limited to 1000 values per range. 
    683683         * 
    684          * @param       string          comma-separated list of integers with ranges (string) 
     684         * @param       string          $list  comma-separated list of integers with ranges (string) 
    685685         * @return      string          new comma-separated list of items 
    686686         * @author      Martin Kutschker <martin.kutschker@activesolution.at> 
     
    752752 
    753753        /** 
    754          * Returns true if the current TYPO3 version (or compatibility version) is compatible to the input version 
    755          * 
    756          * @param       string          Minimum version number required (format x.y.z) 
    757          * @return      boolean         true or false 
    758          */ 
    759         function compat_version($verNumberStr)  { 
    760                 global $TYPO3_CONF_VARS; 
    761                 $currVersionStr = $TYPO3_CONF_VARS['SYS']['compat_version']?$TYPO3_CONF_VARS['SYS']['compat_version']:TYPO3_version; 
    762  
    763                 if (t3lib_div::int_from_ver($currVersionStr) < t3lib_div::int_from_ver($verNumberStr))  { 
    764                         return FALSE; 
    765                 } else { 
    766                         return TRUE; 
    767                 } 
    768         } 
    769  
    770         /** 
    771754         * Makes a positive integer hash out of the first 7 chars from the md5 hash of the input 
    772755         * Usage: 5 
     
    798781         * 
    799782         * @param       string          Accept multiple parameters wich can be comma-separated lists of values and arrays. 
    800          * @param       mixed           $secondParameter: Dummy field, which if set will show a warning! 
     783         * @param       mixed           $secondParameter: Dummy field, which is set will show a warning! 
    801784         * @return      string          Returns the list without any duplicates of values, space around values are trimmed 
    802785         */ 
     
    905888        /** 
    906889         * strtoupper which converts danish (and other characters) characters as well 
    907          * (DEPRECATED, use t3lib_cs::conv_case() instead or for HTML output, wrap your content in <span class="uppercase">...</span>) 
     890         * (DEPRECIATED, use t3lib_cs::conv_case() instead or for HTML output, wrap your content in <span class="uppercase">...</span>) 
    908891         * Usage: 0 
    909892         * 
     
    920903         * Change umlaut characters to plain ASCII with normally two character target 
    921904         * Only known characters will be converted, so don't expect a result for any character. 
    922          * (DEPRECATED: Works only for western europe single-byte charsets! Use t3lib_cs::specCharsToASCII() instead!) 
     905         * (DEPRECIATED: Works only for western europe single-byte charsets! Use t3lib_cs::specCharsToASCII() instead!) 
    923906         * 
    924907         * ä => ae, Ö => Oe 
     
    12101193         * Usage: 3 
    12111194         * 
    1212          * @param       array           one-dimensional array of items 
    1213          * @param       string          item to check for 
     1195         * @param       array           $in_array              one-dimensional array of items 
     1196         * @param       string          $item  item to check for 
    12141197         * @return      boolean         true if $item is in the one-dimensional array $in_array 
    12151198         * @internal 
     
    20932076 
    20942077                        // (Proxy support implemented by Arco <arco@appeltaart.mine.nu>) 
    2095                 if ((substr($url,0,7)=='http://') && ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse']=='1'))    { 
     2078                if((substr($url,0,7)=='http://') && ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse']=='1'))     { 
    20962079                        //external URL without error checking. 
    20972080                        $ch = curl_init(); 
     
    21142097                        curl_close ($ch); 
    21152098                        return $content; 
    2116                 } elseif (function_exists('file_get_contents')) { 
    2117                         return file_get_contents($url); 
    2118                 } elseif ($fd = fopen($url,'rb'))    { 
     2099                } elseif($fd = fopen($url,'rb'))    { 
    21192100                        while (!feof($fd))      { 
    2120                                 $content.=fread($fd, 4096); 
     2101                                $content.=fread($fd, 5000); 
    21212102                        } 
    21222103                        fclose($fd); 
    21232104                        return $content; 
    21242105                } 
    2125  
    2126                 return false; 
    21272106        } 
    21282107 
     
    21362115         */ 
    21372116        function writeFile($file,$content)      { 
    2138                 if (!@is_file($file))   { $changePermissions=true; } 
    2139  
    2140                 if ($fd = fopen($file,'wb'))    { 
    2141                         $res = fwrite($fd,$content); 
    2142                         fclose($fd ); 
    2143  
    2144                         if (!$res)      { 
    2145                                 return false; 
    2146                         } 
    2147                         if ($changePermissions) {       // Change the permissions only if the file has just been created 
    2148                                 t3lib_div::fixPermissions($file); 
    2149                         } 
     2117                if($fd = fopen($file,'wb'))     { 
     2118                        fwrite( $fd, $content); 
     2119                        fclose( $fd ); 
     2120 
     2121                        t3lib_div::fixPermissions($file);       // Change the permissions of the file 
    21502122 
    21512123                        return true; 
    21522124                } 
    2153  
    2154                 return false; 
    21552125        } 
    21562126 
     
    24992469         */ 
    25002470        function debug($var="",$brOrHeader=0)   { 
    2501                 if ($brOrHeader && !t3lib_div::testInt($brOrHeader))   
    2502                         echo '<table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;"><tr><td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">'.htmlspecialchars((string)$brOrHeader).'</td></tr><tr><td>'; 
    2503                 } elseif ($brOrHeader<0)       
     2471                if ($brOrHeader && !t3lib_div::testInt($brOrHeader))
     2472                        echo '<table border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;"><tr><td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">'.htmlspecialchars((string)$brOrHeader).'</td></tr><td>'; 
     2473                } elseif ($brOrHeader<0)
    25042474                        for($a=0;$a<abs(intval($brOrHeader));$a++){echo '<br />';} 
    25052475                } 
     
    25112481                        print_r($var); 
    25122482                        echo '</pre>|</b>'; 
    2513                 } elseif ((string)$var!='')   
     2483                } elseif ((string)$var!='')
    25142484                        echo '<b>|'.htmlspecialchars((string)$var).'|</b>'; 
    25152485                } else { 
     
    25172487                } 
    25182488 
    2519                 if ($brOrHeader && !t3lib_div::testInt($brOrHeader))   
     2489                if ($brOrHeader && !t3lib_div::testInt($brOrHeader))
    25202490                        echo '</td></tr></table>'; 
    2521                 } elseif ($brOrHeader>0)       
     2491                } elseif ($brOrHeader>0)
    25222492                        for($a=0;$a<intval($brOrHeader);$a++){echo '<br />';} 
    25232493                } 
    25242494        } 
    25252495 
    2526         /** 
    2527          * 
    2528          */ 
    2529         function debug_trail()  { 
    2530                 if (function_exists('debug_backtrace')) { 
    2531                         $trail = debug_backtrace(); 
    2532                         $trail = array_reverse($trail); 
    2533                         array_pop($trail); 
    2534  
    2535                         $path = array(); 
    2536                         foreach($trail as $dat) { 
    2537                                 $path[] = $dat['class'].$dat['type'].$dat['function']; 
    2538                         } 
    2539  
    2540                         return implode(' // ',$path); 
    2541                 } else return 'N/A'; 
    2542         } 
    2543  
    2544         function debugRows($rows,$header)       { 
    2545                 if (is_array($rows))    { 
    2546                         reset($rows); 
    2547                         $firstEl = current($rows); 
    2548                         if (is_array($firstEl)) { 
    2549                                 $headerColumns = array_keys($firstEl); 
    2550                                 $tRows = array(); 
    2551  
    2552                                         // Header: 
    2553                                 $tRows[] = '<tr><td colspan="'.count($headerColumns).'" style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;"><strong>'.htmlspecialchars($header).'</strong></td></tr>'; 
    2554                                 $tCells = array(); 
    2555                                 foreach($headerColumns as $key) { 
    2556                                         $tCells[] = ' 
    2557                                                         <td><font face="Verdana,Arial" size="1"><strong>'.htmlspecialchars($key).'</strong></font></td>'; 
    2558                                 } 
    2559                                 $tRows[] = ' 
    2560                                                 <tr>'.implode('',$tCells).' 
    2561                                                 </tr>'; 
    2562  
    2563                                         // Rows: 
    2564                                 foreach($rows as $singleRow)    { 
    2565                                         $tCells = array(); 
    2566                                         foreach($headerColumns as $key) { 
    2567                                                 $tCells[] = ' 
    2568                                                         <td><font face="Verdana,Arial" size="1">'.htmlspecialchars($singleRow[$key]).'</font></td>'; 
    2569                                         } 
    2570                                         $tRows[] = ' 
    2571                                                 <tr>'.implode('',$tCells).' 
    2572                                                 </tr>'; 
    2573                                 } 
    2574  
    2575                                 $table = ' 
    2576                                         <table border="1" cellpadding="1" cellspacing="0" bgcolor="white">'.implode('',$tRows).' 
    2577                                         </table>';