4
0

configureController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. class configureController extends ActionController {
  3. public function categorizeAction () {
  4. $catDAO = new CategoryDAO ();
  5. if (Request::isPost ()) {
  6. $cats = Request::param ('categories', array ());
  7. $ids = Request::param ('ids', array ());
  8. $newCat = Request::param ('new_category');
  9. foreach ($cats as $key => $name) {
  10. if (strlen ($name) > 0) {
  11. $cat = new Category ($name);
  12. $values = array (
  13. 'name' => $cat->name (),
  14. 'color' => $cat->color ()
  15. );
  16. $catDAO->updateCategory ($ids[$key], $values);
  17. } else {
  18. $catDAO->deleteCategory ($ids[$key]);
  19. }
  20. }
  21. if ($newCat != false) {
  22. $cat = new Category ($newCat);
  23. $values = array (
  24. 'id' => $cat->id (),
  25. 'name' => $cat->name (),
  26. 'color' => $cat->color ()
  27. );
  28. $catDAO->addCategory ($values);
  29. }
  30. $catDAO->save ();
  31. }
  32. $this->view->categories = $catDAO->listCategories ();
  33. }
  34. public function fluxAction () {
  35. $feedDAO = new FeedDAO ();
  36. $this->view->feeds = $feedDAO->listFeeds ();
  37. $id = Request::param ('id');
  38. $this->view->flux = false;
  39. if ($id != false) {
  40. $this->view->flux = $feedDAO->searchById ($id);
  41. $catDAO = new CategoryDAO ();
  42. $this->view->categories = $catDAO->listCategories ();
  43. if (Request::isPost () && $this->view->flux) {
  44. $cat = Request::param ('category');
  45. $values = array (
  46. 'category' => $cat
  47. );
  48. $feedDAO->updateFeed ($id, $values);
  49. $this->view->flux->_category ($cat);
  50. }
  51. }
  52. }
  53. public function displayAction () {
  54. if (Request::isPost ()) {
  55. $nb = Request::param ('posts_per_page', 10);
  56. $view = Request::param ('default_view', 'all');
  57. $display = Request::param ('display_posts', 'no');
  58. $sort = Request::param ('sort_order', 'low_to_high');
  59. $this->view->conf->_postsPerPage (intval ($nb));
  60. $this->view->conf->_defaultView ($view);
  61. $this->view->conf->_displayPosts ($display);
  62. $this->view->conf->_sortOrder ($sort);
  63. $values = array (
  64. 'posts_per_page' => $this->view->conf->postsPerPage (),
  65. 'default_view' => $this->view->conf->defaultView (),
  66. 'display_posts' => $this->view->conf->displayPosts (),
  67. 'sort_order' => $this->view->conf->sortOrder ()
  68. );
  69. $confDAO = new RSSConfigurationDAO ();
  70. $confDAO->save ($values);
  71. Session::_param ('conf', $this->view->conf);
  72. }
  73. }
  74. }