1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class Horde_Registry_Nlsconfig
16: {
17: 18: 19: 20: 21:
22: protected $_config;
23:
24: 25:
26: public function __get($name)
27: {
28:
29: $cached = array(
30: 'curr_charset',
31: 'curr_default',
32: 'curr_emails',
33: 'curr_multibyte',
34: 'curr_rtl'
35: );
36:
37: if (in_array($name, $cached) &&
38: $GLOBALS['session']->exists('horde', 'nls/' . $name)) {
39: return $GLOBALS['session']->get('horde', 'nls/' . $name);
40: }
41:
42: if (!isset($this->_config)) {
43: $this->_config = Horde::loadConfiguration('nls.php', 'horde_nls_config', 'horde');
44: }
45:
46: switch ($name) {
47: case 'aliases':
48: case 'charsets':
49: case 'encodings':
50: case 'emails':
51: case 'languages':
52: case 'multibyte':
53: case 'rtl':
54: case 'spelling':
55: $ret = isset($this->_config[$name])
56: ? $this->_config[$name]
57: : array();
58: break;
59:
60: case 'charsets_sort':
61: $ret = $this->charsets;
62: natcasesort($ret);
63: break;
64:
65: case 'curr_charset':
66:
67: $ret = isset($this->_config['charsets'][$GLOBALS['language']])
68: ? $this->_config['charsets'][$GLOBALS['language']]
69: : null;
70: break;
71:
72: case 'curr_default':
73:
74: $ret = isset($this->_config['defaults']['language'])
75: ? $this->_config['defaults']['language']
76: : null;
77: break;
78:
79: case 'curr_emails':
80:
81: $ret = isset($this->_config['emails'][$GLOBALS['language']])
82: ? $this->_config['emails'][$GLOBALS['language']]
83: : null;
84: break;
85:
86: case 'curr_multibyte':
87:
88: $ret = isset($this->_config['multibyte'][$GLOBALS['registry']->getLanguageCharset()]);
89: break;
90:
91: case 'curr_rtl':
92:
93: $ret = isset($this->_config['rtl'][$GLOBALS['language']]);
94: break;
95:
96: case 'encodings_sort':
97: $ret = $this->encodings;
98: asort($ret);
99: break;
100:
101: default:
102: $ret = null;
103: break;
104: }
105:
106: if (in_array($name, $cached)) {
107: $GLOBALS['session']->set('horde', 'nls/' . $name, $ret);
108: }
109:
110: return $ret;
111: }
112:
113: 114: 115: 116: 117: 118: 119:
120: public function validLang($lang)
121: {
122: if (!$GLOBALS['session']->exists('horde', 'nls/valid_' . $lang)) {
123: $GLOBALS['session']->set('horde', 'nls/valid_' . $lang, isset($this->languages[$lang]));
124: }
125:
126: return $GLOBALS['session']->get('horde', 'nls/valid_' . $lang);
127: }
128:
129: }
130: