diff --git a/css/admin.css b/css/admin.css
index a15aa64..82c6b31 100644
--- a/css/admin.css
+++ b/css/admin.css
@@ -97,6 +97,10 @@
margin-top: -1px;
}
+#apps-categories-custom-list select {
+ width: 100%;
+}
+
.side-menu-setting-table {
display: table;
@@ -115,7 +119,7 @@
.side-menu-setting-form {
display: table-cell;
- width: 300px;
+ min-width: 300px;
}
.side-menu-setting-label-short {
diff --git a/lib/Service/AppRepository.php b/lib/Service/AppRepository.php
index 93c8f9c..d91ec75 100644
--- a/lib/Service/AppRepository.php
+++ b/lib/Service/AppRepository.php
@@ -21,10 +21,27 @@ class AppRepository
*/
protected $l10nFactory;
- public function __construct(\OC_App $ocApp, IFactory $l10nFactory)
+ /**
+ * @var ConfigProxy
+ */
+ protected $config;
+
+ /**
+ * @var CategoryRepository
+ */
+ protected $categoryRepository;
+
+ public function __construct(
+ \OC_App $ocApp,
+ IFactory $l10nFactory,
+ ConfigProxy $config,
+ CategoryRepository $categoryRepository
+ )
{
$this->ocApp = $ocApp;
$this->l10nFactory = $l10nFactory;
+ $this->config = $config;
+ $this->categoryRepository = $categoryRepository;
}
/**
@@ -35,6 +52,9 @@ class AppRepository
public function getVisibleApps()
{
$navigation = $this->ocApp->getNavigation();
+ $appCategoriesCustom = $this->config->getAppValueArray('apps-categories-custom', '[]');
+ $categoriesCustom = $this->config->getAppValueArray('categories-custom', '[]');
+ $categories = $this->categoryRepository->getOrderedCategories();
$apps = $this->ocApp->listAllApps();
$visibleApps = [];
@@ -74,6 +94,12 @@ class AppRepository
}
}
+ foreach ($visibleApps as $id => $app) {
+ if (isset($appCategoriesCustom[$id], $categories[$appCategoriesCustom[$id]])) {
+ $visibleApps[$id]['category'] = [$appCategoriesCustom[$id]];
+ }
+ }
+
usort($visibleApps, function ($a, $b) {
return ($a['name'] < $b['name']) ? -1 : 1;
});
diff --git a/lib/Service/CategoryRepository.php b/lib/Service/CategoryRepository.php
index 3e67e63..7559854 100644
--- a/lib/Service/CategoryRepository.php
+++ b/lib/Service/CategoryRepository.php
@@ -5,6 +5,7 @@ namespace OCA\SideMenu\Service;
use OC\App\AppStore\Fetcher\CategoryFetcher;
use OCA\SideMenu\AppInfo\Application;
use OCP\IConfig;
+use OCP\IUserSession;
use OCP\L10N\IFactory;
/**
@@ -34,16 +35,23 @@ class CategoryRepository
*/
protected $iConfig;
+ /**
+ * @var IUserSession
+ */
+ protected $userSession;
+
public function __construct(
CategoryFetcher $categoryFetcher,
ConfigProxy $config,
IConfig $iConfig,
- IFactory $l10nFactory
+ IFactory $l10nFactory,
+ IUserSession $userSession
) {
$this->categoryFetcher = $categoryFetcher;
$this->l10nFactory = $l10nFactory;
$this->config = $config;
$this->iConfig = $iConfig;
+ $this->userSession = $userSession;
}
/**
@@ -56,8 +64,8 @@ class CategoryRepository
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
$type = $this->config->getAppValue('categories-order-type', 'default');
$order = $this->config->getAppValueArray('categories-order', '[]');
-
$categoriesLabels = $this->config->getAppValueArray('cache-categories', '[]');
+ $customCategories = $this->config->getAppValueArray('categories-custom', '[]');
if (empty($categoriesLabels)) {
$categoriesLabels = $this->categoryFetcher->get();
@@ -74,6 +82,18 @@ class CategoryRepository
$categoriesLabels['external_links'] = $this->l10nFactory->get('external')->t('External sites');
$categoriesLabels['other'] = '';
+ $user = $this->userSession->getUser();
+
+ if ($user) {
+ $lang = $this->iConfig->getUserValue($user->getUid(), 'core', 'lang');
+ } else {
+ $lang = 'en';
+ }
+
+ foreach ($customCategories as $category) {
+ $categoriesLabels[$category['id']] = $category[$lang] ?? $category['en'];
+ }
+
asort($categoriesLabels);
if ('custom' === $type) {
diff --git a/lib/Service/LangRepository.php b/lib/Service/LangRepository.php
new file mode 100644
index 0000000..c998a7e
--- /dev/null
+++ b/lib/Service/LangRepository.php
@@ -0,0 +1,43 @@
+
+ */
+class LangRepository
+{
+ /**
+ * @var IDBConnection
+ */
+ protected $db;
+
+ public function __construct(IDBConnection $db)
+ {
+ $this->db = $db;
+ }
+
+ public function getUsedLangs(): array
+ {
+ $qb = $this->db->getQueryBuilder();
+
+ $qb->select($qb->createFunction('DISTINCT configvalue'))
+ ->where('configkey="lang" and appid="core" and configvalue<>"en"')
+ ->from('preferences')
+ ;
+
+ $stmt = $qb->execute();
+
+ $langs = ['en'];
+
+ foreach ($stmt->fetchAll() as $result) {
+ $langs[] = $result['configvalue'];
+ }
+
+ return $langs;
+ }
+}
diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php
index e7a2bab..0f6e390 100644
--- a/lib/Settings/Admin.php
+++ b/lib/Settings/Admin.php
@@ -28,6 +28,7 @@ use OCP\ILogger;
use OCP\Settings\ISettings;
use OCA\Theming\ThemingDefaults;
use OCA\SideMenu\Service\Color;
+use OCA\SideMenu\Service\LangRepository;
class Admin implements ISettings
{
@@ -66,6 +67,11 @@ class Admin implements ISettings
*/
protected $color;
+ /**
+ * @var LangRepository
+ */
+ protected $langRepository;
+
public function __construct(
IL10N $l,
ILogger $logger,
@@ -73,7 +79,8 @@ class Admin implements ISettings
AppRepository $appRepository,
CategoryRepository $categoryRepository,
ThemingDefaults $theming,
- Color $color
+ Color $color,
+ LangRepository $langRepository
) {
$this->l = $l;
$this->logger = $logger;
@@ -82,6 +89,7 @@ class Admin implements ISettings
$this->categoryRepository = $categoryRepository;
$this->theming = $theming;
$this->color = $color;
+ $this->langRepository = $langRepository;
}
/**
@@ -140,10 +148,13 @@ class Admin implements ISettings
'target-blank-apps' => $this->config->getAppValueArray('target-blank-apps', '[]'),
'top-menu-apps' => $this->config->getAppValueArray('top-menu-apps', '[]'),
'default-enabled' => $this->config->getAppValue('default-enabled', '1'),
+ 'apps' => $this->appRepository->getVisibleApps(),
+ 'apps-categories-custom' => $this->config->getAppValueArray('apps-categories-custom', '[]'),
'categories-order-type' => $this->config->getAppValue('categories-order-type', 'default'),
'categories-order' => $this->config->getAppValueArray('categories-order', '[]'),
- 'apps' => $this->appRepository->getVisibleApps(),
+ 'categories-custom' => $this->config->getAppValueArray('categories-custom', '[]'),
'categories' => $this->categoryRepository->getOrderedCategories(),
+ 'langs' => $this->langRepository->getUsedLangs(),
];
return new TemplateResponse(Application::APP_ID, 'settings/admin-form', $parameters, '');
diff --git a/package.json b/package.json
index e87767d..f38078f 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
},
"dependencies": {
"@nextcloud/axios": "^1.8.0",
- "@nextcloud/vue": "^1.4.0",
+ "@nextcloud/vue": "^1.5.0",
"axios": "^0.24.0",
"trim": "0.0.1",
"vue": "^2.6.11"
diff --git a/src/AdminCategoriesCustom.vue b/src/AdminCategoriesCustom.vue
new file mode 100644
index 0000000..909580d
--- /dev/null
+++ b/src/AdminCategoriesCustom.vue
@@ -0,0 +1,182 @@
+
+
+ Dark Theme
oder Breeze Dark Theme
angewendet."
"Dark mode colors": "Farben für den dunklen Modus"
"With categories": "Mit Kategorien"
+"Custom categories": "Benutzerdefinierte Kategorien"
+"Customize application categories": "Anwendungskategorien anpassen"
diff --git a/src/l10n/fixtures/fr.yaml b/src/l10n/fixtures/fr.yaml
index 56b286e..9cb2792 100644
--- a/src/l10n/fixtures/fr.yaml
+++ b/src/l10n/fixtures/fr.yaml
@@ -77,3 +77,5 @@
"This parameters are used when Dark theme or Breeze Dark Theme are enabled.": "Ces paramètres sont utilisés lorsque le thème sombre ou le thème Breeze Dark sont activés."
"Dark mode colors": "Couleurs du mode sombre"
"With categories": "Avec les catégories"
+"Custom categories": "Catégories personnalisées"
+"Customize application categories": "Personnaliser les catégories des applications"
diff --git a/src/l10n/fixtures/zh_CN.yaml b/src/l10n/fixtures/zh_CN.yaml
index 969583d..5282c9f 100644
--- a/src/l10n/fixtures/zh_CN.yaml
+++ b/src/l10n/fixtures/zh_CN.yaml
@@ -77,3 +77,5 @@
"This parameters are used when Dark theme or Breeze Dark Theme are enabled.": "此参数将应用于暗黑主题激活时。"
"Dark mode colors": "暗黑模式颜色"
"With categories": "有类别"
+"Custom categories": "自定义类别"
+"Customize application categories": "自定义应用程序类别"
diff --git a/templates/settings/admin-form.php b/templates/settings/admin-form.php
index 9b53d7d..e75fc2b 100644
--- a/templates/settings/admin-form.php
+++ b/templates/settings/admin-form.php
@@ -497,7 +497,6 @@ $choicesSizes = [
t('Not compatible with touch screens.')); ?>
@@ -790,6 +789,61 @@ $choicesSizes = [ + + + +