public function getData()
 {
     $db = wfGetDB(DB_MASTER);
     $conds = array('rt_page' => $this->handle->getTitle()->getArticleID(), 'rt_type' => RevTag::getType('tp:transver'));
     $options = array('ORDER BY' => 'rt_revision DESC');
     $translationRevision = $db->selectField('revtag', 'rt_value', $conds, __METHOD__, $options);
     if ($translationRevision === false) {
         throw new TranslationHelperException("No definition revision recorded");
     }
     $definitionTitle = Title::makeTitleSafe($this->handle->getTitle()->getNamespace(), $this->handle->getKey() . '/' . $this->group->getSourceLanguage());
     if (!$definitionTitle || !$definitionTitle->exists()) {
         throw new TranslationHelperException("Definition page doesn't exist");
     }
     // Using newFromId instead of newFromTitle, because the page might have been renamed
     $oldrev = Revision::newFromId($translationRevision);
     if (!$oldrev) {
         throw new TranslationHelperException("Old definition version doesn't exist anymore");
     }
     $oldContent = $oldrev->getContent();
     $newContent = $this->getDefinitionContent();
     if (!$oldContent) {
         throw new TranslationHelperException("Old definition version doesn't exist anymore");
     }
     if (!$oldContent instanceof WikitextContent || !$newContent instanceof WikitextContent) {
         throw new TranslationHelperException('Can only work on Wikitext content');
     }
     if ($oldContent->equals($newContent)) {
         throw new TranslationHelperException('No changes');
     }
     $diff = new DifferenceEngine($this->context);
     if (method_exists('DifferenceEngine', 'setTextLanguage')) {
         $diff->setTextLanguage($this->group->getSourceLanguage());
     }
     $diff->setContent($oldContent, $newContent);
     $diff->setReducedLineNumbers();
     $diff->showDiffStyle();
     $html = $diff->getDiff($this->context->msg('tpt-diff-old')->escaped(), $this->context->msg('tpt-diff-new')->escaped());
     return array('value_old' => $oldContent->getNativeData(), 'value_new' => $newContent->getNativeData(), 'revisionid_old' => $oldrev->getId(), 'revisionid_new' => $definitionTitle->getLatestRevId(), 'language' => $this->group->getSourceLanguage(), 'html' => $html);
 }
示例#2
0
 /**
  * Build a diff display between this and the previous either deleted
  * or non-deleted edit.
  *
  * @param $previousRev Revision
  * @param $currentRev Revision
  * @return String: HTML
  */
 function showDiff($previousRev, $currentRev)
 {
     $diffEngine = new DifferenceEngine($this->getContext());
     $diffEngine->showDiffStyle();
     $this->getOutput()->addHTML("<div>" . "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<tr>" . "<td colspan='2' width='50%' align='center' class='diff-otitle'>" . $this->diffHeader($previousRev, 'o') . "</td>\n" . "<td colspan='2' width='50%' align='center' class='diff-ntitle'>" . $this->diffHeader($currentRev, 'n') . "</td>\n" . "</tr>" . $diffEngine->generateDiffBody($previousRev->getText(), $currentRev->getText()) . "</table>" . "</div>\n");
 }
示例#3
0
 function showDiff($revision)
 {
     global $wgOut;
     $dbr = wfGetDB(DB_SLAVE);
     $result = $this->getRevisions($dbr, array('hidden_rev_id' => $revision));
     while ($row = $dbr->fetchObject($result)) {
         $info = $this->listRow($row);
         $list = $this->revisionInfo($row);
         $rev = new Revision($row);
         $rev->mTitle = Title::makeTitle($row->page_namespace, $row->page_title);
         $prevId = $rev->mTitle->getPreviousRevisionID($row->rev_id);
         if ($prevId) {
             $prev = Revision::newFromTitle($rev->mTitle, $prevId);
             $otext = strval($prev->getText());
         } else {
             $wgOut->addHtml("<ul>" . $info . "</ul>\n" . $list);
             $wgOut->addWikiText(wfMsgNoTrans('oversight-nodiff'));
             return;
         }
         $ntext = strval($rev->getText());
         $diffEngine = new DifferenceEngine();
         $diffEngine->showDiffStyle();
         $wgOut->addHtml("<ul>" . $info . "</ul>\n" . $list . "<p><strong>" . wfMsgHTML('oversight-difference') . "</strong>" . "</p>" . "<div>" . "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<tr>" . "<td colspan='2' width='50%' align='center' class='diff-otitle'>" . wfMsgHTML('oversight-prev') . " (#{$prevId})" . "</td>" . "<td colspan='2' width='50%' align='center' class='diff-ntitle'>" . wfMsgHTML('oversight-hidden') . "</td>" . "</tr>" . $diffEngine->generateDiffBody($otext, $ntext) . "</table>" . "</div>\n");
     }
     $dbr->freeResult($result);
 }
