diff options
-rw-r--r-- | appinfo/routes.php | 2 | ||||
-rw-r--r-- | lib/AppInfo/Application.php | 2 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 75 | ||||
-rw-r--r-- | lib/Controller/SiteController.php (renamed from lib/Controller/PageController.php) | 52 | ||||
-rw-r--r-- | personal.php | 6 | ||||
-rw-r--r-- | templates/quota.php | 4 |
6 files changed, 57 insertions, 84 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 4b9c81b..0d032a3 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -21,7 +21,7 @@ return [ 'routes' => [ - ['name' => 'page#showPage', 'url' => '/{id}', 'verb' => 'GET'], + ['name' => 'site#showPage', 'url' => '/{id}', 'verb' => 'GET'], ], 'ocs' => [ ['name' => 'API#get', 'url' => '/api/{apiVersion}', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v1']], diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 0612b01..8d68a61 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -66,7 +66,7 @@ class Application extends App { return [ 'id' => 'external_index' . $site['id'], 'order' => 80 + $site['id'], - 'href' => $url->linkToRoute('external.page.showPage', ['id'=> $site['id']]), + 'href' => $url->linkToRoute('external.site.showPage', ['id'=> $site['id']]), 'icon' => $image, 'type' => $site['type'], 'name' => $site['name'], diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php deleted file mode 100644 index 190c8e0..0000000 --- a/lib/Controller/SettingsController.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCA\External\Controller; - -use OCA\External\SitesManager; -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\TemplateResponse; -use OCP\IRequest; -use OCP\IURLGenerator; - -class SettingsController extends Controller { - /** @var SitesManager */ - protected $sitesManager; - /** @var IURLGenerator */ - protected $url; - - /** - * constructor of the controller - * - * @param string $appName - * @param IRequest $request - * @param SitesManager $sitesManager - * @param IURLGenerator $url - */ - public function __construct($appName, - IRequest $request, - SitesManager $sitesManager, - IURLGenerator $url) { - parent::__construct($appName, $request); - $this->sitesManager = $sitesManager; - $this->url = $url; - } - - /** - * @NoAdminRequired - * @NoCSRFRequired - * - * @return TemplateResponse - */ - public function displayPanel() { - $pages = $this->sitesManager->getSitesToDisplay(); - - $quotaLink = []; - foreach ($pages as $page) { - if ($page['type'] === SitesManager::TYPE_QUOTA) { - $quotaLink = $page; - break; - } - } - - return new TemplateResponse('external', 'quota', [ - 'quotaLink' => $this->url->linkToRoute('external.page.showPage', ['id'=> $quotaLink['id']]), - 'quotaName' => $quotaLink['name'], - ], ''); - } -} diff --git a/lib/Controller/PageController.php b/lib/Controller/SiteController.php index 605717b..43ea2e9 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/SiteController.php @@ -27,21 +27,43 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IL10N; use OCP\INavigationManager; use OCP\IRequest; +use OCP\IURLGenerator; -class PageController extends Controller { +class SiteController extends Controller { /** @var SitesManager */ protected $sitesManager; - /** @var INavigationManager */ protected $navigationManager; + /** @var IURLGenerator */ + protected $url; + /** @var IL10N */ + protected $l10n; - public function __construct($appName, IRequest $request, INavigationManager $navigationManager, SitesManager $sitesManager) { + /** + * SiteController constructor. + * + * @param string $appName + * @param IRequest $request + * @param INavigationManager $navigationManager + * @param SitesManager $sitesManager + * @param IURLGenerator $url + * @param IL10N $l10n + */ + public function __construct($appName, + IRequest $request, + INavigationManager $navigationManager, + SitesManager $sitesManager, + IURLGenerator $url, + IL10N $l10n) { parent::__construct($appName, $request); $this->sitesManager = $sitesManager; $this->navigationManager = $navigationManager; + $this->url = $url; + $this->l10n = $l10n; } /** @@ -70,4 +92,28 @@ class PageController extends Controller { return new RedirectResponse(\OC_Util::getDefaultPageUrl()); } } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * + * @return TemplateResponse + */ + public function renderQuotaLink() { + $sites = $this->sitesManager->getSitesToDisplay(); + + $quotaLinks = []; + foreach ($sites as $site) { + if ($site['type'] === SitesManager::TYPE_QUOTA) { + $quotaLinks[] = [ + 'link' => $this->url->linkToRoute('external.site.showPage', ['id'=> $site['id']]), + 'name' => $site['name'], + ]; + } + } + + return new TemplateResponse('external', 'quota', [ + 'sites' => $quotaLinks, + ], ''); + } } diff --git a/personal.php b/personal.php index 6f4ff5a..c81621f 100644 --- a/personal.php +++ b/personal.php @@ -20,6 +20,6 @@ */ $app = new \OCA\External\AppInfo\Application(); -/** @var \OCA\External\Controller\SettingsController $controller */ -$controller = $app->getContainer()->query(\OCA\External\Controller\SettingsController::class); -return $controller->displayPanel()->render(); +/** @var \OCA\External\Controller\SiteController $controller */ +$controller = $app->getContainer()->query(\OCA\External\Controller\SiteController::class); +return $controller->renderQuotaLink()->render(); diff --git a/templates/quota.php b/templates/quota.php index d2d3f65..24f0c3b 100644 --- a/templates/quota.php +++ b/templates/quota.php @@ -22,5 +22,7 @@ script('external', 'quota'); ?> <div id="quota_link" class="section hidden"> - <a class="button" href="<?php p($_['quotaLink']); ?>"><?php p($_['quotaName']); ?></a> + <?php foreach ($_['sites'] as $site) { ?> + <a class="button" href="<?php p($site['link']); ?>"><?php p($site['name']); ?></a> + <?php } ?> </div> |