Skip to content

Commit

Permalink
Merge pull request #139 from Klap-in/master
Browse files Browse the repository at this point in the history
replace curly braces, some reformatting
  • Loading branch information
splitbrain authored Jul 2, 2022
2 parents 9a20568 + ca14c84 commit f7de07f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
3 changes: 1 addition & 2 deletions helper/popularity.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public function getCounts($key, $orderby = 'cnt', $startdate = '', $enddate = ''

$stmt->execute($replacements);

$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $data;
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions helper/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public function harmonizeExtensionIDs(&$data) {
*/
public function _getPluginsDB() {
global $conf;
/** @var $db PDO */
$db = null;
/** @var PDO $db */
try {
$db = new PDO($this->getConf('db_name'), $this->getConf('db_user'), $this->getConf('db_pass'));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Expand Down Expand Up @@ -504,7 +503,7 @@ public function getFilteredPlugins(
*/
private function _getPluginsSortSql($sort) {
$sortsql = '';
if($sort{0} == '^') {
if($sort[0] == '^') {
$sortsql = ' DESC';
$sort = substr($sort, 1);
}
Expand Down Expand Up @@ -542,7 +541,7 @@ public function getPluginRelations($id) {
$id = strtolower($id);
$meta = array();

/** @var $stmt PDOStatement */
/** @var PDOStatement $stmt */
$stmt = $db->prepare('SELECT plugin,other FROM plugin_conflicts WHERE plugin = ? OR other = ?');
$stmt->execute(array($id, $id));
foreach($stmt as $row) {
Expand Down Expand Up @@ -605,7 +604,7 @@ public function getTags($minlimit, $filter) {
$shown .= ' AND B.type <> 32';
}

/** @var $stmt PDOStatement */
/** @var PDOStatement $stmt */
$stmt = $db->prepare(
"SELECT A.tag, COUNT(A.tag) as cnt
FROM plugin_tags as A, plugins as B
Expand Down Expand Up @@ -646,7 +645,7 @@ public function getMaxPopularity($type = '') {
$sql .= "ORDER BY popularity DESC
LIMIT 1";

/** @var $stmt PDOStatement */
/** @var PDOStatement $stmt */
$stmt = $db->prepare($sql);
$stmt->execute($this->bundled);
$res = $stmt->fetchAll(PDO::FETCH_ASSOC);
Expand All @@ -666,7 +665,7 @@ public function deletePlugin($plugin) {
$db = $this->_getPluginsDB();
if(!$db) return;

/** @var $stmt PDOStatement */
/** @var PDOStatement $stmt */
$stmt = $db->prepare('DELETE FROM plugins WHERE plugin = ?');
$stmt->execute(array($plugin));

Expand All @@ -686,12 +685,13 @@ public function deletePlugin($plugin) {
/**
* render internallink to plugin/template, templates identified by having namespace
*
* @param $R Doku_Renderer_xhtml
* @param $plugin string pluginname
* @param $title string Title of plugin link
* @param Doku_Renderer_xhtml $R
* @param string $plugin pluginname
* @param string|null $title Title of plugin link
* @return string rendered internallink
*/
public function pluginlink(&$R, $plugin, $title = null) {
public function pluginlink(Doku_Renderer_xhtml $R, string $plugin, string $title = null): string
{
if(!getNS($plugin)) {
return $R->internallink(':plugin:'.$plugin, $title, null, true);
} else {
Expand Down Expand Up @@ -764,7 +764,7 @@ public function cleanCompat($compatible, $onlyCompatibleReleases = true) {
* @return string rendered
*/
public function renderCompatibilityHelp($addInfolink = false) {
$infolink = '<sup><a href="http://www.dokuwiki.org/extension_compatibility" title="'.$this->getLang('compatible_with_info').'">?</a></sup>';
$infolink = '<sup><a href="https://www.dokuwiki.org/extension_compatibility" title="'.$this->getLang('compatible_with_info').'">?</a></sup>';
$infolink = $addInfolink ? $infolink : '';
return sprintf($this->getLang('compatible_with'), $infolink);
}
Expand Down
5 changes: 3 additions & 2 deletions syntax/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class syntax_plugin_pluginrepo_entry extends DokuWiki_Syntax_Plugin {

/**
* will hold the repository helper plugin
* @var $hlp helper_plugin_pluginrepo_repository
* @var helper_plugin_pluginrepo_repository $hlp
*/
var $hlp = null;

Expand Down Expand Up @@ -469,7 +469,8 @@ protected function _saveData($data, $id, $name) {
if(in_array($id, $this->hlp->bundled)) {
$compatible = 'xx9999-99-99';
} else {
$compatible = array_shift(array_keys($this->hlp->cleanCompat($data['compatible'])));
$array = array_keys($this->hlp->cleanCompat($data['compatible']));
$compatible = array_shift($array);
}

$type = $this->hlp->parsetype($data['type']);
Expand Down
26 changes: 13 additions & 13 deletions syntax/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class syntax_plugin_pluginrepo_news extends DokuWiki_Syntax_Plugin {

/**
* will hold the repository helper plugin
* @var $hlp helper_plugin_pluginrepo_repository
* @var helper_plugin_pluginrepo_repository $hlp
*/
var $hlp = null;

Expand Down Expand Up @@ -76,7 +76,7 @@ function handle($match, $state, $pos, Doku_Handler $handler){
* Create output
*
* @param string $format output format being rendered
* @param Doku_Renderer $R the current renderer object
* @param Doku_Renderer $renderer the current renderer object
* @param array $data data created by handler() used entries:
* headline: headline of new block
* link: link shown at the bottom of the news block
Expand All @@ -85,27 +85,27 @@ function handle($match, $state, $pos, Doku_Handler $handler){
* ..more see functions below
* @return boolean rendered correctly? (however, returned value is not used at the moment)
*/
function render($format, Doku_Renderer $R, $data) {
function render($format, Doku_Renderer $renderer, $data) {
if($format != 'xhtml') return false;
/** @var Doku_Renderer_xhtml $R */
/** @var Doku_Renderer_xhtml $renderer */

$R->doc .= '<div class="pluginrepo_news">'.NL;
$R->doc .= '<h4>'.hsc($data['headline']).'</h4>'.NL;
$renderer->doc .= '<div class="pluginrepo_news">'.NL;
$renderer->doc .= '<h4>'.hsc($data['headline']).'</h4>'.NL;

switch ($data['style']) {
case 'sameauthor':
$this->showSameAuthor($R, $data);
$this->showSameAuthor($renderer, $data);
break;
default:
$this->showDefault($R,$data);
$this->showDefault($renderer,$data);
}

if ($data['link']) {
$R->doc .= '<p class="more">';
$R->internallink($data['link'],$data['linktext']);
$R->doc .= '</p>'.NL;
$renderer->doc .= '<p class="more">';
$renderer->internallink($data['link'],$data['linktext']);
$renderer->doc .= '</p>'.NL;
}
$R->doc .= '</div>';
$renderer->doc .= '</div>';
return true;
}

Expand Down Expand Up @@ -151,7 +151,7 @@ function showSameAuthor($R, $data) {
* and used by the filtering:
*
*/
function showDefault(&$R, $data) {
function showDefault($R, $data) {
$limit = (is_numeric($data['entries']) ? $data['entries']: 1);
$plugins = $this->hlp->getPlugins($data);
if ($data['random'] == 'no') {
Expand Down
2 changes: 1 addition & 1 deletion syntax/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function _newTable($plugins,$linkopt,$data,$R) {
$popmax = $this->hlp->getMaxPopularity($ID);

$sort = $_REQUEST['pluginsort'];
if ($sort{0} == '^') {
if ($sort[0] == '^') {
$sortcol = substr($sort, 1);
$sortarr = '<span>&uarr;</span>';
} else {
Expand Down

0 comments on commit f7de07f

Please sign in to comment.