forked from splitbrain/dokuwiki-plugin-translation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
117 lines (102 loc) · 3.65 KB
/
admin.php
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* DokuWiki Plugin translation (Admin Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Gohr <[email protected]>
*/
class admin_plugin_translation extends DokuWiki_Admin_Plugin
{
/** @inheritdoc */
public function forAdminOnly()
{
return false;
}
/** @inheritdoc */
function handle()
{
}
/** @inheritdoc */
function html()
{
/** @var helper_plugin_translation $helper */
$helper = plugin_load('helper', "translation");
$default_language = $helper->defaultlang;
/** @var Doku_Renderer_xhtml $xhtml_renderer */
$xhtml_renderer = p_get_renderer('xhtml');
echo "<h1>" . $this->getLang("menu") . "</h1>";
echo "<table id='outdated_translations' class=\"inline\">";
echo "<tr><th>default: $default_language</th>";
if ($this->getConf('show_path')) {
echo "<th>" . $this->getLang('path') . "</th>";
}
foreach ($helper->translations as $t) {
if ($t === $default_language) {
continue;
}
echo "<th>$t</th>";
}
echo "</tr>";
$pages = $this->getAllPages();
foreach ($pages as $page) {
if ($helper->getLangPart($page["id"]) !== $default_language ||
!$helper->istranslatable($page["id"], false) ||
!page_exists($page["id"])
) {
continue;
}
// We have an existing and translatable page in the default language
$showRow = false;
$row = "<tr><td>" . $xhtml_renderer->internallink($page['id'], null, null, true) . "</td>";
if ($this->getConf('show_path')) {
$row .= "<td>" . $xhtml_renderer->internallink($page['id'], $page['id'], null, true) . "</td>";
}
list(/* $lc */, $idpart) = $helper->getTransParts($page["id"]);
foreach ($helper->translations as $t) {
if ($t === $default_language) {
continue;
}
list($translID, /* $name */) = $helper->buildTransID($t, $idpart);
$difflink = '';
if (!page_exists($translID)) {
$class = "missing";
$title = $this->getLang("missing");
$showRow = true;
} else {
$translfn = wikiFN($translID);
if ($page['mtime'] > filemtime($translfn)) {
$class = "outdated";
$difflink = " <a href='";
$difflink .= $helper->getOldDiffLink($page["id"], $page['mtime']);
$difflink .= "'>(diff)</a>";
$title = $this->getLang('old');
$showRow = true;
} else {
$class = "current";
$title = $this->getLang('current');
}
}
$row .= "<td class='$class'>" . $xhtml_renderer->internallink($translID, $title, null,
true) . $difflink . "</td>";
}
$row .= "</tr>";
if ($showRow) {
echo $row;
}
}
echo "</table>";
}
/**
* Get all pages in the translation namespace
*
* @return array
*/
protected function getAllPages()
{
$namespace = $this->getConf("translationns");
$dir = dirname(wikiFN("$namespace:foo"));
$pages = array();
search($pages, $dir, 'search_allpages', array());
return $pages;
}
}