Quick Search:

View

Revision:

Diff

Diff from 1261 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/frank/osc-tickets/install/includes/classes/language.php

Annotated File View

hpdl
266
1 <?php
2 /*
3   $Id: language.php 199 2005-09-22 17:56:13 +0200 (Do, 22 Sep 2005) hpdl $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
383
8   Copyright (c) 2006 osCommerce
hpdl
266
9
10   Released under the GNU General Public License
11 */
12
hpdl
410
13   require('../admin/includes/classes/language.php');
hpdl
266
14
hpdl
410
15   class osC_LanguageInstall extends osC_Language_Admin {
hpdl
266
16
17 /* Private variables */
frank
1261
18     var $_languages = array('en_US' => array('name' => 'English',
19                                              'code' => 'en_US',
20                                              'charset' => 'utf-8',
21                                              'exist' => '1'),
22                             'nl_NL' => array('name' => 'Dutch',
23                                              'code' => 'nl_NL',
24                                              'charset' => 'utf-8',
25                                              'exist' => '0'),
26                             'tr_TR' => array('name' => 'Turkisch',
27                                              'code' => 'tr_TR',
28                                              'charset' => 'utf-8',
29                                              'exist' => '0'),
30                             'es_ES' => array('name' => 'Spanish',
31                                              'code' => 'es_ES',
32                                              'charset' => 'utf-8',
33                                              'exist' => '0'),
34                             'es_CL' => array('name' => 'Chilean',
35                                              'code' => 'es_CL',
36                                              'charset' => 'utf-8',
37                                              'exist' => '0'));
hpdl
266
38
39 /* Class constructor */
40
hpdl
383
41     function osC_LanguageInstall() {
hpdl
468
42       $language = (isset($_GET['language']) && !empty($_GET['language']) ? $_GET['language'] : '');
hpdl
266
43
hpdl
468
44       $this->set($language);
45
hpdl
410
46       $this->_definitions = $this->_parseIniFile();
hpdl
274
47
hpdl
784
48       $this->load(basename($_SERVER['SCRIPT_FILENAME']));
hpdl
266
49     }
50
51 /* Public methods */
52
53     function load($filename) {
hpdl
410
54       $this->_definitions = array_merge($this->_definitions, $this->_parseIniFile($filename));
hpdl
266
55     }
56
57 /* Private methods */
58
59     function _parseIniFile($filename = '', $comment = '#') {
60       if (empty($filename)) {
hpdl
924
61         $contents = file('includes/languages/' . $this->getCode() . '.php');
hpdl
266
62       } else {
hpdl
924
63         if (file_exists('includes/languages/' . $this->getCode() . '/' . $filename) === false) {
hpdl
278
64           return array();
hpdl
268
65         }
66
hpdl
924
67         $contents = file('includes/languages/' . $this->getCode() . '/' . $filename);
hpdl
266
68       }
69
70       $ini_array = array();
71
72       foreach ($contents as $line) {
73         $line = trim($line);
74
75         $firstchar = substr($line, 0, 1);
76
77         if (!empty($line) && ($firstchar != $comment)) {
78           $delimiter = strpos($line, '=');
79
80           if ($delimiter !== false) {
81             $key = trim(substr($line, 0, $delimiter));
82             $value = trim(substr($line, $delimiter + 1));
83
84             $ini_array[$key] = $value;
85           } elseif (isset($key)) {
86             $ini_array[$key] .= trim($line);
87           }
88         }
89       }
90
91       unset($contents);
92
93       return $ini_array;
94     }
frank
1261
95     
96     function _scanLanguage() {
97       $osC_DirectoryListing = new osC_DirectoryListing('includes/languages');
98       $osC_DirectoryListing->setIncludeFiles(false);
99
100       foreach ($osC_DirectoryListing->getFiles() as $directory) {
101         if (array_key_exists($directory['name'], $this->_languages)) {
102           $this->_languages[$directory['name']]['exist'] = 1;
103         }
104       }
105     }
hpdl
266
106   }
107 ?>