aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2023-09-25 00:10:01 +0200
committerGerrit Uitslag <klapinklapin@gmail.com>2023-09-25 00:10:01 +0200
commit851600592bbc8267f78bad982a3c48fc5a00b15f (patch)
treeec81b7411536fb14d4680b88d7563ed7875873f8
parenta835c93a8c9175f580c05a0aeb56b7664f5e8435 (diff)
downloaddokuwiki-851600592bbc8267f78bad982a3c48fc5a00b15f.tar.gz
dokuwiki-851600592bbc8267f78bad982a3c48fc5a00b15f.zip
little refactoring
-rw-r--r--inc/ChangeLog/ChangeLog.php28
-rw-r--r--inc/ChangeLog/RevisionInfo.php4
-rw-r--r--inc/Ui/PageDiff.php24
3 files changed, 37 insertions, 19 deletions
diff --git a/inc/ChangeLog/ChangeLog.php b/inc/ChangeLog/ChangeLog.php
index 442c9e719..4f138c806 100644
--- a/inc/ChangeLog/ChangeLog.php
+++ b/inc/ChangeLog/ChangeLog.php
@@ -158,7 +158,7 @@ abstract class ChangeLog
}
// check if it's already in the memory cache
- if (isset($this->cache[$this->id]) && isset($this->cache[$this->id][$rev])) {
+ if (isset($this->cache[$this->id][$rev])) {
return $this->cache[$this->id][$rev];
}
@@ -173,10 +173,8 @@ abstract class ChangeLog
foreach ($lines as $line) {
$this->parseAndCacheLogLine($line);
}
- if (!isset($this->cache[$this->id][$rev])) {
- return false;
- }
- return $this->cache[$this->id][$rev];
+
+ return $this->cache[$this->id][$rev] ?? false;
}
/**
@@ -430,7 +428,9 @@ abstract class ChangeLog
$revs1[] = $info['date'];
$index++;
- if ($index > (int) ($max / 2)) break 2;
+ if ($index > (int) ($max / 2)) {
+ break 2;
+ }
}
}
@@ -507,10 +507,14 @@ abstract class ChangeLog
if ($info['date'] >= $rev) {
//count revs after reference $rev
$afterCount++;
- if ($afterCount == 1) $beforeCount = count($revs);
+ if ($afterCount == 1) {
+ $beforeCount = count($revs);
+ }
}
//enough revs after reference $rev?
- if ($afterCount > (int) ($max / 2)) break 2;
+ if ($afterCount > (int) ($max / 2)) {
+ break 2;
+ }
}
}
//retrieve next chunk
@@ -546,7 +550,9 @@ abstract class ChangeLog
$revs[] = $info['date'];
$beforeCount++;
//enough revs before reference $rev?
- if ($beforeCount > max((int) ($max / 2), $max - $afterCount)) break 2;
+ if ($beforeCount > max((int) ($max / 2), $max - $afterCount)) {
+ break 2;
+ }
}
}
}
@@ -595,7 +601,9 @@ abstract class ChangeLog
{
global $lang;
- if (isset($this->currentRevision)) return $this->getRevisionInfo($this->currentRevision);
+ if (isset($this->currentRevision)) {
+ return $this->getRevisionInfo($this->currentRevision);
+ }
// get revision id from the item file timestamp and changelog
$fileLastMod = $this->getFilename();
diff --git a/inc/ChangeLog/RevisionInfo.php b/inc/ChangeLog/RevisionInfo.php
index 505261461..9a7553059 100644
--- a/inc/ChangeLog/RevisionInfo.php
+++ b/inc/ChangeLog/RevisionInfo.php
@@ -156,7 +156,9 @@ class RevisionInfo
{
if ($this->val('user')) {
$html = '<bdi>' . editorinfo($this->val('user')) . '</bdi>';
- if (auth_ismanager()) $html .= ' <bdo dir="ltr">(' . $this->val('ip') . ')</bdo>';
+ if (auth_ismanager()) {
+ $html .= ' <bdo dir="ltr">(' . $this->val('ip') . ')</bdo>';
+ }
} else {
$html = '<bdo dir="ltr">' . $this->val('ip') . '</bdo>';
}
diff --git a/inc/Ui/PageDiff.php b/inc/Ui/PageDiff.php
index 155fc9e36..394f295d5 100644
--- a/inc/Ui/PageDiff.php
+++ b/inc/Ui/PageDiff.php
@@ -113,12 +113,15 @@ class PageDiff extends Diff
// read preference from DokuWiki cookie. PageDiff only
$mode = get_doku_pref('difftype', null);
}
- if (in_array($mode, ['inline', 'sidebyside'])) $this->preference['difftype'] = $mode;
+ if (in_array($mode, ['inline', 'sidebyside'])) {
+ $this->preference['difftype'] = $mode;
+ }
if (!$INPUT->has('rev') && !$INPUT->has('rev2')) {
global $INFO, $REV;
- if ($this->id == $INFO['id'])
+ if ($this->id == $INFO['id']) {
$REV = $this->rev1; // store revision back in $REV
+ }
}
}
@@ -373,24 +376,28 @@ class PageDiff extends Diff
*/
$rev1Navi = '';
// move backward both side: ◀◀
- if ($rev1Prev && $rev2Prev)
+ if ($rev1Prev && $rev2Prev) {
$rev1Navi .= $this->diffViewlink('diffbothprevrev', $rev1Prev, $rev2Prev);
+ }
// move backward left side: ◀
- if ($rev1Prev)
+ if ($rev1Prev) {
$rev1Navi .= $this->diffViewlink('diffprevrev', $rev1Prev, $rev2);
+ }
// dropdown
$rev1Navi .= $this->buildDropdownSelector('older', $rev1Options);
// move forward left side: ▶
- if ($rev1Next && ($rev1Next < $rev2))
+ if ($rev1Next && ($rev1Next < $rev2)) {
$rev1Navi .= $this->diffViewlink('diffnextrev', $rev1Next, $rev2);
+ }
/*
* navigation UI for newer revisions / Right side:
*/
$rev2Navi = '';
// move backward right side: ◀
- if ($rev2Prev && ($rev1 < $rev2Prev))
+ if ($rev2Prev && ($rev1 < $rev2Prev)) {
$rev2Navi .= $this->diffViewlink('diffprevrev', $rev1, $rev2Prev);
+ }
// dropdown
$rev2Navi .= $this->buildDropdownSelector('newer', $rev2Options);
// move forward right side: ▶
@@ -402,8 +409,9 @@ class PageDiff extends Diff
}
}
// move forward both side: ▶▶
- if ($rev1Next && $rev2Next)
+ if ($rev1Next && $rev2Next) {
$rev2Navi .= $this->diffViewlink('diffbothnextrev', $rev1Next, $rev2Next);
+ }
return [$rev1Navi, $rev2Navi];
}
@@ -429,7 +437,7 @@ class PageDiff extends Diff
$info['timestamp'] ??= true;
$date = dformat($info['date']);
if ($info['timestamp'] === false) {
- // exteranlly deleted or older file restored
+ // externally deleted or older file restored
$date = preg_replace('/[0-9a-zA-Z]/', '_', $date);
}
$options[$rev] = [