aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-03-21 12:47:57 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-03-21 12:47:57 +0100
commit439b36323e37f669b056cc5228c44bb91196256c (patch)
treeecd84477adf3e12819b26aff2a6d2e644e45ea72 /src/Wallabag/ImportBundle/Controller
parentbd46de6b25f982e1a0d3f975971fe8014db13833 (diff)
parent4083887afe4dd3f568b2dfea3392506b554c79b8 (diff)
downloadwallabag-439b36323e37f669b056cc5228c44bb91196256c.tar.gz
wallabag-439b36323e37f669b056cc5228c44bb91196256c.tar.zst
wallabag-439b36323e37f669b056cc5228c44bb91196256c.zip
Merge pull request #1774 from wallabag/v2-key-translation
Switch to keys in translated files
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php18
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php9
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php9
3 files changed, 23 insertions, 13 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index c88e115e..1d804219 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -17,8 +17,8 @@ class PocketController extends Controller
17 { 17 {
18 $pocket = $this->get('wallabag_import.pocket.import'); 18 $pocket = $this->get('wallabag_import.pocket.import');
19 $form = $this->createFormBuilder($pocket) 19 $form = $this->createFormBuilder($pocket)
20 ->add('read', CheckboxType::class, array( 20 ->add('mark_as_read', CheckboxType::class, array(
21 'label' => 'Mark all as read', 21 'label' => 'import.form.mark_as_read_label',
22 'required' => false, 22 'required' => false,
23 )) 23 ))
24 ->getForm(); 24 ->getForm();
@@ -39,7 +39,7 @@ class PocketController extends Controller
39 ->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface::ABSOLUTE_URL)); 39 ->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface::ABSOLUTE_URL));
40 40
41 $this->get('session')->set('import.pocket.code', $requestToken); 41 $this->get('session')->set('import.pocket.code', $requestToken);
42 $this->get('session')->set('read', $request->request->get('form')['read']); 42 $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
43 43
44 return $this->redirect( 44 return $this->redirect(
45 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL), 45 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL),
@@ -52,10 +52,11 @@ class PocketController extends Controller
52 */ 52 */
53 public function callbackAction() 53 public function callbackAction()
54 { 54 {
55 $message = 'Import failed, please try again.'; 55 $message = 'flashes.import.notice.failed';
56 $pocket = $this->get('wallabag_import.pocket.import'); 56 $pocket = $this->get('wallabag_import.pocket.import');
57 $markAsRead = $this->get('session')->get('read'); 57
58 $this->get('session')->remove('read'); 58 $markAsRead = $this->get('session')->get('mark_as_read');
59 $this->get('session')->remove('mark_as_read');
59 60
60 // something bad happend on pocket side 61 // something bad happend on pocket side
61 if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) { 62 if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) {
@@ -69,7 +70,10 @@ class PocketController extends Controller
69 70
70 if (true === $pocket->setMarkAsRead($markAsRead)->import()) { 71 if (true === $pocket->setMarkAsRead($markAsRead)->import()) {
71 $summary = $pocket->getSummary(); 72 $summary = $pocket->getSummary();
72 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; 73 $message = $this->get('translator')->trans('flashes.import.notice.summary', array(
74 '%imported%' => $summary['imported'],
75 '%skipped%' => $summary['skipped'],
76 ));
73 } 77 }
74 78
75 $this->get('session')->getFlashBag()->add( 79 $this->get('session')->getFlashBag()->add(
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
index 154a0769..1bc9696d 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
@@ -31,11 +31,14 @@ class WallabagV1Controller extends Controller
31 ->setMarkAsRead($markAsRead) 31 ->setMarkAsRead($markAsRead)
32 ->import(); 32 ->import();
33 33
34 $message = 'Import failed, please try again.'; 34 $message = 'flashes.import.notice.failed';
35 35
36 if (true === $res) { 36 if (true === $res) {
37 $summary = $wallabag->getSummary(); 37 $summary = $wallabag->getSummary();
38 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; 38 $message = $this->get('translator')->trans('flashes.import.notice.summary', array(
39 '%imported%' => $summary['imported'],
40 '%skipped%' => $summary['skipped'],
41 ));
39 42
40 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 43 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
41 } 44 }
@@ -49,7 +52,7 @@ class WallabagV1Controller extends Controller
49 } else { 52 } else {
50 $this->get('session')->getFlashBag()->add( 53 $this->get('session')->getFlashBag()->add(
51 'notice', 54 'notice',
52 'Error while processing import. Please verify your import file.' 55 'flashes.import.notice.failed_on_file'
53 ); 56 );
54 } 57 }
55 } 58 }
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
index 6dcd204a..3e6428a0 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
@@ -31,11 +31,14 @@ class WallabagV2Controller extends Controller
31 ->setMarkAsRead($markAsRead) 31 ->setMarkAsRead($markAsRead)
32 ->import(); 32 ->import();
33 33
34 $message = 'Import failed, please try again.'; 34 $message = 'flashes.import.notice.failed';
35 35
36 if (true === $res) { 36 if (true === $res) {
37 $summary = $wallabag->getSummary(); 37 $summary = $wallabag->getSummary();
38 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; 38 $message = $this->get('translator')->trans('flashes.import.notice.summary', array(
39 '%imported%' => $summary['imported'],
40 '%skipped%' => $summary['skipped'],
41 ));
39 42
40 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 43 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
41 } 44 }
@@ -49,7 +52,7 @@ class WallabagV2Controller extends Controller
49 } else { 52 } else {
50 $this->get('session')->getFlashBag()->add( 53 $this->get('session')->getFlashBag()->add(
51 'notice', 54 'notice',
52 'Error while processing import. Please verify your import file.' 55 'flashes.import.notice.failed_on_file'
53 ); 56 );
54 } 57 }
55 } 58 }