diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-02-13 14:32:16 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-03-03 10:03:40 +0100 |
commit | c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae (patch) | |
tree | e40b99c2f84525e05e940bde373835595979fbfb | |
parent | fe8b37c137adbe036f58616c15dbcffd07dd2cd4 (diff) | |
download | wallabag-c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae.tar.gz wallabag-c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae.tar.zst wallabag-c10fcb3bbbd4ef14edd9a862ee18c895d92e30ae.zip |
french translation & pocket
5 files changed, 54 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 902c8323..6c6caa24 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -215,6 +215,8 @@ Import contents: "Importer les contenus" | |||
215 | Import: "Importer" | 215 | Import: "Importer" |
216 | Import > Wallabag v1: "Importer > Wallabag v1" | 216 | Import > Wallabag v1: "Importer > Wallabag v1" |
217 | Import > Wallabag v2: "Importer > Wallabag v2" | 217 | Import > Wallabag v2: "Importer > Wallabag v2" |
218 | Mark all as read ?: "Marquer tout comme lu ?" | ||
219 | Mark all imported entries as read: "Marquer tous les contenus importés comme lus" | ||
218 | 220 | ||
219 | # Quickstart | 221 | # Quickstart |
220 | Quickstart: Pour bien débuter | 222 | Quickstart: Pour bien débuter |
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; | |||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | 6 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
8 | use Wallabag\ImportBundle\Import\PocketImport; | ||
9 | use Symfony\Component\HttpFoundation\Request; | ||
10 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||
11 | |||
8 | 12 | ||
9 | class PocketController extends Controller | 13 | class 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 |
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 5dfd098c..1cc03d5b 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php | |||
@@ -22,6 +22,7 @@ class PocketImport implements ImportInterface | |||
22 | private $consumerKey; | 22 | private $consumerKey; |
23 | private $skippedEntries = 0; | 23 | private $skippedEntries = 0; |
24 | private $importedEntries = 0; | 24 | private $importedEntries = 0; |
25 | private $markAsRead; | ||
25 | protected $accessToken; | 26 | protected $accessToken; |
26 | 27 | ||
27 | public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) | 28 | public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) |
@@ -123,6 +124,27 @@ class PocketImport implements ImportInterface | |||
123 | return true; | 124 | return true; |
124 | } | 125 | } |
125 | 126 | ||
127 | |||
128 | /** | ||
129 | * Set whether articles must be all marked as read. | ||
130 | * | ||
131 | * @param bool $markAsRead | ||
132 | */ | ||
133 | public function setMarkAsRead($markAsRead) | ||
134 | { | ||
135 | $this->markAsRead = $markAsRead; | ||
136 | |||
137 | return $this; | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * Get whether articles must be all marked as read. | ||
142 | */ | ||
143 | public function getRead() | ||
144 | { | ||
145 | return $this->markAsRead; | ||
146 | } | ||
147 | |||
126 | /** | 148 | /** |
127 | * {@inheritdoc} | 149 | * {@inheritdoc} |
128 | */ | 150 | */ |
@@ -201,7 +223,7 @@ class PocketImport implements ImportInterface | |||
201 | $entry = $this->contentProxy->updateEntry($entry, $url); | 223 | $entry = $this->contentProxy->updateEntry($entry, $url); |
202 | 224 | ||
203 | // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted | 225 | // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted |
204 | if ($pocketEntry['status'] == 1) { | 226 | if ($pocketEntry['status'] == 1 | $this->markAsRead) { |
205 | $entry->setArchived(true); | 227 | $entry->setArchived(true); |
206 | } | 228 | } |
207 | 229 | ||
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 1d773d3b..9ea698f9 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php | |||
@@ -128,6 +128,7 @@ class WallabagV1Import implements ImportInterface | |||
128 | */ | 128 | */ |
129 | public function setMarkAsRead($markAsRead) | 129 | public function setMarkAsRead($markAsRead) |
130 | { | 130 | { |
131 | var_dump($markAsRead); | ||
131 | $this->markAsRead = $markAsRead; | 132 | $this->markAsRead = $markAsRead; |
132 | 133 | ||
133 | return $this; | 134 | return $this; |
diff --git a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig index 8aa5da97..3365fc6a 100644 --- a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig +++ b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig | |||
@@ -19,6 +19,13 @@ | |||
19 | <blockquote>{{ import.description|trans }}</blockquote> | 19 | <blockquote>{{ import.description|trans }}</blockquote> |
20 | <p>{% trans %}You can import your data from your Pocket account. You just have to click on the below button and authorize the application to connect to getpocket.com.{% endtrans %}</p> | 20 | <p>{% trans %}You can import your data from your Pocket account. You just have to click on the below button and authorize the application to connect to getpocket.com.{% endtrans %}</p> |
21 | <form method="post" action="{{ path('import_pocket_auth') }}"> | 21 | <form method="post" action="{{ path('import_pocket_auth') }}"> |
22 | <div class="row"> | ||
23 | <div class="input-field col s6 with-checkbox"> | ||
24 | <h6>{% trans %}Mark all as read ?{% endtrans %}</h6> | ||
25 | {{ form_widget(form.read) }} | ||
26 | <label for="form_read">{% trans %}Mark all imported entries as read{% endtrans %}</label> | ||
27 | </div> | ||
28 | </div> | ||
22 | <button class="btn waves-effect waves-light" type="submit" name="action"> | 29 | <button class="btn waves-effect waves-light" type="submit" name="action"> |
23 | {% trans %}Connect to Pocket and import data{% endtrans %} | 30 | {% trans %}Connect to Pocket and import data{% endtrans %} |
24 | </button> | 31 | </button> |