From 80707aa9e3c2925b4ae995661013be622963c217 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 11 Apr 2013 15:48:50 +0200 Subject: translate folder and feed errors and added css and template code for creating folders and feeds and what happens when an error gets triggered --- bl/feedbl.php | 8 +- bl/folderbl.php | 13 +- css/feeds.css | 27 + dependencyinjection/dicontainer.php | 2 +- img/problem.svg | 1749 +++++++++++++++++++++++++++++++++++ templates/part.listfeed.php | 19 +- templates/part.listfolder.php | 15 +- tests/unit/bl/FeedBlTest.php | 12 + tests/unit/bl/FolderBlTest.php | 16 +- 9 files changed, 1843 insertions(+), 18 deletions(-) create mode 100644 img/problem.svg diff --git a/bl/feedbl.php b/bl/feedbl.php index 9dc8cd312..0c0bbe9e0 100644 --- a/bl/feedbl.php +++ b/bl/feedbl.php @@ -58,7 +58,8 @@ class FeedBl extends Bl { // first try if the feed exists already try { $this->mapper->findByUrlHash(md5($feedUrl), $userId); - throw new BLException('Can not add feed: Exists already'); + throw new BLException( + $this->api->getTrans()->t('Can not add feed: Exists already')); } catch(DoesNotExistException $ex){} try { @@ -83,8 +84,9 @@ class FeedBl extends Bl { return $feed; } catch(FetcherException $ex){ $this->api->log($ex->getMessage()); - throw new BLException('Can not add feed with url' . $feedUrl . - ': Not found or bad source'); + throw new BLException( + $this->api->getTrans()->t( + 'Can not add feed: URL does not exist or has invalid xml')); } } diff --git a/bl/folderbl.php b/bl/folderbl.php index 3fcf48c7f..b542f3d34 100644 --- a/bl/folderbl.php +++ b/bl/folderbl.php @@ -25,14 +25,20 @@ namespace OCA\News\Bl; +use \OCA\AppFramework\Core\API; + use \OCA\News\Db\Folder; use \OCA\News\Db\FolderMapper; class FolderBl extends Bl { - public function __construct(FolderMapper $folderMapper){ + private $api; + + public function __construct(FolderMapper $folderMapper, + API $api){ parent::__construct($folderMapper); + $this->api = $api; } @@ -44,8 +50,9 @@ class FolderBl extends Bl { private function allowNoNameTwice($folderName, $userId){ $existingFolders = $this->mapper->findByName($folderName, $userId); if(count($existingFolders) > 0){ - throw new BLException('Error: Folder with name ' . $folderName . - ' exists already!'); + + throw new BLException( + $this->api->getTrans()->t('Can not add folder: Exists already')); } } diff --git a/css/feeds.css b/css/feeds.css index 22a290318..245308ed2 100644 --- a/css/feeds.css +++ b/css/feeds.css @@ -45,6 +45,10 @@ text-transform: uppercase; } +.feed { + text-transform: none; +} + .unread-counter { padding: 8px 6px 8px 5px; overflow: hidden; @@ -101,4 +105,27 @@ button.action:hover { height:20px; } +.progress-icon { + background-image: url('%webroot%/core/img/loading.gif'); +} + +.problem-icon { + background-image: url('%appswebroot%/news/img/problem.svg'); +} + +.failed { + background-color: #EB9DA6 !important; + text-shadow: none !important; +} + + .failed .message { + padding: 5px 20px 5px 32px; + text-transform: none; + background-color: #E83A4E; + text-shadow: none; + color: #fefefe; + } + .folder .feed.failed .message { + padding-left: 48px; + } \ No newline at end of file diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php index 3b13b251a..4881596cf 100644 --- a/dependencyinjection/dicontainer.php +++ b/dependencyinjection/dicontainer.php @@ -102,7 +102,7 @@ class DIContainer extends BaseContainer { * Business Layer */ $this['FolderBl'] = $this->share(function($c){ - return new FolderBl($c['FolderMapper']); + return new FolderBl($c['FolderMapper'], $c['API']); }); $this['FeedBl'] = $this->share(function($c){ diff --git a/img/problem.svg b/img/problem.svg new file mode 100644 index 000000000..9d9c51f8d --- /dev/null +++ b/img/problem.svg @@ -0,0 +1,1749 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/part.listfeed.php b/templates/part.listfeed.php index 73087af28..118bdd0b8 100644 --- a/templates/part.listfeed.php +++ b/templates/part.listfeed.php @@ -1,6 +1,7 @@
  • - + + {{ feed.title }} @@ -36,4 +42,7 @@ title="t('Delete feed')); ?>"> + +
    {{ feed.error }}
  • + diff --git a/templates/part.listfolder.php b/templates/part.listfolder.php index a7e2e7497..9520bf42d 100644 --- a/templates/part.listfolder.php +++ b/templates/part.listfolder.php @@ -2,7 +2,8 @@ active: folderBl.isActive(folder.id), open: folder.opened && folderBl.hasFeeds(folder.id), collapsible: folderBl.hasFeeds(folder.id), - unread: folderBl.getUnreadCount(folder.id) != 0 + unread: folderBl.getUnreadCount(folder.id) != 0, + failed: folder.error }" ng-repeat="folder in folderBl.getAll()" ng-show="folderBl.isVisible(folder.id)" @@ -14,11 +15,15 @@ ng-click="folderBl.toggleFolder(folder.id)"> + ng-click="folderBl.load(folder.id)" + ng-class="{ + progress-icon: !folder.id, + problem-icon: folder.error + }"> {{ folder.name }} - +