本文整理汇总了PHP中Diff::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Diff::load方法的具体用法?PHP Diff::load怎么用?PHP Diff::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diff
的用法示例。
在下文中一共展示了Diff::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: diff
/**
* Generate a diff between two or three revision IDs
*
* @access public
* @param string $method Revision method. Options: unified, inline, context, threeway, raw (default: 'unified')
* @param mixed $rev1
* @param mixed $rev2
* @param mixed $rev3
* @return string|bool False on failure
* @see Diff::load
*
* @fixme: this uses Diff::load, which has been deprecated and Plugin removed from codebase
*/
public function diff($method = 'unified', $rev1, $rev2, $rev3 = null)
{
$r1array = array('action' => 'query', 'prop' => 'revisions', 'revids' => $rev1, 'rvprop' => 'content');
$r2array = array('action' => 'query', 'prop' => 'revisions', 'revids' => $rev2, 'rvprop' => 'content');
$r3array = array('action' => 'query', 'prop' => 'revisions', 'revids' => $rev3, 'rvprop' => 'content');
Hooks::runHook('PreDiff', array(&$r1array, &$r2array, &$r3array, &$method));
$r1text = $r2text = $r3text = null;
if (!is_null($rev3)) {
pecho("Getting {$method} diff of revisions {$rev1}, {$rev2}, and {$rev3}...\n\n", PECHO_NORMAL);
$r3 = $this->apiQuery($r3array);
if (isset($r3['query']['badrevids'])) {
pecho("A bad third revision ID was passed.\n\n", PECHO_FATAL);
return false;
}
foreach ($r3['query']['pages'] as $r3pages) {
$r3text = $r3pages['revisions'][0]['*'];
}
} else {
pecho("Getting {$method} diff of revisions {$rev1} and {$rev2}...\n\n", PECHO_NORMAL);
}
$r1 = $this->apiQuery($r1array);
$r2 = $this->apiQuery($r2array);
if (isset($r1['query']['badrevids'])) {
pecho("A bad first revision ID was passed.\n\n", PECHO_FATAL);
return false;
} elseif (isset($r2['query']['badrevids'])) {
pecho("A bad second revision ID was passed.\n\n", PECHO_FATAL);
return false;
} else {
foreach ($r1['query']['pages'] as $r1pages) {
$r1text = $r1pages['revisions'][0]['*'];
}
foreach ($r2['query']['pages'] as $r2pages) {
$r2text = $r2pages['revisions'][0]['*'];
}
if ($method == "raw") {
return array($r1text, $r2text, $r3text);
}
return Diff::load($method, $r1text, $r2text, $r3text);
}
}