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 16 /** @var helper_plugin_translation $helper */ 17 $helper = plugin_load('helper', "autotranslation"); 18 $default_language = $helper->defaultlang; 19 20 /** @var Doku_Renderer_xhtml $xhtml_renderer */ 21 $xhtml_renderer = p_get_renderer('xhtml'); 22 23 echo "<h1>" . $this->getLang("menu") . "</h1>"; 24 echo "<table id='outdated_translations' class=\"inline\">"; 25 echo "<tr><th>default: $default_language</th>"; 26 if ($this->getConf('show_path')) { 27 echo "<th>" . $this->getLang('path') . "</th>"; 28 } 29 foreach ($helper->translations as $t) { 30 if($t === $default_language) { 31 continue; 32 } 33 echo "<th>$t</th>"; 34 } 35 echo "</tr>"; 36 37 $pages = $this->getAllPages(); 38 foreach ($pages as $page) { 39 if (!$helper->getLangPart($page["id"]) === $default_language || 40 !$helper->istranslatable($page["id"], false) || 41 !page_exists($page["id"]) 42 ) { 43 continue; 44 } 45 // We have an existing and translatable page in the default language 46 $showRow = false; 47 $row = "<tr><td>" . $xhtml_renderer->internallink($page['id'],null,null,true) . "</td>"; 48 if ($this->getConf('show_path')) { 49 $row .= "<td>" . $xhtml_renderer->internallink($page['id'],$page['id'],null,true) . "</td>"; 50 } 51 52 list($lc, $idpart) = $helper->getTransParts($page["id"]); 53 54 foreach ($helper->translations as $t) { 55 if ($t === $default_language) { 56 continue; 57 } 58 59 list($translID, $name) = $helper->buildTransID($t, $idpart); 60 61 62 $difflink = ''; 63 if(!page_exists($translID)) { 64 $class = "missing"; 65 $title = $this->getLang("missing"); 66 $showRow = true; 67 } else { 68 $translfn = wikiFN($translID); 69 if($page['mtime'] > filemtime($translfn)) { 70 $class = "outdated"; 71 $difflink = " <a href='"; 72 $difflink .= $helper->getOldDiffLink($page["id"], $page['mtime']); 73 $difflink .= "'>(diff)</a>"; 74 $title = $this->getLang('old'); 75 $showRow = true; 76 } else { 77 $class = "current"; 78 $title = $this->getLang('current'); 79 } 80 } 81 $row .= "<td class='$class'>" . $xhtml_renderer->internallink($translID,$title,null,true) . $difflink . "</td>"; 82 } 83 $row .= "</tr>"; 84 85 if ($showRow) { 86 echo $row; 87 } 88 89 } 90 echo "</table>"; 91 92 } 93 94 function getAllPages() { 95 $namespace = $this->getConf("translationns"); 96 $dir = dirname(wikiFN("$namespace:foo")); 97 $pages = array(); 98 search($pages, $dir, 'search_allpages',array()); 99 return $pages; 100 } 101} 102