  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: language.php 383 2006-01-09 16:35:46Z hpdl $ |
| |
| 3 | + | $Id: language.php 410 2006-01-26 09:17:09Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
14 | 14 | | |
| |
15 | 15 | | /* Private variables */ |
| |
16 | 16 | | var $_code, |
  |
17 | | - | $_languages = array(); |
| |
| 17 | + | $_languages = array(), |
| |
| 18 | + | $_definitions = array(); |
|
18 | 19 | | |
| |
19 | 20 | | /* Class constructor */ |
| |
20 | 21 | | |
| |
|
|
 |
… |
|
29 | 30 | | while ($Qlanguages->next()) { |
| |
30 | 31 | | $this->_languages[$Qlanguages->value('code')] = array('id' => $Qlanguages->valueInt('languages_id'), |
| |
31 | 32 | | 'name' => $Qlanguages->value('name'), |
  |
| 33 | + | 'locale' => $Qlanguages->value('locale'), |
| |
| 34 | + | 'charset' => $Qlanguages->value('charset'), |
| |
| 35 | + | 'date_format_short' => $Qlanguages->value('date_format_short'), |
| |
| 36 | + | 'date_format_long' => $Qlanguages->value('date_format_long'), |
| |
| 37 | + | 'time_format' => $Qlanguages->value('time_format'), |
| |
| 38 | + | 'text_direction' => $Qlanguages->value('text_direction'), |
|
32 | 39 | | 'image' => $Qlanguages->value('image'), |
  |
33 | | - | 'directory' => $Qlanguages->value('directory')); |
| |
| 40 | + | 'currencies_id' => $Qlanguages->valueInt('currencies_id'), |
| |
| 41 | + | 'numeric_separator_decimal' => $Qlanguages->value('numeric_separator_decimal'), |
| |
| 42 | + | 'numeric_separator_thousands' => $Qlanguages->value('numeric_separator_thousands')); |
|
34 | 43 | | } |
| |
35 | 44 | | |
| |
36 | 45 | | $Qlanguages->freeResult(); |
| |
|
|
 |
… |
|
40 | 49 | | |
| |
41 | 50 | | /* Public methods */ |
| |
42 | 51 | | |
  |
| 52 | + | function load($key) { |
| |
| 53 | + | global $osC_Database; |
| |
| 54 | + | |
| |
| 55 | + | $Qdef = $osC_Database->query('select * from :table_languages_definitions where languages_id = :languages_id and content_group = :content_group'); |
| |
| 56 | + | $Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); |
| |
| 57 | + | $Qdef->bindInt(':languages_id', $this->getID()); |
| |
| 58 | + | $Qdef->bindValue(':content_group', $key); |
| |
| 59 | + | $Qdef->setCache('languages-' . $this->_code . '-' . $key); |
| |
| 60 | + | $Qdef->execute(); |
| |
| 61 | + | |
| |
| 62 | + | while ($Qdef->next()) { |
| |
| 63 | + | $this->_definitions[$Qdef->value('definition_key')] = $Qdef->value('definition_value'); |
| |
| 64 | + | } |
| |
| 65 | + | |
| |
| 66 | + | $Qdef->freeResult(); |
| |
| 67 | + | } |
| |
| 68 | + | |
| |
| 69 | + | function get($key) { |
| |
| 70 | + | if (isset($this->_definitions[$key])) { |
| |
| 71 | + | return $this->_definitions[$key]; |
| |
| 72 | + | } |
| |
| 73 | + | |
| |
| 74 | + | return $key; |
| |
| 75 | + | } |
| |
| 76 | + | |
|
43 | 77 | | function set($code = '') { |
| |
44 | 78 | | $this->_code = $code; |
| |
45 | 79 | | |
| |
|
|
 |
… |
|
128 | 162 | | return $this->_languages; |
| |
129 | 163 | | } |
| |
130 | 164 | | |
  |
| 165 | + | function getData($key, $language = '') { |
| |
| 166 | + | if (empty($language)) { |
| |
| 167 | + | $language = $this->_code; |
| |
| 168 | + | } |
| |
| 169 | + | |
| |
| 170 | + | return $this->_languages[$language][$key]; |
| |
| 171 | + | } |
| |
| 172 | + | |
| |
| 173 | + | function getCodeFromID($id) { |
| |
| 174 | + | foreach ($this->_languages as $code => $lang) { |
| |
| 175 | + | if ($lang['id'] == $id) { |
| |
| 176 | + | return $code; |
| |
| 177 | + | } |
| |
| 178 | + | } |
| |
| 179 | + | } |
| |
| 180 | + | |
|
131 | 181 | | function getID() { |
| |
132 | 182 | | return $this->_languages[$this->_code]['id']; |
| |
133 | 183 | | } |
| |
|
|
 |
… |
|
140 | 190 | | return $this->_code; |
| |
141 | 191 | | } |
| |
142 | 192 | | |
  |
| 193 | + | function getLocale() { |
| |
| 194 | + | return $this->_languages[$this->_code]['locale']; |
| |
| 195 | + | } |
| |
| 196 | + | |
| |
| 197 | + | function getCharacterSet() { |
| |
| 198 | + | return $this->_languages[$this->_code]['charset']; |
| |
| 199 | + | } |
| |
| 200 | + | |
| |
| 201 | + | function getDateFormatShort() { |
| |
| 202 | + | return $this->_languages[$this->_code]['date_format_short']; |
| |
| 203 | + | } |
| |
| 204 | + | |
| |
| 205 | + | function getDateFormatLong() { |
| |
| 206 | + | return $this->_languages[$this->_code]['date_format_long']; |
| |
| 207 | + | } |
| |
| 208 | + | |
| |
| 209 | + | function getTimeFormat() { |
| |
| 210 | + | return $this->_languages[$this->_code]['time_format']; |
| |
| 211 | + | } |
| |
| 212 | + | |
| |
| 213 | + | function getTextDirection() { |
| |
| 214 | + | return $this->_languages[$this->_code]['text_direction']; |
| |
| 215 | + | } |
| |
| 216 | + | |
|
143 | 217 | | function getImage() { |
| |
144 | 218 | | return $this->_languages[$this->_code]['image']; |
| |
145 | 219 | | } |
| |
146 | 220 | | |
  |
147 | | - | function getDirectory() { |
| |
148 | | - | return $this->_languages[$this->_code]['directory']; |
| |
| 221 | + | function getCurrencyID() { |
| |
| 222 | + | return $this->_languages[$this->_code]['currencies_id']; |
|
149 | 223 | | } |
| |
150 | 224 | | |
  |
151 | | - | function load($definition = false) { |
| |
152 | | - | if (is_string($definition)) { |
| |
153 | | - | include('includes/languages/' . $this->getDirectory() . '/' . $definition); |
| |
154 | | - | } else { |
| |
155 | | - | include('includes/languages/' . $this->getDirectory() . '.php'); |
| |
156 | | - | } |
| |
| 225 | + | function getNumericDecimalSeparator() { |
| |
| 226 | + | return $this->_languages[$this->_code]['numeric_separator_decimal']; |
|
157 | 227 | | } |
  |
| 228 | + | |
| |
| 229 | + | function getNumericThousandsSeparator() { |
| |
| 230 | + | return $this->_languages[$this->_code]['numeric_separator_thousands']; |
| |
| 231 | + | } |
  |
158 | 232 | | } |
| |
159 | 233 | | ?> |