summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2016-07-23 21:24:54 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2016-07-23 21:24:54 +0200
commit004fcbbcc7609ca83807f2e38967ef54f469bf72 (patch)
tree49eb99b4ea92b2045793fc567f719b31ec7f9042 /config
parent60abc0ed4438c9b6fda245b0dc33cb483bc2aeaf (diff)
Move to new directory structure
Diffstat (limited to 'config')
-rw-r--r--config/appconfig.php137
-rw-r--r--config/config.php181
-rw-r--r--config/dependencyexception.php28
-rw-r--r--config/schema.json182
4 files changed, 0 insertions, 528 deletions
diff --git a/config/appconfig.php b/config/appconfig.php
deleted file mode 100644
index 55dcd6d1a..000000000
--- a/config/appconfig.php
+++ /dev/null
@@ -1,137 +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 2012
- * @copyright Bernhard Posselt 2012, 2014
- */
-
-namespace OCA\News\Config;
-
-use SimpleXMLElement;
-
-use OCP\INavigationManager;
-use OCP\IURLGenerator;
-use OCP\Util;
-use OCP\App;
-
-// Used to parse app.json file, should be in core at some point
-class AppConfig {
-
- private $config;
- private $navigationManager;
- private $urlGenerator;
-
- /**
- * TODO: External deps that are needed:
- * - add jobs
- * - connect to hooks
- */
- public function __construct(INavigationManager $navigationManager,
- IURLGenerator $urlGenerator) {
- $this->navigationManager = $navigationManager;
- $this->urlGenerator = $urlGenerator;
- $this->config = [];
- }
-
-
- /**
- * Parse an xml config
- */
- private function parseConfig($string) {
- // no need to worry about XXE since local file
- $xml = simplexml_load_string($string, 'SimpleXMLElement');
- return json_decode(json_encode((array)$xml), true);
- }
-
-
- /**
- * @param string|array $data path to the config file or an array with the
- * config
- */
- public function loadConfig($data) {
- if(is_array($data)) {
- $this->config = $data;
- } else {
- $this->config = $this->parseConfig($data);
- }
- }
-
-
- /**
- * @param string $key if given returns the value of the config at index $key
- * @return array|mixed the config
- */
- public function getConfig($key=null) {
- // FIXME: is this function interface a good idea?
- if($key !== null) {
- return $this->config[$key];
- } else {
- return $this->config;
- }
- }
-
-
- /**
- * Registers all config options
- */
- public function registerAll() {
- $this->registerNavigation();
- $this->registerHooks();
- // IJob API is fucked up, so silence the code checker
- $class = '\OCP\BackgroundJob';
- $class::addRegularTask($this->config['cron']['job'], 'run');
- App::registerAdmin($this->config['id'], $this->config['admin']);
- }
-
-
- /**
- * Parses the navigation and creates a navigation entry if needed
- */
- public function registerNavigation() {
- if (array_key_exists('navigation', $this->config)) {
- $this->navigationManager->add(function () {
- $nav =& $this->config['navigation'];
-
- $navConfig = [
- 'id' => $this->config['id'],
- 'order' => $nav['order'],
- 'name' => $nav['name']
- ];
-
- $navConfig['href'] = $this->urlGenerator->linkToRoute(
- $nav['route']
- );
- $navConfig['icon'] = $this->urlGenerator->imagePath(
- $this->config['id'], $nav['icon']
- );
-
- return $navConfig;
- });
- }
- }
-
-
- /**
- * Registers all hooks in the config
- */
- public function registerHooks() {
- // FIXME: this is temporarily static because core emitters are not
- // future proof, therefore legacy code in here
- foreach ($this->config['hooks'] as $hook) {
- $listener = explode('::', $hook['channel']);
- $reaction = explode('::', $hook['subscriber']);
-
- // config is written like HookNamespace::method => Class::method
- Util::connectHook($listener[0], $listener[1], $reaction[0],
- $reaction[1]);
- }
- }
-
-
-}
diff --git a/config/config.php b/config/config.php
deleted file mode 100644
index a91c5053f..000000000
--- a/config/config.php
+++ /dev/null
@@ -1,181 +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 2012
- * @copyright Bernhard Posselt 2012, 2014
- */
-
-namespace OCA\News\Config;
-
-use OCP\ILogger;
-use OCP\Files\Folder;
-
-
-class Config {
-
- private $fileSystem;
- private $autoPurgeMinimumInterval; // seconds, used to define how
- // long deleted folders and feeds
- // should still be kept for an
- // undo actions
- private $autoPurgeCount; // number of allowed unread articles per feed
- private $maxRedirects; // seconds
- private $feedFetcherTimeout; // seconds
- private $useCronUpdates; // turn off updates run by owncloud cronjob
- private $logger;
- private $loggerParams;
- private $maxSize;
- private $exploreUrl;
-
- public function __construct(Folder $fileSystem,
- ILogger $logger,
- $LoggerParameters) {
- $this->fileSystem = $fileSystem;
- $this->autoPurgeMinimumInterval = 60;
- $this->autoPurgeCount = 200;
- $this->maxRedirects = 10;
- $this->maxSize = 100*1024*1024; // 100Mb
- $this->feedFetcherTimeout = 60;
- $this->useCronUpdates = true;
- $this->logger = $logger;
- $this->exploreUrl = '';
- $this->loggerParams = $LoggerParameters;
- }
-
- public function getAutoPurgeMinimumInterval() {
- if ($this->autoPurgeMinimumInterval > 60) {
- return $this->autoPurgeMinimumInterval;
- } else {
- return 60;
- }
- }
-
- public function getAutoPurgeCount() {
- return $this->autoPurgeCount;
- }
-
-
- public function getMaxRedirects() {
- return $this->maxRedirects;
- }
-
-
- public function getFeedFetcherTimeout() {
- return $this->feedFetcherTimeout;
- }
-
-
- public function getUseCronUpdates() {
- return $this->useCronUpdates;
- }
-
-
- public function getMaxSize() {
- return $this->maxSize;
- }
-
-
- public function getExploreUrl() {
- return $this->exploreUrl;
- }
-
-
- public function setAutoPurgeMinimumInterval($value) {
- $this->autoPurgeMinimumInterval = $value;
- }
-
-
- public function setAutoPurgeCount($value) {
- $this->autoPurgeCount = $value;
- }
-
-
- public function setMaxRedirects($value) {
- $this->maxRedirects = $value;
- }
-
-
- public function setFeedFetcherTimeout($value) {
- $this->feedFetcherTimeout = $value;
- }
-
-
- public function setUseCronUpdates($value) {
- $this->useCronUpdates = $value;
- }
-
- public function setMaxSize($value) {
- $this->maxSize = $value;
- }
-
-
- public function setExploreUrl($value) {
- $this->exploreUrl = $value;
- }
-
-
- public function read($configPath, $createIfNotExists=false) {
- if($createIfNotExists && !$this->fileSystem->nodeExists($configPath)) {
- $this->fileSystem->newFile($configPath);
- $this->write($configPath);
-
- } else {
-
- $content = $this->fileSystem->get($configPath)->getContent();
- $configValues = parse_ini_string($content);
-
- if($configValues === false || count($configValues) === 0) {
- $this->logger->warning(
- 'Configuration invalid. Ignoring values.',
- $this->loggerParams
- );
- } else {
-
- foreach($configValues as $key => $value) {
- if(property_exists($this, $key)) {
- $type = gettype($this->$key);
- settype($value, $type);
- $this->$key = $value;
- } else {
- $this->logger->warning(
- 'Configuration value "' . $key .
- '" does not exist. Ignored value.' ,
- $this->loggerParams
- );
- }
- }
-
- }
- }
- }
-
-
- public function write($configPath) {
- $ini =
- 'autoPurgeMinimumInterval = ' .
- $this->autoPurgeMinimumInterval . "\n" .
- 'autoPurgeCount = ' .
- $this->autoPurgeCount . "\n" .
- 'maxRedirects = ' .
- $this->maxRedirects . "\n" .
- 'maxSize = ' .
- $this->maxSize . "\n" .
- 'exploreUrl = ' .
- $this->exploreUrl . "\n" .
- 'feedFetcherTimeout = ' .
- $this->feedFetcherTimeout . "\n" .
- 'useCronUpdates = ' .
- var_export($this->useCronUpdates, true);
- ;
-
- $this->fileSystem->get($configPath)->putContent($ini);
- }
-
-
-}
diff --git a/config/dependencyexception.php b/config/dependencyexception.php
deleted file mode 100644
index 690d187c3..000000000
--- a/config/dependencyexception.php
+++ /dev/null
@@ -1,28 +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 2012
- * @copyright Bernhard Posselt 2012, 2014
- */
-
-namespace OCA\News\Config;
-
-class DependencyException extends \Exception {
-
-
- /**
- * Constructor
- * @param string $msg the error message
- */
- public function __construct($msg){
- parent::__construct($msg);
- }
-
-
-} \ No newline at end of file
diff --git a/config/schema.json b/config/schema.json
deleted file mode 100644
index 13dca5132..000000000
--- a/config/schema.json
+++ /dev/null
@@ -1,182 +0,0 @@
-{
- "title": "ownCloud App Schema",
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "id": {
- "type": "string",
- "pattern": "^[a-z_]+$"
- },
- "description": {
- "type": "string"
- },
- "licence": {
- "type": "string",
- "enum": ["AGPL", "MIT", "GPL", "LGPL", "BSD","Apache"]
- },
- "admin": {
- "type": "boolean"
- },
- "version": {
- "type": "string",
- "pattern": "^[0-9]+(\\.[0-9]+)*$"
- },
- "authors": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "email": {
- "type": "string",
- "pattern": "^.+@.+\\..+$"
- },
- "homepage": {
- "type": "string",
- "pattern": "^https?://.*$"
- }
- },
- "required": ["name", "email"],
- "additionalProperties": false
- }
- },
- "repository": {
- "type": "object",
- "properties": {
- "type": {
- "type": "string"
- },
- "url": {
- "type": "string"
- }
- },
- "required": ["type", "url"],
- "additionalProperties": false
- },
- "homepage": {
- "type": "string",
- "pattern": "^https?://.*$"
- },
- "bugs": {
- "type": "string",
- "pattern": "^https?://.*$"
- },
- "documentation": {
- "type": "object",
- "properties": {
- "user": {
- "type": "string",
- "pattern": "^https?://.*$"
- },
- "admin": {
- "type": "string",
- "pattern": "^https?://.*$"
- },
- "developer": {
- "type": "string",
- "pattern": "^https?://.*$"
- }
- },
- "additionalProperties": false
- },
- "jobs": {
- "type": "array",
- "items": {
- "type": "string",
- "pattern": "^[a-zA-Z-_:\\\\]+$"
- }
- },
- "hooks": {
- "type": "object",
- "patternProperties": {
- "^[a-zA-Z-_:\\\\]+$": {
- "type": "string",
- "pattern": "^[a-zA-Z-_:\\\\]+$"
- }
- }
- },
- "navigation": {
- "type": "object",
- "properties": {
- "route": {
- "type": "string",
- "pattern": "^([a-z]+(\\.[a-z]+)*)*|(/.+/.*)$"
- },
- "icon": {
- "type": "string"
- },
- "name": {
- "type": "string"
- },
- "order": {
- "type": "integer"
- }
- },
- "additionalProperties": false
- },
- "categories": {
- "type": "array",
- "items": {
- "type": "string",
- "enum": ["Filesystem", "Authentication", "PIM", "Multimedia",
- "Productivity", "Games", "Tools", "Other"]
- },
- "minItems": 1,
- "uniqueItems": true
- },
- "dependencies": {
- "type": "object",
- "properties": {
- "databases": {
- "type": "array",
- "items": {
- "type": "string",
- "enum": ["pgsql", "mysql", "sqlite3", "mssql", "oracle"]
- },
- "uniqueItems": true
- },
- "php": {
- "type": "string",
- "pattern": "^((=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*(,(=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*)*|\\*)$"
- },
- "apps": {
- "type": "object",
- "patternProperties": {
- "^[a-z_]+$": {
- "type": "string",
- "pattern": "^((=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*(,(=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*)*|\\*)$"
- }
- }
- },
- "libs": {
- "type": "object",
- "patternProperties": {
- "^[a-z_]+$": {
- "type": "string",
- "pattern": "^((=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*(,(=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*)*|\\*)$"
- }
- }
- },
- "owncloud": {
- "type": "string",
- "pattern": "^((=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*(,(=|<|>|<=|>=)?[0-9]+(\\.[0-9]+)*)*|\\*)$"
- }
- },
- "additionalProperties": false
- }
- },
- "required": [
- "name",
- "id",
- "description",
- "licence",
- "version",
- "authors",
- "repository"
- ],
- "additionalProperties": false
-} \ No newline at end of file