Skip to content

Commit

Permalink
Merge pull request #497 from splitbrain/bot/autofix
Browse files Browse the repository at this point in the history
🤖 Automatic code style fixes
  • Loading branch information
Klap-in authored Oct 25, 2023
2 parents e731542 + c4c9581 commit b8f0fcc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
16 changes: 12 additions & 4 deletions DokuImageProcessorDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ public static function adjustGetImageLinks($file, $orig_srcpath)
$w = 0;
$h = 0;
$rev = '';
if (preg_match('/[?&]w=(\d+)/', $file, $m)) $w = $m[1];
if (preg_match('/[?&]h=(\d+)/', $file, $m)) $h = $m[1];
if (preg_match('/[&?]rev=(\d+)/', $file, $m)) $rev = $m[1];
if (preg_match('/[?&]w=(\d+)/', $file, $m)) {
$w = $m[1];
}
if (preg_match('/[?&]h=(\d+)/', $file, $m)) {
$h = $m[1];
}
if (preg_match('/[&?]rev=(\d+)/', $file, $m)) {
$rev = $m[1];
}

if (media_isexternal($media)) {
$local = media_get_from_URL($media, $ext, -1);
if (!$local) $local = $media; // let mpdf try again
if (!$local) {
$local = $media;
} // let mpdf try again
} else {
$media = cleanID($media);
//check permissions (namespace only)
Expand Down
40 changes: 30 additions & 10 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public function convert(Event $event)

// our event?
$allowedEvents = ['export_pdfbook', 'export_pdf', 'export_pdfns'];
if (!in_array($event->data, $allowedEvents)) return;
if (!in_array($event->data, $allowedEvents)) {
return;
}

try {
//collect pages and check permissions
Expand Down Expand Up @@ -211,7 +213,9 @@ protected function collectExportablePages(Event $event)
if (!empty($excludesns)) {
$result = array_filter($result, function ($item) use ($excludesns) {
foreach ($excludesns as $ns) {
if (strpos($item['id'], $ns . ':') === 0) return false;
if (strpos($item['id'], $ns . ':') === 0) {
return false;
}
}
return true;
});
Expand Down Expand Up @@ -376,7 +380,9 @@ protected function wikiToDW2PDF($id, $rev = '', $date_at = '')
{
$file = wikiFN($id, $rev);

if (!file_exists($file)) return '';
if (!file_exists($file)) {
return '';
}

//ensure $id is in global $ID (needed for parsing)
global $ID;
Expand Down Expand Up @@ -883,8 +889,12 @@ public function getExportedPages()
*/
public function cbDateSort($a, $b)
{
if ($b['rev'] < $a['rev']) return -1;
if ($b['rev'] > $a['rev']) return 1;
if ($b['rev'] < $a['rev']) {
return -1;
}
if ($b['rev'] > $a['rev']) {
return 1;
}
return strcmp($b['id'], $a['id']);
}

Expand Down Expand Up @@ -913,14 +923,22 @@ public function cbPagenameSort($a, $b)
// have we reached the page level?
if ($i === ($countA - 1) || $i === ($countB - 1)) {
// start page first
if ($partA == $conf['start']) return -1;
if ($partB == $conf['start']) return 1;
if ($partA == $conf['start']) {
return -1;
}
if ($partB == $conf['start']) {
return 1;
}
}

// prefer page over namespace
if ($partA === $partB) {
if (!isset($partsA[$i + 1])) return -1;
if (!isset($partsB[$i + 1])) return 1;
if (!isset($partsA[$i + 1])) {
return -1;
}
if (!isset($partsB[$i + 1])) {
return 1;
}
continue;
}

Expand Down Expand Up @@ -1094,7 +1112,9 @@ protected function getDocumentLanguage($pageid)
$trans = plugin_load('helper', 'translation');
if ($trans) {
$tr = $trans->getLangPart($pageid);
if ($tr) $lang = $tr;
if ($tr) {
$lang = $tr;
}
}

return $lang;
Expand Down
8 changes: 6 additions & 2 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function document_start()
*/
public function canRender($format)
{
if ($format == 'xhtml') return true;
if ($format == 'xhtml') {
return true;
}
return false;
}

Expand All @@ -70,7 +72,9 @@ public function canRender($format)
*/
public function header($text, $level, $pos, $returnonly = false)
{
if (!$text) return; //skip empty headlines
if (!$text) {
return;
} //skip empty headlines
global $ID;

$hid = $this->_headerToLink($text, true);
Expand Down

0 comments on commit b8f0fcc

Please sign in to comment.