Revert "Merge tag 'v2.10.6'"
This reverts commit122ea4ab9e
, reversing changes made toc54a11e250
.
This commit is contained in:
@@ -4,9 +4,23 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\{InputInterface,InputArgument};
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
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
|
||||
{
|
||||
@@ -25,7 +39,7 @@ class ExtManager extends Extension
|
||||
/** @var ExtManagerTheme */
|
||||
protected Themelet $theme;
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event): void
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $page, $user;
|
||||
if ($event->page_matches("ext_manager")) {
|
||||
@@ -64,20 +78,21 @@ class ExtManager extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
public function onCliGen(CliGenEvent $event): void
|
||||
public function onCommand(CommandEvent $event)
|
||||
{
|
||||
$event->app->register('disable-all-ext')
|
||||
->setDescription('Disable all extensions')
|
||||
->setCode(function (InputInterface $input, OutputInterface $output): int {
|
||||
$this->write_config([]);
|
||||
return Command::SUCCESS;
|
||||
});
|
||||
if ($event->cmd == "help") {
|
||||
print "\tdisable-all-ext\n";
|
||||
print "\t\tdisable all extensions\n\n";
|
||||
}
|
||||
if ($event->cmd == "disable-all-ext") {
|
||||
$this->write_config([]);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event): void
|
||||
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
|
||||
{
|
||||
global $user;
|
||||
if ($event->parent === "system") {
|
||||
if ($event->parent==="system") {
|
||||
if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) {
|
||||
$event->add_nav_link("ext_manager", new Link('ext_manager'), "Extension Manager");
|
||||
} else {
|
||||
@@ -86,7 +101,7 @@ class ExtManager extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event): void
|
||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event)
|
||||
{
|
||||
global $user;
|
||||
if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) {
|
||||
@@ -95,40 +110,25 @@ 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, fn ($x) => Extension::is_enabled($x->key));
|
||||
$extensions = array_filter($extensions, "Shimmie2\__extman_extactive");
|
||||
}
|
||||
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);
|
||||
});
|
||||
usort($extensions, "Shimmie2\__extman_extcmp");
|
||||
return $extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $settings
|
||||
*/
|
||||
private function set_things(array $settings): void
|
||||
private function set_things($settings)
|
||||
{
|
||||
$core = ExtensionInfo::get_core_extensions();
|
||||
$extras = [];
|
||||
|
||||
foreach (ExtensionInfo::get_all_keys() as $key) {
|
||||
if (in_array($key, $core)) {
|
||||
continue; // core extensions are always enabled
|
||||
}
|
||||
if (isset($settings["ext_$key"]) && $settings["ext_$key"] === "on") {
|
||||
if (!in_array($key, $core) && isset($settings["ext_$key"])) {
|
||||
$extras[] = $key;
|
||||
}
|
||||
}
|
||||
@@ -137,14 +137,19 @@ class ExtManager extends Extension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $extras
|
||||
* #param string[] $extras
|
||||
*/
|
||||
private function write_config(array $extras): void
|
||||
private function write_config(array $extras)
|
||||
{
|
||||
file_put_contents(
|
||||
"data/config/extensions.conf.php",
|
||||
'<' . '?php' . "\n" .
|
||||
'define("EXTRA_EXTS", "' . implode(",", $extras) . '");' . "\n"
|
||||
);
|
||||
|
||||
// when the list of active extensions changes, we can be
|
||||
// pretty sure that the list of who reacts to what will
|
||||
// change too
|
||||
_clear_cached_event_listeners();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user