当前位置: 首页>>代码示例>>PHP>>正文


PHP DifferenceEngine::generateDiffBody方法代码示例

本文整理汇总了PHP中DifferenceEngine::generateDiffBody方法的典型用法代码示例。如果您正苦于以下问题:PHP DifferenceEngine::generateDiffBody方法的具体用法?PHP DifferenceEngine::generateDiffBody怎么用?PHP DifferenceEngine::generateDiffBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DifferenceEngine的用法示例。


在下文中一共展示了DifferenceEngine::generateDiffBody方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetDiff

 public function testGetDiff()
 {
     $engine = new DifferenceEngine();
     $textA = 'foo';
     $textB = 'foobar';
     $diff = $engine->generateDiffBody($textA, $textB);
     $this->assertContains('<span class="diffchange diffchange-inline">foo</span>', $diff);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:DiffEngineTest.php

示例2: addToEditView

 /**
  * 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;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:73,代码来源:FlaggablePageView.php

示例3: showDiff

 /**
  * 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");
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:SpecialUndelete.php

示例4: showDiff

 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);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:HideRevision_body.php

示例5: showDiff

 /**
  * 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");
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:14,代码来源:SpecialUndelete.php

示例6: showDetails

 /**
  * @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);
 }
开发者ID:aahashderuffy,项目名称:extensions,代码行数:57,代码来源:SpecialAbuseLog.php

示例7: showDetails

 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);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:49,代码来源:SpecialAbuseLog.php

示例8: statusInterface

	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 );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:74,代码来源:SpecialPremoderation.php


注:本文中的DifferenceEngine::generateDiffBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。