diff options
Diffstat (limited to 'src/WallabagBundle/Controller')
-rw-r--r-- | src/WallabagBundle/Controller/EntryController.php | 92 | ||||
-rw-r--r-- | src/WallabagBundle/Controller/StaticController.php | 20 |
2 files changed, 102 insertions, 10 deletions
diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php index 233a6c32..fbbb76aa 100644 --- a/src/WallabagBundle/Controller/EntryController.php +++ b/src/WallabagBundle/Controller/EntryController.php | |||
@@ -4,67 +4,139 @@ namespace WallabagBundle\Controller; | |||
4 | 4 | ||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | ||
7 | use WallabagBundle\Repository; | 8 | use WallabagBundle\Repository; |
9 | use WallabagBundle\Entity\Entries; | ||
8 | 10 | ||
9 | class EntryController extends Controller | 11 | class EntryController extends Controller |
10 | { | 12 | { |
11 | /** | 13 | /** |
14 | * Shows unread entries for current user | ||
15 | * | ||
12 | * @Route("/unread", name="unread") | 16 | * @Route("/unread", name="unread") |
17 | * @return \Symfony\Component\HttpFoundation\Response | ||
13 | */ | 18 | */ |
14 | public function showUnreadAction() | 19 | public function showUnreadAction() |
15 | { | 20 | { |
16 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | 21 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); |
17 | $entries = $repository->findUnreadByUser(1); | 22 | $entries = $repository->findUnreadByUser(1, 0); |
18 | 23 | ||
19 | return $this->render( | 24 | return $this->render( |
20 | 'WallabagBundle:Entry:entries.html.twig', | 25 | 'WallabagBundle:Entry:entries.html.twig', |
21 | array('entries' => $entries) | 26 | array('entries' => $entries) |
22 | ); | 27 | ); |
23 | |||
24 | } | 28 | } |
25 | 29 | ||
26 | /** | 30 | /** |
31 | * Shows read entries for current user | ||
32 | * | ||
27 | * @Route("/archive", name="archive") | 33 | * @Route("/archive", name="archive") |
34 | * @return \Symfony\Component\HttpFoundation\Response | ||
28 | */ | 35 | */ |
29 | public function showArchiveAction() | 36 | public function showArchiveAction() |
30 | { | 37 | { |
31 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | 38 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); |
32 | $entries = $repository->findArchiveByUser(1); | 39 | $entries = $repository->findArchiveByUser(1, 0); |
33 | 40 | ||
34 | return $this->render( | 41 | return $this->render( |
35 | 'WallabagBundle:Entry:entries.html.twig', | 42 | 'WallabagBundle:Entry:entries.html.twig', |
36 | array('entries' => $entries) | 43 | array('entries' => $entries) |
37 | ); | 44 | ); |
38 | |||
39 | } | 45 | } |
40 | 46 | ||
41 | /** | 47 | /** |
48 | * Shows starred entries for current user | ||
49 | * | ||
42 | * @Route("/starred", name="starred") | 50 | * @Route("/starred", name="starred") |
51 | * @return \Symfony\Component\HttpFoundation\Response | ||
43 | */ | 52 | */ |
44 | public function showStarredAction() | 53 | public function showStarredAction() |
45 | { | 54 | { |
46 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | 55 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); |
47 | $entries = $repository->findStarredByUser(1); | 56 | $entries = $repository->findStarredByUser(1, 0); |
48 | 57 | ||
49 | return $this->render( | 58 | return $this->render( |
50 | 'WallabagBundle:Entry:entries.html.twig', | 59 | 'WallabagBundle:Entry:entries.html.twig', |
51 | array('entries' => $entries) | 60 | array('entries' => $entries) |
52 | ); | 61 | ); |
53 | |||
54 | } | 62 | } |
55 | 63 | ||
56 | /** | 64 | /** |
65 | * Shows entry content | ||
66 | * | ||
67 | * @param Entries $entry | ||
57 | * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") | 68 | * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") |
69 | * @return \Symfony\Component\HttpFoundation\Response | ||
58 | */ | 70 | */ |
59 | public function viewAction($id) | 71 | public function viewAction(Entries $entry) |
60 | { | 72 | { |
61 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | ||
62 | $entry = $repository->find($id); | ||
63 | |||
64 | return $this->render( | 73 | return $this->render( |
65 | 'WallabagBundle:Entry:entry.html.twig', | 74 | 'WallabagBundle:Entry:entry.html.twig', |
66 | array('entry' => $entry) | 75 | array('entry' => $entry) |
67 | ); | 76 | ); |
77 | } | ||
78 | |||
79 | /** | ||
80 | * Changes read status for an entry | ||
81 | * | ||
82 | * @param Request $request | ||
83 | * @param Entries $entry | ||
84 | * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry") | ||
85 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
86 | */ | ||
87 | public function toggleArchiveAction(Request $request, Entries $entry) | ||
88 | { | ||
89 | $entry->toggleArchive(); | ||
90 | $this->getDoctrine()->getManager()->flush(); | ||
91 | |||
92 | $this->get('session')->getFlashBag()->add( | ||
93 | 'notice', | ||
94 | 'Entry archived' | ||
95 | ); | ||
96 | |||
97 | return $this->redirect($request->headers->get('referer')); | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Changes favorite status for an entry | ||
102 | * | ||
103 | * @param Request $request | ||
104 | * @param Entries $entry | ||
105 | * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry") | ||
106 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
107 | */ | ||
108 | public function toggleStarAction(Request $request, Entries $entry) | ||
109 | { | ||
110 | $entry->toggleStar(); | ||
111 | $this->getDoctrine()->getManager()->flush(); | ||
112 | |||
113 | $this->get('session')->getFlashBag()->add( | ||
114 | 'notice', | ||
115 | 'Entry starred' | ||
116 | ); | ||
117 | |||
118 | return $this->redirect($request->headers->get('referer')); | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * Deletes entry | ||
123 | * | ||
124 | * @param Request $request | ||
125 | * @param Entries $entry | ||
126 | * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry") | ||
127 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
128 | */ | ||
129 | public function deleteEntryAction(Request $request, Entries $entry) | ||
130 | { | ||
131 | $em = $this->getDoctrine()->getEntityManager(); | ||
132 | $em->remove($entry); | ||
133 | $em->flush(); | ||
134 | |||
135 | $this->get('session')->getFlashBag()->add( | ||
136 | 'notice', | ||
137 | 'Entry deleted' | ||
138 | ); | ||
68 | 139 | ||
140 | return $this->redirect($request->headers->get('referer')); | ||
69 | } | 141 | } |
70 | } | 142 | } |
diff --git a/src/WallabagBundle/Controller/StaticController.php b/src/WallabagBundle/Controller/StaticController.php new file mode 100644 index 00000000..aee2bb7e --- /dev/null +++ b/src/WallabagBundle/Controller/StaticController.php | |||
@@ -0,0 +1,20 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace WallabagBundle\Controller; | ||
4 | |||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | |||
8 | class StaticController extends Controller | ||
9 | { | ||
10 | /** | ||
11 | * @Route("/about", name="about") | ||
12 | */ | ||
13 | public function aboutAction() | ||
14 | { | ||
15 | return $this->render( | ||
16 | 'WallabagBundle:Static:about.html.twig', | ||
17 | array() | ||
18 | ); | ||
19 | } | ||
20 | } | ||