-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXml2Wiki.php
More file actions
executable file
·98 lines (67 loc) · 2.27 KB
/
Copy pathXml2Wiki.php
File metadata and controls
executable file
·98 lines (67 loc) · 2.27 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/php
<?php
/**
* Convert generated XML-file (by LuaRaw2XML.lua) to Wiki-pages
*
* needs as first parameter the xml-file. Example:
* > ./Xml2Wiki.php tmp/factorio-data.xml factorio/data/base/locale factorio/data/core/locale
*
*
* export XDEBUG_CONFIG="idekey=PHPSTORM"
*/
ini_set('include_path', ini_get('include_path') . ':' . dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib");
include_once('FactContent.php');
include_once('FactModules.php');
include_once('FactContentItem.php');
include_once('FactContentDataRawList.php');
include_once('FactPage.php');
include_once('FactTransDefault.php');
const FACT_TIMEZONE = 'UTC';
date_default_timezone_set(FACT_TIMEZONE);
$xml = simplexml_load_file($argv[1]);
$content = new FactContent($xml);
$modules = new FactModules($content);
$trans = new FactTransDefault($modules->getLocalPaths());
#createItemPages($content, $trans);
createDataRawList($content, $trans);
/**
* create ITEM pages
*
* @param FactContent $content
*/
function createItemPages(FactContent $rawContent, FactTransDefault $trans)
{
$trans->setDefault('entity-names', 'entity-name');
$content = new FactContentItem($rawContent);
$page = new FactPage($trans, 'templates/PageItem.phtml');
foreach ($content->getKeys() as $key) {
$item = $content->get($key);
foreach ($trans->getAvailableLanguages() as $language) {
if ($language != FactTrans::DEFAULT_LANGUAGE) {
$pagename = 'Item:' . $key . '/' . $language;
} else {
$pagename = 'Item:' . $key;
}
echo "\nPagename: $pagename";
echo " / $language: " . $trans->getFallbackLDefaultOrKey($language, $key);
$page->createPage($key, $item, $language);
}
}
}
function createDataRawList(FactContent $rawContent, FactTrans $trans)
{
# $trans->setDefault('', ''); // no translation needed
$content = new FactContentDataRawList($rawContent);
# $page = new FactPage($trans, 'lib/PageContent.phtml');
foreach ($content->getKeys() as $key) {
$list = $content->get($key);
echo "\n$key : \n";
print_r($list);
}
}
// create item-overview pages
// create item-templates
// ....
// create ENTITY-pages
// create RECIPE-pages
// create RESEARCH-pages