From 0426541acbeb44d240e6dbf7a93f3a104bea61b4 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 22 Oct 2012 18:00:13 +0200 Subject: Grosse màj : ajout de la configuration + ajouts divers fonctionnalités MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/App_FrontController.php | 1 + app/controllers/configureController.php | 64 +++++++++++++++- app/controllers/feedController.php | 43 ++++++----- app/controllers/indexController.php | 6 +- app/layout/aside.phtml | 8 +- app/models/Category.php | 113 ++++++++++++++++++++++++++++ app/models/Entry.php | 16 +++- app/models/Feed.php | 126 +++++++++++++++++++++----------- app/models/RSSConfiguration.php | 16 ++++ app/views/configure/categorize.phtml | 17 ++++- app/views/configure/display.phtml | 6 ++ app/views/configure/flux.phtml | 45 +++++++++++- app/views/index/index.phtml | 8 +- 13 files changed, 393 insertions(+), 76 deletions(-) create mode 100755 app/models/Category.php (limited to 'app') diff --git a/app/App_FrontController.php b/app/App_FrontController.php index 5a2b27eed..bffe80ea3 100644 --- a/app/App_FrontController.php +++ b/app/App_FrontController.php @@ -23,6 +23,7 @@ class App_FrontController extends FrontController { private function loadModels () { include (APP_PATH . '/models/RSSConfiguration.php'); + include (APP_PATH . '/models/Category.php'); include (APP_PATH . '/models/Feed.php'); include (APP_PATH . '/models/Entry.php'); } diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 0f5d6b658..5642ef547 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -2,11 +2,66 @@ class configureController extends ActionController { public function categorizeAction () { - + $catDAO = new CategoryDAO (); + + if (Request::isPost ()) { + $cats = Request::param ('categories', array ()); + $ids = Request::param ('ids', array ()); + $newCat = Request::param ('new_category'); + + foreach ($cats as $key => $name) { + if (strlen ($name) > 0) { + $cat = new Category ($name); + $values = array ( + 'name' => $cat->name (), + 'color' => $cat->color () + ); + $catDAO->updateCategory ($ids[$key], $values); + } else { + $catDAO->deleteCategory ($ids[$key]); + } + } + + if ($newCat != false) { + $cat = new Category ($newCat); + $values = array ( + 'id' => $cat->id (), + 'name' => $cat->name (), + 'color' => $cat->color () + ); + $catDAO->addCategory ($values); + } + + $catDAO->save (); + + } + + $this->view->categories = $catDAO->listCategories (); } public function fluxAction () { - + $feedDAO = new FeedDAO (); + $this->view->feeds = $feedDAO->listFeeds (); + + $id = Request::param ('id'); + + $this->view->flux = false; + if ($id != false) { + $this->view->flux = $feedDAO->searchById ($id); + + $catDAO = new CategoryDAO (); + $this->view->categories = $catDAO->listCategories (); + + if (Request::isPost () && $this->view->flux) { + $cat = Request::param ('category'); + $values = array ( + 'category' => $cat + ); + $feedDAO->updateFeed ($id, $values); + + $this->view->flux->_category ($cat); + } + } } public function displayAction () { @@ -14,15 +69,18 @@ class configureController extends ActionController { $nb = Request::param ('posts_per_page', 10); $view = Request::param ('default_view', 'all'); $display = Request::param ('display_posts', 'no'); + $sort = Request::param ('sort_order', 'low_to_high'); $this->view->conf->_postsPerPage (intval ($nb)); $this->view->conf->_defaultView ($view); $this->view->conf->_displayPosts ($display); + $this->view->conf->_sortOrder ($sort); $values = array ( 'posts_per_page' => $this->view->conf->postsPerPage (), 'default_view' => $this->view->conf->defaultView (), - 'display_posts' => $this->view->conf->displayPosts () + 'display_posts' => $this->view->conf->displayPosts (), + 'sort_order' => $this->view->conf->sortOrder () ); $confDAO = new RSSConfigurationDAO (); diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 3b4a90b64..5bf7d9ec6 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -7,7 +7,8 @@ class feedController extends ActionController { try { $feed = new Feed ($url); - $entries = $feed->loadEntries (); + $feed->load (); + $entries = $feed->entries (false); $feed_entries = array (); if ($entries !== false) { @@ -24,6 +25,7 @@ class feedController extends ActionController { 'date' => $entry->date (true), 'is_read' => $entry->isRead (), 'is_favorite' => $entry->isFavorite (), + 'feed' => $feed->id () ); $entryDAO->addEntry ($values); @@ -35,8 +37,11 @@ class feedController extends ActionController { $values = array ( 'id' => $feed->id (), 'url' => $feed->url (), - 'categories' => $feed->categories (), - 'entries' => $feed_entries + 'category' => $feed->category (), + 'entries' => $feed_entries, + 'name' => $feed->name (), + 'website' => $feed->website (), + 'description' => $feed->description (), ); $feedDAO->addFeed ($values); } catch (Exception $e) { @@ -54,27 +59,31 @@ class feedController extends ActionController { $feeds = $feedDAO->listFeeds (); foreach ($feeds as $feed) { - $entries = $feed->loadEntries (); + $feed->load (); + $entries = $feed->entries (false); $feed_entries = $feed->entries (); if ($entries !== false) { foreach ($entries as $entry) { - $values = array ( - 'id' => $entry->id (), - 'guid' => $entry->guid (), - 'title' => $entry->title (), - 'author' => $entry->author (), - 'content' => $entry->content (), - 'link' => $entry->link (), - 'date' => $entry->date (true), - 'is_read' => $entry->isRead (), - 'is_favorite' => $entry->isFavorite (), - ); - $entryDAO->addEntry ($values); - if (!in_array ($entry->id (), $feed_entries)) { + $values = array ( + 'id' => $entry->id (), + 'guid' => $entry->guid (), + 'title' => $entry->title (), + 'author' => $entry->author (), + 'content' => $entry->content (), + 'link' => $entry->link (), + 'date' => $entry->date (true), + 'is_read' => $entry->isRead (), + 'is_favorite' => $entry->isFavorite (), + 'feed' => $feed->id () + ); + $entryDAO->addEntry ($values); + $feed_entries[] = $entry->id (); } + + // TODO gérer suppression des articles trop vieux (à paramétrer) } } diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 3fda234ca..b9d770e81 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -11,7 +11,11 @@ class indexController extends ActionController { $entries = $entryDAO->listEntries (); } - usort ($entries, 'sortEntriesByDate'); + if ($this->view->conf->sortOrder () == 'high_to_low') { + usort ($entries, 'sortReverseEntriesByDate'); + } else { + usort ($entries, 'sortEntriesByDate'); + } //gestion pagination $page = Request::param ('page', 1); diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml index 6e2e4965d..db4c482c1 100644 --- a/app/layout/aside.phtml +++ b/app/layout/aside.phtml @@ -9,7 +9,7 @@ Flux RSS
  • > - Configurer + Configurer
  • Mettre les flux à jour @@ -21,12 +21,12 @@
    + + +
    conf->displayPosts () ? ' checked="checked"' : ''; ?> /> diff --git a/app/views/configure/flux.phtml b/app/views/configure/flux.phtml index 126f6b48a..34255bc59 100644 --- a/app/views/configure/flux.phtml +++ b/app/views/configure/flux.phtml @@ -1,3 +1,44 @@ -
    - Fonctionnalité non implémentée (pour le moment) +
    +
    +
      +
    • Vox flux RSS

    • + feeds)) { ?> + feeds as $feed) { ?> +
    • flux && $this->flux->id () == $feed->id ()) ? 'class="active"' : ''; ?>> + name (); ?> +
    • + + +
    • Aucun flux
    • + +
    +
    + + flux) { ?> +
    +

    flux->name (); ?>

    + flux->description (); ?> + + + flux->website (); ?> + + + flux->entries ()); ?> + + categories)) { ?> + +
    + categories as $cat) { ?> + id () == $this->flux->category () ? ' checked="checked"' : ''; ?> /> + +
    + +
    + + + +
    + +
    Aucun flux sélectionné
    +
    diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 2dfdb5064..8863d08a2 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -14,7 +14,13 @@
    -
    author (); ?> a écrit le date (); ?>,
    + author (); ?> +
    + + le date (); ?> + feed (true); ?> + sur name (); ?>, +

    title (); ?>

    content (); ?>
    -- cgit v1.2.3