/**
  * Builds a table with all translations of $title.
  *
  * @param $title Title (default: null)
  * @return void
  */
 function showTranslations(Title $title)
 {
     global $wgOut, $wgUser, $wgLang;
     $sk = $wgUser->getSkin();
     $namespace = $title->getNamespace();
     $message = $title->getDBkey();
     $inMessageGroup = TranslateUtils::messageKeyToGroup($title->getNamespace(), $title->getText());
     if (!$inMessageGroup) {
         $wgOut->addWikiMsg('translate-translations-no-message', $title->getPrefixedText());
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace' => $namespace, 'page_title ' . $dbr->buildLike("{$message}/", $dbr->anyString())), __METHOD__, array('ORDER BY' => 'page_title', 'USE INDEX' => 'name_title'));
     if (!$res->numRows()) {
         $wgOut->addWikiMsg('translate-translations-no-message', $title->getPrefixedText());
         return;
     } else {
         $wgOut->addWikiMsg('translate-translations-count', $wgLang->formatNum($res->numRows()));
     }
     // Normal output.
     $titles = array();
     foreach ($res as $s) {
         $titles[] = $s->page_title;
     }
     $pageInfo = TranslateUtils::getContents($titles, $namespace);
     $tableheader = Xml::openElement('table', array('class' => 'mw-sp-translate-table sortable'));
     $tableheader .= Xml::openElement('tr');
     $tableheader .= Xml::element('th', null, wfMsg('allmessagesname'));
     $tableheader .= Xml::element('th', null, wfMsg('allmessagescurrent'));
     $tableheader .= Xml::closeElement('tr');
     // Adapted version of TranslateUtils:makeListing() by Nikerabbit.
     $out = $tableheader;
     $canTranslate = $wgUser->isAllowed('translate');
     $ajaxPageList = array();
     $historyText = "&#160;<sup>" . wfMsgHtml('translate-translations-history-short') . "</sup>&#160;";
     foreach ($res as $s) {
         $key = $s->page_title;
         $tTitle = Title::makeTitle($s->page_namespace, $key);
         $ajaxPageList[] = $tTitle->getPrefixedDBkey();
         $code = $this->getCode($s->page_title);
         $text = TranslateUtils::getLanguageName($code, false, $wgLang->getCode()) . " ({$code})";
         $text = htmlspecialchars($text);
         if ($canTranslate) {
             $tools['edit'] = TranslationHelpers::ajaxEditLink($tTitle, $text);
         } else {
             $tools['edit'] = $sk->link($tTitle, $text);
         }
         $tools['history'] = $sk->link($tTitle, $historyText, array('action', 'title' => wfMsg('history-title', $tTitle->getPrefixedDBkey())), array('action' => 'history'));
         if (TranslateEditAddons::isFuzzy($tTitle)) {
             $class = 'orig';
         } else {
             $class = 'def';
         }
         $leftColumn = $tools['history'] . $tools['edit'];
         $out .= Xml::tags('tr', array('class' => $class), Xml::tags('td', null, $leftColumn) . Xml::tags('td', array('lang' => $code, 'dir' => Language::factory($code)->getDir()), TranslateUtils::convertWhiteSpaceToHTML($pageInfo[$key][0])));
     }
     $out .= Xml::closeElement('table');
     $wgOut->addHTML($out);
     $vars = array('trlKeys' => $ajaxPageList);
     $wgOut->addScript(Skin::makeVariablesScript($vars));
 }