本文整理汇总了PHP中DifferenceEngine::setText方法的典型用法代码示例。如果您正苦于以下问题:PHP DifferenceEngine::setText方法的具体用法?PHP DifferenceEngine::setText怎么用?PHP DifferenceEngine::setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DifferenceEngine
的用法示例。
在下文中一共展示了DifferenceEngine::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHtmlDiff
/**
* Gets the HTML of the diff that MediaWiki displays to the user.
*/
public function getHtmlDiff($pageTitle, $oldText, $newText)
{
$de = new DifferenceEngine($pageTitle);
$de->setText($oldText, $newText);
$difftext = $de->getDiff("Old", "New");
return $difftext;
}
示例2: showEditForm
//.........这里部分代码省略.........
} else {
// Hide the toolbar and edit area, user can click preview to get it back
// Add an confirmation checkbox and explanation.
$toolbar = '';
$recreate = '<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>';
}
}
$tabindex = 2;
$checkboxes = $this->getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis, 'want_traditional_editor' => $this->userWantsTraditionalEditor));
$checkboxhtml = implode($checkboxes, "\n");
$buttons = $this->getEditButtons($tabindex);
$buttonshtml = implode($buttons, "\n");
$safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1');
$wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
if (is_callable($formCallback)) {
call_user_func_array($formCallback, array(&$wgOut));
}
wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
// Put these up at the top to ensure they aren't lost on early form submission
$this->showFormBeforeText();
$wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
{$this->editFormTextBeforeContent}
END
);
if ($this->isConflict || $this->diff) {
# MeanEditor: should be redundant, but let's be sure
$this->noVisualEditor = true;
}
# MeanEditor: also apply htmlspecialchars? See $encodedtext
$html_text = $this->safeUnicodeOutput($this->textbox1);
if (!($this->noVisualEditor || $this->userWantsTraditionalEditor)) {
$this->noVisualEditor = wfRunHooks('EditPage::wiki2html', array($this->mArticle, $wgUser, &$this, &$html_text));
}
if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
$this->noVisualEditor = wfRunHooks('EditPage::showBox', array(&$this, $html_text, $rows, $cols, $ew));
}
if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
$wgOut->addHTML("<input type='hidden' value=\"0\" name=\"wpNoVisualEditor\" />\n");
} else {
$wgOut->addHTML("<input type='hidden' value=\"1\" name=\"wpNoVisualEditor\" />\n");
$this->showTextbox1($classes);
}
$wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
$wgOut->addHTML(<<<END
{$this->editFormTextAfterWarn}
{$metadata}
{$editsummary}
{$summarypreview}
{$checkboxhtml}
{$safemodehtml}
END
);
$wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
/**
* To make it harder for someone to slip a user a page
* which submits an edit form to the wiki without their
* knowledge, a random token is associated with the login
* session. If it's not passed back with the submission,
* we won't save the page, or render user JavaScript and
* CSS previews.
*
* For anon editors, who may not have a session, we just
* include the constant suffix to prevent editing from
* broken text-mangling proxies.
*/
$token = htmlspecialchars($wgUser->editToken());
$wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
$this->showEditTools();
$wgOut->addHTML(<<<END
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
<div class='hiddencats'>
{$formattedhiddencats}
</div>
END
);
if ($this->isConflict && wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
$wgOut->wrapWikiMsg('==$1==', "yourdiff");
$de = new DifferenceEngine($this->mTitle);
$de->setText($this->textbox2, $this->textbox1);
$de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
$wgOut->wrapWikiMsg('==$1==', "yourtext");
$this->showTextbox2();
}
$wgOut->addHTML($this->editFormTextBottom);
$wgOut->addHTML("</form>\n");
if (!$wgUser->getOption('previewontop')) {
$this->displayPreviewArea($previewOutput, false);
}
wfProfileOut($fname);
}
示例3: makeADifference
function makeADifference($text, $title, $section)
{
global $wgOut;
/* make an article object */
$rtitle = Title::newFromText($title);
$rarticle = new Article($rtitle, $rtitle->getArticleID());
$epage = new EditPage($rarticle);
$epage->section = $section;
/* customized getDiff from EditPage */
$oldtext = $epage->mArticle->fetchContent();
$edittime = $epage->mArticle->getTimestamp();
$newtext = $epage->mArticle->replaceSection($section, $text, '', $edittime);
$newtext = $epage->mArticle->preSaveTransform($newtext);
$oldtitle = wfMsgExt('currentrev', array('parseinline'));
$newtitle = wfMsgExt('yourtext', array('parseinline'));
if ($oldtext !== false || $newtext != '') {
$de = new DifferenceEngine($epage->mTitle);
$de->setText($oldtext, $newtext);
$difftext = $de->getDiff($oldtitle, $newtitle);
} else {
$difftext = '';
}
$diffdiv = '<div id="wikiDiff">' . $difftext . '</div>';
$wgOut->addHTML($diffdiv);
}
示例4: perform
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);
}
}
示例5: extractRowInfo
//.........这里部分代码省略.........
$vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
} else {
$vals['sha1'] = '';
}
}
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
$vals['commenthidden'] = '';
} else {
$comment = $revision->getComment();
if ($this->fld_comment) {
$vals['comment'] = $comment;
}
if ($this->fld_parsedcomment) {
$vals['parsedcomment'] = Linker::formatComment($comment, $title);
}
}
}
if ($this->fld_tags) {
if ($row->ts_tags) {
$tags = explode(',', $row->ts_tags);
$this->getResult()->setIndexedTagName($tags, 'tag');
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
if (!is_null($this->token)) {
$tokenFunctions = $this->getTokenFunctions();
foreach ($this->token as $t) {
$val = call_user_func($tokenFunctions[$t], $title->getArticleID(), $title, $revision);
if ($val === false) {
$this->setWarning("Action '{$t}' is not allowed for the current user");
} else {
$vals[$t . 'token'] = $val;
}
}
}
$text = null;
global $wgParser;
if ($this->fld_content || !is_null($this->difftotext)) {
$text = $revision->getText();
// Expand templates after getting section content because
// template-added sections don't count and Parser::preprocess()
// will have less input
if ($this->section !== false) {
$text = $wgParser->getSection($text, $this->section, false);
if ($text === false) {
$this->dieUsage("There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection');
}
}
}
if ($this->fld_content && !$revision->isDeleted(Revision::DELETED_TEXT)) {
if ($this->generateXML) {
$wgParser->startExternalParse($title, ParserOptions::newFromContext($this->getContext()), OT_PREPROCESS);
$dom = $wgParser->preprocessToDom($text);
if (is_callable(array($dom, 'saveXML'))) {
$xml = $dom->saveXML();
} else {
$xml = $dom->__toString();
}
$vals['parsetree'] = $xml;
}
if ($this->expandTemplates && !$this->parseContent) {
$text = $wgParser->preprocess($text, $title, ParserOptions::newFromContext($this->getContext()));
}
if ($this->parseContent) {
$text = $wgParser->parse($text, $title, ParserOptions::newFromContext($this->getContext()))->getText();
}
ApiResult::setContent($vals, $text);
} elseif ($this->fld_content) {
$vals['texthidden'] = '';
}
if (!is_null($this->diffto) || !is_null($this->difftotext)) {
global $wgAPIMaxUncachedDiffs;
static $n = 0;
// Number of uncached diffs we've had
if ($n < $wgAPIMaxUncachedDiffs) {
$vals['diff'] = array();
$context = new DerivativeContext($this->getContext());
$context->setTitle($title);
if (!is_null($this->difftotext)) {
$engine = new DifferenceEngine($context);
$engine->setText($text, $this->difftotext);
} else {
$engine = new DifferenceEngine($context, $revision->getID(), $this->diffto);
$vals['diff']['from'] = $engine->getOldid();
$vals['diff']['to'] = $engine->getNewid();
}
$difftext = $engine->getDiffBody();
ApiResult::setContent($vals['diff'], $difftext);
if (!$engine->wasCacheHit()) {
$n++;
}
} else {
$vals['diff']['notcached'] = '';
}
}
return $vals;
}
示例6: execute
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" );
//.........这里部分代码省略.........
示例7: spamPageWithContent
/**
* Show "your edit contains spam" page with your diff and text
*
* @param $match Text which triggered one or more filters
*/
public function spamPageWithContent($match = false)
{
global $wgOut;
$this->textbox2 = $this->textbox1;
$wgOut->prepareErrorPage(wfMessage('spamprotectiontitle'));
$wgOut->addHTML('<div id="spamprotected">');
$wgOut->addWikiMsg('spamprotectiontext');
if ($match) {
$wgOut->addWikiMsg('spamprotectionmatch', wfEscapeWikiText($match));
}
$wgOut->addHTML('</div>');
$wgOut->wrapWikiMsg('<h2>$1</h2>', "yourdiff");
$de = new DifferenceEngine($this->mArticle->getContext());
$de->setText($this->getCurrentText(), $this->textbox2);
$de->showDiff(wfMsg("storedversion"), wfMsgExt('yourtext', 'parseinline'));
$wgOut->wrapWikiMsg('<h2>$1</h2>', "yourtext");
$this->showTextbox2();
$wgOut->addReturnTo($this->getContextTitle(), array('action' => 'edit'));
}
示例8: getLastDiff
protected function getLastDiff()
{
// Shortcuts
$title = $this->handle->getTitle();
$latestRevId = $title->getLatestRevID();
$previousRevId = $title->getPreviousRevisionID($latestRevId);
$latestRev = Revision::newFromTitle($title, $latestRevId);
$previousRev = Revision::newFromTitle($title, $previousRevId);
$diffText = '';
if ($latestRev && $previousRev) {
$latest = $latestRev->getText();
$previous = $previousRev->getText();
if ($previous !== $latest) {
$diff = new DifferenceEngine();
if (method_exists('DifferenceEngine', 'setTextLanguage')) {
$diff->setTextLanguage($this->getTargetLanguage());
}
$diff->setText($previous, $latest);
$diff->setReducedLineNumbers();
$diff->showDiffStyle();
$diffText = $diff->getDiff(false, false);
}
}
if (!$latestRev) {
return null;
}
global $wgUser;
$user = $latestRev->getUserText(Revision::FOR_THIS_USER, $wgUser);
$comment = $latestRev->getComment();
if ($diffText === '') {
if (strval($comment) !== '') {
$text = wfMessage('translate-dynagroup-byc', $user, $comment)->escaped();
} else {
$text = wfMessage('translate-dynagroup-by', $user)->escaped();
}
} else {
if (strval($comment) !== '') {
$text = wfMessage('translate-dynagroup-lastc', $user, $comment)->escaped();
} else {
$text = wfMessage('translate-dynagroup-last', $user)->escaped();
}
}
return TranslateUtils::fieldset($text, $diffText, array('class' => 'mw-sp-translate-latestchange'));
}
示例9: getDiff
/**
* 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.
*
* @return string HTML
*/
function getDiff()
{
$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);
} else {
$difftext = '';
}
return '<div id="wikiDiff">' . $difftext . '</div>';
}
示例10: showConflict
protected function showConflict()
{
if (wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$this->out))) {
// diff
$this->out->addHtml('<div id="diff">');
$this->out->wrapWikiMsg('<h2>$1</h2>', 'editpagelayout-diff-header');
$de = new DifferenceEngine($this->mTitle);
$de->setText($this->textbox2, $this->textbox1);
$de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
$this->out->addHtml('</div>');
// user's edit
$this->out->addHtml('<div id="myedit">');
$this->out->wrapWikiMsg('<h2>$1</h2>', 'editpagelayout-myedit-header');
$this->showTextbox2();
$this->out->addHtml('</div>');
}
}
示例11: showDiff
/**
* 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);
wfRunHooks('EditPageGetDiffText', array($this, &$newtext));
$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>');
}
示例12: showEditForm
//.........这里部分代码省略.........
$recreate = '';
if ($this->deletedSinceEdit) {
if ('save' != $this->formtype) {
$wgOut->addWikiText(wfMsg('deletedwhileediting'));
} else {
// Hide the toolbar and edit area, use can click preview to get it back
// Add an confirmation checkbox and explanation.
$toolbar = '';
$hidden = 'type="hidden" style="display:none;"';
$recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
$recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
}
}
$tabindex = 2;
$checkboxes = self::getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
$checkboxhtml = implode($checkboxes, "\n");
$button_action = 'mv_do_ajax_form_submit(\'' . $this->mvd_id . '\', \'%s\');';
$buttons = $this->getEditButtons($tabindex, $button_action);
$buttonshtml = implode($buttons, "\n");
$safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Html::Hidden('safemode', '1');
$wgOut->addHTML(<<<END
{$toolbar}
END
);
// remove form because set earlier
// <form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
if (is_callable($formCallback)) {
call_user_func_array($formCallback, array(&$wgOut));
}
wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
// Put these up at the top to ensure they aren't lost on early form submission
$wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
$wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
<textarea class="mv_ajax_textarea" tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}' {$ew} {$hidden}>
END
. htmlspecialchars($this->safeUnicodeOutput($this->stripped_edit_text)) . "\n</textarea>\n\t\t");
// close advanced display_edit div
$wgOut->addHTML("</div>");
// $wgOut->addWikiText( $copywarn );
$wgOut->addHTML($this->editFormTextAfterWarn);
$separator = wfMsgExt('pipe-separator', 'escapenoentities');
$wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$summarypreview}\n{$checkboxhtml}\n{$safemodehtml}\n");
$wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
$wgOut->addHTML('<div class="mw-editTools">');
$wgOut->addWikiText(wfMsgForContent('edittools'));
$wgOut->addHTML('</div>');
$wgOut->addHTML($this->editFormTextAfterTools);
$wgOut->addHTML("\n<div class='templatesUsed'>\n{$formattedtemplates}\n</div>\n");
/**
* To make it harder for someone to slip a user a page
* which submits an edit form to the wiki without their
* knowledge, a random token is associated with the login
* session. If it's not passed back with the submission,
* we won't save the page, or render user JavaScript and
* CSS previews.
*
* For anon editors, who may not have a session, we just
* include the constant suffix to prevent editing from
* broken text-mangling proxies.
*/
$token = htmlspecialchars($wgUser->editToken());
$wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
# If a blank edit summary was previously provided, and the appropriate
# user preference is active, pass a hidden tag here. This will stop the
# user being bounced back more than once in the event that a summary
# is not required.
if ($this->missingSummary) {
$wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
}
# For a bit more sophisticated detection of blank summaries, hash the
# automatic one and pass that in a hidden field.
$autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
$wgOut->addHTML(Html::Hidden('wpAutoSummary', $autosumm));
if ($this->isConflict) {
$wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
$de = new DifferenceEngine($this->mTitle);
$de->setText($this->textbox2, $this->stripped_edit_text);
$de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
$wgOut->addWikiText('==' . wfMsg("yourtext") . '==');
$wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
}
$wgOut->addHTML($this->editFormTextBottom);
$wgOut->addHTML("</form>\n");
if (!$wgUser->getOption('previewontop')) {
if ($this->formtype == 'preview') {
$this->showPreview($previewOutput);
} else {
$wgOut->addHTML('<div id="wikiPreview"></div>');
}
if ($this->formtype == 'diff') {
$this->showDiff();
}
}
$wgOut->addHTML($closeFormHtml);
wfProfileOut($fname);
}
示例13: showConflict
/**
* Show an edit conflict. textbox1 is already shown in showEditForm().
* If you want to use another entry point to this function, be careful.
*/
protected function showConflict()
{
global $wgOut;
if (wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
$wgOut->wrapWikiMsg('<h2>$1</h2>', "yourdiff");
$de = new DifferenceEngine($this->mArticle->getContext());
$de->setText($this->textbox2, $this->textbox1);
$de->showDiff(wfMessage('yourtext')->parse(), wfMessage('storedversion')->text());
$wgOut->wrapWikiMsg('<h2>$1</h2>', "yourtext");
$this->showTextbox2();
}
}
示例14: importForm
/**
* @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) {
//.........这里部分代码省略.........
示例15: showEditForm
//.........这里部分代码省略.........
}
$hidden = '';
$recreate = '';
if ($this->deletedSinceEdit) {
if ('save' != $this->formtype) {
$wgOut->addWikiText(wfMsg('deletedwhileediting'));
} else {
// Hide the toolbar and edit area, use can click preview to get it back
// Add an confirmation checkbox and explanation.
$toolbar = '';
$hidden = 'type="hidden" style="display:none;"';
$recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
$recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
}
}
$temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => '5', 'value' => wfMsg('savearticle'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('tooltip-save'));
$buttons['save'] = Xml::element('input', $temp, '');
$temp = array('id' => 'wpDiff', 'name' => 'wpDiff', 'type' => 'submit', 'tabindex' => '7', 'value' => wfMsg('showdiff'), 'accesskey' => wfMsg('accesskey-diff'), 'title' => wfMsg('tooltip-diff'));
$buttons['diff'] = Xml::element('input', $temp, '');
global $wgLivePreview;
if ($wgLivePreview && $wgUser->getOption('uselivepreview')) {
$temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => '', 'title' => wfMsg('tooltip-preview'), 'style' => 'display: none;');
$buttons['preview'] = Xml::element('input', $temp, '');
$temp = array('id' => 'wpLivePreview', 'name' => 'wpLivePreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showlivepreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => '', 'onclick' => $this->doLivePreviewScript());
$buttons['live'] = Xml::element('input', $temp, '');
} else {
$temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview'));
$buttons['preview'] = Xml::element('input', $temp, '');
$buttons['live'] = '';
}
$safemodehtml = $this->checkUnicodeCompliantBrowser() ? "" : "<input type='hidden' name=\"safemode\" value='1' />\n";
$wgOut->addHTML(<<<END
<form id="editform" name="editform" method="post" action="{$action}"
enctype="multipart/form-data">
END
);
if (is_callable($formCallback)) {
call_user_func_array($formCallback, array(&$wgOut));
}
// Put these up at the top to ensure they aren't lost on early form submission
$wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
$this->addStructureFields();
$wgOut->addHTML(<<<END
{$toolbar}
{$recreate}
{$commentsubject}
<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew} {$hidden}>
END
. htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t");
$wgOut->addWikiText($copywarn);
$wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$checkboxhtml}\n{$safemodehtml}\n");
$wgOut->addHTML("\n<div class='editButtons'>\n\t{$buttons['save']}\n\t{$buttons['preview']}\n\t{$buttons['live']}\n\t{$buttons['diff']}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
$wgOut->addWikiText(wfMsgForContent('edittools'));
$wgOut->addHTML("\n<div class='templatesUsed'>\n{$templates}\n</div>\n");
if ($wgUser->isLoggedIn()) {
/**
* To make it harder for someone to slip a user a page
* which submits an edit form to the wiki without their
* knowledge, a random token is associated with the login
* session. If it's not passed back with the submission,
* we won't save the page, or render user JavaScript and
* CSS previews.
*/
$token = htmlspecialchars($wgUser->editToken());
$wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
}
# If a blank edit summary was previously provided, and the appropriate
# user preference is active, pass a hidden tag here. This will stop the
# user being bounced back more than once in the event that a summary
# is not required.
if ($this->missingSummary) {
$wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
}
# For a bit more sophisticated detection of blank summaries, hash the
# automatic one and pass that in a hidden field.
$autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
$wgOut->addHTML("<input type=\"hidden\" name=\"wpAutoSummary\" value=\"{$autosumm}\" />\n");
if ($this->isConflict) {
require_once "DifferenceEngine.php";
$wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
$de = new DifferenceEngine($this->mTitle);
$de->setText($this->textbox2, $this->textbox1);
$de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
$wgOut->addWikiText('==' . wfMsg("yourtext") . '==');
$wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
}
$wgOut->addHTML("</form>\n");
if (!$wgUser->getOption('previewontop')) {
if ($this->formtype == 'preview') {
$this->showPreview();
} else {
$wgOut->addHTML('<div id="wikiPreview"></div>');
}
if ($this->formtype == 'diff') {
$wgOut->addHTML($this->getDiff());
}
}
wfProfileOut($fname);
}