public function getRevisionsAround($rev1, $rev2, $max = 50)
{
$max = floor(abs($max) / 2) * 2 + 1;
$rev1 = max($rev1, 0);
$rev2 = max($rev2, 0);
if ($rev2) {
if ($rev2 < $rev1) {
$rev = $rev2;
$rev2 = $rev1;
$rev1 = $rev;
}
} else {
//empty right side means a removed page. Look up last revision.
$revs = $this->getRevisions(-1, 1);
$rev2 = $revs[0];
}
//collect revisions around rev2
list($revs2, $allrevs, $fp, $lines, $head, $tail) = $this->retrieveRevisionsAround($rev2, $max);
if (empty($revs2)) {
return array(array(), array());
}
//collect revisions around rev1
$index = array_search($rev1, $allrevs);
if ($index === false) {
//no overlapping revisions
list($revs1, , , , , ) = $this->retrieveRevisionsAround($rev1, $max);
if (empty($revs1)) {
$revs1 = array();
}
} else {
//revisions overlaps, reuse revisions around rev2
$revs1 = $allrevs;
while ($head > 0) {
for ($i = count($lines) - 1; $i >= 0; $i--) {
$tmp = parseChangelogLine($lines[$i]);
if ($tmp !== false) {
$this->cache[$this->id][$tmp['date']] = $tmp;
$revs1[] = $tmp['date'];
$index++;
if ($index > floor($max / 2)) {
break 2;
}
}
}
list($lines, $head, $tail) = $this->readAdjacentChunk($fp, $head, $tail, -1);
}
sort($revs1);
//return wanted selection
$revs1 = array_slice($revs1, max($index - floor($max / 2), 0), $max);
}
return array(array_reverse($revs1), array_reverse($revs2));
}