|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Provides XML file handling for language schemas |
|
5
|
|
|
* |
|
6
|
|
|
* PHP Version 5 |
|
7
|
|
|
* |
|
8
|
|
|
* @category Core |
|
9
|
|
|
* @package XML |
|
10
|
|
|
* @author Hans-Joachim Piepereit <[email protected]> |
|
11
|
|
|
* @copyright 2013 cSphere Team |
|
12
|
|
|
* @license http://opensource.org/licenses/bsd-license Simplified BSD License |
|
13
|
|
|
* @link http://www.csphere.eu |
|
14
|
|
|
**/ |
|
15
|
|
|
|
|
16
|
|
|
namespace csphere\core\xml; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Provides XML file handling for language schemas |
|
20
|
|
|
* |
|
21
|
|
|
* @category Core |
|
22
|
|
|
* @package XML |
|
23
|
|
|
* @author Hans-Joachim Piepereit <[email protected]> |
|
24
|
|
|
* @copyright 2013 cSphere Team |
|
25
|
|
|
* @license http://opensource.org/licenses/bsd-license Simplified BSD License |
|
26
|
|
|
* @link http://www.csphere.eu |
|
27
|
|
|
**/ |
|
28
|
|
|
|
|
29
|
|
|
class Driver_Language extends Base |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Determine the driver specific source file |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $type Type of target, e.g. plugin |
|
35
|
|
|
* @param string $name Directory name of the target |
|
36
|
|
|
* @param string $lang Language if more than one is possible |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
**/ |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
protected function file($type, $name, $lang) |
|
42
|
|
|
{ |
|
43
|
|
|
$file = ''; |
|
44
|
|
|
|
|
45
|
|
|
// Language file can be part of a theme or plugin |
|
46
|
|
|
if ($type == 'plugin') { |
|
47
|
|
|
|
|
48
|
|
|
$file = 'csphere/plugins/' . $name . '/languages/' . $lang . '.xml'; |
|
49
|
|
|
|
|
50
|
|
|
} elseif ($type == 'theme') { |
|
51
|
|
|
|
|
52
|
|
|
$file = 'csphere/themes/' . $name . '/languages/' . $lang . '.xml'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return $file; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Change data array for easier usage |
|
60
|
|
|
* |
|
61
|
|
|
* @param array $array Formated array generated earlier |
|
62
|
|
|
* |
|
63
|
|
|
* @return array |
|
64
|
|
|
**/ |
|
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
protected function change(array $array) |
|
67
|
|
|
{ |
|
68
|
|
|
// Shorten array depth for common elements |
|
69
|
|
|
$array = $this->common($array); |
|
70
|
|
|
|
|
71
|
|
|
// Shorten array depth for simple elements |
|
72
|
|
|
$array['translation'] = $array['translation'][0]; |
|
73
|
|
|
|
|
74
|
|
|
// Definitions are essential for translations |
|
75
|
|
|
if (isset($array['definitions'][0]['define'])) { |
|
76
|
|
|
|
|
77
|
|
|
$array['definitions'] = $array['definitions'][0]['define']; |
|
78
|
|
|
} else { |
|
79
|
|
|
|
|
80
|
|
|
$array['definitions'] = []; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// Set icon URL |
|
84
|
|
|
$array['icon']['url'] = ''; |
|
85
|
|
|
|
|
86
|
|
|
if ($array['icon']['type'] == 'famfamfam') { |
|
87
|
|
|
|
|
88
|
|
|
$array['icon']['url'] = \csphere\core\url\Load::image( |
|
89
|
|
|
'famfamfam', 'flags', $array['icon']['value'] |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
return $array; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|