entryController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. class FreshRSS_entry_Controller extends Minz_ActionController {
  3. public function firstAction () {
  4. if (login_is_conf ($this->view->conf) && !is_logged ()) {
  5. Minz_Error::error (
  6. 403,
  7. array ('error' => array (Minz_Translate::t ('access_denied')))
  8. );
  9. }
  10. $this->params = array ();
  11. $this->redirect = false;
  12. $ajax = Minz_Request::param ('ajax');
  13. if ($ajax) {
  14. $this->view->_useLayout (false);
  15. }
  16. }
  17. public function lastAction () {
  18. $ajax = Minz_Request::param ('ajax');
  19. if (!$ajax && $this->redirect) {
  20. Minz_Request::forward (array (
  21. 'c' => 'index',
  22. 'a' => 'index',
  23. 'params' => $this->params
  24. ), true);
  25. } else {
  26. Minz_Request::_param ('ajax');
  27. }
  28. }
  29. public function readAction () {
  30. $this->redirect = true;
  31. $id = Minz_Request::param ('id');
  32. $is_read = Minz_Request::param ('is_read');
  33. $get = Minz_Request::param ('get');
  34. $nextGet = Minz_Request::param ('nextGet', $get);
  35. $idMax = Minz_Request::param ('idMax', 0);
  36. $is_read = !!$is_read;
  37. $entryDAO = new FreshRSS_EntryDAO ();
  38. if ($id == false) {
  39. if (!$get) {
  40. $entryDAO->markReadEntries ($idMax);
  41. } else {
  42. $typeGet = $get[0];
  43. $get = substr ($get, 2);
  44. switch ($typeGet) {
  45. case 'c':
  46. $entryDAO->markReadCat ($get, $idMax);
  47. break;
  48. case 'f':
  49. $entryDAO->markReadFeed ($get, $idMax);
  50. break;
  51. case 's':
  52. $entryDAO->markReadEntries ($idMax, true);
  53. break;
  54. case 'a':
  55. $entryDAO->markReadEntries ($idMax);
  56. break;
  57. }
  58. if ($nextGet !== 'a') {
  59. $this->params = array ('get' => $nextGet);
  60. }
  61. }
  62. $notif = array (
  63. 'type' => 'good',
  64. 'content' => Minz_Translate::t ('feeds_marked_read')
  65. );
  66. Minz_Session::_param ('notification', $notif);
  67. } else {
  68. $entryDAO->markRead ($id, $is_read);
  69. }
  70. }
  71. public function bookmarkAction () {
  72. $this->redirect = true;
  73. $id = Minz_Request::param ('id');
  74. if ($id) {
  75. $entryDAO = new FreshRSS_EntryDAO ();
  76. $entryDAO->markFavorite ($id, Minz_Request::param ('is_favorite'));
  77. }
  78. }
  79. public function optimizeAction() {
  80. @set_time_limit(300);
  81. invalidateHttpCache();
  82. // La table des entrées a tendance à grossir énormément
  83. // Cette action permet d'optimiser cette table permettant de grapiller un peu de place
  84. // Cette fonctionnalité n'est à appeler qu'occasionnellement
  85. $entryDAO = new FreshRSS_EntryDAO();
  86. $entryDAO->optimizeTable();
  87. invalidateHttpCache();
  88. $notif = array (
  89. 'type' => 'good',
  90. 'content' => Minz_Translate::t ('optimization_complete')
  91. );
  92. Minz_Session::_param ('notification', $notif);
  93. Minz_Request::forward(array(
  94. 'c' => 'configure',
  95. 'a' => 'display'
  96. ), true);
  97. }
  98. }