1<?php 2 3use dokuwiki\Extension\AdminPlugin; 4 5/** 6 * DokuWiki Plugin translation (Admin Component) 7 * 8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9 * @author Andreas Gohr <andi@splitbrain.org> 10 */ 11class admin_plugin_translation extends AdminPlugin 12{ 13 /** @inheritdoc */ 14 public function forAdminOnly() 15 { 16 return false; 17 } 18 19 /** @inheritdoc */ 20 public function handle() 21 { 22 } 23 24 /** @inheritdoc */ 25 public function html() 26 { 27 28 /** @var helper_plugin_translation $helper */ 29 $helper = plugin_load('helper', "translation"); 30 $default_language = $helper->defaultlang; 31 32 /** @var Doku_Renderer_xhtml $xhtml_renderer */ 33 $xhtml_renderer = p_get_renderer('xhtml'); 34 35 echo "<h1>" . $this->getLang("menu") . "</h1>"; 36 echo "<table id='outdated_translations' class=\"inline\">"; 37 echo "<tr><th>default: $default_language</th>"; 38 if ($this->getConf('show_path')) { 39 echo "<th>" . $this->getLang('path') . "</th>"; 40 } 41 foreach ($helper->translations as $t) { 42 if ($t === $default_language) { 43 continue; 44 } 45 echo "<th>$t</th>"; 46 } 47 echo "</tr>"; 48 49 $pages = $helper->getAllTranslatablePages(); 50 foreach ($pages as $page) { 51 // We have an existing and translatable page in the default language 52 $showRow = false; 53 $row = "<tr><td>" . $xhtml_renderer->internallink($page['id'], null, null, true) . "</td>"; 54 if ($this->getConf('show_path')) { 55 $row .= "<td>" . $xhtml_renderer->internallink($page['id'], $page['id'], null, true) . "</td>"; 56 } 57 58 [, $idpart] = $helper->getTransParts($page["id"]); 59 60 foreach ($helper->translations as $t) { 61 if ($t === $default_language) { 62 continue; 63 } 64 65 [$translID, ] = $helper->buildTransID($t, $idpart); 66 67 $difflink = ''; 68 if (!page_exists($translID)) { 69 $class = "missing"; 70 $title = $this->getLang("missing"); 71 $showRow = true; 72 } else { 73 $translfn = wikiFN($translID); 74 if ($page['mtime'] > filemtime($translfn)) { 75 $class = "outdated"; 76 $difflink = " <a href='"; 77 $difflink .= $helper->getOldDiffLink($page["id"], $page['mtime']); 78 $difflink .= "'>(diff)</a>"; 79 $title = $this->getLang('old'); 80 $showRow = true; 81 } else { 82 $class = "current"; 83 $title = $this->getLang('current'); 84 } 85 } 86 $row .= "<td class='$class'>" . $xhtml_renderer->internallink( 87 $translID, 88 $title, 89 null, 90 true 91 ) . $difflink . "</td>"; 92 } 93 $row .= "</tr>"; 94 95 if ($showRow) { 96 echo $row; 97 } 98 } 99 echo "</table>"; 100 } 101 102} 103