示例#4
0
 /**
  * Build a diff display between this and the previous either deleted
  * or non-deleted edit.
  *
  * @param $previousRev Revision
  * @param $currentRev Revision
  * @return String: HTML
  */
 function showDiff($previousRev, $currentRev)
 {
     $diffEngine = new DifferenceEngine($this->getContext());
     $diffEngine->showDiffStyle();
     $this->getOutput()->addHTML("<div>" . "<table style='width: 98%;' cellpadding='0' cellspacing='4' class='diff'>" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<tr>" . "<td colspan='2' style='width: 50%; text-align: center' class='diff-otitle'>" . $this->diffHeader($previousRev, 'o') . "</td>\n" . "<td colspan='2' style='width: 50%;  text-align: center' class='diff-ntitle'>" . $this->diffHeader($currentRev, 'n') . "</td>\n" . "</tr>" . $diffEngine->generateDiffBody($previousRev->getText(Revision::FOR_THIS_USER, $this->getUser()), $currentRev->getText(Revision::FOR_THIS_USER, $this->getUser())) . "</table>" . "</div>\n");
 }
示例#5
0
 /**
  * Get a diff between the current contents of the edit box and the
  * version of the page we're editing from.
  *
  * If this is a section edit, we'll replace the section as for final
  * save and then make a comparison.
  */
 function showDiff()
 {
     $oldtext = $this->mArticle->fetchContent();
     $newtext = $this->mArticle->replaceSection($this->section, $this->textbox1, $this->summary, $this->edittime);
     $newtext = $this->mArticle->preSaveTransform($newtext);
     $oldtitle = wfMsgExt('currentrev', array('parseinline'));
     $newtitle = wfMsgExt('yourtext', array('parseinline'));
     if ($oldtext !== false || $newtext != '') {
         $de = new DifferenceEngine($this->mTitle);
         $de->setText($oldtext, $newtext);
         $difftext = $de->getDiff($oldtitle, $newtitle);
         $de->showDiffStyle();
     } else {
         $difftext = '';
     }
     global $wgOut;
     $wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</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;
 }
 function perform($bPerformEdits = true)
 {
     global $wgRequest, $wgOut, $wgUser, $wgTitle, $wgLang;
     $iMaxPerCriterion = $bPerformEdits ? MER_MAX_EXECUTE_PAGES : MER_MAX_PREVIEW_DIFFS;
     $aErrors = array();
     $aPages = $this->getPages($aErrors, $iMaxPerCriterion);
     if ($aPages === null) {
         $this->showForm(wfMsg('masseditregex-err-nopages'));
         return;
     }
     // Show the form again ready for further editing if we're just previewing
     if (!$bPerformEdits) {
         $this->showForm();
     }
     $diff = new DifferenceEngine();
     $diff->showDiffStyle();
     // send CSS link to the browser for diff colours
     $wgOut->addHTML('<ul>');
     if (count($aErrors)) {
         $wgOut->addHTML('<li>' . join('</li><li> ', $aErrors) . '</li>');
     }
     $htmlDiff = '';
     $editToken = $wgUser->editToken();
     $iArticleCount = 0;
     foreach ($aPages as $p) {
         $iArticleCount++;
         if (!isset($p['revisions'])) {
             $wgOut->addHTML('<li>' . wfMsg('masseditregex-page-not-exists', $p['title']) . '</li>');
             continue;
             // empty page
         }
         $curContent = $p['revisions'][0]['*'];
         $iCount = 0;
         $newContent = $curContent;
         foreach ($this->aMatch as $i => $strMatch) {
             $this->strNextReplace = $this->aReplace[$i];
             $result = @preg_replace_callback($strMatch, array($this, 'regexCallback'), $newContent, -1, $iCount);
             if ($result !== null) {
                 $newContent = $result;
             } else {
                 $strErrorMsg = '<li>' . wfMsg('masseditregex-badregex') . ' <b>' . htmlspecialchars($strMatch) . '</b></li>';
                 $wgOut->addHTML($strErrorMsg);
                 unset($this->aMatch[$i]);
             }
         }
         if ($bPerformEdits) {
             // Not in preview mode, make the edits
             $wgOut->addHTML('<li>' . wfMsg('masseditregex-num-changes', $p['title'], $iCount) . '</li>');
             $req = new DerivativeRequest($wgRequest, array('action' => 'edit', 'bot' => true, 'title' => $p['title'], 'summary' => $this->strSummary, 'text' => $newContent, 'basetimestamp' => $p['starttimestamp'], 'watchlist' => 'nochange', 'nocreate' => 1, 'token' => $editToken), true);
             $processor = new ApiMain($req, true);
             try {
                 $processor->execute();
             } catch (UsageException $e) {
                 $wgOut->addHTML('<li><ul><li>' . wfMsg('masseditregex-editfailed') . ' ' . $e . '</li></ul></li>');
             }
         } else {
             // In preview mode, display the first few diffs
             $diff->setText($curContent, $newContent);
             $htmlDiff .= $diff->getDiff('<b>' . $p['title'] . ' - ' . wfMsg('masseditregex-before') . '</b>', '<b>' . wfMsg('masseditregex-after') . '</b>');
             if ($iArticleCount >= MER_MAX_PREVIEW_DIFFS) {
                 $htmlDiff .= Xml::element('p', null, wfMsg('masseditregex-max-preview-diffs', $wgLang->formatNum(MER_MAX_PREVIEW_DIFFS)));
                 break;
             }
         }
     }
     $wgOut->addHTML('</ul>');
     if ($bPerformEdits) {
         $wgOut->addWikiMsg('masseditregex-num-articles-changed', $iArticleCount);
         $wgOut->addHTML($this->sk->makeKnownLinkObj(SpecialPage::getSafeTitleFor('Contributions', $wgUser->getName()), wfMsgHtml('masseditregex-view-full-summary')));
     } else {
         // Only previewing, show the diffs now (after any errors)
         $wgOut->addHTML($htmlDiff);
     }
 }
	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;
	}
