[ext_manager] don't disable hidden extensions

This commit is contained in:
Shish 2024-01-06 21:04:12 +00:00
parent 886a645a2c
commit d16f58ec7f
2 changed files with 24 additions and 21 deletions

View file

@ -4,24 +4,6 @@ declare(strict_types=1);
namespace Shimmie2;
function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int
{
if ($a->beta === true && $b->beta === false) {
return 1;
}
if ($a->beta === false && $b->beta === true) {
return -1;
}
return strcmp($a->name, $b->name);
}
function __extman_extactive(ExtensionInfo $a): bool
{
return Extension::is_enabled($a->key);
}
class ExtensionAuthor
{
public string $name;
@ -110,15 +92,24 @@ class ExtManager extends Extension
}
/**
* #return ExtensionInfo[]
* @return ExtensionInfo[]
*/
private function get_extensions(bool $all): array
{
$extensions = ExtensionInfo::get_all();
if (!$all) {
$extensions = array_filter($extensions, "Shimmie2\__extman_extactive");
$extensions = array_filter($extensions, fn ($x) => Extension::is_enabled($x->key));
}
usort($extensions, "Shimmie2\__extman_extcmp");
usort($extensions, function ($a, $b) {
if ($a->beta === true && $b->beta === false) {
return 1;
}
if ($a->beta === false && $b->beta === true) {
return -1;
}
return strcmp($a->name, $b->name);
});
return $extensions;
}

View file

@ -86,6 +86,18 @@ class ExtManagerTheme extends Themelet
));
}
if($editable) {
foreach ($extensions as $extension) {
if ($extension->visibility === ExtensionVisibility::HIDDEN && !$extension->core) {
$form->appendChild(INPUT([
"type" => 'hidden',
"name" => "ext_{$extension->key}",
"value" => ($extension->is_enabled() === true) ? "on" : "off"
]));
}
}
}
$page->set_title("Extensions");
$page->set_heading("Extensions");
$page->add_block(new NavBlock());