aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-02-13 14:32:16 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-03-03 10:03:40 +0100
commitc10fcb3bbbd4ef14edd9a862ee18c895d92e30ae (patch)
treee40b99c2f84525e05e940bde373835595979fbfb /src/Wallabag/ImportBundle/Controller
parentfe8b37c137adbe036f58616c15dbcffd07dd2cd4 (diff)
downloadwallabag-c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae.tar.gz
wallabag-c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae.tar.zst
wallabag-c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae.zip
french translation & pocket
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index 1c1b4fa8..bfd9fc5b 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -5,6 +5,10 @@ namespace Wallabag\ImportBundle\Controller;
5use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 6use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Wallabag\ImportBundle\Import\PocketImport;
9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
11
8 12
9class PocketController extends Controller 13class PocketController extends Controller
10{ 14{
@@ -13,21 +17,33 @@ class PocketController extends Controller
13 */ 17 */
14 public function indexAction() 18 public function indexAction()
15 { 19 {
20 $pocket = $this->get('wallabag_import.pocket.import');
21 $form = $this->createFormBuilder($pocket)
22 ->add('read', CheckboxType::class, array(
23 'label' => 'Mark all as read',
24 'required' => false,
25 ))
26 ->getForm();
27 ;
28
16 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [ 29 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
17 'import' => $this->get('wallabag_import.pocket.import'), 30 'import' => $this->get('wallabag_import.pocket.import'),
18 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true, 31 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true,
32 'form' => $form->createView(),
19 ]); 33 ]);
20 } 34 }
21 35
22 /** 36 /**
23 * @Route("/pocket/auth", name="import_pocket_auth") 37 * @Route("/pocket/auth", name="import_pocket_auth")
24 */ 38 */
25 public function authAction() 39 public function authAction(Request $request)
26 { 40 {
27 $requestToken = $this->get('wallabag_import.pocket.import') 41 $requestToken = $this->get('wallabag_import.pocket.import')
28 ->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface::ABSOLUTE_URL)); 42 ->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface::ABSOLUTE_URL));
29 43
30 $this->get('session')->set('import.pocket.code', $requestToken); 44 $this->get('session')->set('import.pocket.code', $requestToken);
45 $markAsRead = $request->request->get('form')['read'];
46 $this->get('session')->set('read', $markAsRead);
31 47
32 return $this->redirect( 48 return $this->redirect(
33 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL), 49 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL),
@@ -42,6 +58,7 @@ class PocketController extends Controller
42 { 58 {
43 $message = 'Import failed, please try again.'; 59 $message = 'Import failed, please try again.';
44 $pocket = $this->get('wallabag_import.pocket.import'); 60 $pocket = $this->get('wallabag_import.pocket.import');
61 $markAsRead = $this->get('session')->get('read');
45 62
46 // something bad happend on pocket side 63 // something bad happend on pocket side
47 if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) { 64 if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) {
@@ -53,11 +70,13 @@ class PocketController extends Controller
53 return $this->redirect($this->generateUrl('import_pocket')); 70 return $this->redirect($this->generateUrl('import_pocket'));
54 } 71 }
55 72
56 if (true === $pocket->import()) { 73 if (true === $pocket->setMarkAsRead($markAsRead)->import()) {
57 $summary = $pocket->getSummary(); 74 $summary = $pocket->getSummary();
58 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; 75 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.';
59 } 76 }
60 77
78 $this->get('session')->remove('read');
79
61 $this->get('session')->getFlashBag()->add( 80 $this->get('session')->getFlashBag()->add(
62 'notice', 81 'notice',
63 $message 82 $message