From 18111846b2d065ed8ce6e678ca2d4054c27d53c9 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 31 Jan 2024 23:39:55 +0100 Subject: [PATCH 1/9] phpdocs --- helper/repository.php | 2 +- syntax/news.php | 25 +++++++++++++++++++------ syntax/table.php | 43 ++++++++++++++++++++++++++++--------------- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/helper/repository.php b/helper/repository.php index 0e9e21a..90983ce 100644 --- a/helper/repository.php +++ b/helper/repository.php @@ -237,7 +237,7 @@ public function getPluginsDB() * * @param array $filter with entries used * * @return array data per plugin */ @@ -277,12 +278,29 @@ public function getPlugins($filter = null) } else { [$bundledINsql, $bundledINvalues] = $this->prepareINstmt('bundled', $this->bundled); - $where_filtered = "'" . $this->obsoleteTag . "' NOT IN(SELECT tag - FROM plugin_tags - WHERE plugin_tags.plugin = A.plugin)" - . " AND A.securityissue = ''" - . " AND (A.downloadurl <> '' OR A.plugin " . $bundledINsql . ")"; + $where_filtered = "'$this->obsoleteTag' NOT IN(SELECT tag + FROM plugin_tags + WHERE plugin_tags.plugin = A.plugin) + AND A.securityissue = '' + AND (A.downloadurl <> '' OR A.plugin $bundledINsql)"; $values = $bundledINvalues; + + if ($filter['onlyrecent']) { + $rows = 0; + $recentDates = []; + foreach ($this->getDokuReleases() as $release) { + if (++$rows > 2) { + break; + } + $recentDates[] = $release['date']; + } + [$compatibilityINsql, $compatibilityINvalues] = $this->prepareINstmt('bestcompat', $recentDates); + $where_filtered .= " AND A.bestcompatible $compatibilityINsql"; + $values = array_merge( + $compatibilityINvalues, + $values + ); + } } if (!$filter['includetemplates']) { $where_filtered .= " AND A.type <> 32"; // templates are only type=32, has no other type. diff --git a/syntax/news.php b/syntax/news.php index 8df7854..90e902d 100644 --- a/syntax/news.php +++ b/syntax/news.php @@ -92,6 +92,7 @@ public function handle($match, $state, $pos, Doku_Handler $handler) 'pluginsort' => '', 'showall' => false, 'includetemplates' => false, + 'onlyrecent' => true ]; return $this->hlp->parseData($match, $initialData); } @@ -188,6 +189,7 @@ public function showSameAuthor($R, $data) *
  • 'pluginsort' str shortcuts assumed
  • *
  • 'showall' bool
  • *
  • 'includetemplates' bool
  • + *
  • 'onlyrecent' bool
  • * * * diff --git a/syntax/table.php b/syntax/table.php index 58bf0e0..ccd10f4 100644 --- a/syntax/table.php +++ b/syntax/table.php @@ -347,7 +347,8 @@ public function showPluginTable($R, $data) 'plugintag' => $data['plugintag'] ?: trim($INPUT->str('plugintag')), 'pluginsort' => $data['pluginsort'] ?: strtolower(trim($INPUT->str('pluginsort'))), 'showall' => $data['showall'] ?: $INPUT->str('showall') == 'yes', - 'includetemplates' => $data['includetemplates'] ?: $INPUT->str('includetemplates') == 'yes' + 'includetemplates' => $data['includetemplates'] ?: $INPUT->str('includetemplates') == 'yes', + 'onlyrecent' => false ]; $plugins = $this->hlp->getPlugins($request); From 11698de69825ce8ce1042537fa81197bd70ee1ad Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 8 Feb 2024 23:56:48 +0100 Subject: [PATCH 5/9] allow YES/NO/Yes/No, if not numeric set to 0 --- helper/repository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helper/repository.php b/helper/repository.php index f72b32b..f8185a2 100644 --- a/helper/repository.php +++ b/helper/repository.php @@ -111,14 +111,16 @@ public function convertToType($key, $value) $hasNoValue = ['random', 'onlyrecent']; $isInteger = ['entries', 'plugintype', 'cloudmin']; if (in_array($key, $hasYesValue)) { - $value = $value == 'yes'; + $value = strtolower($value) == 'yes'; } if (in_array($key, $hasNoValue)) { - $value = $value == 'no'; + $value = strtolower($value) != 'no'; } if (in_array($key, $isInteger)) { if (is_numeric($value)) { $value = (int) $value; + } else { + $value = 0; } } From 2e7a3cf9f783c65e32045c377ac2e241abd83905 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 8 Feb 2024 23:57:29 +0100 Subject: [PATCH 6/9] show message if no sameauthor is found --- syntax/news.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/news.php b/syntax/news.php index 90e902d..c268043 100644 --- a/syntax/news.php +++ b/syntax/news.php @@ -158,7 +158,7 @@ public function showSameAuthor($R, $data) } $rel = $this->hlp->getPluginRelations($id); - if (count($rel) == 0) { + if (count($rel['sameauthor']) == 0) { $R->doc .= '

    Can\'t find any other plugins or templates

    '; return; } From 1a022be48586ec8642abab402737aba7d196cc6a Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 8 Feb 2024 23:59:38 +0100 Subject: [PATCH 7/9] limit max entries to available extensions, not more --- syntax/news.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/syntax/news.php b/syntax/news.php index c268043..67197dd 100644 --- a/syntax/news.php +++ b/syntax/news.php @@ -198,13 +198,17 @@ public function showSameAuthor($R, $data) */ public function showDefault($R, $data) { - $limit = $data['entries'] > 0 ? $data['entries'] : 1; $plugins = $this->hlp->getPlugins($data); + + $limit = $data['entries'] > 0 ? $data['entries'] : 1; + $limit = min($limit, count($plugins)); + if ($data['random']) { - $start = random_int(0, count($plugins) - 1 - $limit); + $start = random_int(0, count($plugins) - $limit); } else { $start = 0; } + for ($i = 0; $i < $limit; $i++) { $row = $plugins[$start + $i]; $linkText = ucfirst(noNS($row['plugin'])) . ($row['type'] == 32 ? ' template' : ' plugin'); From 0806dc5bb3a64d5fad0e484a03a75a2efc768348 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 8 Feb 2024 23:59:48 +0100 Subject: [PATCH 8/9] refactor --- syntax/news.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/news.php b/syntax/news.php index 67197dd..083c79f 100644 --- a/syntax/news.php +++ b/syntax/news.php @@ -164,10 +164,10 @@ public function showSameAuthor($R, $data) } $limit = $data['entries'] > 0 ? $data['entries'] : 10; - $itr = 0; + $i = 0; $R->doc .= '
      '; - while ($itr < count($rel['sameauthor']) && $itr < $limit) { - $R->doc .= '
    • ' . $this->hlp->pluginlink($R, $rel['sameauthor'][$itr++]) . '
    • '; + while ($i < count($rel['sameauthor']) && $i < $limit) { + $R->doc .= '
    • ' . $this->hlp->pluginlink($R, $rel['sameauthor'][$i++]) . '
    • '; } $R->doc .= '
    '; } From bf906a03a6384a3d21ef3179d02c4d8bbba5d032 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Fri, 9 Feb 2024 00:01:30 +0100 Subject: [PATCH 9/9] update plugin.info.txt --- plugin.info.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.info.txt b/plugin.info.txt index 0e7f2d3..939fed9 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,8 +1,8 @@ base pluginrepo author Andreas Gohr/HÃ¥kan Sandell email sandell.hakan@gmail.com -date 2024-01-30 +date 2024-02-09 name Repository plugin -desc Helps organizing the plugin repository -url http://www.dokuwiki.org/plugin:pluginrepo +desc Helps organizing the plugin and template repository +url https://www.dokuwiki.org/plugin:repository minphp 7.4