diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2012-09-07 15:21:03 +0200 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2012-09-07 15:21:03 +0200 |
commit | a59854cc809828501371dc934362c81a82e83cee (patch) | |
tree | 24e9172389f9fdf3aaaac50452f90c8dc9e77ed1 /lib | |
parent | ce2e3bd0cba51d5625c53d14bd58204eca89eaf2 (diff) |
adding space between) and {
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backgroundjob.php | 26 | ||||
-rw-r--r-- | lib/collection.php | 6 | ||||
-rw-r--r-- | lib/feedmapper.php | 34 | ||||
-rw-r--r-- | lib/folder.php | 20 | ||||
-rw-r--r-- | lib/foldermapper.php | 18 | ||||
-rw-r--r-- | lib/item.php | 46 | ||||
-rw-r--r-- | lib/itemmapper.php | 28 | ||||
-rw-r--r-- | lib/utils.php | 4 |
8 files changed, 91 insertions, 91 deletions
diff --git a/lib/backgroundjob.php b/lib/backgroundjob.php index c9f37d3d4..896fd6f03 100644 --- a/lib/backgroundjob.php +++ b/lib/backgroundjob.php @@ -26,11 +26,11 @@ namespace OCA\News; * This class maps a feed to an entry in the feeds table of the database. */ class Backgroundjob { - static public function sortFeeds( $a, $b ){ - if( $a['id'] == $b['id'] ){ + static public function sortFeeds( $a, $b ) { + if( $a['id'] == $b['id'] ) { return 0; } - elseif( $a['id'] < $b['id'] ){ + elseif( $a['id'] < $b['id'] ) { return -1; } else{ @@ -38,8 +38,8 @@ class Backgroundjob { } } - static public function run(){ - if( \OC::$CLI ){ + static public function run() { + if( \OC::$CLI ) { self::cliStep(); } else{ @@ -47,17 +47,17 @@ class Backgroundjob { } } - static private function cliStep(){ + static private function cliStep() { $feedmapper = new FeedMapper(); // Iterate over all feeds $feeds = $feedmapper->findAll(); - foreach( $feeds as $feed ){ + foreach( $feeds as $feed ) { self::updateFeed( $feedmapper, $feed ); } } - static private function webStep(){ + static private function webStep() { // Iterate over all users $lastid = \OCP\Config::getAppValue('news', 'backgroundjob_lastid',0); @@ -66,8 +66,8 @@ class Backgroundjob { usort( $feeds, array( 'OCA\News\Backgroundjob', 'sortFeeds' )); $done = false; - foreach( $feeds as $feed ){ - if( $feed['id'] > $lastid ){ + foreach( $feeds as $feed ) { + if( $feed['id'] > $lastid ) { // set lastid BEFORE updating feed! \OCP\Config::setAppValue('news', 'backgroundjob_lastid',$feed['id']); $done = true; @@ -75,15 +75,15 @@ class Backgroundjob { } } - if( !$done ){ + if( !$done ) { \OCP\Config::setAppValue('news', 'backgroundjob_lastid',0); } } - static private function updateFeed( $feedmapper, $feed ){ + static private function updateFeed( $feedmapper, $feed ) { $newfeed = null; $newfeed = Utils::fetch( $feed['url'] ); - if( $newfeed !== null ){ + if( $newfeed !== null ) { $feedmapper = new FeedMapper(); $newfeedid = $feedmapper->save($newfeed, $feed['folderid'] ); } diff --git a/lib/collection.php b/lib/collection.php index 4f7f06d7a..3c36dbceb 100644 --- a/lib/collection.php +++ b/lib/collection.php @@ -19,15 +19,15 @@ class Collection { private $id; - public function __construct($id){ + public function __construct($id) { $this->id = $id; } - public function getId(){ + public function getId() { return $this->id; } - public function setId($id){ + public function setId($id) { $this->id = $id; } diff --git a/lib/feedmapper.php b/lib/feedmapper.php index eec3ade64..85797c44c 100644 --- a/lib/feedmapper.php +++ b/lib/feedmapper.php @@ -20,7 +20,7 @@ class FeedMapper { const tableName = '*PREFIX*news_feeds'; private $userid; - public function __construct($userid = null){ + public function __construct($userid = null) { if ($userid !== null) { $this->userid = $userid; } @@ -32,7 +32,7 @@ class FeedMapper { * @param row a row from the feeds table of the database * @returns an object of the class OCA\News\Feed */ - public function fromRow($row){ + public function fromRow($row) { $url = $row['url']; $title = $row['title']; $id = $row['id']; @@ -48,10 +48,10 @@ class FeedMapper { * @param userid * @returns */ - public function findAll(){ + public function findAll() { $query = 'SELECT * FROM ' . self::tableName; $params = array(); - if( $this->userid ){ + if( $this->userid ) { $query = $query.' WHERE user_id = ?'; $params[] = $this->userid; } @@ -75,7 +75,7 @@ class FeedMapper { * @param id The id of the feed in the database table. * @returns */ - public function findById($id){ + public function findById($id) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE id = ?'); $result = $stmt->execute(array($id)); if(!$row = $result->fetchRow()) @@ -89,7 +89,7 @@ class FeedMapper { * @param folderid The id of the folder in the database table. * @returns a list of feeds */ - public function findByFolderId($folderid){ + public function findByFolderId($folderid) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE user_id = ? AND folder_id = ?'); $result = $stmt->execute(array($this->userid, $folderid)); $feeds = array(); @@ -106,7 +106,7 @@ class FeedMapper { * @param id The id of the feed in the database table. * @returns an instance of OCA\News\Feed */ - public function findWithItems($id){ + public function findWithItems($id) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE id = ?'); $result = $stmt->execute(array($id)); $row = $result->fetchRow(); @@ -125,25 +125,25 @@ class FeedMapper { * @return id of the feed corresponding to the url passed as parameters * null - if there is no such feed */ - public function findIdFromUrl($url){ + public function findIdFromUrl($url) { $url_hash = md5($url); $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE url_hash = ?'); $result = $stmt->execute(array($url_hash)); $row = $result->fetchRow(); $id = null; - if ($row != null){ + if ($row != null) { $id = $row['id']; } return $id; } - public function mostRecent(){ + public function mostRecent() { //FIXME: does something like SELECT TOP 1 * exists in pear/mdb2 ?? $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' ORDER BY lastmodified'); $result = $stmt->execute(); $row = $result->fetchRow(); $id = null; - if ($row != null){ + if ($row != null) { $id = $row['id']; } return $id; @@ -155,7 +155,7 @@ class FeedMapper { * @returns The id of the feed in the database table. */ //TODO: handle error case - public function save(Feed $feed, $folderid){ + public function save(Feed $feed, $folderid) { $title = $feed->getTitle(); $url = $feed->getUrl(); $url_hash = md5($url); @@ -169,7 +169,7 @@ class FeedMapper { //FIXME: Detect when feed contains already a database id $feedid = $this->findIdFromUrl($url); - if ($feedid === null){ + if ($feedid === null) { $query = \OCP\DB::prepare(" INSERT INTO " . self::tableName . "(url, url_hash, title, favicon_link, folder_id, user_id, added, lastmodified) @@ -209,7 +209,7 @@ class FeedMapper { $items = $feed->getItems(); if ($items !== null) { - foreach($items as $item){ + foreach($items as $item) { $itemMapper->save($item, $feedid); } } @@ -218,7 +218,7 @@ class FeedMapper { } - public function deleteById($id){ + public function deleteById($id) { if ($id == null) { return false; } @@ -233,12 +233,12 @@ class FeedMapper { return true; } - public function delete(Feed $feed){ + public function delete(Feed $feed) { $id = $feed->getId(); return deleteById($id); } - public function deleteAll($folderid){ + public function deleteAll($folderid) { if ($folderid == null) { return false; } diff --git a/lib/folder.php b/lib/folder.php index 41577d844..6ed2103bb 100644 --- a/lib/folder.php +++ b/lib/folder.php @@ -21,41 +21,41 @@ class Folder extends Collection { private $children; private $parent; - public function __construct($name, $id = null, Collection $parent = null){ + public function __construct($name, $id = null, Collection $parent = null) { $this->name = $name; - if ($id !== null){ + if ($id !== null) { parent::__construct($id); } $this->children = array(); - if ($parent !== null){ + if ($parent !== null) { $this->parent = $parent; } } - public function getName(){ + public function getName() { return $this->name; } - public function setName($name){ + public function setName($name) { $this->name = $name; } - public function getParentId(){ - if ($this->parent === null){ + public function getParentId() { + if ($this->parent === null) { return 0; } return $this->parent->getId(); } - public function addChild(Collection $child){ + public function addChild(Collection $child) { $this->children[] = $child; } - public function addChildren($children){ + public function addChildren($children) { $this->children = $children; } - public function getChildren(){ + public function getChildren() { return $this->children; } diff --git a/lib/foldermapper.php b/lib/foldermapper.php index 4eb78b119..431d80893 100644 --- a/lib/foldermapper.php +++ b/lib/foldermapper.php @@ -21,7 +21,7 @@ class FolderMapper { private $userid; - public function __construct($userid = null){ + public function __construct($userid = null) { if ($userid !== null) { $this->userid = $userid; } @@ -40,7 +40,7 @@ class FolderMapper { ' WHERE user_id = ? AND parent_id = ?'); $result = $stmt->execute(array($this->userid, $parentid)); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $folderid = $row['id']; $folder = new Folder($row['name'], $folderid); $children = self::childrenOf($folderid); @@ -66,7 +66,7 @@ class FolderMapper { ' WHERE user_id = ? AND parent_id = ?'); $result = $stmt->execute(array($this->userid, $parentid)); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $folderid = $row['id']; $folder = new Folder($row['name'], $folderid); $children = self::childrenOfWithFeeds($folderid); @@ -83,7 +83,7 @@ class FolderMapper { * @param id The id of the folder in the database table. * @returns an instance of OC_News_Folder */ - public function find($id){ + public function find($id) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE user_id = ? AND id = ?'); @@ -100,7 +100,7 @@ class FolderMapper { * @param folder the folder to be saved * @returns The id of the folder in the database table. */ - public function save(Folder $folder){ + public function save(Folder $folder) { $query = \OCP\DB::prepare(' INSERT INTO ' . self::tableName . '(name, parent_id, user_id) @@ -133,7 +133,7 @@ class FolderMapper { * @brief Updates the folder * @param folder the folder to be updated */ - public function update(Folder $folder){ + public function update(Folder $folder) { $query = \OCP\DB::prepare('UPDATE ' . self::tableName . ' SET name = ? ' . ' WHERE id = ?'); @@ -147,7 +147,7 @@ class FolderMapper { * @param folder the folder to be deleted (an instance of OCA\News\Folder) * @returns true if the folder has been deleted, false if an error occurred */ - public function delete(Folder $folder){ + public function delete(Folder $folder) { $folderid = $folder->getId(); return deleteById(folderid); } @@ -157,8 +157,8 @@ class FolderMapper { * @param folder the folder to be deleted (an instance of OCA\News\Folder) * @returns true if the folder has been deleted, false if an error occurred */ - public function deleteById($folderid){ - if ($folderid == null){ + public function deleteById($folderid) { + if ($folderid == null) { return false; } diff --git a/lib/item.php b/lib/item.php index e64eaa044..114751cfe 100644 --- a/lib/item.php +++ b/lib/item.php @@ -35,7 +35,7 @@ class Item { private $author; private $date; //date is stored in the Unix format - public function __construct($url, $title, $guid, $body, $id = null){ + public function __construct($url, $title, $guid, $body, $id = null) { $this->title = $title; $this->url = $url; $this->guid = $guid; @@ -48,43 +48,43 @@ class Item { } } - public function getGuid(){ + public function getGuid() { return $this->guid; } - public function setGuid($guid){ + public function setGuid($guid) { $this->guid = $guid; } - public function getId(){ + public function getId() { return $this->id; } - public function setId($id){ + public function setId($id) { $this->id = $id; } - public function setRead(){ + public function setRead() { $this->status &= ~StatusFlag::UNREAD; } - public function setUnread(){ + public function setUnread() { $this->status |= StatusFlag::UNREAD; } - public function isRead(){ + public function isRead() { return !($this->status & StatusFlag::UNREAD); } - public function setImportant(){ + public function setImportant() { $this->status |= StatusFlag::IMPORTANT; } - public function setUnimportant(){ + public function setUnimportant() { $this->status &= ~StatusFlag::IMPORTANT; } - public function isImportant(){ + public function isImportant() { return ($this->status & StatusFlag::IMPORTANT); } @@ -92,11 +92,11 @@ class Item { * NOTE: this is needed to store items in the database, otherwise * the status of an item should be retrieved with methods: isRead(), isImportant(), ... */ - public function getStatus(){ + public function getStatus() { return $this->status; } - public function setStatus($status){ + public function setStatus($status) { $this->status = $status; } @@ -104,44 +104,44 @@ class Item { * http://www.php.net/manual/en/language.oop5.overloading.php#object.get */ - public function getTitle(){ + public function getTitle() { return $this->title; } - public function setTitle($title){ + public function setTitle($title) { $this->title = $title; } - public function getUrl(){ + public function getUrl() { return $this->url; } - public function setUrl($url){ + public function setUrl($url) { $this->url = $url; } - public function getBody(){ + public function getBody() { return $this->body; } - public function setBody($body){ + public function setBody($body) { $this->body = $body; } - public function getAuthor(){ + public function getAuthor() { return $this->author; } - public function setAuthor($author){ + public function setAuthor($author) { $this->author = $author; } - public function getDate(){ + public function getDate() { return $this->date; } //TODO: check if the parameter is in the Unix format - public function setDate($date){ + public function setDate($date) { $this->date = $date; } } diff --git a/lib/itemmapper.php b/lib/itemmapper.php index 70b616985..1da04f8ef 100644 --- a/lib/itemmapper.php +++ b/lib/itemmapper.php @@ -21,7 +21,7 @@ class ItemMapper { const tableName = '*PREFIX*news_items'; private $userid; - public function __construct($userid = null){ + public function __construct($userid = null) { if ($userid !== null) { $this->userid = $userid; } @@ -33,7 +33,7 @@ class ItemMapper { * @param row a row from the items table of the database * @returns an object of the class OC_News_Item */ - public function fromRow($row){ + public function fromRow($row) { $url = $row['url']; $title = $row['title']; $guid = $row['guid']; @@ -51,7 +51,7 @@ class ItemMapper { * @brief Retrieve all the item corresponding to a feed from the database * @param feedid The id of the feed in the database table. */ - public function findAll($feedid){ + public function findAll($feedid) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE feed_id = ? ORDER BY pub_date DESC'); $result = $stmt->execute(array($feedid)); @@ -70,7 +70,7 @@ class ItemMapper { * @param feedid The id of the feed in the database table. * @param status one of the constants defined in OCA\News\StatusFlag */ - public function findAllStatus($feedid, $status){ + public function findAllStatus($feedid, $status) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE feed_id = ? AND ((status & ?) > 0) @@ -90,7 +90,7 @@ class ItemMapper { * @brief Retrieve all the items from the database with a particular status * @param status one of the constants defined in OCA\News\StatusFlag */ - public function findEveryItemByStatus($status){ + public function findEveryItemByStatus($status) { $stmt = \OCP\DB::prepare('SELECT ' . self::tableName . '.* FROM ' . self::tableName . ' JOIN '. FeedMapper::tableName .' ON '. FeedMapper::tableName .'.id = ' . self::tableName . '.feed_id @@ -108,7 +108,7 @@ class ItemMapper { return $items; } - public function countAllStatus($feedid, $status){ + public function countAllStatus($feedid, $status) { $stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . ' WHERE feed_id = ? AND ((status & ?) > 0)'); @@ -120,7 +120,7 @@ class ItemMapper { * @brief Count all the items from the database with a particular status * @param status one of the constants defined in OCA\News\StatusFlag */ - public function countEveryItemByStatus($status){ + public function countEveryItemByStatus($status) { $stmt = \OCP\DB::prepare('SELECT COUNT(*) as size FROM ' . self::tableName . ' JOIN '. FeedMapper::tableName .' ON '. FeedMapper::tableName .'.id = ' . self::tableName . '.feed_id @@ -131,7 +131,7 @@ class ItemMapper { return $result['size']; } - public function findIdFromGuid($guid_hash, $guid, $feedid){ + public function findIdFromGuid($guid_hash, $guid, $feedid) { $stmt = \OCP\DB::prepare(' SELECT * FROM ' . self::tableName . ' WHERE guid_hash = ? @@ -141,7 +141,7 @@ class ItemMapper { //TODO: if there is more than one row, falling back to comparing $guid $row = $result->fetchRow(); $id = null; - if ($row != null){ + if ($row != null) { $id = $row['id']; } return $id; @@ -151,7 +151,7 @@ class ItemMapper { * @brief Update the item after its status has changed * @returns The item whose status has changed. */ - public function update(Item $item){ + public function update(Item $item) { $itemid = $item->getId(); $status = $item->getStatus(); @@ -175,7 +175,7 @@ class ItemMapper { * @brief Save the feed and all its items into the database * @returns The id of the feed in the database table. */ - public function save(Item $item, $feedid){ + public function save(Item $item, $feedid) { $guid = $item->getGuid(); $guid_hash = md5($guid); @@ -183,7 +183,7 @@ class ItemMapper { $itemid = $this->findIdFromGuid($guid_hash, $guid, $feedid); - if ($itemid == null){ + if ($itemid == null) { $title = $item->getTitle(); $body = $item->getBody(); $author = $item->getAuthor(); @@ -233,7 +233,7 @@ class ItemMapper { * @brief Retrieve an item from the database * @param id The id of the feed in the database table. */ - public function find($id){ + public function find($id) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE id = ?'); $result = $stmt->execute(array($id)); $row = $result->fetchRow(); @@ -250,7 +250,7 @@ class ItemMapper { * @param feedid The id of the feed that we wish to delete * @return */ - public function deleteAll($feedid){ + public function deleteAll($feedid) { if ($feedid == null) { return false; } diff --git a/lib/utils.php b/lib/utils.php index 7c1f8ee4a..ab80018d6 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -43,7 +43,7 @@ class Utils { * @param url remote url of the feed * @returns an instance of OC_News_Feed */ - public static function fetch($url){ + public static function fetch($url) { $spfeed = new \SimplePie_Core(); $spfeed->set_feed_url( $url ); $spfeed->enable_cache( false ); @@ -106,7 +106,7 @@ class Utils { * @param url remote url of the feed * @returns an instance of OC_News_Feed */ - public static function slimFetch($url){ + public static function slimFetch($url) { $spfeed = new \SimplePie_Core(); $spfeed->set_feed_url( $url ); $spfeed->enable_cache( false ); |