From 004fcbbcc7609ca83807f2e38967ef54f469bf72 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 23 Jul 2016 21:24:54 +0200 Subject: Move to new directory structure --- utility/opmlexporter.php | 91 -------------------------------------- utility/picofeedclientfactory.php | 40 ----------------- utility/picofeedfaviconfactory.php | 38 ---------------- utility/proxyconfigparser.php | 65 --------------------------- utility/time.php | 30 ------------- utility/updater.php | 54 ---------------------- 6 files changed, 318 deletions(-) delete mode 100644 utility/opmlexporter.php delete mode 100644 utility/picofeedclientfactory.php delete mode 100644 utility/picofeedfaviconfactory.php delete mode 100644 utility/proxyconfigparser.php delete mode 100644 utility/time.php delete mode 100644 utility/updater.php (limited to 'utility') diff --git a/utility/opmlexporter.php b/utility/opmlexporter.php deleted file mode 100644 index d786c0c6f..000000000 --- a/utility/opmlexporter.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - -namespace OCA\News\Utility; - -/** -* Exports the OPML -*/ -class OPMLExporter { - - /** - * Generates the OPML for the active user - * - * @param \OCA\News\Db\Folder[] $folders - * @param \OCA\News\Db\Feed[] $feeds - * @return \DomDocument the document - */ - public function build($folders, $feeds){ - $document = new \DomDocument('1.0', 'UTF-8'); - $document->formatOutput = true; - - $root = $document->createElement('opml'); - $root->setAttribute('version', '2.0'); - - // head - $head = $document->createElement('head'); - - $title = $document->createElement('title', 'Subscriptions'); - $head->appendChild($title); - - $root->appendChild($head); - - // body - $body = $document->createElement('body'); - - // feeds with folders - foreach($folders as $folder) { - $folderOutline = $document->createElement('outline'); - $folderOutline->setAttribute('title', $folder->getName()); - $folderOutline->setAttribute('text', $folder->getName()); - - // feeds in folders - foreach ($feeds as $feed) { - if ($feed->getFolderId() === $folder->getId()) { - $feedOutline = $this->createFeedOutline($feed, $document); - $folderOutline->appendChild($feedOutline); - } - } - - $body->appendChild($folderOutline); - } - - // feeds without folders - foreach ($feeds as $feed) { - if ($feed->getFolderId() === 0) { - $feedOutline = $this->createFeedOutline($feed, $document); - $body->appendChild($feedOutline); - } - } - - $root->appendChild($body); - - $document->appendChild($root); - - return $document; - } - - - protected function createFeedOutline($feed, $document) { - $feedOutline = $document->createElement('outline'); - $feedOutline->setAttribute('title', $feed->getTitle()); - $feedOutline->setAttribute('text', $feed->getTitle()); - $feedOutline->setAttribute('type', 'rss'); - $feedOutline->setAttribute('xmlUrl', $feed->getUrl()); - $feedOutline->setAttribute('htmlUrl', $feed->getLink()); - return $feedOutline; - } - - -} - diff --git a/utility/picofeedclientfactory.php b/utility/picofeedclientfactory.php deleted file mode 100644 index a57f7f022..000000000 --- a/utility/picofeedclientfactory.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - - -namespace OCA\News\Utility; - -use \PicoFeed\Config\Config; -use \PicoFeed\Client\Client; - -class PicoFeedClientFactory { - - private $config; - - public function __construct(Config $config) { - $this->config = $config; - } - - - /** - * Returns a new instance of an PicoFeed Http client - * @return \PicoFeed\Client instance - */ - public function build() { - $client = Client::getInstance(); - $client->setConfig($this->config); - return $client; - } - - -} \ No newline at end of file diff --git a/utility/picofeedfaviconfactory.php b/utility/picofeedfaviconfactory.php deleted file mode 100644 index b3a48747a..000000000 --- a/utility/picofeedfaviconfactory.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - - -namespace OCA\News\Utility; - -use \PicoFeed\Config\Config; -use \PicoFeed\Reader\Favicon; - -class PicoFeedFaviconFactory { - - private $config; - - public function __construct(Config $config) { - $this->config = $config; - } - - - /** - * Returns a new instance of an PicoFeed Http client - * @return \PicoFeed\Favicon instance - */ - public function build() { - return new Favicon($this->config); - } - - -} \ No newline at end of file diff --git a/utility/proxyconfigparser.php b/utility/proxyconfigparser.php deleted file mode 100644 index 4710477e8..000000000 --- a/utility/proxyconfigparser.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - - -namespace OCA\News\Utility; - -use \OCP\IConfig; - - -class ProxyConfigParser { - - private $config; - - public function __construct(IConfig $config) { - $this->config = $config; - } - - - /** - * Parses the config and splits up the port + url - * @return array - */ - public function parse() { - $proxy = $this->config->getSystemValue('proxy'); - $userpasswd = $this->config->getSystemValue('proxyuserpwd'); - - $result = [ - 'host' => null, - 'port' => null, - 'user' => null, - 'password' => null - ]; - - // we need to filter out the port -.- - $url = new \Net_URL2($proxy); - $port = $url->getPort(); - - $url->setPort(false); - $host = $url->getUrl(); - - - $result['host'] = $host; - $result['port'] = $port; - - if ($userpasswd) { - $auth = explode(':', $userpasswd, 2); - $result['user'] = $auth[0]; - $result['password'] = $auth[1]; - } - - return $result; - } - - -} \ No newline at end of file diff --git a/utility/time.php b/utility/time.php deleted file mode 100644 index e6ea2b470..000000000 --- a/utility/time.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @copyright Bernhard Posselt 2016 - */ - -namespace OCA\News\Utility; - -class Time { - public function getTime() { - return time(); - } - - /** - * @return int the current unix time in miliseconds - */ - public function getMicroTime() { - $utimestamp = microtime(true); - $timestamp = floor($utimestamp); - $milliseconds = round(($utimestamp - $timestamp) * 1000000); - $result = ($timestamp * 1000000) + $milliseconds; - return $result; - } - -} \ No newline at end of file diff --git a/utility/updater.php b/utility/updater.php deleted file mode 100644 index a6f8dc28a..000000000 --- a/utility/updater.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - - -namespace OCA\News\Utility; - -use \OCA\News\Service\FolderService; -use \OCA\News\Service\FeedService; -use \OCA\News\Service\ItemService; - - -class Updater { - - - private $folderService; - private $feedService; - private $itemService; - - public function __construct(FolderService $folderService, - FeedService $feedService, - ItemService $itemService) { - $this->folderService = $folderService; - $this->feedService = $feedService; - $this->itemService = $itemService; - } - - - public function beforeUpdate() { - $this->folderService->purgeDeleted(); - $this->feedService->purgeDeleted(); - } - - - public function update() { - $this->feedService->updateAll(); - } - - - public function afterUpdate() { - $this->itemService->autoPurgeOld(); - } - - -} \ No newline at end of file -- cgit v1.2.3