summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-09-29 21:22:34 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-09-29 21:22:34 +0200
commit26d950486ba5e48dd5ba44a4924760c88ed6c7ac (patch)
tree1e4c039fc3250e9d049c93ab6b3cea462b00f5f9 /controller
parent45d7c475d3075f33017111fa8e8f952abedd7b46 (diff)
add default locale and developer names and move the method to the pagecontroller, @cosenal
Diffstat (limited to 'controller')
-rw-r--r--controller/appcontroller.php78
-rw-r--r--controller/pagecontroller.php54
2 files changed, 53 insertions, 79 deletions
diff --git a/controller/appcontroller.php b/controller/appcontroller.php
deleted file mode 100644
index 138668950..000000000
--- a/controller/appcontroller.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Alessandro Cosentino 2014
- * @copyright Bernhard Posselt 2014
- */
-
-namespace OCA\News\Controller;
-
-use \OCP\IRequest;
-use \OCP\IURLGenerator;
-use \OCP\AppFramework\Controller;
-use \OCP\AppFramework\Http;
-use \OCP\AppFramework\Http\JSONResponse;
-
-use \OCA\News\Config\AppConfig;
-
-class AppController extends Controller {
-
- private $urlGenerator;
- private $appConfig;
-
- public function __construct($appName,
- IRequest $request,
- IURLGenerator $urlGenerator,
- AppConfig $appConfig){
- parent::__construct($appName, $request);
- $this->urlGenerator = $urlGenerator;
- $this->appConfig = $appConfig;
- }
-
- /**
- * @NoCSRFRequired
- * @PublicPage
- *
- * Generates a web app manifest, according to specs in:
- * https://developer.mozilla.org/en-US/Apps/Build/Manifest
- */
- public function manifest() {
- $config = $this->appConfig->getConfig();
-
- // size of the icons: 128x128 is required by FxOS for all app manifests
- $iconSizes = ['128', '512'];
- $icons = [];
-
- foreach ($iconSizes as $size) {
- $filename = 'app-' . $size . '.png';
- if (file_exists(__DIR__ . '/../img/' . $filename)) {
- $icons[$size] = $this->urlGenerator->imagePath($config['id'],
- $filename);
- }
- }
-
- $authors = [];
- foreach ($config['authors'] as $author) {
- $authors[] = $author['name'];
- }
-
- return [
- "name" => $config['name'],
- "description" => $config['description'],
- "launch_path" => $this->urlGenerator->linkToRoute(
- $config['id'] . '.page.index'),
- "icons" => $icons,
- "developer" => [
- "name" => implode(', ', $authors),
- "url" => $config['homepage']
- ]
- ];
- }
-
-} \ No newline at end of file
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php
index 27377eab4..e8b651608 100644
--- a/controller/pagecontroller.php
+++ b/controller/pagecontroller.php
@@ -13,26 +13,34 @@
namespace OCA\News\Controller;
-use OCP\AppFramework\Http\TemplateResponse;
+use \OCP\AppFramework\Http\TemplateResponse;
use \OCP\IRequest;
use \OCP\IConfig;
use \OCP\IL10N;
+use \OCP\IURLGenerator;
use \OCP\AppFramework\Controller;
+use \OCA\News\Config\AppConfig;
class PageController extends Controller {
private $settings;
private $l10n;
private $userId;
+ private $appConfig;
+ private $urlGenerator;
public function __construct($appName,
IRequest $request,
IConfig $settings,
+ IURLGenerator $urlGenerator,
+ AppConfig $appConfig,
IL10N $l10n,
$userId){
parent::__construct($appName, $request);
$this->settings = $settings;
+ $this->urlGenerator = $urlGenerator;
+ $this->appConfig = $appConfig;
$this->l10n = $l10n;
$this->userId = $userId;
}
@@ -82,4 +90,48 @@ class PageController extends Controller {
}
+ /**
+ * @NoCSRFRequired
+ * @PublicPage
+ *
+ * Generates a web app manifest, according to specs in:
+ * https://developer.mozilla.org/en-US/Apps/Build/Manifest
+ */
+ public function manifest() {
+ $config = $this->appConfig->getConfig();
+
+ // size of the icons: 128x128 is required by FxOS for all app manifests
+ $iconSizes = ['128', '512'];
+ $icons = [];
+
+ $locale = str_replace('_', '-', $this->l10n->getLanguageCode());
+
+ foreach ($iconSizes as $size) {
+ $filename = 'app-' . $size . '.png';
+ if (file_exists(__DIR__ . '/../img/' . $filename)) {
+ $icons[$size] = $this->urlGenerator->imagePath($config['id'],
+ $filename);
+ }
+ }
+
+ $authors = [];
+ foreach ($config['authors'] as $author) {
+ $authors[] = $author['name'];
+ }
+
+ return [
+ "name" => $config['name'],
+ "type" => 'web',
+ "default_locale" => $locale,
+ "description" => $config['description'],
+ "launch_path" => $this->urlGenerator->linkToRoute(
+ $config['id'] . '.page.index'),
+ "icons" => $icons,
+ "developer" => [
+ "name" => implode(', ', $authors),
+ "url" => $config['homepage']
+ ]
+ ];
+ }
+
} \ No newline at end of file