1<?php 2 3// must be run within Dokuwiki 4if(!defined('DOKU_INC')) die(); 5 6class admin_plugin_translation extends DokuWiki_Admin_Plugin { 7 function forAdminOnly() { 8 return false; 9 } 10 11 function handle() { 12 } 13 14 function html() { 15 // 1. find the default language and the approbiate namespace 16 /** @var helper_plugin_translation $helper */ 17 $helper = plugin_load('helper', "translation"); 18 $default_language = $helper->defaultlang; 19 20 echo "<h1>" . $this->getLang("outdated translations") . "</h1>"; 21 // 2. search for all pages in the default language that should be translated 22 $pages = $this->getAllPages(); 23 /** @var Doku_Renderer_xhtml $xhtml_renderer */ 24 $xhtml_renderer = p_get_renderer('xhtml'); 25 echo "<table id='outdated_translations'>"; 26 27 echo "<tr><th>default: $default_language</th>"; 28 foreach ($helper->translations as $t) { 29 if($t === $default_language) { 30 continue; 31 } 32 echo "<th>$t</th>"; 33 } 34 echo "</tr>"; 35 36 foreach ($pages as $page) { 37 if ($helper->getLangPart($page["id"]) === $default_language && 38 $helper->istranslatable($page["id"], false) && 39 page_exists($page["id"]) 40 ) { 41 $row = "<tr><td>" . $xhtml_renderer->internallink($page['id'],null,null,true) . "</td>"; 42 $showRow = false; 43 44 list($lc, $idpart) = $helper->getTransParts($page["id"]); 45 46 foreach ($helper->translations as $t) { 47 if ($t === $default_language) { 48 continue; 49 } 50 51 list($transl, $name) = $helper->buildTransID($t, $idpart); 52 53 // 3. check if the translated pages exist & their age compared to the original 54 $difflink = ''; 55 if(!page_exists($transl)) { 56 $class = "missing"; 57 $title = $this->getLang("missing"); 58 $showRow = true; 59 } else { 60 $translfn = wikiFN($transl); 61 if($page['mtime'] > @filemtime($translfn)) { 62 $class = "outdated"; 63 $difflink = " <a href='"; 64 $difflink .= $helper->getOldDiffLink($page["id"], $page['mtime']); 65 $difflink .= "'>(diff)</a>"; 66 $title = $this->getLang("outdated"); 67 $showRow = true; 68 } else { 69 $class = "current"; 70 $title = $this->getLang('current'); 71 } 72 } 73 $row .= "<td class='$class'>" . $xhtml_renderer->internallink($transl,$title,null,true) . $difflink . "</td>"; 74 } 75 $row .= "</tr>"; 76 77 // 4. print a table if the translation may be outdated 78 if ($showRow) { 79 echo $row; 80 } 81 } 82 } 83 echo "</table>"; 84 85 } 86 87 function getAllPages() { 88 global $conf; 89 $namespace = $this->getConf("translationns"); 90 $dir = $conf['datadir'] . '/' . str_replace(':', '/', $namespace); 91 $pages = array(); 92 search($pages, $dir, 'search_allpages',array()); 93 return $pages; 94 } 95}