initial commit
This commit is contained in:
34
lib/Settings/AppSettings.php
Normal file
34
lib/Settings/AppSettings.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?
|
||||
|
||||
namespace OCA\PrideFlags\Settings;
|
||||
|
||||
use OCA\PrideFlags\AppConstants;
|
||||
use OCP\IConfig;
|
||||
|
||||
class AppSettings {
|
||||
public const FOLDER_VARIANT = 'folderVariant';
|
||||
public const BUTTON_VARIANT = 'buttonVariant';
|
||||
|
||||
public function __construct(private IConfig $config) {
|
||||
}
|
||||
|
||||
public function getStringSetting(string $key, string $default = ''): string {
|
||||
return $this->config->getAppValue(AppConstants::APP_ID, $key) ?: $default;
|
||||
}
|
||||
|
||||
public function setStringSetting(string $key, string $value): void {
|
||||
$this->config->setAppValue(AppConstants::APP_ID, $key, $value);
|
||||
}
|
||||
|
||||
public function getAll(): array {
|
||||
return [
|
||||
AppSettings::FOLDER_VARIANT => $this->getStringSetting(AppSettings::FOLDER_VARIANT, 'pride'),
|
||||
AppSettings::BUTTON_VARIANT => $this->getStringSetting(AppSettings::BUTTON_VARIANT, 'trans'),
|
||||
];
|
||||
}
|
||||
|
||||
public function set($folder, $button): void {
|
||||
$this->setStringSetting(AppSettings::FOLDER_VARIANT, $folder);
|
||||
$this->setStringSetting(AppSettings::BUTTON_VARIANT, $button);
|
||||
}
|
||||
}
|
30
lib/Settings/PersonalSection.php
Normal file
30
lib/Settings/PersonalSection.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\PrideFlags\Settings;
|
||||
|
||||
use OCA\PrideFlags\AppConstants;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Settings\IIConSection;
|
||||
|
||||
class PersonalSection implements IIconSection {
|
||||
public function __construct(private IL10N $l10n, private IURLGenerator $urlGenerator) {}
|
||||
|
||||
public function getID(): string {
|
||||
return AppConstants::APP_ID;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return 'Pride';
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 100;
|
||||
}
|
||||
|
||||
public function getIcon(): string {
|
||||
return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg');
|
||||
}
|
||||
}
|
25
lib/Settings/PersonalSettings.php
Normal file
25
lib/Settings/PersonalSettings.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\PrideFlags\Settings;
|
||||
|
||||
use OCA\PrideFlags\AppConstants;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\Util;
|
||||
|
||||
class PersonalSettings implements ISettings {
|
||||
public function getForm(): TemplateResponse {
|
||||
Util::addScript(AppConstants::APP_ID, 'pride-settings');
|
||||
return new TemplateResponse(AppConstants::APP_ID, 'settings', []);
|
||||
}
|
||||
|
||||
public function getSection(): string {
|
||||
return AppConstants::APP_ID;
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 50;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user