Quick Search:

View

Revision:

Diff

Diff from 1268 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
1268
18     var $_languages = array();
19     
hpdl
266
20 /* Class constructor */
21
hpdl
383
22     function osC_LanguageInstall() {
frank
1268
23       $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages');
24       $osC_DirectoryListing->setIncludeDirectories(false);
25
26       foreach ($osC_DirectoryListing->getFiles() as $file) {
27         $osC_XML = new osC_XML(file_get_contents('../includes/languages/' . $file['name']));
28         $lang = $osC_XML->toArray();
29
30         $this->_languages[$lang['language']['data']['code']] = array('name' => $lang['language']['data']['title'],
31                                                                      'code' => $lang['language']['data']['code'],
32                                                                      'charset' => $lang['language']['data']['character_set']);
33       }
34
35       unset($lang);
36
hpdl
468
37       $language = (isset($_GET['language']) && !empty($_GET['language']) ? $_GET['language'] : '');
hpdl
266
38
hpdl
468
39       $this->set($language);
40
hpdl
410
41       $this->_definitions = $this->_parseIniFile();
hpdl
274
42
hpdl
784
43       $this->load(basename($_SERVER['SCRIPT_FILENAME']));
hpdl
266
44     }
45
46 /* Public methods */
47
48     function load($filename) {
hpdl
410
49       $this->_definitions = array_merge($this->_definitions, $this->_parseIniFile($filename));
hpdl
266
50     }
51
52 /* Private methods */
53
54     function _parseIniFile($filename = '', $comment = '#') {
55       if (empty($filename)) {
hpdl
924
56         $contents = file('includes/languages/' . $this->getCode() . '.php');
hpdl
266
57       } else {
hpdl
924
58         if (file_exists('includes/languages/' . $this->getCode() . '/' . $filename) === false) {
hpdl
278
59           return array();
hpdl
268
60         }
61
hpdl
924
62         $contents = file('includes/languages/' . $this->getCode() . '/' . $filename);
hpdl
266
63       }
64
65       $ini_array = array();
66
67       foreach ($contents as $line) {
68         $line = trim($line);
69
70         $firstchar = substr($line, 0, 1);
71
72         if (!empty($line) && ($firstchar != $comment)) {
73           $delimiter = strpos($line, '=');
74
75           if ($delimiter !== false) {
76             $key = trim(substr($line, 0, $delimiter));
77             $value = trim(substr($line, $delimiter + 1));
78
79             $ini_array[$key] = $value;
80           } elseif (isset($key)) {
81             $ini_array[$key] .= trim($line);
82           }
83         }
84       }
85
86       unset($contents);
87
88       return $ini_array;
89     }
90   }
91 ?>