|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Provides XML file handling for changelog 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 changelog 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_Changelog 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
|
|
|
unset($lang); |
|
44
|
|
|
|
|
45
|
|
|
$file = ''; |
|
46
|
|
|
|
|
47
|
|
|
// Changelog file can be part of a theme or plugin |
|
48
|
|
|
if ($type == 'plugin') { |
|
49
|
|
|
|
|
50
|
|
|
$file = 'csphere/plugins/' . $name . '/changelog.xml'; |
|
51
|
|
|
|
|
52
|
|
|
} elseif ($type == 'theme') { |
|
53
|
|
|
|
|
54
|
|
|
$file = 'csphere/themes/' . $name . '/changelog.xml'; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $file; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Change data array for easier usage |
|
62
|
|
|
* |
|
63
|
|
|
* @param array $array Formated array generated earlier |
|
64
|
|
|
* |
|
65
|
|
|
* @return array |
|
66
|
|
|
**/ |
|
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
protected function change(array $array) |
|
69
|
|
|
{ |
|
70
|
|
|
// Shorten array depth for simple elements |
|
71
|
|
|
$array['history'] = $array['history'][0]; |
|
72
|
|
|
|
|
73
|
|
|
if (isset($array['updates'])) { |
|
74
|
|
|
|
|
75
|
|
|
// Shorten array depth for array elements |
|
76
|
|
|
$array['updates'] = $array['updates'][0]['update']; |
|
77
|
|
|
|
|
78
|
|
|
// Shorten updates as good as possible |
|
79
|
|
|
$updates_c = count($array['updates']); |
|
80
|
|
|
|
|
81
|
|
|
for ($i = 0; $i < $updates_c; $i++) { |
|
82
|
|
|
|
|
83
|
|
|
$array['updates'][$i] = $this->_update($array['updates'][$i]); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
// Move attr content to main array |
|
88
|
|
|
$array['updates'] = $this->loopattr($array['updates']); |
|
89
|
|
|
|
|
90
|
|
|
return $array; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Change data updates sub-array for easier usage |
|
95
|
|
|
* |
|
96
|
|
|
* @param array $update One update out of the data array |
|
97
|
|
|
* |
|
98
|
|
|
* @return array |
|
99
|
|
|
**/ |
|
|
|
|
|
|
100
|
|
|
|
|
101
|
|
|
private function _update(array $update) |
|
102
|
|
|
{ |
|
103
|
|
|
// Shorten info and instructions |
|
104
|
|
|
$update['information'] = $update['information'][0]['value']; |
|
105
|
|
|
$update['instructions'] = $update['instructions'][0]['value']; |
|
106
|
|
|
|
|
107
|
|
|
// Shorten optional data: added, reworked, fixed, removed |
|
108
|
|
|
if (isset($update['added'][0]['item'])) { |
|
109
|
|
|
|
|
110
|
|
|
$update['added'] = $update['added'][0]['item']; |
|
111
|
|
|
} else { |
|
112
|
|
|
|
|
113
|
|
|
$update['added'] = []; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
if (isset($update['reworked'][0]['item'])) { |
|
117
|
|
|
|
|
118
|
|
|
$update['reworked'] = $update['reworked'][0]['item']; |
|
119
|
|
|
} else { |
|
120
|
|
|
|
|
121
|
|
|
$update['reworked'] = []; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
if (isset($update['fixed'][0]['item'])) { |
|
125
|
|
|
|
|
126
|
|
|
$update['fixed'] = $update['fixed'][0]['item']; |
|
127
|
|
|
} else { |
|
128
|
|
|
|
|
129
|
|
|
$update['fixed'] = []; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
if (isset($update['removed'][0]['item'])) { |
|
133
|
|
|
|
|
134
|
|
|
$update['removed'] = $update['removed'][0]['item']; |
|
135
|
|
|
} else { |
|
136
|
|
|
|
|
137
|
|
|
$update['removed'] = []; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
return $update; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|