entryController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. class entryController extends ActionController {
  3. public function firstAction () {
  4. $ajax = Request::param ('ajax');
  5. if ($ajax) {
  6. $this->view->_useLayout (false);
  7. }
  8. }
  9. public function lastAction () {
  10. $ajax = Request::param ('ajax');
  11. if (!$ajax) {
  12. Request::forward (array (), true);
  13. }
  14. }
  15. public function readAction () {
  16. $id = Request::param ('id');
  17. $is_read = Request::param ('is_read');
  18. if ($is_read) {
  19. $is_read = true;
  20. } else {
  21. $is_read = false;
  22. }
  23. $entryDAO = new EntryDAO ();
  24. if ($id == false) {
  25. $entries = $entryDAO->listNotReadEntries ();
  26. } else {
  27. $entry = $entryDAO->searchById ($id);
  28. $entries = $entry !== false ? array ($entry) : array ();
  29. }
  30. foreach ($entries as $entry) {
  31. $values = array (
  32. 'is_read' => $is_read,
  33. );
  34. $entryDAO->updateEntry ($entry->id (), $values);
  35. }
  36. }
  37. public function bookmarkAction () {
  38. $id = Request::param ('id');
  39. $is_fav = Request::param ('is_favorite');
  40. if ($is_fav) {
  41. $is_fav = true;
  42. } else {
  43. $is_fav = false;
  44. }
  45. $entryDAO = new EntryDAO ();
  46. if ($id != false) {
  47. $entry = $entryDAO->searchById ($id);
  48. if ($entry != false) {
  49. $values = array (
  50. 'is_favorite' => $is_fav,
  51. );
  52. $entryDAO->updateEntry ($entry->id (), $values);
  53. }
  54. }
  55. }
  56. }