-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3113520
commit 9730265
Showing
6 changed files
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<?php | ||
|
||
use dokuwiki\Extension\Plugin; | ||
|
||
/** | ||
* DokuWiki Plugin dbquery (Helper Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
class helper_plugin_dbquery extends dokuwiki\Extension\Plugin | ||
class helper_plugin_dbquery extends Plugin | ||
{ | ||
/** @var PDO[] do not access directly, use getPDO instead */ | ||
protected $pdo = []; | ||
|
@@ -76,6 +78,7 @@ public function executeQuery($query, $dsnalias = null) | |
$params = $this->gatherVariables(); | ||
$sth = $this->prepareStatement($pdo, $query, $params); | ||
$sth->execute(); | ||
|
||
$data = $sth->fetchAll(PDO::FETCH_ASSOC); | ||
$sth->closeCursor(); | ||
|
||
|
@@ -101,13 +104,13 @@ public function prepareStatement(\PDO $pdo, $sql, $parameters) | |
$groupids[] = ":$id"; | ||
} | ||
unset($parameters[':groups']); | ||
$sql = str_replace(':groups', join(',', $groupids), $sql); | ||
$sql = str_replace(':groups', implode(',', $groupids), $sql); | ||
|
||
$sth = $pdo->prepare($sql); | ||
foreach ($parameters as $key => $val) { | ||
if (is_array($val)) continue; | ||
if (is_object($val)) continue; | ||
if (strpos($sql, $key) === false) continue; // skip if parameter is missing | ||
if (!str_contains($sql, $key)) continue; // skip if parameter is missing | ||
|
||
if (is_int($val)) { | ||
$sth->bindValue($key, $val, PDO::PARAM_INT); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<?php | ||
|
||
use dokuwiki\Extension\SyntaxPlugin; | ||
|
||
/** | ||
* DokuWiki Plugin dbquery (Syntax Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
class syntax_plugin_dbquery_macro extends \dokuwiki\Extension\SyntaxPlugin | ||
class syntax_plugin_dbquery_macro extends SyntaxPlugin | ||
{ | ||
/** @inheritDoc */ | ||
public function getType() | ||
|
@@ -45,10 +47,9 @@ public function render($mode, Doku_Renderer $renderer, $data) | |
[$name, $value] = sexplode('=', $data[0], 2); | ||
$name = trim($name); | ||
$value = trim($value); | ||
if(!$value) $value = true; | ||
if (!$value) $value = true; | ||
|
||
$renderer->info['dbquery'][$name] = $value; | ||
return true; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<?php | ||
|
||
use dokuwiki\Extension\SyntaxPlugin; | ||
|
||
/** | ||
* DokuWiki Plugin dbquery (Syntax Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
class syntax_plugin_dbquery_query extends DokuWiki_Syntax_Plugin | ||
class syntax_plugin_dbquery_query extends SyntaxPlugin | ||
{ | ||
/** @inheritDoc */ | ||
public function getType() | ||
|
@@ -57,12 +59,10 @@ public function render($mode, Doku_Renderer $renderer, $data) | |
|
||
if (count($result) === 1 && isset($result[0]['status']) && isset($qdata['codeblocks'][$result[0]['status']])) { | ||
$this->renderStatus($result, $qdata['codeblocks'][$result[0]['status']], $renderer); | ||
} elseif ($qdata['macros']['transpose']) { | ||
$this->renderTransposedResultTable($result, $renderer); | ||
} else { | ||
if ($qdata['macros']['transpose']) { | ||
$this->renderTransposedResultTable($result, $renderer); | ||
} else { | ||
$this->renderResultTable($result, $renderer); | ||
} | ||
$this->renderResultTable($result, $renderer); | ||
} | ||
|
||
return true; | ||
|
@@ -77,7 +77,7 @@ public function render($mode, Doku_Renderer $renderer, $data) | |
*/ | ||
public function renderStatus($result, $html, Doku_Renderer $R) | ||
{ | ||
$value = isset($result[0]['result']) ? $result[0]['result'] : ''; | ||
$value = $result[0]['result'] ?? ''; | ||
$html = str_replace(':result', hsc($value), $html); | ||
$R->doc .= $html; | ||
} | ||
|
@@ -172,7 +172,7 @@ protected function cellFormat($content, Doku_Renderer $R) | |
if (preg_match('/^\[\[(https?:\/\/[^|\]]+)(|.*?)?]]$/', $content, $m)) { | ||
$url = $m[1]; | ||
$title = $m[2] ?? ''; | ||
$title = trim($title,'|'); | ||
$title = trim($title, '|'); | ||
$R->externallink($url, $title); | ||
return; | ||
} | ||
|
@@ -181,12 +181,11 @@ protected function cellFormat($content, Doku_Renderer $R) | |
if (preg_match('/^\[\[([^|\]]+)(|.*?)?]]$/', $content, $m)) { | ||
$page = cleanID($m[1]); | ||
$title = $m[2] ?? ''; | ||
$title = trim($title,'|'); | ||
$title = trim($title, '|'); | ||
$R->internallink($page, $title); | ||
return; | ||
} | ||
|
||
$R->cdata($content); | ||
} | ||
} | ||
|