1: <?php
2: /**
3: * This file contains some little function to retrieving current encoding.
4: *
5: * @package Core
6: * @subpackage Backend
7: * @version SVN Revision $Rev:$
8: *
9: * @author Holger Librenz
10: * @copyright four for business AG <www.4fb.de>
11: * @license http://www.contenido.org/license/LIZENZ.txt
12: * @link http://www.4fb.de
13: * @link http://www.contenido.org
14: */
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: /**
19: * Returns encoding for language with ID $iLang (global $lang in CONTENIDO
20: * style).
21: * The parameter $db has to be an instance of cDb (global $db in con)
22: * and
23: * $cfg is the equivalent to global $cfg array in CONTENIDO.
24: * If no encoding is found or any parameter is not valid, the function will
25: * return
26: * false, otherwise the encoding as string like it is stored in database.
27: *
28: * @param cDb $db not used any more!
29: * @param int $lang
30: * @return string
31: */
32: function getEncodingByLanguage($db, $lang) {
33: // check parameters and use cRegistry values if they are invalid
34: if (!is_numeric($lang)) {
35: $lang = cRegistry::getLanguageId();
36: }
37:
38: $lang = cSecurity::toInteger($lang);
39: if ($lang > 0) {
40: // load the language object with the given ID and return the encoding
41: $apiLanguage = new cApiLanguage($lang);
42: if ($apiLanguage->isLoaded()) {
43: return trim($apiLanguage->get('encoding'));
44: }
45: }
46:
47: return false;
48: }
49:
50: /**
51: * Special version of htmlentites for iso-8859-2
52: * Returns transformed string
53: *
54: * @param string $input
55: * @return string
56: */
57: function htmlentities_iso88592($input = '') {
58: $arrEntities_pl = array(
59: 'ê',
60: 'ó',
61: '±',
62: '¶',
63: '³',
64: '¿',
65: '¼',
66: 'æ',
67: 'ñ',
68: 'Ê',
69: 'Ó',
70: '¡',
71: '¦',
72: '£',
73: '¬',
74: '¯',
75: 'Æ',
76: 'Ñ'
77: );
78: $arrEntities = conGetHtmlTranslationTable(HTML_ENTITIES);
79: $arrEntities = array_diff($arrEntities, $arrEntities_pl);
80:
81: return strtr($input, $arrEntities);
82: }
83: