-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathTranslation.class.php
More file actions
executable file
·76 lines (66 loc) · 2.33 KB
/
Copy pathTranslation.class.php
File metadata and controls
executable file
·76 lines (66 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
class Translation
{
var $navigation = array();
var $attributes = array();
var $categories = array();
var $cat_tr = array();
var $meta = array();
function Translation($lang)
{
$file = "api_$lang/translation/translation.xml";
//$file = "api_en/translation/translation.xml";
// Three new lines from Casey 25 July 2011
$xml = new DOMDocument('1.0', 'utf-8');
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->load($file);
//$xml =& openXML($file);
$this->parse($xml);
}
function parse($xml)
{
$nav = $xml->getElementsByTagName('navigation');
$nav = $nav->item(0);
foreach ($nav->childNodes as $child) {
$this->navigation[$child->nodeName] = $child->getText();
}
$attr = $xml->getElementsByTagName('attributes');
$attr = $attr->item(0);
foreach ($attr->childNodes as $child) {
$this->attributes[$child->nodeName] = $child->getText();
}
$cats = $xml->getElementsByTagName('categories');
$cats = $cats->item(0);
foreach ($cats->childNodes as $c) {
$name = htmlspecialchars($c->getAttribute('name'));
$this->categories[$name] = array('' => array());
$this->cat_tr[$name] = htmlspecialchars(trim($c->firstChild->nodeValue));
if ($c->childCount > 0) {
foreach ($c->childNodes as $s) {
if ($s->nodeType == 1) {
$this->categories[$name][$s->getAttribute('name')] = array();
$this->cat_tr[$s->getAttribute('name')] = trim($s->firstChild->nodeValue);
}
}
}
}
$meta = $xml->getElementsByTagName('meta');
$meta = $meta->item(0);
foreach ($meta->childNodes as $child) {
$nodeName = $child->nodeName;
eregi("<$nodeName>(.*)<\/$nodeName>", $child->toString(), $matches);
$this->meta[$nodeName] = $matches[1];
}
}
function test()
{
echo '<pre>';
print_r($this->navigation);
print_r($this->attributes);
print_r($this->categories);
print_r($this->cat_tr);
print_r($this->meta);
}
}
?>