diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 16:45:36 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 16:45:36 +0200 |
commit | 42d69a95f3276a2d6089ca68f635c4e2f6aa7a23 (patch) | |
tree | 6a17fd7998f291e6dec1d996c1e7c724b92b8e58 /appinfo | |
parent | 0e6598b0734fb927109f745d9c0f3a8605a30ca5 (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 'appinfo')
-rw-r--r-- | appinfo/app.php | 6 | ||||
-rw-r--r-- | appinfo/application.php | 834 | ||||
-rw-r--r-- | appinfo/database.xml | 516 | ||||
-rw-r--r-- | appinfo/info.xml | 10 | ||||
-rw-r--r-- | appinfo/routes.php | 138 |
5 files changed, 752 insertions, 752 deletions
diff --git a/appinfo/app.php b/appinfo/app.php index 8188d3eeb..2809795fb 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -18,9 +18,9 @@ use \OCA\News\Config\DependencyException; // Turn all errors into exceptions to combat shitty library behavior set_error_handler(function ($code, $message) { - if ($code === E_ERROR || $code === E_USER_ERROR) { - throw new \Exception($message, $code); - } + if ($code === E_ERROR || $code === E_USER_ERROR) { + throw new \Exception($message, $code); + } }); $container = new Application(); diff --git a/appinfo/application.php b/appinfo/application.php index e410ce701..8a1f02a4c 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -56,432 +56,432 @@ use \OCA\News\ArticleEnhancer\RegexArticleEnhancer; $thirdPartyLibs = [ - '\HTMLPurifier' => 'htmlpurifier/library/HTMLPurifier.auto.php', - '\SimplePie' => 'simplepie/autoloader.php', - '\ZendXML\Security' => 'ZendXml/vendor/autoload.php', - '\Net_URL2' => 'Net_URL2/Net/URL2.php' + '\HTMLPurifier' => 'htmlpurifier/library/HTMLPurifier.auto.php', + '\SimplePie' => 'simplepie/autoloader.php', + '\ZendXML\Security' => 'ZendXml/vendor/autoload.php', + '\Net_URL2' => 'Net_URL2/Net/URL2.php' ]; // to prevent clashes with installed app framework versions foreach ($thirdPartyLibs as $class => $path) { - if (!class_exists($class)) { - require_once __DIR__ . '/../3rdparty/' . $path; - } + if (!class_exists($class)) { + require_once __DIR__ . '/../3rdparty/' . $path; + } } class Application extends App { - public function __construct(array $urlParams=array()){ - parent::__construct('news', $urlParams); - - $container = $this->getContainer(); - - - /** - * Controllers - */ - $container->registerService('PageController', function($c) { - return new PageController( - $c->query('AppName'), - $c->query('Request'), - $c->query('CoreConfig'), - $c->query('URLGenerator'), - $c->query('AppConfig'), - $c->query('L10N'), - $c->query('UserId') - ); - }); - - $container->registerService('AdminController', function($c) { - return new AdminController( - $c->query('AppName'), - $c->query('Request'), - $c->query('Config'), - $c->query('ConfigPath') - ); - }); - - $container->registerService('FolderController', function($c) { - return new FolderController( - $c->query('AppName'), - $c->query('Request'), - $c->query('FolderService'), - $c->query('FeedService'), - $c->query('ItemService'), - $c->query('UserId') - ); - }); - - $container->registerService('FeedController', function($c) { - return new FeedController( - $c->query('AppName'), - $c->query('Request'), - $c->query('FolderService'), - $c->query('FeedService'), - $c->query('ItemService'), - $c->query('CoreConfig'), - $c->query('UserId') - ); - }); - - $container->registerService('ItemController', function($c) { - return new ItemController( - $c->query('AppName'), - $c->query('Request'), - $c->query('FeedService'), - $c->query('ItemService'), - $c->query('CoreConfig'), - $c->query('UserId') - ); - }); - - $container->registerService('ExportController', function($c) { - return new ExportController( - $c->query('AppName'), - $c->query('Request'), - $c->query('FolderService'), - $c->query('FeedService'), - $c->query('ItemService'), - $c->query('OPMLExporter'), - $c->query('UserId') - ); - }); - - $container->registerService('UtilityApiController', function($c) { - return new UtilityApiController( - $c->query('AppName'), - $c->query('Request'), - $c->query('Updater'), - $c->query('CoreConfig') - ); - }); - - $container->registerService('FolderApiController', function($c) { - return new FolderApiController( - $c->query('AppName'), - $c->query('Request'), - $c->query('FolderService'), - $c->query('ItemService'), - $c->query('UserId') - ); - }); - - $container->registerService('FeedApiController', function($c) { - return new FeedApiController( - $c->query('AppName'), - $c->query('Request'), - $c->query('FeedService'), - $c->query('ItemService'), - $c->query('Logger'), - $c->query('UserId'), - $c->query('LoggerParameters') - ); - }); - - $container->registerService('ItemApiController', function($c) { - return new ItemApiController( - $c->query('AppName'), - $c->query('Request'), - $c->query('ItemService'), - $c->query('UserId') - ); - }); - - /** - * Business Layer - */ - $container->registerService('FolderService', function($c) { - return new FolderService( - $c->query('FolderMapper'), - $c->query('L10N'), - $c->query('TimeFactory'), - $c->query('Config') - ); - }); - - $container->registerService('FeedService', function($c) { - return new FeedService( - $c->query('FeedMapper'), - $c->query('Fetcher'), - $c->query('ItemMapper'), - $c->query('Logger'), - $c->query('L10N'), - $c->query('TimeFactory'), - $c->query('Config'), - $c->query('Enhancer'), - $c->query('HTMLPurifier'), - $c->query('LoggerParameters') - ); - }); - - $container->registerService('ItemService', function($c) { - return new ItemService( - $c->query('ItemMapper'), - $c->query('StatusFlag'), - $c->query('TimeFactory'), - $c->query('Config') - ); - }); - - // compability for plugins pre 3.0 - $container->registerService('FolderBusinessLayer', function($c) { - return $c->query('FolderService'); - }); - $container->registerService('FeedBusinessLayer', function($c) { - return $c->query('FeedService'); - }); - $container->registerService('ItemBusinessLayer', function($c) { - return $c->query('ItemService'); - }); - - /** - * Mappers - */ - $container->registerService('MapperFactory', function($c) { - return new MapperFactory( - $c->query('DatabaseType'), - $c->query('Db') - ); - }); - - $container->registerService('FolderMapper', function($c) { - return new FolderMapper( - $c->query('Db') - ); - }); - - $container->registerService('FeedMapper', function($c) { - return new FeedMapper( - $c->query('Db') - ); - }); - - $container->registerService('ItemMapper', function($c) { - return $c->query('MapperFactory')->getItemMapper( - $c->query('Db') - ); - }); - - - /** - * App config parser - */ - $container->registerService('AppConfig', function($c) { - // order extensions in name => version - $loadedExtensions = get_loaded_extensions(); - $extensions = []; - foreach ($loadedExtensions as $extension) { - $extensions[$extension] = phpversion($extension); - } - - $extensions['libxml'] = LIBXML_DOTTED_VERSION; - - $config = new AppConfig( - $c->query('ServerContainer')->getNavigationManager(), - $c->query('URLGenerator'), - phpversion(), - implode('.', Util::getVersion()), - $extensions, - $c->query('DatabaseType') - ); - - $config->loadConfig(__DIR__ . '/app.json'); - - return $config; - }); - - /** - * Core - */ - $container->registerService('L10N', function($c) { - return $c->query('ServerContainer')->getL10N($c->query('AppName')); - }); - - $container->registerService('URLGenerator', function($c) { - return $c->query('ServerContainer')->getURLGenerator(); - }); - - $container->registerService('UserId', function() { - return User::getUser(); - }); - - $container->registerService('Logger', function($c) { - return $c->query('ServerContainer')->getLogger(); - }); - - $container->registerService('LoggerParameters', function($c) { - return ['app' => $c->query('AppName')]; - }); - - $container->registerService('Db', function($c) { - return $c->query('ServerContainer')->getDb(); - }); - - $container->registerService('CoreConfig', function($c) { - return $c->query('ServerContainer')->getConfig(); - }); - - $container->registerService('DatabaseType', function($c) { - return $c->query('ServerContainer')->getConfig()->getSystemValue('dbtype'); - }); - - - /** - * Utility - */ - $container->registerService('ConfigView', function() { - $view = new View('/news/config'); - if (!$view->file_exists('')) { - $view->mkdir(''); - } - - return $view; - }); - - $container->registerService('ConfigPath', function() { - return 'config.ini'; - }); - - $container->registerService('Config', function($c) { - $config = new Config( - $c->query('ConfigView'), - $c->query('Logger'), - $c->query('LoggerParameters') - ); - $config->read($c->query('ConfigPath'), true); - return $config; - }); - - $container->registerService('simplePieCacheDirectory', function($c) { - $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') . - '/news/cache/simplepie'; - - if(!is_dir($directory)) { - mkdir($directory, 0770, true); - } - return $directory; - }); - - $container->registerService('HTMLPurifier', function($c) { - $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') . - '/news/cache/purifier'; - - if(!is_dir($directory)) { - mkdir($directory, 0770, true); - } - - $config = \HTMLPurifier_Config::createDefault(); - $config->set('HTML.ForbiddenAttributes', 'class'); - $config->set('Cache.SerializerPath', $directory); - $config->set('HTML.SafeIframe', true); - $config->set('URI.SafeIframeRegexp', - '%^(?:https?:)?//(' . - 'www.youtube(?:-nocookie)?.com/embed/|' . - 'player.vimeo.com/video/)%'); //allow YouTube and Vimeo - return new \HTMLPurifier($config); - }); - - $container->registerService('GlobalArticleEnhancer', function() { - return new GlobalArticleEnhancer(); - }); - - $container->registerService('Enhancer', function($c) { - $enhancer = new Enhancer(); - - // register simple enhancers from config json file - $xpathEnhancerConfig = file_get_contents( - __DIR__ . '/../articleenhancer/xpathenhancers.json' - ); - - foreach(json_decode($xpathEnhancerConfig, true) as $feed => $config) { - $articleEnhancer = new XPathArticleEnhancer( - $c->query('SimplePieAPIFactory'), - $config, - $c->query('Config') - ); - $enhancer->registerEnhancer($feed, $articleEnhancer); - } - - $regexEnhancerConfig = file_get_contents( - __DIR__ . '/../articleenhancer/regexenhancers.json' - ); - foreach(json_decode($regexEnhancerConfig, true) as $feed => $config) { - foreach ($config as $matchArticleUrl => $regex) { - $articleEnhancer = new RegexArticleEnhancer($matchArticleUrl, $regex); - $enhancer->registerEnhancer($feed, $articleEnhancer); - } - } - - $enhancer->registerGlobalEnhancer($c->query('GlobalArticleEnhancer')); - - return $enhancer; - }); - - /** - * Fetchers - */ - $container->registerService('Fetcher', function($c) { - $fetcher = new Fetcher(); - - // register fetchers in order - // the most generic fetcher should be the last one - $fetcher->registerFetcher($c->query('FeedFetcher')); - - return $fetcher; - }); - - $container->registerService('FeedFetcher', function($c) { - return new FeedFetcher($c->query('SimplePieAPIFactory'), - $c->query('FaviconFetcher'), - $c->query('TimeFactory'), - $c->query('simplePieCacheDirectory'), - $c->query('Config'), - $c->query('AppConfig') - ); - }); - - $container->registerService('StatusFlag', function() { - return new StatusFlag(); - }); - - $container->registerService('OPMLExporter', function() { - return new OPMLExporter(); - }); - - $container->registerService('Updater', function($c) { - return new Updater( - $c->query('FolderService'), - $c->query('FeedService'), - $c->query('ItemService') - ); - }); - - $container->registerService('SimplePieAPIFactory', function() { - return new SimplePieAPIFactory(); - }); - - $container->registerService('FaviconFetcher', function($c) { - return new FaviconFetcher( - $c->query('SimplePieAPIFactory') - ); - }); - - } - - public function getAppConfig() { - return $this->getContainer()->query('AppConfig'); - } - - - public function getLogger() { - return $this->getContainer()->query('Logger'); - } - - - public function getLoggerParameters() { - return $this->getContainer()->query('LoggerParameters'); - } + public function __construct(array $urlParams=array()){ + parent::__construct('news', $urlParams); + + $container = $this->getContainer(); + + + /** + * Controllers + */ + $container->registerService('PageController', function($c) { + return new PageController( + $c->query('AppName'), + $c->query('Request'), + $c->query('CoreConfig'), + $c->query('URLGenerator'), + $c->query('AppConfig'), + $c->query('L10N'), + $c->query('UserId') + ); + }); + + $container->registerService('AdminController', function($c) { + return new AdminController( + $c->query('AppName'), + $c->query('Request'), + $c->query('Config'), + $c->query('ConfigPath') + ); + }); + + $container->registerService('FolderController', function($c) { + return new FolderController( + $c->query('AppName'), + $c->query('Request'), + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService'), + $c->query('UserId') + ); + }); + + $container->registerService('FeedController', function($c) { + return new FeedController( + $c->query('AppName'), + $c->query('Request'), + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService'), + $c->query('CoreConfig'), + $c->query('UserId') + ); + }); + + $container->registerService('ItemController', function($c) { + return new ItemController( + $c->query('AppName'), + $c->query('Request'), + $c->query('FeedService'), + $c->query('ItemService'), + $c->query('CoreConfig'), + $c->query('UserId') + ); + }); + + $container->registerService('ExportController', function($c) { + return new ExportController( + $c->query('AppName'), + $c->query('Request'), + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService'), + $c->query('OPMLExporter'), + $c->query('UserId') + ); + }); + + $container->registerService('UtilityApiController', function($c) { + return new UtilityApiController( + $c->query('AppName'), + $c->query('Request'), + $c->query('Updater'), + $c->query('CoreConfig') + ); + }); + + $container->registerService('FolderApiController', function($c) { + return new FolderApiController( + $c->query('AppName'), + $c->query('Request'), + $c->query('FolderService'), + $c->query('ItemService'), + $c->query('UserId') + ); + }); + + $container->registerService('FeedApiController', function($c) { + return new FeedApiController( + $c->query('AppName'), + $c->query('Request'), + $c->query('FeedService'), + $c->query('ItemService'), + $c->query('Logger'), + $c->query('UserId'), + $c->query('LoggerParameters') + ); + }); + + $container->registerService('ItemApiController', function($c) { + return new ItemApiController( + $c->query('AppName'), + $c->query('Request'), + $c->query('ItemService'), + $c->query('UserId') + ); + }); + + /** + * Business Layer + */ + $container->registerService('FolderService', function($c) { + return new FolderService( + $c->query('FolderMapper'), + $c->query('L10N'), + $c->query('TimeFactory'), + $c->query('Config') + ); + }); + + $container->registerService('FeedService', function($c) { + return new FeedService( + $c->query('FeedMapper'), + $c->query('Fetcher'), + $c->query('ItemMapper'), + $c->query('Logger'), + $c->query('L10N'), + $c->query('TimeFactory'), + $c->query('Config'), + $c->query('Enhancer'), + $c->query('HTMLPurifier'), + $c->query('LoggerParameters') + ); + }); + + $container->registerService('ItemService', function($c) { + return new ItemService( + $c->query('ItemMapper'), + $c->query('StatusFlag'), + $c->query('TimeFactory'), + $c->query('Config') + ); + }); + + // compability for plugins pre 3.0 + $container->registerService('FolderBusinessLayer', function($c) { + return $c->query('FolderService'); + }); + $container->registerService('FeedBusinessLayer', function($c) { + return $c->query('FeedService'); + }); + $container->registerService('ItemBusinessLayer', function($c) { + return $c->query('ItemService'); + }); + + /** + * Mappers + */ + $container->registerService('MapperFactory', function($c) { + return new MapperFactory( + $c->query('DatabaseType'), + $c->query('Db') + ); + }); + + $container->registerService('FolderMapper', function($c) { + return new FolderMapper( + $c->query('Db') + ); + }); + + $container->registerService('FeedMapper', function($c) { + return new FeedMapper( + $c->query('Db') + ); + }); + + $container->registerService('ItemMapper', function($c) { + return $c->query('MapperFactory')->getItemMapper( + $c->query('Db') + ); + }); + + + /** + * App config parser + */ + $container->registerService('AppConfig', function($c) { + // order extensions in name => version + $loadedExtensions = get_loaded_extensions(); + $extensions = []; + foreach ($loadedExtensions as $extension) { + $extensions[$extension] = phpversion($extension); + } + + $extensions['libxml'] = LIBXML_DOTTED_VERSION; + + $config = new AppConfig( + $c->query('ServerContainer')->getNavigationManager(), + $c->query('URLGenerator'), + phpversion(), + implode('.', Util::getVersion()), + $extensions, + $c->query('DatabaseType') + ); + + $config->loadConfig(__DIR__ . '/app.json'); + + return $config; + }); + + /** + * Core + */ + $container->registerService('L10N', function($c) { + return $c->query('ServerContainer')->getL10N($c->query('AppName')); + }); + + $container->registerService('URLGenerator', function($c) { + return $c->query('ServerContainer')->getURLGenerator(); + }); + + $container->registerService('UserId', function() { + return User::getUser(); + }); + + $container->registerService('Logger', function($c) { + return $c->query('ServerContainer')->getLogger(); + }); + + $container->registerService('LoggerParameters', function($c) { + return ['app' => $c->query('AppName')]; + }); + + $container->registerService('Db', function($c) { + return $c->query('ServerContainer')->getDb(); + }); + + $container->registerService('CoreConfig', function($c) { + return $c->query('ServerContainer')->getConfig(); + }); + + $container->registerService('DatabaseType', function($c) { + return $c->query('ServerContainer')->getConfig()->getSystemValue('dbtype'); + }); + + + /** + * Utility + */ + $container->registerService('ConfigView', function() { + $view = new View('/news/config'); + if (!$view->file_exists('')) { + $view->mkdir(''); + } + + return $view; + }); + + $container->registerService('ConfigPath', function() { + return 'config.ini'; + }); + + $container->registerService('Config', function($c) { + $config = new Config( + $c->query('ConfigView'), + $c->query('Logger'), + $c->query('LoggerParameters') + ); + $config->read($c->query('ConfigPath'), true); + return $config; + }); + + $container->registerService('simplePieCacheDirectory', function($c) { + $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') . + '/news/cache/simplepie'; + + if(!is_dir($directory)) { + mkdir($directory, 0770, true); + } + return $directory; + }); + + $container->registerService('HTMLPurifier', function($c) { + $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') . + '/news/cache/purifier'; + + if(!is_dir($directory)) { + mkdir($directory, 0770, true); + } + + $config = \HTMLPurifier_Config::createDefault(); + $config->set('HTML.ForbiddenAttributes', 'class'); + $config->set('Cache.SerializerPath', $directory); + $config->set('HTML.SafeIframe', true); + $config->set('URI.SafeIframeRegexp', + '%^(?:https?:)?//(' . + 'www.youtube(?:-nocookie)?.com/embed/|' . + 'player.vimeo.com/video/)%'); //allow YouTube and Vimeo + return new \HTMLPurifier($config); + }); + + $container->registerService('GlobalArticleEnhancer', function() { + return new GlobalArticleEnhancer(); + }); + + $container->registerService('Enhancer', function($c) { + $enhancer = new Enhancer(); + + // register simple enhancers from config json file + $xpathEnhancerConfig = file_get_contents( + __DIR__ . '/../articleenhancer/xpathenhancers.json' + ); + + foreach(json_decode($xpathEnhancerConfig, true) as $feed => $config) { + $articleEnhancer = new XPathArticleEnhancer( + $c->query('SimplePieAPIFactory'), + $config, + $c->query('Config') + ); + $enhancer->registerEnhancer($feed, $articleEnhancer); + } + + $regexEnhancerConfig = file_get_contents( + __DIR__ . '/../articleenhancer/regexenhancers.json' + ); + foreach(json_decode($regexEnhancerConfig, true) as $feed => $config) { + foreach ($config as $matchArticleUrl => $regex) { + $articleEnhancer = new RegexArticleEnhancer($matchArticleUrl, $regex); + $enhancer->registerEnhancer($feed, $articleEnhancer); + } + } + + $enhancer->registerGlobalEnhancer($c->query('GlobalArticleEnhancer')); + + return $enhancer; + }); + + /** + * Fetchers + */ + $container->registerService('Fetcher', function($c) { + $fetcher = new Fetcher(); + + // register fetchers in order + // the most generic fetcher should be the last one + $fetcher->registerFetcher($c->query('FeedFetcher')); + + return $fetcher; + }); + + $container->registerService('FeedFetcher', function($c) { + return new FeedFetcher($c->query('SimplePieAPIFactory'), + $c->query('FaviconFetcher'), + $c->query('TimeFactory'), + $c->query('simplePieCacheDirectory'), + $c->query('Config'), + $c->query('AppConfig') + ); + }); + + $container->registerService('StatusFlag', function() { + return new StatusFlag(); + }); + + $container->registerService('OPMLExporter', function() { + return new OPMLExporter(); + }); + + $container->registerService('Updater', function($c) { + return new Updater( + $c->query('FolderService'), + $c->query('FeedService'), + $c->query('ItemService') + ); + }); + + $container->registerService('SimplePieAPIFactory', function() { + return new SimplePieAPIFactory(); + }); + + $container->registerService('FaviconFetcher', function($c) { + return new FaviconFetcher( + $c->query('SimplePieAPIFactory') + ); + }); + + } + + public function getAppConfig() { + return $this->getContainer()->query('AppConfig'); + } + + + public function getLogger() { + return $this->getContainer()->query('Logger'); + } + + + public function getLoggerParameters() { + return $this->getContainer()->query('LoggerParameters'); + } } diff --git a/appinfo/database.xml b/appinfo/database.xml index eebd7603b..12b1ba4f9 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -1,269 +1,269 @@ <database> - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - <charset>utf8</charset> - <table> - <name>*dbprefix*news_folders</name> - <declaration> - <field> - <name>id</name> - <type>integer</type> - <notnull>true</notnull> - <autoincrement>true</autoincrement> - <unsigned>true</unsigned> - <primary>true</primary> - <length>8</length> - </field> - <field> - <name>parent_id</name> - <type>integer</type> - <length>8</length> - <notnull>false</notnull> - </field> - <field> - <name>name</name> - <type>text</type> - <length>100</length> - <notnull>true</notnull> - </field> - <field> - <name>user_id</name> - <type>text</type> - <default></default> - <notnull>true</notnull> - <length>64</length> - </field> - <field> - <name>opened</name> - <type>boolean</type> - <default>true</default> - <notnull>true</notnull> - </field> - <field> - <name>deleted_at</name> - <type>integer</type> - <length>8</length> - <default>0</default> - <notnull>false</notnull> - <unsigned>true</unsigned> - </fiel |