diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-11 15:33:34 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-11 15:33:34 +0100 |
commit | fef624f0c4becc126a8e2d576cd1a8fc3c80cea0 (patch) | |
tree | 2157a2b7a5305f81dd5764188f49a6f88816b1bd | |
parent | 5492e60510379add1523454f322def81167be8be (diff) |
spaces to tabs
-rw-r--r-- | coffee/controllers/addnewcontroller.coffee | 2 | ||||
-rw-r--r-- | coffee/controllers/feedcontroller.coffee | 106 | ||||
-rw-r--r-- | coffee/controllers/settingscontroller.coffee | 4 | ||||
-rw-r--r-- | coffee/directives/droppable.coffee | 4 | ||||
-rw-r--r-- | controller/news.ajax.controller.php | 814 | ||||
-rw-r--r-- | templates/main.php | 44 | ||||
-rw-r--r-- | templates/part.addnew.php | 64 | ||||
-rw-r--r-- | templates/part.feed.starred.php | 30 | ||||
-rw-r--r-- | templates/part.feed.unread.php | 36 | ||||
-rw-r--r-- | templates/part.listfeed.php | 18 | ||||
-rw-r--r-- | templates/part.listfolder.php | 22 |
11 files changed, 572 insertions, 572 deletions
diff --git a/coffee/controllers/addnewcontroller.coffee b/coffee/controllers/addnewcontroller.coffee index 348b1ecb1..27fd071b7 100644 --- a/coffee/controllers/addnewcontroller.coffee +++ b/coffee/controllers/addnewcontroller.coffee @@ -15,6 +15,6 @@ angular.module('News').factory '_AddNewController', ['Controller', (Controller) -> - class AddNewController extends Controller + class AddNewController extends Controller ]
\ No newline at end of file diff --git a/coffee/controllers/feedcontroller.coffee b/coffee/controllers/feedcontroller.coffee index 4717a6594..9f3e733ee 100644 --- a/coffee/controllers/feedcontroller.coffee +++ b/coffee/controllers/feedcontroller.coffee @@ -26,60 +26,60 @@ angular.module('News').factory '_FeedController', ['Controller', (Controller) -> @$scope.folders = @folderModel.getItems() @$scope.feedType = @feedType - @$scope.getShowAll = => - return @showAll.showAll - - @$scope.setShowAll = (value) => - @showAll.showAll = value - @persistence.showAll(value) - @$rootScope.$broadcast('triggerHideRead') - - @$scope.addFeed = (url, folder) => - @$scope.feedEmptyError = false - @$scope.feedExistsError = false - @$scope.feedError = false + @$scope.getShowAll = => + return @showAll.showAll + + @$scope.setShowAll = (value) => + @showAll.showAll = value + @persistence.showAll(value) + @$rootScope.$broadcast('triggerHideRead') + + @$scope.addFeed = (url, folder) => + @$scope.feedEmptyError = false + @$scope.feedExistsError = false + @$scope.feedError = false - if url == undefined or url.trim() == '' - @$scope.feedEmptyError = true - else - url = url.trim() - for feed in @feedModel.getItems() - if url == feed.url # FIXME: can we really compare this - @$scope.feedExistsError = true - - if not (@$scope.feedEmptyError or @$scope.feedExistsError) - if folder == undefined - folderId = 0 - else - folderId = folder.id - @addingFeed = true - onSuccess = => - @$scope.feedUrl = '' - @addingFeed = false - onError = => - @$scope.feedError = true - @addingFeed = false - @persistence.createFeed(url, folderId, onSuccess, onError) - - - @$scope.addFolder = (name) => - @$scope.folderEmptyError = false - @$scope.folderExistsError = false - - if name == undefined or name.trim() == '' - @$scope.folderEmptyError = true - else - name = name.trim() - for folder in @folderModel.getItems() - if name.toLowerCase() == folder.name.toLowerCase() - @$scope.folderExistsError = true - - if not (@$scope.folderEmptyError or @$scope.folderExistsError) - @addingFolder = true - onSuccess = => - @$scope.folderName = '' - @addingFolder = false - @persistence.createFolder(name, onSuccess) + if url == undefined or url.trim() == '' + @$scope.feedEmptyError = true + else + url = url.trim() + for feed in @feedModel.getItems() + if url == feed.url # FIXME: can we really compare this + @$scope.feedExistsError = true + + if not (@$scope.feedEmptyError or @$scope.feedExistsError) + if folder == undefined + folderId = 0 + else + folderId = folder.id + @addingFeed = true + onSuccess = => + @$scope.feedUrl = '' + @addingFeed = false + onError = => + @$scope.feedError = true + @addingFeed = false + @persistence.createFeed(url, folderId, onSuccess, onError) + + + @$scope.addFolder = (name) => + @$scope.folderEmptyError = false + @$scope.folderExistsError = false + + if name == undefined or name.trim() == '' + @$scope.folderEmptyError = true + else + name = name.trim() + for folder in @folderModel.getItems() + if name.toLowerCase() == folder.name.toLowerCase() + @$scope.folderExistsError = true + + if not (@$scope.folderEmptyError or @$scope.folderExistsError) + @addingFolder = true + onSuccess = => + @$scope.folderName = '' + @addingFolder = false + @persistence.createFolder(name, onSuccess) @$scope.toggleFolder = (folderId) => folder = @folderModel.getItemById(folderId) diff --git a/coffee/controllers/settingscontroller.coffee b/coffee/controllers/settingscontroller.coffee index 9afda5407..ef862b77e 100644 --- a/coffee/controllers/settingscontroller.coffee +++ b/coffee/controllers/settingscontroller.coffee @@ -18,7 +18,7 @@ angular.module('News').factory '_SettingsController', ['Controller', class SettingsController extends Controller - constructor: (@$scope, @$rootScope, @persistence, @opmlParser) -> + constructor: (@$scope, @$rootScope, @persistence, @opmlParser) -> @add = false @settings = false @@ -27,7 +27,7 @@ angular.module('News').factory '_SettingsController', ['Controller', @$scope.$on 'readFile', (scope, fileContent) => structure = @opmlParser.parseXML(fileContent) - @parseOPMLStructure(structure) + @parseOPMLStructure(structure) @$scope.$on 'hidesettings', => @add = false diff --git a/coffee/directives/droppable.coffee b/coffee/directives/droppable.coffee index a9c134096..6579f8db4 100644 --- a/coffee/directives/droppable.coffee +++ b/coffee/directives/droppable.coffee @@ -20,11 +20,11 @@ angular.module('News').directive 'droppable', ['$rootScope', ($rootScope) -> details = accept: '.feed' - hoverClass: 'drag-and-drop' + hoverClass: 'drag-and-drop' greedy: true drop: (event, ui) -> # in case jquery ui did something weird - $('.drag-and-drop').removeClass('drag-and-drop') + $('.drag-and-drop').removeClass('drag-and-drop') data = folderId: parseInt($elem.data('id'), 10) diff --git a/controller/news.ajax.controller.php b/controller/news.ajax.controller.php index 7e96b2c2a..552bb32de 100644 --- a/controller/news.ajax.controller.php +++ b/controller/news.ajax.controller.php @@ -17,412 +17,412 @@ namespace OCA\News; */ class NewsAjaxController extends Controller { - private $feedMapper; - private $folderMapper; - private $itemMapper; - - /** - * @param Request $request: the object with the request instance - * @param string $api: an instance of the api wrapper - * @param FeedMapper $feedMapepr an instance of the feed mapper - * @param FolderMapper $folderMapper an instance of the folder mapper - * @param ItemMapper $itemMapper an instance of the item mapper - */ - public function __construct($request, $api, $feedMapper, $folderMapper, - $itemMapper){ - parent::__construct($request, $api); - $this->feedMapper = $feedMapper; - $this->folderMapper = $folderMapper; - $this->itemMapper = $itemMapper; - } - - - /** - * @brief turns a post parameter which got a boolean from javascript to - * a boolean in PHP - * @param string $param the post parameter that should be turned into a bool - * @return a PHP boolean - */ - public function postParamToBool($param){ - if($param === 'false') { - return false; - } else { - return true; - } - } - - - /** - * This turns a folder result into an array which can be sent to the client - * as JSON - * @param array $folders the database query result for folders - * @return an array ready for sending as JSON - */ - private function foldersToArray($folders){ - $foldersArray = array(); - foreach($folders as $folder){ - if($folder instanceof \OCA\News\Folder){ - array_push($foldersArray, array( - 'id' => (int)$folder->getId(), - 'name' => $folder->getName(), - 'open' => $folder->getOpened()==="1", - 'hasChildren' => count($folder->getChildren()) > 0, - 'show' => true - ) - ); - } - } - return $foldersArray; - } - - - /** - * This turns a feed result into an array which can be sent to the client - * as JSON - * @param array $feeds the database query result for feeds - * @return an array ready for sending as JSON - */ - private function feedsToArray($feeds){ - $feedsArray = array(); - foreach($feeds as $feed){ - array_push($feedsArray, array( - 'id' => (int)$feed->getId(), - 'name' => $feed->getTitle(), - 'unreadCount' => (int)$this->itemMapper->getUnreadCount(FeedType::FEED, - $feed->getId()), - 'folderId' => (int)$feed->getFolderId(), - 'show' => true, - 'icon' => 'url(' . $feed->getFavicon() .')', - 'url' => $feed->getUrl() - ) - ); - } - return $feedsArray; - } - - - /** - * This turns an items result into an array which can be sent to the client - * as JSON - * @param array $items the database query result for items - * @return an array ready for sending as JSON - */ - private function itemsToArray($items){ - $itemsArray = array(); - foreach($items as $item){ - - $enclosure = $item->getEnclosure(); - if($enclosure){ - $enclosure = array( - 'link' => $enclosure->getLink(), - 'type' => $enclosure->getMimeType() - ); - } - - array_push($itemsArray, array( - 'id' => (int)$item->getId(), - 'title' => $item->getTitle(), - 'isRead' => (bool)$item->isRead(), - 'isImportant' => (bool)$item->isImportant(), - 'feedId' => (int)$item->getFeedId(), - 'feedTitle' => $item->getFeedTitle(), - 'date' => (int)$item->getDate(), - 'body' => $item->getBody(), - 'author' => $item->getAuthor(), - 'url' => $item->getUrl(), - 'enclosure' => $enclosure - ) - ); - } - return $itemsArray; - } - - - /** - * This is being called when the app starts and all feeds - * and folders are requested - */ - public function init(){ - $folders = $this->folderMapper->childrenOfWithFeeds(0); - $foldersArray = $this->foldersToArray($folders); - - $feeds = $this->feedMapper->findAll(); - $feedsArray = $this->feedsToArray($feeds); - - $activeFeed = array(); - $activeFeed['id'] = (int)$this->api->getUserValue('lastViewedFeed'); - $activeFeed['type'] = (int)$this->api->getUserValue('lastViewedFeedType'); - - $showAll = $this->api->getUserValue('showAll') === "1"; - - $starredCount = $this->itemMapper->getUnreadCount(\OCA\News\FeedType::STARRED, 0); - - $result = array( - 'folders' => $foldersArray, - 'feeds' => $feedsArray, - 'activeFeed' => $activeFeed, - 'showAll' => $showAll, - 'userId' => $this->userId, - 'starredCount' => $starredCount - ); - - return $this->renderJSON($result); - } - - - /** - * loads the next X feeds from the server - */ - public function loadFeed(){ - $feedType = (int)$this->params('type'); - $feedId = (int)$this->params('id'); - $latestFeedId = (int)$this->params('latestFeedId'); - $latestTimestamp = (int)$this->params('latestTimestamp'); - $limit = (int)$this->params('limit'); - - // FIXME: integrate latestFeedId, latestTimestamp and limit - $this->api->setUserValue('lastViewedFeed', $feedId); - $this->api->setUserValue('lastViewedFeedType', $feedType); - - $showAll = $this->api->getUserValue('showAll'); - - $items = $this->itemMapper->getItems($feedType, $feedId, $showAll); - $itemsArray = $this->itemsToArray($items); - - // update unread count of all feeds - $feeds = $this->feedMapper->findAll(); - $feedsArray = array(); - - foreach($feeds as $feed){ - $unreadCount = $this->itemMapper->countAllStatus($feed->getId(), StatusFlag::UNREAD); - $unreadArray = array( - 'id' => (int)$feed->getId(), - 'unreadCount' => (int)$unreadCount - ); - array_push($feedsArray, $unreadArray); - } - - $result = array( - 'items' => $itemsArray, - 'feeds' => $feedsArray - ); - - return $this->renderJSON($result); - - } - - - /** - * Used for setting the showAll value from a post request - */ - public function setShowAll(){ - $showAll = $this->postParamToBool($this->params('showAll')); - $this->api->setUserValue('showAll', $showAll); - return $this->renderJSON(); - } - - - /** - * Used for setting the showAll value from a post request - */ - public function collapseFolder(){ - $folderId = (int)$this->params('folderId'); - $opened = $this->postParamToBool($this->params('opened')); - - $folder = $this->folderMapper->find($folderId); - $folder->setOpened($opened); - $this->folderMapper->update($folder); - return $this->renderJSON(); - } - - - /** - * Deletes a feed - */ - public function deleteFeed(){ - $feedId = (int)$this->params('feedId'); - $this->feedMapper->deleteById($feedId); - return $this->renderJSON(); - } - - - /** - * Deletes a folder - */ - public function deleteFolder(){ - $folderId = (int)$this->params('folderId'); - $this->folderMapper->deleteById($folderId); - return $this->renderJSON(); - } - - - /** - * Sets the status of an item - */ - public function setItemStatus(){ - $itemId = (int)$this->params('itemId'); - $status = $this->params('status'); - $item = $this->itemMapper->findById($itemId); - - switch ($status) { - case 'read': - $item->setRead(); - break; - case 'unread': - $item->setUnread(); - break; - case 'important': - $item->setImportant(); - break; - case 'unimportant': - $item->setUnimportant(); - break; - default: - exit(); - break; - } - - $this->itemMapper->update($item); - return $this->renderJSON(); - } - - - /** - * Changes the name of a folder - */ - public function changeFolderName(){ - $folderId = (int)$this->params('folderId'); - $folderName = $this->params('folderName'); - $folder = $this->folderMapper->find($folderId); - $folder->setName($folderName); - $this->folderMapper->update($folder); - return $this->renderJSON(); - } - - - /** - * Moves a feed to a new folder - */ - public function moveFeedToFolder(){ - $feedId = (int)$this->params('feedId'); - $folderId = (int)$this->params('folderId'); - $feed = $this->feedMapper->findById($feedId); - if($folderId === 0) { - $this->feedMapper->save($feed, $folderId); - } else { - $folder = $this->folderMapper->find($folderId); - if(!$folder){ - $msgString = 'Can not move feed %s to folder %s'; - $msg = $this->trans->t($msgString, array($feedId, $folderId)); - return $this->renderJSONError($msg, __FILE__); - } - $this->feedMapper->save($feed, $folder->getId()); - } - return $this->renderJSON(); - } - - - /** - * Pulls new feed items from its url - */ - public function updateFeed(){ - $feedId = (int)$this->params('feedId'); - $feed = $this->feedMapper->findById($feedId); - $newFeed = Utils::fetch($feed->getUrl()); - - $newFeedId = false; - if ($newFeed !== null) { - $newFeedId = $this->feedMapper->save($newFeed, $feed->getFolderId()); - } - - if($newFeedId){ - $feeds = array($this->feedMapper->findById($feedId)); - $feedsArray = array( - 'feeds' => $this->feedsToArray($feeds) - ); - return $this->renderJSON($feedsArray); - } else { - $msgString = 'Error updating feed %s'; - $msg = $this->trans->t($msgString, array($feed->getUrl())); - return $this->renderJSONError($msg, __FILE__); - } - - } - - - /** - * Creates a new folder - */ - public function createFolder(){ - $folderName = $this->params('folderName'); - $folder = new Folder($folderName); - $folderId = $this->folderMapper->save($folder); - $folders = array($this->folderMapper->findById($folderId)); - $foldersArray = array( - 'folders' => $this->foldersToArray($folders) - ); - return $this->renderJSON($foldersArray); - } - - - /** - * Creates a new feed - */ - public function createFeed(){ - $feedUrl = trim($this->params('feedUrl')); - $folderId = (int)$this->params('folderId'); - - $folder = $this->folderMapper->findById($folderId); - - if(!$folder && $folderId !== 0){ - $msgString = 'Folder with id %s does not exist'; - $msg = $this->trans->t($msgString, array($folderId)); - var_dump($folder); - return $this->renderJSONError($msg, __FILE__); - } - - if($this->feedMapper->findIdFromUrl($feedUrl)){ - $msgString = 'Feed %s does already exist'; - $msg = $this->trans->t($msgString, array($feedUrl)); - return $this->renderJSONError($msg, __FILE__); - } - - $feed = Utils::fetch($feedUrl); - if($feed){ - $feedId = $this->feedMapper->save($feed, $folderId); - $feeds = array($this->feedMapper->findById($feedId)); - $feedsArray = array( - 'feeds' => $this->feedsToArray($feeds) - ); - return $this->renderJSON($feedsArray); - } else { - $msgString = 'Could not create feed %s'; - $msg = $this->trans->t($msgString, array($feedUrl)); - return $this->renderJSONError($msg, __FILE__); - } - } - - - /** - * Sets all items read that are older than the current transmitted - * dates and ids - */ - public function setAllItemsRead($feedId, $mostRecentItemId){ - $feedId = (int)$this->params('feedId'); - $mostRecentItemId = (int)$this->params('mostRecentItemId'); - - $feed = $this->feedMapper->findById($feedId); - - if($feed){ - $this->itemMapper->markAllRead($feed->getId(), $mostRecentItemId); - - $feeds = array($this->feedMapper->findById($feed->getId())); - $feedsArray = array( - 'feeds' => $this->feedsToArray($feeds) - ); - return $this->renderJSON($feedsArray); - } - - } + private $feedMapper; + private $folderMapper; + private $itemMapper; + + /** + * @param Request $request: the object with the request instance + * @param string $api: an instance of the api wrapper + * @param FeedMapper $feedMapepr an instance of the feed mapper + * @param FolderMapper $folderMapper an instance of the folder mapper + * @param ItemMapper $itemMapper an instance of the item mapper + */ + public function __construct($request, $api, $feedMapper, $folderMapper, + $itemMapper){ + parent::__construct($request, $api); + $this->feedMapper = $feedMapper; + $this->folderMapper = $folderMapper; + $this->itemMapper = $itemMapper; + } + + + /** + * @brief turns a post parameter which got a boolean from javascript to + * a boolean in PHP + * @param string $param the post parameter that should be turned into a bool + * @return a PHP boolean + */ + public function postParamToBool($param){ + if($param === 'false') { + return false; + } else { + return true; + } + } + + + /** + * This turns a folder result into an array which can be sent to the client + * as JSON + * @param array $folders the database query result for folders + * @return an array ready for sending as JSON + */ + private function foldersToArray($folders){ + $foldersArray = array(); + foreach($folders as $folder){ + if($folder instanceof \OCA\News\Folder){ + array_push($foldersArray, array( + 'id' => (int)$folder->getId(), + 'name' => $folder->getName(), + 'open' => $folder->getOpened()==="1", + 'hasChildren' => count($folder->getChildren()) > 0, + 'show' => true + ) + ); + } + } + return $foldersArray; + } + + + /** + * This turns a feed result into an array which can be sent to the client + * as JSON + * @param array $feeds the database query result for feeds + * @return an array ready for sending as JSON + */ + private function feedsToArray($feeds){ + $feedsArray = array(); + foreach($feeds as $feed){ + array_push($feedsArray, array( + 'id' => (int)$feed->getId(), + 'name' => $feed->getTitle(), + 'unreadCount' => (int)$this->itemMapper->getUnreadCount(FeedType::FEED, + $feed->getId()), + 'folderId' => (int)$feed->getFolderId(), + 'show' => true, + 'icon' => 'url(' . $feed->getFavicon() .')', + 'url' => $feed->getUrl() + ) + ); + } + return $feedsArray; + } + + + /** + * This turns an items result into an array which can be sent to the client + * as JSON + * @param array $items the database query result for items + * @return an array ready for sending as JSON + */ + private function itemsToArray($items){ + $itemsArray = array(); + foreach($items as $item){ + + $enclosure = $item->getEnclosure(); + if($enclosure){ + $enclosure = array( + 'link' => $enclosure->getLink(), + 'type' => $enclosure->getMimeType() + ); + } + + array_push($itemsArray, array( + 'id' => (int)$item->getId(), + 'title' => $item->getTitle(), + 'isRead' => (bool)$item->isRead(), + 'isImportant' => (bool)$item->isImportant(), + 'feedId' => (int)$item->getFeedId(), + 'feedTitle' => $item->getFeedTitle(), + 'date' => (int)$item->getDate(), + 'body' => $item->getBody(), + 'author' => $item->getAuthor(), + 'url' => $item->getUrl(), + 'enclosure' => $enclosure + ) + ); + } + return $itemsArray; + } + + + /** + * This is being called when the app starts and all feeds + * and folders are requested + */ + public function init(){ + $folders = $this->folderMapper->childrenOfWithFeeds(0); + $foldersArray = $this->foldersToArray($folders); + + $feeds = $this->feedMapper->findAll(); + $feedsArray = $this->feedsToArray($feeds); + + $activeFeed = array(); + $activeFeed['id'] = (int)$this->api->getUserValue('lastViewedFeed'); + $activeFeed['type'] = (int)$this->api->getUserValue('lastViewedFeedType'); + + $showAll = $this->api->getUserValue('showAll') === "1"; + + $starredCount = $this->itemMapper->getUnreadCount(\OCA\News\FeedType::STARRED, 0); + + $result = array( + 'folders' => $foldersArray, + 'feeds' => $feedsArray, + 'activeFeed' => $activeFeed, + 'showAll' => $showAll, + 'userId' => $this->userId, + 'starredCount' => $starredCount + ); + + return $this->renderJSON($result); + } + + + /** + * loads the next X feeds from the server + */ + public function loadFeed(){ + $feedType = (int)$this->params('type'); + $feedId = (int)$this->params('id'); + $latestFeedId = (int)$this->params('latestFeedId'); + $latestTimestamp = (int)$this->params('latestTimestamp'); + $limit = (int)$this->params('limit'); + + // FIXME: integrate latestFeedId, latestTimestamp and limit + $this->api->setUserValue('lastViewedFeed', $feedId); + $this->api->setUserValue('lastViewedFeedType', $feedType); + + $showAll = $this->api->getUserValue('showAll'); + + $items = $this->itemMapper->getItems($feedType, $feedId, $showAll); |