creates a superclass collection for feeds and folders

This commit is contained in:
Alessandro Cosentino 2012-06-07 16:19:25 -04:00
Родитель b1fc686d20
Коммит e583df60d3
6 изменённых файлов: 23 добавлений и 34 удалений

Просмотреть файл

@ -22,6 +22,7 @@
*/
OC::$CLASSPATH['OC_News_Item'] = 'apps/news/lib/item.php';
OC::$CLASSPATH['OC_News_Collection'] = 'apps/news/lib/collection.php';
OC::$CLASSPATH['OC_News_Feed'] = 'apps/news/lib/feed.php';
OC::$CLASSPATH['OC_News_Folder'] = 'apps/news/lib/folder.php';

Просмотреть файл

@ -37,7 +37,13 @@ OCP\App::setActiveNavigationEntry('news');
//OCP\Util::addscript('news','news');
OCP\Util::addStyle('news', 'news');
$foldermapper = new OC_News_FolderMapper();
//this is the root folder, which contains all sub-folders and feeds
$allfeeds = null;
$tmpl = new OCP\Template( 'news', 'main', 'user' );
$tmpl->assign('allfeeds', $allfeeds);
$tmpl->printPage();
?>

Просмотреть файл

@ -23,10 +23,9 @@
/**
* This class models a feed.
*/
class OC_News_Feed {
class OC_News_Feed extends OC_News_Collection {
private $url;
private $id; //id of the feed in the database
private $spfeed; //encapsulate a SimplePie_Core object
private $items; //array that contains all the items of the feed
@ -39,14 +38,6 @@ class OC_News_Feed {
}
}
public function getId(){
return $this->id;
}
public function setId($id){
$this->id = $id;
}
public function getUrl(){
return $this->url;
}

Просмотреть файл

@ -23,18 +23,18 @@
/**
* This class models a folder that contains feeds.
*/
class OC_News_Folder {
class OC_News_Folder extends OC_News_Collection {
private $name;
private $id;
private $feeds;
private $children;
private $parent;
public function __construct($name, $parent = null){
$this->name = $name;
$this->parent = $parent;
$this->feeds = array();
$this->children = array();
if ($parent !== null){
$this->parent = $parent;
}
}
public function getName(){
@ -45,23 +45,15 @@ class OC_News_Folder {
$this->name = $name;
}
public function getId(){
return $this->id;
}
public function setId($id){
$this->id = $id;
}
public function getParentId(){
if ($this->parent == null){
if ($this->parent === null){
return 0;
}
return $this->parent->getId();
}
public function addFeed(OC_News_Feed $feed){
$this->feeds[] = $feed;
public function addChild(OC_News_Collection $child){
$this->children[] = $child;
}
}

Просмотреть файл

@ -27,19 +27,18 @@ class OC_News_FolderMapper {
const tableName = '*PREFIX*news_folders';
public function root(){
$root = new OC_News_Folder('All feeds');
return $root;
}
/**
* @brief Retrieve a feed from the database
* @param id The id of the feed in the database table.
* @returns
*/
public function find($id){
$stmt = OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE id = ?');
$result = $stmt->execute(array($id));
$row = $result->fetchRow();
$url = $row['url'];
$title = $row['title'];
$feed = new OC_News_Feed($url, $title, null, $id);
return $feed;
}
/**

Просмотреть файл

@ -1,6 +1,6 @@
<div id="leftcontent" class="leftcontent">
<ul id="feeds">
<?php echo $this->inc("test"); ?>
<?php echo $this->inc("part.feeds"); ?>
</ul>
</div>
<div id="bottomcontrols">