Quick Search:

View

Revision:

Diff

Diff from 1498 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/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
1315
8   Copyright (c) 2007 osCommerce
hpdl
266
9
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
266
13 */
14
hpdl
410
15   require('../admin/includes/classes/language.php');
hpdl
266
16
hpdl
410
17   class osC_LanguageInstall extends osC_Language_Admin {
hpdl
266
18
19 /* Private variables */
frank
1283
20     var $_languages = array();
21     
hpdl
266
22 /* Class constructor */
23
hpdl
383
24     function osC_LanguageInstall() {
frank
1283
25       $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages');
26       $osC_DirectoryListing->setIncludeDirectories(false);
hpdl
1315
27       $osC_DirectoryListing->setCheckExtension('xml');
frank
1283
28
29       foreach ($osC_DirectoryListing->getFiles() as $file) {
30         $osC_XML = new osC_XML(file_get_contents('../includes/languages/' . $file['name']));
31         $lang = $osC_XML->toArray();
32
33         $this->_languages[$lang['language']['data']['code']] = array('name' => $lang['language']['data']['title'],
34                                                                      'code' => $lang['language']['data']['code'],
35                                                                      'charset' => $lang['language']['data']['character_set']);
36       }
37
38       unset($lang);
39
hpdl
468
40       $language = (isset($_GET['language']) && !empty($_GET['language']) ? $_GET['language'] : '');
hpdl
266
41
hpdl
468
42       $this->set($language);
43
hpdl
410
44       $this->_definitions = $this->_parseIniFile();
hpdl
274
45
hpdl
784
46       $this->load(basename($_SERVER['SCRIPT_FILENAME']));
hpdl
266
47     }
48
49 /* Public methods */
50
51     function load($filename) {
hpdl
410
52       $this->_definitions = array_merge($this->_definitions, $this->_parseIniFile($filename));
hpdl
266
53     }
54
55 /* Private methods */
56
57     function _parseIniFile($filename = '', $comment = '#') {
58       if (empty($filename)) {
hpdl
924
59         $contents = file('includes/languages/' . $this->getCode() . '.php');
hpdl
266
60       } else {
hpdl
924
61         if (file_exists('includes/languages/' . $this->getCode() . '/' . $filename) === false) {
hpdl
278
62           return array();
hpdl
268
63         }
64
hpdl
924
65         $contents = file('includes/languages/' . $this->getCode() . '/' . $filename);
hpdl
266
66       }
67
68       $ini_array = array();
69
70       foreach ($contents as $line) {
71         $line = trim($line);
72
73         $firstchar = substr($line, 0, 1);
74
75         if (!empty($line) && ($firstchar != $comment)) {
76           $delimiter = strpos($line, '=');
77
78           if ($delimiter !== false) {
79             $key = trim(substr($line, 0, $delimiter));
80             $value = trim(substr($line, $delimiter + 1));
81
82             $ini_array[$key] = $value;
83           } elseif (isset($key)) {
84             $ini_array[$key] .= trim($line);
85           }
86         }
87       }
88
89       unset($contents);
90
91       return $ini_array;
92     }
93   }
94 ?>