diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-06-30 20:02:00 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-06-30 20:02:00 -0400 |
commit | f8f6fd3d778fe95bac15e52747ff5b1f6461c136 (patch) | |
tree | a6a895d6f356641d6c5263d64cd3853ad9a0f794 | |
parent | 6f3404ee971a130b90cf1773b9e67f4feef0be74 (diff) |
shows folder list
-rw-r--r-- | index.php | 5 | ||||
-rw-r--r-- | js/news.js | 7 | ||||
-rw-r--r-- | lib/foldermapper.php | 17 | ||||
-rw-r--r-- | templates/part.feeds.php | 24 |
4 files changed, 38 insertions, 15 deletions
@@ -11,10 +11,6 @@ * */ -// this is temporary. -//TODO: change it once the new app system is complete -require_once('../owncloud/lib/base.php'); - // load SimplePie library require_once('3rdparty/SimplePie/SimplePieAutoloader.php'); @@ -29,7 +25,6 @@ OCP\Util::addStyle('news', 'news'); $foldermapper = new OC_News_FolderMapper(OCP\USER::getUser()); -//this is the root folder, which contains all sub-folders and feeds $allfeeds = $foldermapper->root(); $tmpl = new OCP\Template( 'news', 'main', 'user' ); diff --git a/js/news.js b/js/news.js index 6ef7de93b..e97d1227c 100644 --- a/js/news.js +++ b/js/news.js @@ -48,5 +48,10 @@ $(document).ready(function(){ $('#addfeedfolder').click(News.UI.overview); $('#addfeedfolder').keydown(News.UI.overview); - + + $('.collapsable').click(function(){ + $(this).parent().children().toggle(); + $(this).toggle(); + }); + });
\ No newline at end of file diff --git a/lib/foldermapper.php b/lib/foldermapper.php index 97b146dcd..925726ab8 100644 --- a/lib/foldermapper.php +++ b/lib/foldermapper.php @@ -39,11 +39,22 @@ class OC_News_FolderMapper { } /** - * @brief Retrieve a feed from the database - * @param id The id of the feed in the database table. - * @returns + * @brief Retrieve a folder from the database + * @param id The id of the folder in the database table. + * @returns an instance of OC_News_Folder */ public function find($id){ + $stmt = OCP\DB::prepare('SELECT * + FROM ' . self::tableName . + ' WHERE user_id = ? AND id = ?'); + $result = $stmt->execute(array($this->userid, 0)); + + while( $row = $result->fetchRow()){ + $child = new OC_News_Folder($row['name'], $row['id']); + $root->addChild($child); + } + + return $root; } /** diff --git a/templates/part.feeds.php b/templates/part.feeds.php index a10848e8f..a2fc0bb24 100644 --- a/templates/part.feeds.php +++ b/templates/part.feeds.php @@ -1,9 +1,21 @@ -<?php - $allfeeds = $_['allfeeds']->getChildren(); - - foreach($allfeeds as $collection) { - if ($collection instanceOf OC_News_Folder){ - echo $collection->getName() . '<br>'; +<?php + + function print_folder(OC_News_Folder $folder, $depth){ + echo '<ul style="margin-left:' . 10*$depth . 'px;"> <li style="background-image:url(' . + OC_Helper::imagePath('core', 'filetypes/folder.png') . '); background-repeat:no-repeat; background-position:0px 8px; padding-left: 20px; ">' . + '<span class="collapsable">' . $folder->getName() .'</span><ul>'; + $children = $folder->getChildren(); + foreach($children as $child) { + if ($child instanceOf OC_News_Folder){ + print_folder($child, $depth+1); + } + else { //print all feeds contained in the folder + echo '<li>' . $child->getTitle(). '</li>'; + } } + echo '</ul></li></ul>'; } + + print_folder($_['allfeeds'], 0); + ?> |