Skip to content

Commit 9730265

Browse files
committed
automatic code style fixes
1 parent 3113520 commit 9730265

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

conf/default.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Default settings for the dbquery plugin
45
*
@@ -9,4 +10,3 @@
910
$conf['dsn'] = '';
1011
$conf['user'] = '';
1112
$conf['pass'] = '';
12-

conf/metadata.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Options for the dbquery plugin
45
*
@@ -9,5 +10,3 @@
910
$meta['dsn'] = [];
1011
$meta['user'] = ['string'];
1112
$meta['pass'] = ['password'];
12-
13-

helper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
use dokuwiki\Extension\Plugin;
4+
35
/**
46
* DokuWiki Plugin dbquery (Helper Component)
57
*
68
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
79
* @author Andreas Gohr <[email protected]>
810
*/
9-
class helper_plugin_dbquery extends dokuwiki\Extension\Plugin
11+
class helper_plugin_dbquery extends Plugin
1012
{
1113
/** @var PDO[] do not access directly, use getPDO instead */
1214
protected $pdo = [];
@@ -76,6 +78,7 @@ public function executeQuery($query, $dsnalias = null)
7678
$params = $this->gatherVariables();
7779
$sth = $this->prepareStatement($pdo, $query, $params);
7880
$sth->execute();
81+
7982
$data = $sth->fetchAll(PDO::FETCH_ASSOC);
8083
$sth->closeCursor();
8184

@@ -101,13 +104,13 @@ public function prepareStatement(\PDO $pdo, $sql, $parameters)
101104
$groupids[] = ":$id";
102105
}
103106
unset($parameters[':groups']);
104-
$sql = str_replace(':groups', join(',', $groupids), $sql);
107+
$sql = str_replace(':groups', implode(',', $groupids), $sql);
105108

106109
$sth = $pdo->prepare($sql);
107110
foreach ($parameters as $key => $val) {
108111
if (is_array($val)) continue;
109112
if (is_object($val)) continue;
110-
if (strpos($sql, $key) === false) continue; // skip if parameter is missing
113+
if (!str_contains($sql, $key)) continue; // skip if parameter is missing
111114

112115
if (is_int($val)) {
113116
$sth->bindValue($key, $val, PDO::PARAM_INT);

renderer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
class renderer_plugin_dbquery extends \Doku_Renderer
1212
{
13-
1413
protected $codeBlocks = [];
1514
protected $lastHeader = '';
1615

@@ -53,5 +52,4 @@ public function document_end()
5352
'macros' => $this->info['dbquery'],
5453
]);
5554
}
56-
5755
}

syntax/macro.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
use dokuwiki\Extension\SyntaxPlugin;
4+
35
/**
46
* DokuWiki Plugin dbquery (Syntax Component)
57
*
68
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
79
* @author Andreas Gohr <[email protected]>
810
*/
9-
class syntax_plugin_dbquery_macro extends \dokuwiki\Extension\SyntaxPlugin
11+
class syntax_plugin_dbquery_macro extends SyntaxPlugin
1012
{
1113
/** @inheritDoc */
1214
public function getType()
@@ -45,10 +47,9 @@ public function render($mode, Doku_Renderer $renderer, $data)
4547
[$name, $value] = sexplode('=', $data[0], 2);
4648
$name = trim($name);
4749
$value = trim($value);
48-
if(!$value) $value = true;
50+
if (!$value) $value = true;
4951

5052
$renderer->info['dbquery'][$name] = $value;
5153
return true;
5254
}
5355
}
54-

syntax/query.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
use dokuwiki\Extension\SyntaxPlugin;
4+
35
/**
46
* DokuWiki Plugin dbquery (Syntax Component)
57
*
68
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
79
* @author Andreas Gohr <[email protected]>
810
*/
9-
class syntax_plugin_dbquery_query extends DokuWiki_Syntax_Plugin
11+
class syntax_plugin_dbquery_query extends SyntaxPlugin
1012
{
1113
/** @inheritDoc */
1214
public function getType()
@@ -57,12 +59,10 @@ public function render($mode, Doku_Renderer $renderer, $data)
5759

5860
if (count($result) === 1 && isset($result[0]['status']) && isset($qdata['codeblocks'][$result[0]['status']])) {
5961
$this->renderStatus($result, $qdata['codeblocks'][$result[0]['status']], $renderer);
62+
} elseif ($qdata['macros']['transpose']) {
63+
$this->renderTransposedResultTable($result, $renderer);
6064
} else {
61-
if ($qdata['macros']['transpose']) {
62-
$this->renderTransposedResultTable($result, $renderer);
63-
} else {
64-
$this->renderResultTable($result, $renderer);
65-
}
65+
$this->renderResultTable($result, $renderer);
6666
}
6767

6868
return true;
@@ -77,7 +77,7 @@ public function render($mode, Doku_Renderer $renderer, $data)
7777
*/
7878
public function renderStatus($result, $html, Doku_Renderer $R)
7979
{
80-
$value = isset($result[0]['result']) ? $result[0]['result'] : '';
80+
$value = $result[0]['result'] ?? '';
8181
$html = str_replace(':result', hsc($value), $html);
8282
$R->doc .= $html;
8383
}
@@ -172,7 +172,7 @@ protected function cellFormat($content, Doku_Renderer $R)
172172
if (preg_match('/^\[\[(https?:\/\/[^|\]]+)(|.*?)?]]$/', $content, $m)) {
173173
$url = $m[1];
174174
$title = $m[2] ?? '';
175-
$title = trim($title,'|');
175+
$title = trim($title, '|');
176176
$R->externallink($url, $title);
177177
return;
178178
}
@@ -181,12 +181,11 @@ protected function cellFormat($content, Doku_Renderer $R)
181181
if (preg_match('/^\[\[([^|\]]+)(|.*?)?]]$/', $content, $m)) {
182182
$page = cleanID($m[1]);
183183
$title = $m[2] ?? '';
184-
$title = trim($title,'|');
184+
$title = trim($title, '|');
185185
$R->internallink($page, $title);
186186
return;
187187
}
188188

189189
$R->cdata($content);
190190
}
191191
}
192-

0 commit comments

Comments
 (0)