示例#9
0
 function showDetails($id)
 {
     if (!self::canSeeDetails()) {
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $row = $dbr->selectRow(array('abuse_filter_log', 'abuse_filter'), '*', array('afl_id' => $id), __METHOD__, array(), array('abuse_filter' => array('LEFT JOIN', 'af_id=afl_filter')));
     if (!$row) {
         return;
     }
     if ($row->afl_deleted && !self::canSeeHidden()) {
         global $wgOut;
         $wgOut->addWikiMsg('abusefilter-log-details-hidden');
         return;
     }
     $output = '';
     $output .= Xml::element('legend', null, wfMsg('abusefilter-log-details-legend', $id));
     $output .= Xml::tags('p', null, $this->formatRow($row, false));
     // Load data
     $vars = AbuseFilter::loadVarDump($row->afl_var_dump);
     // Diff, if available
     if ($vars->getVar('action')->toString() == 'edit') {
         $old_wikitext = $vars->getVar('old_wikitext')->toString();
         $new_wikitext = $vars->getVar('new_wikitext')->toString();
         $diffEngine = new DifferenceEngine($this->mSearchTitle);
         $diffEngine->showDiffStyle();
         $formattedDiff = $diffEngine->generateDiffBody($old_wikitext, $new_wikitext);
         static $colDescriptions = "<col class='diff-marker' />\n        <col class='diff-content' />\n        <col class='diff-marker' />\n        <col class='diff-content' />";
         $formattedDiff = "<table class='diff'>{$colDescriptions}<tbody>{$formattedDiff}</tbody></table>";
         $output .= Xml::tags('h3', null, wfMsgExt('abusefilter-log-details-diff', 'parseinline'));
         $output .= $formattedDiff;
     }
     $output .= Xml::element('h3', null, wfMsg('abusefilter-log-details-vars'));
     // Build a table.
     $output .= AbuseFilter::buildVarDumpTable($vars);
     if (self::canSeePrivate()) {
         // Private stuff, like IPs.
         $header = Xml::element('th', null, wfMsg('abusefilter-log-details-var')) . Xml::element('th', null, wfMsg('abusefilter-log-details-val'));
         $output .= Xml::element('h3', null, wfMsg('abusefilter-log-details-private'));
         $output .= Xml::openElement('table', array('class' => 'wikitable mw-abuselog-private', 'style' => 'width: 80%;')) . Xml::openElement('tbody');
         $output .= $header;
         // IP address
         $output .= Xml::tags('tr', null, Xml::element('td', array('style' => 'width: 30%;'), wfMsg('abusefilter-log-details-ip')) . Xml::element('td', null, $row->afl_ip));
         $output .= Xml::closeElement('tbody') . Xml::closeElement('table');
     }
     $output = Xml::tags('fieldset', null, $output);
     global $wgOut;
     $wgOut->addHTML($output);
 }
 public static function addModules(OutputPage $out)
 {
     $modules = array('ext.translate.quickedit');
     Hooks::run('TranslateBeforeAddModules', array(&$modules));
     $out->addModules($modules);
     // Might be needed, but ajax doesn't load it
     // Globals :(
     $diff = new DifferenceEngine();
     $diff->showDiffStyle();
 }
 /**
  * Displays the sections and changes for the user to review
  * @param TranslatablePage $page
  * @param array $sections
  */
 public function showPage(TranslatablePage $page, array $sections)
 {
     global $wgContLang;
     $out = $this->getOutput();
     $out->setSubtitle(Linker::link($page->getTitle()));
     $out->addModules('ext.translate.special.pagetranslation');
     $out->addWikiMsg('tpt-showpage-intro');
     $formParams = array('method' => 'post', 'action' => $this->getPageTitle()->getFullURL(), 'class' => 'mw-tpt-sp-markform');
     $out->addHTML(Xml::openElement('form', $formParams) . Html::hidden('title', $this->getPageTitle()->getPrefixedText()) . Html::hidden('revision', $page->getRevision()) . Html::hidden('target', $page->getTitle()->getPrefixedtext()) . Html::hidden('token', $this->getUser()->getEditToken()));
     $out->wrapWikiMsg('==$1==', 'tpt-sections-oldnew');
     $diffOld = $this->msg('tpt-diff-old')->escaped();
     $diffNew = $this->msg('tpt-diff-new')->escaped();
     $hasChanges = false;
     // Check whether page title was previously marked for translation.
     // If the page is marked for translation the first time, default to checked.
     $defaultChecked = $page->hasPageDisplayTitle();
     /**
      * @var TPSection $s
      */
     foreach ($sections as $s) {
         if ($s->name === 'Page display title') {
             // Set section type as new if title previously unchecked
             $s->type = $defaultChecked ? $s->type : 'new';
             // Checkbox for page title optional translation
             $this->getOutput()->addHTML(Xml::checkLabel($this->msg('tpt-translate-title')->text(), 'translatetitle', 'mw-translate-title', $defaultChecked));
         }
         if ($s->type === 'new') {
             $hasChanges = true;
             $name = $this->msg('tpt-section-new', $s->name)->escaped();
         } else {
             $name = $this->msg('tpt-section', $s->name)->escaped();
         }
         if ($s->type === 'changed') {
             $hasChanges = true;
             $diff = new DifferenceEngine();
             if (method_exists('DifferenceEngine', 'setTextLanguage')) {
                 $diff->setTextLanguage($wgContLang);
             }
             $diff->setReducedLineNumbers();
             $oldContent = ContentHandler::makeContent($s->getOldText(), $diff->getTitle());
             $newContent = ContentHandler::makeContent($s->getText(), $diff->getTitle());
             $diff->setContent($oldContent, $newContent);
             $text = $diff->getDiff($diffOld, $diffNew);
             $diffOld = $diffNew = null;
             $diff->showDiffStyle();
             $id = "tpt-sect-{$s->id}-action-nofuzzy";
             $checkLabel = Xml::checkLabel($this->msg('tpt-action-nofuzzy')->text(), $id, $id, false);
             $text = $checkLabel . $text;
         } else {
             $text = TranslateUtils::convertWhiteSpaceToHTML($s->getText());
         }
         # For changed text, the language is set by $diff->setTextLanguage()
         $lang = $s->type === 'changed' ? null : $wgContLang;
         $out->addHTML(MessageWebImporter::makeSectionElement($name, $s->type, $text, $lang));
     }
     $deletedSections = $page->getParse()->getDeletedSections();
     if (count($deletedSections)) {
         $hasChanges = true;
         $out->wrapWikiMsg('==$1==', 'tpt-sections-deleted');
         /**
          * @var TPSection $s
          */
         foreach ($deletedSections as $s) {
             $name = $this->msg('tpt-section-deleted', $s->id)->escaped();
             $text = TranslateUtils::convertWhiteSpaceToHTML($s->getText());
             $out->addHTML(MessageWebImporter::makeSectionElement($name, $s->type, $text, $wgContLang));
         }
     }
     // Display template changes if applicable
     if ($page->getMarkedTag() !== false) {
         $hasChanges = true;
         $newTemplate = $page->getParse()->getTemplatePretty();
         $oldPage = TranslatablePage::newFromRevision($page->getTitle(), $page->getMarkedTag());
         $oldTemplate = $oldPage->getParse()->getTemplatePretty();
         if ($oldTemplate !== $newTemplate) {
             $out->wrapWikiMsg('==$1==', 'tpt-sections-template');
             $diff = new DifferenceEngine();
             if (method_exists('DifferenceEngine', 'setTextLanguage')) {
                 $diff->setTextLanguage($wgContLang);
             }
             $oldContent = ContentHandler::makeContent($oldTemplate, $diff->getTitle());
             $newContent = ContentHandler::makeContent($newTemplate, $diff->getTitle());
             $diff->setContent($oldContent, $newContent);
             $text = $diff->getDiff($this->msg('tpt-diff-old')->escaped(), $this->msg('tpt-diff-new')->escaped());
             $diff->showDiffStyle();
             $diff->setReducedLineNumbers();
             $contentParams = array('class' => 'mw-tpt-sp-content');
             $out->addHTML(Xml::tags('div', $contentParams, $text));
         }
     }
     if (!$hasChanges) {
         $out->wrapWikiMsg('<div class="successbox">$1</div>', 'tpt-mark-nochanges');
     }
     $this->priorityLanguagesForm($page);
     $out->addHTML(Xml::submitButton($this->msg('tpt-submit')->text()) . Xml::closeElement('form'));
 }
	protected function statusInterface() {
		global $wgOut, $wgUser, $wgPremoderationStrict;
		
		$params = $this->mParams;
		if( !isset( $params['id'] ) ) {
			$wgOut->setPageTitle( wfMsg( 'premoderation-manager-invalidaction' ) );
			$wgOut->addWikiMsg( 'premoderation-invalidaction' );
			return;		
		}
		
		$id = intval( $params['id'] );
		$dbr = wfGetDB( DB_SLAVE );
		$res = $dbr->select(
			'pm_queue',
			'*',
			"pmq_id = '$id'",
			__METHOD__,
			array( 'LIMIT' => 1 )
		);
		$row = $dbr->fetchRow( $res );
		if( !$row ) {
			$wgOut->setPageTitle( wfMsg( 'premoderation-manager-invalidaction' ) );
			$wgOut->addWikiMsg( 'premoderation-notexists-id' );
			return;
		}
		
		$wgOut->setPageTitle( wfMsg( 'premoderation-manager-status' ) );
		$wgOut->addWikiMsg( 'premoderation-status-intro' );
		
		$wgOut->addHTML( '<h2>' . wfMsg( 'premoderation-status-info' ) . '</h2>' .
			$this->getListTableHeader( 'status' ) . $this->formatListTableRow( $row ) .
			Xml::closeElement( 'table' ) );
		
		if( $wgUser->isAllowed( 'premoderation-viewip' ) ) {
			$wgOut->addWikiMsg( 'premoderation-private-ip', $row['pmq_ip'] );
		}
		
		$rev = Revision::newFromID( $row['pmq_page_last_id'] );
		$diff = new DifferenceEngine();
		$diff->showDiffStyle();
		$formattedDiff = $diff->generateDiffBody(
			isset( $rev ) ? $rev->getText() : '', $row['pmq_text']
		);
		
		$wgOut->addHTML( '<h2>' . wfMsg( 'premoderation-diff-h2' ) . '</h2>' .
			"<table class='mw-abusefilter-diff-multiline'><col class='diff-marker' />" .
			"<col class='diff-content' /><col class='diff-marker' /><col class='diff-content' />" .
			"<tbody>" . $formattedDiff . "</tbody></table>" );
		
		if( $row['pmq_status'] == 'approved' ) {
			return;
		}
		
		$externalConflicts = $this->checkExternalConflicts( $row['pmq_page_last_id'],
			$row['pmq_page_ns'], $row['pmq_page_title'] );
		if( $externalConflicts ) {
			$wgOut->addHTML( '<h2>' . wfMsg( 'premoderation-external-conflicts-h2' ) . '</h2>' );
			if( $wgPremoderationStrict ) {
				$wgOut->addWikiMsg( 'premoderation-error-externals' );
				return;			
			}
			$wgOut->addWikiMsg( 'premoderation-external-edits' );
		}
		
		$this->checkInternalConflicts( $dbr, $id, $row['pmq_page_ns'], $row['pmq_page_title'] );
		
		$final = Xml::fieldset( wfMsg( 'premoderation-status-fieldset' ) ) .
			Xml::openElement( 'form', array( 'id' => 'prem-status-form', 'method' => 'post' ) ) .
			$this->getStatusForm( $row['pmq_status'] ) .
			'<input type="hidden" name="id" value="' . $id . '" />' .
			Xml::closeElement( 'form' ) . Xml::closeElement( 'fieldset' );
			
		$wgOut->addHTML( $final );
	}
示例#13
0
 /**
  * Get a diff between the current contents of the edit box and the
  * version of the page we're editing from.
  *
  * If this is a section edit, we'll replace the section as for final
  * save and then make a comparison.
  */
 function showDiff()
 {
     global $wgUser, $wgContLang, $wgParser, $wgOut;
     $oldtitlemsg = 'currentrev';
     # if message does not exist, show diff against the preloaded default
     if ($this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists()) {
         $oldtext = $this->mTitle->getDefaultMessageText();
         if ($oldtext !== false) {
             $oldtitlemsg = 'defaultmessagetext';
         }
     } else {
         $oldtext = $this->mArticle->getRawText();
     }
     $newtext = $this->mArticle->replaceSection($this->section, $this->textbox1, $this->summary, $this->edittime);
     wfRunHooks('EditPageGetDiffText', array($this, &$newtext));
     $popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
     $newtext = $wgParser->preSaveTransform($newtext, $this->mTitle, $wgUser, $popts);
     if ($oldtext !== false || $newtext != '') {
         $oldtitle = wfMessage($oldtitlemsg)->parse();
         $newtitle = wfMessage('yourtext')->parse();
         $de = new DifferenceEngine($this->mArticle->getContext());
         $de->setText($oldtext, $newtext);
         $difftext = $de->getDiff($oldtitle, $newtitle);
         $de->showDiffStyle();
     } else {
         $difftext = '';
     }
     $wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</div>');
 }
示例#14
0
 /**
  * @todo Very long code block; split up.
  *
  * @param $group MessageGroup
  * @param $code
  */
 public function importForm($group, $code)
 {
     $this->setSubtitle($group, $code);
     $formParams = array('method' => 'post', 'action' => $this->getTitle()->getFullURL(array('group' => $group->getId())), 'class' => 'mw-translate-manage');
     global $wgRequest, $wgLang;
     if ($wgRequest->wasPosted() && $wgRequest->getBool('process', false) && $this->user->isAllowed('translate-manage') && $this->user->matchEditToken($wgRequest->getVal('token'))) {
         $process = true;
     } else {
         $process = false;
     }
     $this->out->addHTML(Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedText()) . Html::hidden('token', $this->user->editToken()) . Html::hidden('group', $group->getId()) . Html::hidden('process', 1));
     // BEGIN
     $cache = new MessageGroupCache($group, $code);
     if (!$cache->exists() && $code === 'en') {
         $cache->create();
     }
     $collection = $group->initCollection($code);
     $collection->loadTranslations();
     $diff = new DifferenceEngine();
     $diff->showDiffStyle();
     $diff->setReducedLineNumbers();
     $ignoredMessages = $collection->getTags('ignored');
     if (!is_array($ignoredMessages)) {
         $ignoredMessages = array();
     }
     $messages = $group->load($code);
     $changed = array();
     foreach ($messages as $key => $value) {
         // ignored? ignore!
         if (in_array($key, $ignoredMessages)) {
             continue;
         }
         $fuzzy = $old = false;
         if (isset($collection[$key])) {
             $old = $collection[$key]->translation();
         }
         // No changes at all, ignore.
         if (str_replace(TRANSLATE_FUZZY, '', $old) === $value) {
             continue;
         }
         if ($old === false) {
             $name = wfMsgHtml('translate-manage-import-new', '<code style="font-weight:normal;">' . htmlspecialchars($key) . '</code>');
             $text = TranslateUtils::convertWhiteSpaceToHTML($value);
             $changed[] = MessageWebImporter::makeSectionElement($name, 'new', $text);
         } else {
             if (TranslateEditAddons::hasFuzzyString($old)) {
                 // NO-OP
             } else {
                 $transTitle = MessageWebImporter::makeTranslationTitle($group, $key, $code);
                 if (TranslateEditAddons::isFuzzy($transTitle)) {
                     $old = TRANSLATE_FUZZY . $old;
                 }
             }
             $diff->setText($old, $value);
             $text = $diff->getDiff('', '');
             $type = 'changed';
             if ($process) {
                 if (!count($changed)) {
                     $changed[] = '<ul>';
                 }
                 $action = $wgRequest->getVal(MessageWebImporter::escapeNameForPHP("action-{$type}-{$key}"));
                 if ($action === null) {
                     $message = wfMsgExt('translate-manage-inconsistent', 'parseinline', wfEscapeWikiText("action-{$type}-{$key}"));
                     $changed[] = "<li>{$message}</li></ul>";
                     $process = false;
                 } else {
                     // Initialise processing time counter.
                     if (!isset($this->time)) {
                         $this->time = wfTimestamp();
                     }
                     $fuzzybot = FuzzyBot::getUser();
                     $message = MessageWebImporter::doAction($action, $group, $key, $code, $value, '', $fuzzybot, EDIT_FORCE_BOT);
                     $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;
                 }
             }
             if ($code !== 'en') {
                 $actions = array('import', 'conflict', 'ignore');
             } else {
                 $actions = array('import', 'fuzzy', 'ignore');
             }
             $act = array();
             if ($this->user->isAllowed('translate-manage')) {
                 $defaction = $fuzzy ? 'conflict' : 'import';
                 foreach ($actions as $action) {
                     $label = wfMsg("translate-manage-action-{$action}");
                     $name = MessageWebImporter::escapeNameForPHP("action-{$type}-{$key}");
                     $selected = $wgRequest->getVal($name, $defaction);
                     $id = Sanitizer::escapeId("action-{$key}-{$action}");
                     $act[] = Xml::radioLabel($label, $name, $action, $id, $action === $selected);
                 }
             }
             $name = wfMsg('translate-manage-import-diff', '<code style="font-weight:normal;">' . htmlspecialchars($key) . '</code>', implode(' ', $act));
             $changed[] = MessageWebImporter::makeSectionElement($name, $type, $text);
         }
     }
     if (!$process) {
         $collection->filter('hastranslation', false);
         $keys = $collection->getMessageKeys();
         $diff = array_diff($keys, array_keys($messages));
         foreach ($diff as $s) {
             $name = wfMsgHtml('translate-manage-import-deleted', '<code style="font-weight:normal;">' . htmlspecialchars($s) . '</code>');
             $text = TranslateUtils::convertWhiteSpaceToHTML($collection[$s]->translation());
             $changed[] = MessageWebImporter::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>';
         }
         $cache->create();
         $message = wfMsgExt('translate-manage-import-rebuild', 'parseinline');
         $changed[] = "<li>{$message}</li>";
         $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));
             if ($this->user->isAllowed('translate-manage')) {
                 $this->out->addHTML(Xml::submitButton(wfMsg('translate-manage-submit')));
             }
         } elseif ($this->user->isAllowed('translate-manage')) {
             $cache->create();
             // Update timestamp
             $this->out->addWikiMsg('translate-manage-nochanges');
         }
     }
     $this->out->addHTML('</form>');
     if ($code === 'en') {
         $this->doModLangs($group);
     } else {
         $this->out->addHTML('<p>' . $this->skin->link($this->getTitle(), wfMsgHtml('translate-manage-return-to-group'), array(), array('group' => $group->getId())) . '</p>');
     }
 }
 /**
  * @param $msg
  * @param $old
  * @param $new
  * @return string
  */
 function getDiffRow($msg, $old, $new)
 {
     if (!is_array($old)) {
         $old = explode("\n", preg_replace("/\\\r\\\n?/", "\n", $old));
     }
     if (!is_array($new)) {
         $new = explode("\n", preg_replace("/\\\r\\\n?/", "\n", $new));
     }
     $diffEngine = new DifferenceEngine($this->getContext());
     $diffEngine->showDiffStyle();
     // We can't use $diffEngine->generateDiffBody since it doesn't allow custom formatters
     $diff = new Diff($old, $new);
     $formatter = new TableDiffFormatterFullContext();
     $formattedDiff = $diffEngine->addHeader($formatter->format($diff), '', '');
     return Xml::tags('tr', null, Xml::tags('th', null, $this->msg($msg)->parse()) . Xml::tags('td', array('colspan' => 2), $formattedDiff)) . "\n";
 }
 protected function showChanges($allowed, $limit)
 {
     global $wgContLang;
     $diff = new DifferenceEngine($this->getContext());
     $diff->showDiffStyle();
     $diff->setReducedLineNumbers();
     $this->diff = $diff;
     $out = $this->getOutput();
     $out->addHtml('' . Html::openElement('form', array('method' => 'post')) . Html::hidden('title', $this->getPageTitle()->getPrefixedText()) . Html::hidden('token', $this->getUser()->getEditToken()) . $this->getLegend());
     // The above count as two
     $limit = $limit - 2;
     $changefile = TranslateUtils::cacheFile(self::CHANGEFILE);
     $reader = CdbReader::open($changefile);
     $groups = unserialize($reader->get('#keys'));
     foreach ($groups as $id) {
         $group = MessageGroups::getGroup($id);
         if (!$group) {
             continue;
         }
         $changes = unserialize($reader->get($id));
         $out->addHtml(Html::element('h2', array(), $group->getLabel()));
         // Reduce page existance queries to one per group
         $lb = new LinkBatch();
         $ns = $group->getNamespace();
         $isCap = MWNamespace::isCapitalized($ns);
         foreach ($changes as $code => $subchanges) {
             foreach ($subchanges as $messages) {
                 foreach ($messages as $params) {
                     // Constructing title objects is way slower
                     $key = $params['key'];
                     if ($isCap) {
                         $key = $wgContLang->ucfirst($key);
                     }
                     $lb->add($ns, "{$key}/{$code}");
                 }
             }
         }
         $lb->execute();
         foreach ($changes as $code => $subchanges) {
             foreach ($subchanges as $type => $messages) {
                 foreach ($messages as $params) {
                     $change = $this->formatChange($group, $code, $type, $params, $limit);
                     $out->addHtml($change);
                     if ($limit <= 0) {
                         // We need to restrict the changes per page per form submission
                         // limitations as well as performance.
                         $out->wrapWikiMsg("<div class=warning>\n\$1\n</div>", 'translate-smg-more');
                         break 4;
                     }
                 }
             }
         }
     }
     $attribs = array('type' => 'submit', 'class' => 'mw-translate-smg-submit');
     if (!$allowed) {
         $attribs['disabled'] = 'disabled';
         $attribs['title'] = $this->msg('translate-smg-notallowed')->text();
     }
     $button = Html::element('button', $attribs, $this->msg('translate-smg-submit')->text());
     $out->addHtml($button);
     $out->addHtml(Html::closeElement('form'));
 }
