本文整理汇总了PHP中Revision::decompressRevisionText方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::decompressRevisionText方法的具体用法?PHP Revision::decompressRevisionText怎么用?PHP Revision::decompressRevisionText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::decompressRevisionText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEdits
public static function getEdits($articleId)
{
$dbr = wfGetDB(DB_SLAVE);
$gr = 0;
$gr = $dbr->selectField('good_revision', array('gr_rev'), array('gr_page' => $articleId));
$edits = self::getSigEdits($gr);
if ($edits) {
return $edits;
}
$res = $dbr->select(array('revision', 'text'), array('rev_id', 'old_text', 'old_flags', 'rev_timestamp', 'rev_user', 'rev_user_text'), array('rev_page' => $articleId, 'rev_text_id = old_id'), __METHOD__, array('order by' => 'rev_timestamp asc'));
$txts = array();
$grTxt = false;
foreach ($res as $row) {
$flags = explode(',', $row->old_flags);
$rowText = Revision::decompressRevisionText($row->old_text, $flags);
$stepsSection = Wikitext::getStepsSection($rowText);
//print("Got txt for rev" . $row->rev_id . "\n");
$txts[] = array('text' => $stepsSection[0], 'rev_page' => $row->rev_page, 'rev_id' => $row->rev_id, 'rev_user' => $row->rev_user, 'rev_user_text' => $row->rev_user_text);
if ($row->rev_id == $gr) {
$grTxt = $stepsSection[0];
break;
}
}
if (!$grText) {
$grText = $txts[sizeof($txts) - 1]['text'];
$gr = $txts[sizeof($txts) - 1]['rev_id'];
}
global $wgContLang;
$segmentedGr = $wgContLang->segmentForDiff($grText);
$grArr = explode("\n", $segmentedGr);
$grSize = strlen($segmentedGr) - sizeof($grArr) + 1;
// Amount added
$added = 0;
$edits = array();
$first = true;
$lastAdds = 0;
foreach ($txts as $txt) {
$txtArr = explode("\n", $wgContLang->segmentForDiff($txt['text']));
//print("diff for rev " . $txt['rev_id'] . " " . wfTimestampNow() . "\n");
$diffs = new Diff($txtArr, $grArr);
$adds = 0;
foreach ($diffs as $diff) {
foreach ($diff as $d) {
if ($d->type == 'copy') {
foreach ($d->closing as $cl) {
$adds += strlen($cl);
}
} elseif ($d->type == 'change') {
$wld = new WordLevelDiff($d->orig, $d->closing);
foreach ($wld->edits as $edit) {
if ($edit->type == 'copy') {
foreach ($edit->orig as $o) {
$adds += strlen($o);
}
}
}
}
}
}
if ($adds > $added) {
$newAdded = $adds - $added;
$added = $adds;
} else {
$newAdded = 0;
}
if ($newAdded > 0) {
// First edit or didn't add steps
// This prevents counting the steps section formatting fix as a contributor
if ($first || $lastAdds != 0) {
$edits[] = array('added' => $newAdded, 'gr' => $gr, 'rev' => $txt['rev_id'], 'page' => $txt['page_id'], 'user' => $txt['rev_user'], 'username' => $txt['rev_user_text']);
}
}
$first = false;
$lastAdds = $adds;
}
if ($edits) {
self::saveSigEdits($edits);
}
return $edits;
}
示例2: getContentRaw
/**
* @return string
*/
public function getContentRaw()
{
if ($this->decompressedContent === null) {
$this->decompressedContent = \Revision::decompressRevisionText($this->content, $this->flags);
}
return $this->decompressedContent;
}