/** * @param $group MessageGroup */ public function doModLangs($group) { global $wgLang; $languages = array_keys(Language::getLanguageNames(false)); $modified = $codes = array(); foreach ($languages as $code) { if ($code === 'en') { continue; } $cache = new MessageGroupCache($group, $code); if ($cache->isValid()) { continue; } $link = $this->skin->link($this->getTitle(), htmlspecialchars(TranslateUtils::getLanguageName($code, false, $wgLang->getCode()) . " ({$code})"), array(), array('group' => $group->getId(), 'language' => $code)); if (!$cache->exists()) { $modified[] = wfMsgHtml('translate-manage-modlang-new', $link); } else { $modified[] = $link; } $codes[] = $code; } if (count($modified)) { $this->out->addWikiMsg('translate-manage-modlangs', $wgLang->formatNum(count($modified))); if ($this->user->isAllowed('translate-manage')) { $this->out->addHTML($this->rebuildButton($group, $codes, 'import')); } $this->out->addHTML('<ul><li>' . implode("</li>\n<li>", $modified) . '</li></ul>'); } }
protected function showEmail( $step ) { $header = new HtmlTag( 'h2' ); $step_message = 'translate-fs-email-title'; $header->style( 'opacity', 0.4 )->content( wfMsg( $step_message ) ); if ( $step && ( $step !== 'translate-fs-target-title' && $step !== 'translate-fs-permissions-title' ) ) { $this->out->addHtml( $header ); return $step; } if ( $this->user->isEmailConfirmed() ) { $header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) ); $this->out->addHtml( $header ); return $step; // Start translating step } $this->out->addHtml( $header->style( 'opacity', false ) ); $this->out->addWikiMsg( 'translate-fs-email-text' ); return $step_message; }
function setBottomText(OutputPage $out, FormOptions $opts) { if (isset($this->mTargetTitle) && is_object($this->mTargetTitle)) { global $wgUser; $out->setFeedAppendQuery("target=" . urlencode($this->mTargetTitle->getPrefixedDBkey())); } if (isset($this->mResultEmpty) && $this->mResultEmpty) { $out->addWikiMsg('recentchangeslinked-noresult'); } }
public function execute( $messages ) { global $wgOut, $wgLang; $this->out = $wgOut; // Set up diff engine $diff = new DifferenceEngine; $diff->showDiffStyle(); $diff->setReducedLineNumbers(); // Check whether we do processing $process = $this->allowProcess(); // Initialise collection $group = $this->getGroup(); $code = $this->getCode(); $collection = $group->initCollection( $code ); $collection->loadTranslations(); $this->out->addHTML( $this->doHeader() ); // Determine changes $alldone = $process; $changed = array(); foreach ( $messages as $key => $value ) { $fuzzy = $old = false; if ( isset( $collection[$key] ) ) { $old = $collection[$key]->translation(); } // No changes at all, ignore if ( strval( $old ) === strval( $value ) ) { continue; } if ( $old === false ) { $name = wfMsgHtml( 'translate-manage-import-new', '<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>' ); $text = TranslateUtils::convertWhiteSpaceToHTML( $value ); $changed[] = self::makeSectionElement( $name, 'new', $text ); } else { $diff->setText( $old, $value ); $text = $diff->getDiff( '', '' ); $type = 'changed'; global $wgRequest; $action = $wgRequest->getVal( self::escapeNameForPHP( "action-$type-$key" ) ); if ( $process ) { if ( !count( $changed ) ) { $changed[] = '<ul>'; } if ( $action === null ) { $message = wfMsgExt( 'translate-manage-inconsistent', 'parseinline', wfEscapeWikiText( "action-$type-$key" ) ); $changed[] = "<li>$message</li></ul>"; $process = false; } else { // Check processing time if ( !isset( $this->time ) ) { $this->time = wfTimestamp(); } $message = self::doAction( $action, $group, $key, $code, $value ); $key = array_shift( $message ); $params = $message; $message = wfMsgExt( $key, 'parseinline', $params ); $changed[] = "<li>$message</li>"; if ( $this->checkProcessTime() ) { $process = false; $duration = $wgLang->formatNum( $this->processingTime ); $message = wfMsgExt( 'translate-manage-toolong', 'parseinline', $duration ); $changed[] = "<li>$message</li></ul>"; } continue; } } $alldone = false; $actions = $this->getActions(); $defaction = $this->getDefaultAction( $fuzzy, $action ); $act = array(); foreach ( $actions as $action ) { $label = wfMsg( "translate-manage-action-$action" ); $name = self::escapeNameForPHP( "action-$type-$key" ); $id = Sanitizer::escapeId( "action-$key-$action" ); $act[] = Xml::radioLabel( $label, $name, $action, $id, $action === $defaction ); } $name = wfMsg( 'translate-manage-import-diff', '<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>', implode( ' ', $act ) ); $changed[] = self::makeSectionElement( $name, $type, $text ); } } if ( !$process ) { $collection->filter( 'hastranslation', false ); $keys = $collection->getMessageKeys(); $diff = array_diff( $keys, array_keys( $messages ) ); foreach ( $diff as $s ) { // @todo FIXME: Use CSS file. $name = wfMsgHtml( 'translate-manage-import-deleted', '<code style="font-weight:normal;">' . htmlspecialchars( $s ) . '</code>' ); $text = TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() ); $changed[] = self::makeSectionElement( $name, 'deleted', $text ); } } if ( $process || ( !count( $changed ) && $code !== 'en' ) ) { if ( !count( $changed ) ) { $this->out->addWikiMsg( 'translate-manage-nochanges-other' ); } if ( !count( $changed ) || strpos( $changed[count( $changed ) - 1], '<li>' ) !== 0 ) { $changed[] = '<ul>'; } $message = wfMsgExt( 'translate-manage-import-done', 'parseinline' ); $changed[] = "<li>$message</li></ul>"; $this->out->addHTML( implode( "\n", $changed ) ); } else { // END if ( count( $changed ) ) { if ( $code === 'en' ) { $this->out->addWikiMsg( 'translate-manage-intro-en' ); } else { $lang = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() ); $this->out->addWikiMsg( 'translate-manage-intro-other', $lang ); } $this->out->addHTML( Html::hidden( 'language', $code ) ); $this->out->addHTML( implode( "\n", $changed ) ); $this->out->addHTML( Xml::submitButton( wfMsg( 'translate-manage-submit' ) ) ); } else { $this->out->addWikiMsg( 'translate-manage-nochanges' ); } } $this->out->addHTML( $this->doFooter() ); return $alldone; }
/** * If there are rows in the deletion log for this page, show them, * along with a nice little note for the user * * @param OutputPage $out */ protected function showDeletionLog($out) { global $wgUser; $loglist = new LogEventsList($wgUser->getSkin(), $out); $pager = new LogPager($loglist, 'delete', false, $this->mTitle->getPrefixedText()); $count = $pager->getNumRows(); if ($count > 0) { $pager->mLimit = 10; $out->addHTML('<div class="mw-warning-with-logexcerpt">'); $out->addWikiMsg('recreate-deleted-warn'); $out->addHTML($loglist->beginLogEventsList() . $pager->getBody() . $loglist->endLogEventsList()); if ($count > 10) { $out->addHTML($wgUser->getSkin()->link(SpecialPage::getTitleFor('Log'), wfMsgHtml('deletelog-fulllog'), array(), array('type' => 'delete', 'page' => $this->mTitle->getPrefixedText()))); } $out->addHTML('</div>'); return true; } return false; }
/** * If there are rows in the deletion log for this page, show them, * along with a nice little note for the user * * @param OutputPage $out */ private function showDeletionLog($out) { $title = $this->mTitle; $reader = new LogReader(new FauxRequest(array('page' => $title->getPrefixedText(), 'type' => 'delete'))); if ($reader->hasRows()) { $out->addHtml('<div id="mw-recreate-deleted-warn">'); $out->addWikiMsg('recreate-deleted-warn'); $viewer = new LogViewer($reader); $viewer->showList($out); $out->addHtml('</div>'); } }
/** * If there are rows in the deletion log for this file, show them, * along with a nice little note for the user * * @param OutputPage $out * @param string filename */ private function showDeletionLog($out, $filename) { global $wgUser; $loglist = new LogEventsList($wgUser->getSkin(), $out); $pager = new LogPager($loglist, 'delete', false, $filename); if ($pager->getNumRows() > 0) { $out->addHTML('<div class="mw-warning-with-logexcerpt">'); $out->addWikiMsg('upload-wasdeleted'); $out->addHTML($loglist->beginLogEventsList() . $pager->getBody() . $loglist->endLogEventsList()); $out->addHTML('</div>'); } }
function setBottomText(OutputPage $out, FormOptions $opts) { if (isset($this->mResultEmpty) && $this->mResultEmpty) { $out->addWikiMsg('recentchangeslinked-noresult'); } }
/** * If there are rows in the deletion log for this file, show them, * along with a nice little note for the user * * @param OutputPage $out * @param string filename */ private function showDeletionLog($out, $filename) { $reader = new LogReader(new FauxRequest(array('page' => $filename, 'type' => 'delete'))); if ($reader->hasRows()) { $out->addHtml('<div id="mw-upload-deleted-warn">'); $out->addWikiMsg('upload-wasdeleted'); $viewer = new LogViewer($reader); $viewer->showList($out); $out->addHtml('</div>'); } }
public function execute($messages) { $context = RequestContext::getMain(); $this->out = $context->getOutput(); // Set up diff engine $diff = new DifferenceEngine(); $diff->showDiffStyle(); $diff->setReducedLineNumbers(); // Check whether we do processing $process = $this->allowProcess(); // Initialise collection $group = $this->getGroup(); $code = $this->getCode(); $collection = $group->initCollection($code); $collection->loadTranslations(); $this->out->addHTML($this->doHeader()); // Determine changes $alldone = $process; $changed = array(); foreach ($messages as $key => $value) { $fuzzy = $old = false; if (isset($collection[$key])) { $old = $collection[$key]->translation(); } // No changes at all, ignore if (strval($old) === strval($value)) { continue; } if ($old === false) { $para = '<code class="mw-tmi-new">' . htmlspecialchars($key) . '</code>'; $name = $context->msg('translate-manage-import-new')->rawParams($para)->escaped(); $text = TranslateUtils::convertWhiteSpaceToHTML($value); $changed[] = self::makeSectionElement($name, 'new', $text); } else { $oldContent = ContentHandler::makeContent($old, $diff->getTitle()); $newContent = ContentHandler::makeContent($value, $diff->getTitle()); $diff->setContent($oldContent, $newContent); $text = $diff->getDiff('', ''); $type = 'changed'; $action = $context->getRequest()->getVal(self::escapeNameForPHP("action-{$type}-{$key}")); if ($process) { if (!count($changed)) { $changed[] = '<ul>'; } if ($action === null) { $message = $context->msg('translate-manage-inconsistent', wfEscapeWikiText("action-{$type}-{$key}"))->parse(); $changed[] = "<li>{$message}</li></ul>"; $process = false; } else { // Check processing time if (!isset($this->time)) { $this->time = wfTimestamp(); } $message = self::doAction($action, $group, $key, $code, $value); $key = array_shift($message); $params = $message; $message = $context->msg($key, $params)->parse(); $changed[] = "<li>{$message}</li>"; if ($this->checkProcessTime()) { $process = false; $message = $context->msg('translate-manage-toolong')->numParams($this->processingTime)->parse(); $changed[] = "<li>{$message}</li></ul>"; } continue; } } $alldone = false; $actions = $this->getActions(); $defaction = $this->getDefaultAction($fuzzy, $action); $act = array(); // Give grep a chance to find the usages: // translate-manage-action-import, translate-manage-action-conflict, // translate-manage-action-ignore, translate-manage-action-fuzzy foreach ($actions as $action) { $label = $context->msg("translate-manage-action-{$action}")->text(); $name = self::escapeNameForPHP("action-{$type}-{$key}"); $id = Sanitizer::escapeId("action-{$key}-{$action}"); $act[] = Xml::radioLabel($label, $name, $action, $id, $action === $defaction); } $param = '<code class="mw-tmi-diff">' . htmlspecialchars($key) . '</code>'; $name = $context->msg('translate-manage-import-diff', $param, implode(' ', $act))->text(); $changed[] = self::makeSectionElement($name, $type, $text); } } if (!$process) { $collection->filter('hastranslation', false); $keys = $collection->getMessageKeys(); $diff = array_diff($keys, array_keys($messages)); foreach ($diff as $s) { $para = '<code class="mw-tmi-deleted">' . htmlspecialchars($s) . '</code>'; $name = $context->msg('translate-manage-import-deleted')->rawParams($para)->escaped(); $text = TranslateUtils::convertWhiteSpaceToHTML($collection[$s]->translation()); $changed[] = self::makeSectionElement($name, 'deleted', $text); } } if ($process || !count($changed) && $code !== 'en') { if (!count($changed)) { $this->out->addWikiMsg('translate-manage-nochanges-other'); } if (!count($changed) || strpos($changed[count($changed) - 1], '<li>') !== 0) { $changed[] = '<ul>'; } $message = $context->msg('translate-manage-import-done')->parse(); $changed[] = "<li>{$message}</li></ul>"; $this->out->addHTML(implode("\n", $changed)); } else { // END if (count($changed)) { if ($code === 'en') { $this->out->addWikiMsg('translate-manage-intro-en'); } else { $lang = TranslateUtils::getLanguageName($code, $context->getLanguage()->getCode()); $this->out->addWikiMsg('translate-manage-intro-other', $lang); } $this->out->addHTML(Html::hidden('language', $code)); $this->out->addHTML(implode("\n", $changed)); $this->out->addHTML(Xml::submitButton($context->msg('translate-manage-submit')->text())); } else { $this->out->addWikiMsg('translate-manage-nochanges'); } } $this->out->addHTML($this->doFooter()); return $alldone; }