summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-10-21 16:45:36 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-10-21 16:45:36 +0200
commit42d69a95f3276a2d6089ca68f635c4e2f6aa7a23 (patch)
tree6a17fd7998f291e6dec1d996c1e7c724b92b8e58 /config
parent0e6598b0734fb927109f745d9c0f3a8605a30ca5 (diff)
convert tabs indention to indention with 4 spaces because of mixing of both variants in code and better readability on github and websites because you cant set the indention width there and 8 spaces will be used for a tab
Diffstat (limited to 'config')
-rw-r--r--config/appconfig.php528
-rw-r--r--config/config.php290
-rw-r--r--config/schema.json326
3 files changed, 572 insertions, 572 deletions
diff --git a/config/appconfig.php b/config/appconfig.php
index e738b22cd..a9045eb9a 100644
--- a/config/appconfig.php
+++ b/config/appconfig.php
@@ -22,271 +22,271 @@ use \OCP\App;
// Used to parse app.json file, should be in core at some point
class AppConfig {
- private $config;
- private $navigationManager;
- private $urlGenerator;
- private $phpVersion;
- private $ownCloudVersion;
- private $installedExtensions;
- private $databaseType;
-
- /**
- * TODO: External deps that are needed:
- * - add jobs
- * - connect to hooks
- */
- public function __construct(INavigationManager $navigationManager,
- IURLGenerator $urlGenerator,
- $phpVersion,
- $ownCloudVersion,
- $installedExtensions,
- $databaseType) {
- $this->navigationManager = $navigationManager;
- $this->urlGenerator = $urlGenerator;
- $this->ownCloudVersion = $ownCloudVersion;
- $this->phpVersion = $phpVersion;
- $this->installedExtensions = $installedExtensions;
- $this->databaseType = $databaseType;
- $this->config = [];
- }
-
-
- /**
- * @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 {
- $json = file_get_contents($data);
- $this->config = json_decode($json, true);
- }
-
- // fill config with default values if no navigation is added
- if(array_key_exists('navigation', $this->config)) {
- $nav =& $this->config['navigation'];
-
- // add defaults
- $defaults = [
- 'id' => $this->config['id'],
- 'route' => $this->config['id'] . '.page.index',
- 'order' => 10,
- 'icon' => 'app.svg',
- 'name' => $this->config['name']
- ];
-
- foreach($defaults as $key => $value) {
- if(!array_key_exists($key, $nav)) {
- $nav[$key] = $value;
- }
- }
- }
- }
-
- /**
- * @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->registerBackgroundJobs();
- $this->registerHooks();
- $this->registerAdmin();
- }
-
-
- /**
- * Parses the navigation and creates a navigation entry if needed
- */
- public function registerNavigation() {
- // if key is missing, don't create a navigation
- if(array_key_exists('navigation', $this->config)) {
- $nav =& $this->config['navigation'];
-
- $navConfig = [
- 'id' => $nav['id'],
- 'order' => $nav['order'],
- 'name' => $nav['name']
- ];
-
- $navConfig['href'] = $this->urlGenerator->linkToRoute($nav['route']);
- $navConfig['icon'] = $this->urlGenerator->imagePath($nav['id'],
- $nav['icon']);
-
- $this->navigationManager->add($navConfig);
- }
-
- }
-
- /**
- * Registers admin pages
- */
- public function registerAdmin() {
- if ($this->config['admin']) {
- App::registerAdmin($this->config['id'], 'admin/admin');
- }
- }
-
-
- /**
- * Registers all jobs in the config
- */
- public function registerBackgroundJobs() {
- // FIXME: this is temporarily static because core jobs are not public
- // yet, therefore legacy code
- foreach ($this->config['jobs'] as $job) {
- Backgroundjob::addRegularTask($job, 'run');
- }
- }
-
-
- /**
- * 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 $listen => $react) {
- $listener = explode('::', $listen);
- $reaction = explode('::', $react);
-
- // config is written like HookNamespace::method => Class::method
- Util::connectHook($listener[0], $listener[1], $reaction[0],
- $reaction[1]);
- }
- }
-
-
- private function testDatabaseDependencies($deps) {
- if(array_key_exists('databases', $deps)) {
- $databases = $deps['databases'];
- $databaseType = $this->databaseType;
-
- if(!in_array($databaseType, $databases)) {
- return 'Database ' . $databaseType . ' not supported.' .
- 'App is only compatible with ' .
- implode(', ', $databases);
- }
- }
-
- return '';
- }
-
-
- private function testPHPDependencies($deps) {
- if (array_key_exists('php', $deps)) {
- return $this->requireVersion($this->phpVersion, $deps['php'],
- 'PHP');
- }
-
- return '';
- }
-
-
- private function testLibraryDependencies($deps) {
- if (array_key_exists('libs', $deps)) {
- foreach ($deps['libs'] as $lib => $versions) {
- if(array_key_exists($lib, $this->installedExtensions)) {
- return $this->requireVersion($this->installedExtensions[$lib],
- $versions, 'PHP extension ' . $lib);
- } else {
- return 'PHP extension ' . $lib . ' required but not installed';
- }
- }
- }
-
- return '';
- }
-
-
- /**
- * Validates all dependencies that the app has
- * @throws DependencyException if one version is not satisfied
- */
- public function testDependencies() {
- if(array_key_exists('dependencies', $this->config)) {
- $deps = $this->config['dependencies'];
-
- $msg = $this->testDatabaseDependencies($deps);
- $msg .= $this->testPHPDependencies($deps);
- $msg .= $this->testLibraryDependencies($deps);
-
- if($msg !== '') {
- throw new DependencyException($msg);
- }
- }
- }
-
-
- /**
- * Compares a version with a version requirement string
- * @param string $actual the actual version that is there
- * @param string $required a version requirement in the form of
- * <=5.3,>4.5 versions are separated with a comma
- * @param string $versionType a description of the string that is prepended
- * to the error message
- * @return string an error message if the version is not met,
+ private $config;
+ private $navigationManager;
+ private $urlGenerator;
+ private $phpVersion;
+ private $ownCloudVersion;
+ private $installedExtensions;
+ private $databaseType;
+
+ /**
+ * TODO: External deps that are needed:
+ * - add jobs
+ * - connect to hooks
+ */
+ public function __construct(INavigationManager $navigationManager,
+ IURLGenerator $urlGenerator,
+ $phpVersion,
+ $ownCloudVersion,
+ $installedExtensions,
+ $databaseType) {
+ $this->navigationManager = $navigationManager;
+ $this->urlGenerator = $urlGenerator;
+ $this->ownCloudVersion = $ownCloudVersion;
+ $this->phpVersion = $phpVersion;
+ $this->installedExtensions = $installedExtensions;
+ $this->databaseType = $databaseType;
+ $this->config = [];
+ }
+
+
+ /**
+ * @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 {
+ $json = file_get_contents($data);
+ $this->config = json_decode($json, true);
+ }
+
+ // fill config with default values if no navigation is added
+ if(array_key_exists('navigation', $this->config)) {
+ $nav =& $this->config['navigation'];
+
+ // add defaults
+ $defaults = [
+ 'id' => $this->config['id'],
+ 'route' => $this->config['id'] . '.page.index',
+ 'order' => 10,
+ 'icon' => 'app.svg',
+ 'name' => $this->config['name']
+ ];
+
+ foreach($defaults as $key => $value) {
+ if(!array_key_exists($key, $nav)) {
+ $nav[$key] = $value;
+ }
+ }
+ }
+ }
+
+ /**
+ * @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->registerBackgroundJobs();
+ $this->registerHooks();
+ $this->registerAdmin();
+ }
+
+
+ /**
+ * Parses the navigation and creates a navigation entry if needed
+ */
+ public function registerNavigation() {
+ // if key is missing, don't create a navigation
+ if(array_key_exists('navigation', $this->config)) {
+ $nav =& $this->config['navigation'];
+
+ $navConfig = [
+ 'id' => $nav['id'],
+ 'order' => $nav['order'],
+ 'name' => $nav['name']
+ ];
+
+ $navConfig['href'] = $this->urlGenerator->linkToRoute($nav['route']);
+ $navConfig['icon'] = $this->urlGenerator->imagePath($nav['id'],
+ $nav['icon']);
+
+ $this->navigationManager->add($navConfig);
+ }
+
+ }
+
+ /**
+ * Registers admin pages
+ */
+ public function registerAdmin() {
+ if ($this->config['admin']) {
+ App::registerAdmin($this->config['id'], 'admin/admin');
+ }
+ }
+
+
+ /**
+ * Registers all jobs in the config
+ */
+ public function registerBackgroundJobs() {
+ // FIXME: this is temporarily static because core jobs are not public
+ // yet, therefore legacy code
+ foreach ($this->config['jobs'] as $job) {
+ Backgroundjob::addRegularTask($job, 'run');
+ }
+ }
+
+
+ /**
+ * 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 $listen => $react) {
+ $listener = explode('::', $listen);
+ $reaction = explode('::', $react);
+
+ // config is written like HookNamespace::method => Class::method
+ Util::connectHook($listener[0], $listener[1], $reaction[0],
+ $reaction[1]);
+ }
+ }
+
+
+ private function testDatabaseDependencies($deps) {
+ if(array_key_exists('databases', $deps)) {
+ $databases = $deps['databases'];
+ $databaseType = $this->databaseType;
+
+ if(!in_array($databaseType, $databases)) {
+ return 'Database ' . $databaseType . ' not supported.' .
+ 'App is only compatible with ' .
+ implode(', ', $databases);
+ }
+ }
+
+ return '';
+ }
+
+
+ private function testPHPDependencies($deps) {
+ if (array_key_exists('php', $deps)) {
+ return $this->requireVersion($this->phpVersion, $deps['php'],
+ 'PHP');
+ }
+
+ return '';
+ }
+
+
+ private function testLibraryDependencies($deps) {
+ if (array_key_exists('libs', $deps)) {
+ foreach ($deps['libs'] as $lib => $versions) {
+ if(array_key_exists($lib, $this->installedExtensions)) {
+ return $this->requireVersion($this->installedExtensions[$lib],
+ $versions, 'PHP extension ' . $lib);
+ } else {
+ return 'PHP extension ' . $lib . ' required but not installed';
+ }
+ }
+ }
+
+ return '';
+ }
+
+
+ /**
+ * Validates all dependencies that the app has
+ * @throws DependencyException if one version is not satisfied
+ */
+ public function testDependencies() {
+ if(array_key_exists('dependencies', $this->config)) {
+ $deps = $this->config['dependencies'];
+
+ $msg = $this->testDatabaseDependencies($deps);
+ $msg .= $this->testPHPDependencies($deps);
+ $msg .= $this->testLibraryDependencies($deps);
+
+ if($msg !== '') {
+ throw new DependencyException($msg);
+ }
+ }
+ }
+
+
+ /**
+ * Compares a version with a version requirement string
+ * @param string $actual the actual version that is there
+ * @param string $required a version requirement in the form of
+ * <=5.3,>4.5 versions are separated with a comma
+ * @param string $versionType a description of the string that is prepended
+ * to the error message
+ * @return string an error message if the version is not met,
* empty string if ok
- */
- private function requireVersion($actual, $required, $versionType) {
- $requiredVersions = $this->splitVersions($required);
-
- foreach($requiredVersions as $version) {
- // accept * as wildcard for any version
- if($version['version'] === '*') {
- continue;
- }
- if(!version_compare($actual, $version['version'], $version['operator'])) {
- return $versionType . ' Version not satisfied: ' . $version['operator'] .
- $version['version'] . ' required but found ' . $actual . '\n';
- }
- }
-
- return '';
- }
-
-
- /**
- * Versions can be separated by a comma so split them
- * @param string $versions a version requirement in the form of
- * <=5.3,>4.5 versions are separated with a comma
- * @return array of arrays with key=version value=operator
- */
- private function splitVersions($versions) {
- $result = [];
- $versions = explode(',', $versions);
-
- foreach($versions as $version) {
- preg_match('/^(?<operator><|<=|>=|>|<>)?(?<version>.*)$/', $version, $matches);
- if($matches['operator'] !== '') {
- $required = [
- 'version' => $matches['version'],
- 'operator' => $matches['operator'],
- ];
- } else {
- $required = [
- 'version' => $matches['version'],
- 'operator' => '==',
- ];
- }
- $result[] = $required;
- }
-
- return $result;
- }
+ */
+ private function requireVersion($actual, $required, $versionType) {
+ $requiredVersions = $this->splitVersions($required);
+
+ foreach($requiredVersions as $version) {
+ // accept * as wildcard for any version
+ if($version['version'] === '*') {
+ continue;
+ }
+ if(!version_compare($actual, $version['version'], $version['operator'])) {
+ return $versionType . ' Version not satisfied: ' . $version['operator'] .
+ $version['version'] . ' required but found ' . $actual . '\n';
+ }
+ }
+
+ return '';
+ }
+
+
+ /**
+ * Versions can be separated by a comma so split them
+ * @param string $versions a version requirement in the form of
+ * <=5.3,>4.5 versions are separated with a comma
+ * @return array of arrays with key=version value=operator
+ */
+ private function splitVersions($versions) {
+ $result = [];
+ $versions = explode(',', $versions);
+
+ foreach($versions as $version) {
+ preg_match('/^(?<operator><|<=|>=|>|<>)?(?<version>.*)$/', $version, $matches);
+ if($matches['operator'] !== '') {
+ $required = [
+ 'version' => $matches['version'],
+ 'operator' => $matches['operator'],
+ ];
+ } else {
+ $required = [
+ 'version' => $matches['version'],
+ 'operator' => '==',
+ ];
+ }
+ $result[] = $required;
+ }
+
+ return $result;
+ }
} \ No newline at end of file
diff --git a/config/config.php b/config/config.php
index d84e4076c..25e8a2294 100644
--- a/config/config.php
+++ b/config/config.php
@@ -18,179 +18,179 @@ use \OCP\ILogger;
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 $simplePieCacheDuration; // seconds
- private $feedFetcherTimeout; // seconds
- private $useCronUpdates; // turn off updates run by owncloud cronjob
- private $proxyHost;
- private $proxyPort;
- private $proxyUser;
- private $proxyPassword;
- private $logger;
- private $loggerParams;
+ 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 $simplePieCacheDuration; // seconds
+ private $feedFetcherTimeout; // seconds
+ private $useCronUpdates; // turn off updates run by owncloud cronjob
+ private $proxyHost;
+ private $proxyPort;
+ private $proxyUser;
+ private $proxyPassword;
+ private $logger;
+ private $loggerParams;
- public function __construct($fileSystem, ILogger $logger, $loggerParams) {
- $this->fileSystem = $fileSystem;
- $this->autoPurgeMinimumInterval = 60;
- $this->autoPurgeCount = 200;
- $this->simplePieCacheDuration = 30*60;
- $this->feedFetcherTimeout = 60;
- $this->useCronUpdates = true;
- $this->logger = $logger;
- $this->proxyHost = '';
- $this->proxyPort = 8080;
- $this->proxyUser = '';
- $this->proxyPassword = '';
- $this->loggerParams = $loggerParams;
- }
+ public function __construct($fileSystem, ILogger $logger, $loggerParams) {
+ $this->fileSystem = $fileSystem;
+ $this->autoPurgeMinimumInterval = 60;
+ $this->autoPurgeCount = 200;
+ $this->simplePieCacheDuration = 30*60;
+ $this->feedFetcherTimeout = 60;
+ $this->useCronUpdates = true;
+ $this->logger = $logger;
+ $this->proxyHost = '';
+ $this->proxyPort = 8080;
+ $this->proxyUser = '';
+ $this->proxyPassword = '';
+ $this->loggerParams = $loggerParams;
+ }
- public function getProxyPort() {
- return $this->proxyPort;
- }
+ public function getProxyPort() {
+ return $this->proxyPort;
+ }
- public function getProxyHost() {
- return $this->proxyHost;
- }
+ public function getProxyHost() {
+ return $this->proxyHost;
+ }
- public function getProxyAuth() {
- if($this->proxyUser === '') {
- return null;
- } else {
- return $this->proxyUser . ':' . $this->proxyPassword;
- }
- }
+ public function getProxyAuth() {
+ if($this->proxyUser === '') {
+ return null;
+ } else {
+ return $this->proxyUser . ':' . $this->proxyPassword;
+ }
+ }
- public function getProxyUser() {
- return $this->proxyUser;
- }
+ public function getProxyUser() {
+ return $this->proxyUser;
+ }
- public function getProxyPassword() {
- return $this->proxyPassword;
- }
+ public function getProxyPassword() {
+ return $this->proxyPassword;
+ }
- public function getAutoPurgeMinimumInterval() {
- if ($this->autoPurgeMinimumInterval > 60) {
- return $this->autoPurgeMinimumInterval;
- } else {
- return 60;
- }
- }
+ public function getAutoPurgeMinimumInterval() {
+ if ($this->autoPurgeMinimumInterval > 60) {
+ return $this->autoPurgeMinimumInterval;
+ } else {
+ return 60;
+ }
+ }
- public function getAutoPurgeCount() {
- return $this->autoPurgeCount;
- }
-
-
- public function getSimplePieCacheDuration() {
- return $this->simplePieCacheDuration;
- }
-
-
- public function getFeedFetcherTimeout() {
- return $this->feedFetcherTimeout;
- }
-
-
- public function getUseCronUpdates() {
- return $this->useCronUpdates;
- }
-
-
- public function setAutoPurgeMinimumInterval($value) {
- $this->autoPurgeMinimumInterval = $value;
- }
-
-
- public function setAutoPurgeCount($value) {
- $this->autoPurgeCount = $value;
- }
-
-
- public function setSimplePieCacheDuration($value) {
- $this->simplePieCacheDuration = $value;
- }
-
-
- public function setFeedFetcherTimeout($value) {
- $this->feedFetcherTimeout = $value;
- }
+ public function getAutoPurgeCount() {
+ return $this->autoPurgeCount;
+ }
+
+
+ public function getSimplePieCacheDuration() {
+ return $this->simplePieCacheDuration;
+ }
+
+
+ public function getFeedFetcherTimeout() {
+ return $this->feedFetcherTimeout;
+ }
+
+
+ public function getUseCronUpdates() {
+ return $this->useCronUpdates;
+ }
+
+
+ public function setAutoPurgeMinimumInterval($value) {
+ $this->autoPurgeMinimumInterval = $value;
+ }
+
+
+ public function setAutoPurgeCount($value) {
+ $this->autoPurgeCount = $value;
+ }
+
+
+ public function setSimplePieCacheDuration($value) {
+ $this->simplePieCacheDuration = $value;
+ }
+
+
+ public function setFeedFetcherTimeout($value) {
+ $this->feedFetcherTimeout = $value;
+ }
- public function setUseCronUpdates($value) {
- $this->useCronUpdates = $value;
- }
+ public function setUseCronUpdates($value) {
+ $this->useCronUpdates = $value;
+ }
- public function setProxyPort($value) {
- $this->proxyPort = $value;
- }
+ public function setProxyPort($value) {
+ $this->proxyPort = $value;
+ }
- public function setProxyHost($value) {
- $this->proxyHost = $value;
- }
+ public function setProxyHost($value) {
+ $this->proxyHost = $value;
+ }
- public function setProxyUser($value) {
- $this->proxyUser = $value;
- }
+ public function setProxyUser($value) {
+ $this->proxyUser = $value;
+ }
- public function setProxyPassword($value) {
- $this->proxyPassword = $value;
- }
+ public function setProxyPassword($value) {
+ $this->proxyPassword = $value;
+ }
- public function read($configPath, $createIfNotExists=false) {
- if($createIfNotExists && !$this->fileSystem->file_exists($configPath)) {
+ public function read($configPath, $createIfNotExists=false) {
+ if($createIfNotExists && !$this->fileSystem->file_exists($configPath)) {
- $this->write($configPath);
+ $this->write($configPath);
- } else {
+ } else {
- $content = $this->fileSystem->file_get_contents($configPath);
- $configValues = parse_ini_string($content);
+ $content = $this->fileSystem->file_get_contents($configPath);
+ $configValues = parse_ini_string($content);
- if($configValues === false || count($configValues) === 0) {
- $this->logger->warning('Configuration invalid. Ignoring values.',
- $this->loggerParams);
- } else {
+ 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);