public function contents() { $optional = $this->context->msg('translate-optional')->escaped(); $this->doLinkBatch(); $sourceLang = Language::factory($this->group->getSourceLanguage()); $targetLang = Language::factory($this->collection->getLanguage()); $titleMap = $this->collection->keys(); $output = ''; $this->collection->initMessages(); // Just to be sure /** * @var TMessage $m */ foreach ($this->collection as $key => $m) { $tools = array(); /** * @var Title $title */ $title = $titleMap[$key]; $original = $m->definition(); $translation = $m->translation(); $hasTranslation = $translation !== null; if ($hasTranslation) { $message = $translation; $extraAttribs = self::getLanguageAttributes($targetLang); } else { $message = $original; $extraAttribs = self::getLanguageAttributes($sourceLang); } Hooks::run('TranslateFormatMessageBeforeTable', array(&$message, $m, $this->group, $targetLang, &$extraAttribs)); // Using Html::element( a ) because Linker::link is memory hog. // It takes about 20 KiB per call, and that times 5000 is quite // a lot of memory. $niceTitle = htmlspecialchars($this->context->getLanguage()->truncate($title->getPrefixedText(), -35)); $linkAttribs = array('href' => $title->getLocalUrl(array('action' => 'edit'))); $linkAttribs += TranslationEditPage::jsEdit($title, $this->group->getId()); $tools['edit'] = Html::element('a', $linkAttribs, $niceTitle); $anchor = 'msg_' . $key; $anchor = Xml::element('a', array('id' => $anchor, 'href' => "#{$anchor}"), "↓"); $extra = ''; if ($m->hasTag('optional')) { $extra = '<br />' . $optional; } $tqeData = $extraAttribs + array('data-title' => $title->getPrefixedText(), 'data-group' => $this->group->getId(), 'id' => 'tqe-anchor-' . substr(sha1($title->getPrefixedText()), 0, 12), 'class' => 'tqe-inlineeditable ' . ($hasTranslation ? 'translated' : 'untranslated')); $button = $this->getReviewButton($m); $status = $this->getReviewStatus($m); $leftColumn = $button . $anchor . $tools['edit'] . $extra . $status; if ($this->reviewMode) { $output .= Xml::tags('tr', array('class' => 'orig'), Xml::tags('td', array('rowspan' => '2'), $leftColumn) . Xml::tags('td', self::getLanguageAttributes($sourceLang), TranslateUtils::convertWhiteSpaceToHTML($original))); $output .= Xml::tags('tr', null, Xml::tags('td', $tqeData, TranslateUtils::convertWhiteSpaceToHTML($message))); } else { $output .= Xml::tags('tr', array('class' => 'def'), Xml::tags('td', null, $leftColumn) . Xml::tags('td', $tqeData, TranslateUtils::convertWhiteSpaceToHTML($message))); } $output .= "\n"; } return $output; }