示例#17
0
 public static function addModules(OutputPage $out)
 {
     $out->addModules('ext.translate.quickedit');
     // Might be needed, but ajax doesn't load it
     // Globals :(
     /// @todo: remove when 1.17 is no longer supported.
     // The RL module name is different in 1.17 and >1.17
     $diff = new DifferenceEngine();
     $diff->showDiffStyle();
 }
 public static function diffUndo(array $args, array $named)
 {
     if (count($args) !== 1) {
         throw new WrongNumberArgumentsException($args, 'one');
     }
     list($diffContent) = $args;
     $differenceEngine = new \DifferenceEngine();
     $multi = $differenceEngine->getMultiNotice();
     $notice = '';
     if ($diffContent === '') {
         $notice = '<div class="mw-diff-empty">' . wfMessage('diff-empty')->parse() . "</div>\n";
     }
     $differenceEngine->showDiffStyle();
     return self::html($differenceEngine->addHeader($diffContent, wfMessage('flow-undo-latest-revision'), wfMessage('flow-undo-your-text'), $multi, $notice));
 }
示例#19
0
 /**
  * Get a diff between the current contents of the edit box and the
  * version of the page we're editing from.
  *
  * If this is a section edit, we'll replace the section as for final
  * save and then make a comparison.
  */
 function showDiff()
 {
     global $wgUser, $wgContLang, $wgParser, $wgOut;
     $oldtext = $this->mArticle->getRawText();
     $newtext = $this->mArticle->replaceSection($this->section, $this->textbox1, $this->summary, $this->edittime);
     wfRunHooks('EditPageGetDiffText', array($this, &$newtext));
     $popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
     $newtext = $wgParser->preSaveTransform($newtext, $this->mTitle, $wgUser, $popts);
     if ($oldtext !== false || $newtext != '') {
         $oldtitle = wfMsgExt('currentrev', array('parseinline'));
         $newtitle = wfMsgExt('yourtext', array('parseinline'));
         $de = new DifferenceEngine($this->mArticle->getContext());
         $de->setText($oldtext, $newtext);
         $difftext = $de->getDiff($oldtitle, $newtitle);
         $de->showDiffStyle();
     } else {
         $difftext = '';
     }
     $wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</div>');
 }
 /**
  * @param $id
  * @return mixed
  */
 function showDetails($id)
 {
     $out = $this->getOutput();
     $dbr = wfGetDB(DB_SLAVE);
     $row = $dbr->selectRow(array('abuse_filter_log', 'abuse_filter'), '*', array('afl_id' => $id), __METHOD__, array(), array('abuse_filter' => array('LEFT JOIN', 'af_id=afl_filter')));
     if (!$row) {
         return;
     }
     if (AbuseFilter::decodeGlobalName($row->afl_filter)) {
         $filter_hidden = null;
     } else {
         $filter_hidden = $row->af_hidden;
     }
     if (!self::canSeeDetails($row->afl_filter, $filter_hidden)) {
         $out->addWikiMsg('abusefilter-log-cannot-see-details');
         return;
     }
     if (self::isHidden($row) && !self::canSeeHidden()) {
         $out->addWikiMsg('abusefilter-log-details-hidden');
         return;
     }
     $output = Xml::element('legend', null, $this->msg('abusefilter-log-details-legend', $id)->text());
     $output .= Xml::tags('p', null, $this->formatRow($row, false));
     // Load data
     $vars = AbuseFilter::loadVarDump($row->afl_var_dump);
     // Diff, if available
     if ($vars && $vars->getVar('action')->toString() == 'edit') {
         $old_wikitext = $vars->getVar('old_wikitext')->toString();
         $new_wikitext = $vars->getVar('new_wikitext')->toString();
         $diffEngine = new DifferenceEngine($this->getContext());
         $diffEngine->showDiffStyle();
         // Note: generateDiffBody has been deprecated in favour of generateTextDiffBody in 1.21 but we can't use it for b/c
         $formattedDiff = $diffEngine->generateDiffBody($old_wikitext, $new_wikitext);
         $formattedDiff = $diffEngine->addHeader($formattedDiff, '', '');
         $output .= Xml::tags('h3', null, $this->msg('abusefilter-log-details-diff')->parse());
         $output .= $formattedDiff;
     }
     $output .= Xml::element('h3', null, $this->msg('abusefilter-log-details-vars')->text());
     // Build a table.
     $output .= AbuseFilter::buildVarDumpTable($vars);
     if (self::canSeePrivate()) {
         // Private stuff, like IPs.
         $header = Xml::element('th', null, $this->msg('abusefilter-log-details-var')->text()) . Xml::element('th', null, $this->msg('abusefilter-log-details-val')->text());
         $output .= Xml::element('h3', null, $this->msg('abusefilter-log-details-private')->text());
         $output .= Xml::openElement('table', array('class' => 'wikitable mw-abuselog-private', 'style' => 'width: 80%;')) . Xml::openElement('tbody');
         $output .= $header;
         // IP address
         $output .= Xml::tags('tr', null, Xml::element('td', array('style' => 'width: 30%;'), $this->msg('abusefilter-log-details-ip')->text()) . Xml::element('td', null, $row->afl_ip));
         $output .= Xml::closeElement('tbody') . Xml::closeElement('table');
     }
     $output = Xml::tags('fieldset', null, $output);
     $out->addHTML($output);
 }
 /**
  * Adds stable version tags to page when editing
  */
 public function addToEditView(EditPage $editPage)
 {
     global $wgParser;
     $reqUser = $this->getUser();
     $this->load();
     # Must be reviewable. UI may be limited to unobtrusive patrolling system.
     if (!$this->article->isReviewable()) {
         return true;
     }
     $items = array();
     # Show stabilization log
     $log = $this->stabilityLogNotice();
     if ($log) {
         $items[] = $log;
     }
     # Check the newest stable version
     $frev = $this->article->getStableRev();
     if ($frev) {
         $quality = $frev->getQuality();
         # Find out revision id of base version
         $latestId = $this->article->getLatest();
         $revId = $editPage->oldid ? $editPage->oldid : $latestId;
         # Let users know if their edit will have to be reviewed.
         # Note: if the log excerpt was shown then this is redundant.
         if (!$log && $this->editWillRequireReview($editPage)) {
             $items[] = wfMsgExt('revreview-editnotice', 'parseinline');
         }
         # Add a notice if there are pending edits...
         if ($this->article->revsArePending()) {
             $revsSince = $this->article->getPendingRevCount();
             $items[] = FlaggedRevsXML::pendingEditNotice($this->article, $frev, $revsSince);
         }
         # Show diff to stable, to make things less confusing.
         # This can be disabled via user preferences and other conditions...
         if ($frev->getRevId() < $latestId && $reqUser->getBoolOption('flaggedrevseditdiffs') && $revId == $latestId && $editPage->section != 'new' && $editPage->formtype != 'diff') {
             # Left diff side...
             $leftNote = $quality ? 'revreview-hist-quality' : 'revreview-hist-basic';
             $lClass = FlaggedRevsXML::getQualityColor((int) $quality);
             $leftNote = "<span class='{$lClass}'>[" . wfMsgHtml($leftNote) . "]</span>";
             # Right diff side...
             $rClass = FlaggedRevsXML::getQualityColor(false);
             $rightNote = "<span class='{$rClass}'>[" . wfMsgHtml('revreview-hist-pending') . "]</span>";
             # Get the stable version source
             $text = $frev->getRevText();
             # Are we editing a section?
             $section = $editPage->section == "" ? false : intval($editPage->section);
             if ($section !== false) {
                 $text = $wgParser->getSection($text, $section);
             }
             if ($text !== false && strcmp($text, $editPage->textbox1) !== 0) {
                 $diffEngine = new DifferenceEngine($this->article->getTitle());
                 $diffBody = $diffEngine->generateDiffBody($text, $editPage->textbox1);
                 $diffHtml = wfMsgExt('review-edit-diff', 'parseinline') . ' ' . FlaggedRevsXML::diffToggle() . "<div id='mw-fr-stablediff'>" . self::getFormattedDiff($diffBody, '', $leftNote, $rightNote) . "</div>\n";
                 $items[] = $diffHtml;
                 $diffEngine->showDiffStyle();
                 // add CSS
             }
         }
         # Output items
         if (count($items)) {
             $html = "<table class='flaggedrevs_editnotice plainlinks'>";
             foreach ($items as $item) {
                 $html .= '<tr><td>' . $item . '</td></tr>';
             }
             $html .= '</table>';
             $this->out->addHTML($html);
         }
     }
     return true;
 }
	/**
	 * Displays the sections and changes for the user to review
	 * @param $page TranslatablePage
	 * @param $sections array
	 */
	public function showPage( TranslatablePage $page, Array $sections ) {
		global $wgOut, $wgContLang;

		$wgOut->setSubtitle( $this->user->getSkin()->link( $page->getTitle() ) );
		$wgOut->addModules( 'ext.translate.special.pagetranslation' );

		$wgOut->addWikiMsg( 'tpt-showpage-intro' );

		$formParams = array(
			'method' => 'post',
			'action' => $this->getTitle()->getFullURL(),
			'class'  => 'mw-tpt-sp-markform',
		);

		$wgOut->addHTML(
			Xml::openElement( 'form', $formParams ) .
			Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
			Html::hidden( 'revision', $page->getRevision() ) .
			Html::hidden( 'target', $page->getTitle()->getPrefixedtext() ) .
			Html::hidden( 'token', $this->user->editToken() )
		);

		$wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-oldnew' );

		$diffOld = wfMsgHtml( 'tpt-diff-old' );
		$diffNew = wfMsgHtml( 'tpt-diff-new' );

		foreach ( $sections as $s ) {
			if ( $s->type === 'new' ) {
				$input = Xml::input( 'tpt-sect-' . $s->id, 15, $s->name );
				$name = wfMsgHtml( 'tpt-section-new', $input );
			} else {
				$name = wfMsgHtml( 'tpt-section', htmlspecialchars( $s->name ) );
			}

			if ( $s->type === 'changed' ) {
				$diff = new DifferenceEngine;
				if ( method_exists( 'DifferenceEngine', 'setTextLanguage' ) ) {
					$diff->setTextLanguage( $wgContLang );
				}
				$diff->setReducedLineNumbers();
				$diff->setText( $s->getOldText(), $s->getText() );
				$text = $diff->getDiff( $diffOld, $diffNew );
				$diffOld = $diffNew = null;
				$diff->showDiffStyle();

				$id = "tpt-sect-{$s->id}-action-nofuzzy";
				$text = Xml::checkLabel( wfMsg( 'tpt-action-nofuzzy' ), $id, $id, false ) . $text;
			} else {
				$text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() );
			}

			# For changed text, the language is set by $diff->setTextLanguage()
			$lang = $s->type === 'changed' ? null : $wgContLang;
			$wgOut->addHTML( MessageWebImporter::makeSectionElement( $name, $s->type, $text, $lang ) );
		}

		$deletedSections = $page->getParse()->getDeletedSections();
		if ( count( $deletedSections ) ) {
			$wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-deleted' );

			foreach ( $deletedSections as $s ) {
				$name = wfMsgHtml( 'tpt-section-deleted', htmlspecialchars( $s->id ) );
				$text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() );
				$wgOut->addHTML( MessageWebImporter::makeSectionElement( $name, $s->type, $text, $wgContLang ) );
			}
		}

		// Display template changes if applicable
		if ( $page->getMarkedTag() !== false ) {
			$newTemplate = $page->getParse()->getTemplatePretty();
			$oldPage = TranslatablePage::newFromRevision( $page->getTitle(), $page->getMarkedTag() );
			$oldTemplate = $oldPage->getParse()->getTemplatePretty();

			if ( $oldTemplate !== $newTemplate ) {
				$wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-template' );

				$diff = new DifferenceEngine;
				if ( method_exists( 'DifferenceEngine', 'setTextLanguage' ) ) {
					$diff->setTextLanguage( $wgContLang );
				}
				$diff->setText( $oldTemplate, $newTemplate );
				$text = $diff->getDiff( wfMsgHtml( 'tpt-diff-old' ), wfMsgHtml( 'tpt-diff-new' ) );
				$diff->showDiffStyle();
				$diff->setReducedLineNumbers();

				$contentParams = array( 'class' => 'mw-tpt-sp-content' );
				$wgOut->addHTML( Xml::tags( 'div', $contentParams, $text ) );
			}
		}

		$wgOut->addHTML(
			Xml::submitButton( wfMsg( 'tpt-submit' ) ) .
			Xml::closeElement( 'form' )
		);
	}