diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2017-01-27 09:34:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 09:34:32 +0100 |
commit | 6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch) | |
tree | e76f3e8142399316ec5660fab8c646b2c34b8336 /src/Wallabag/ImportBundle/Controller | |
parent | 05fa529bcfde01be5d320cb532900d72cf4b0830 (diff) | |
parent | 78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff) | |
download | wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip |
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
6 files changed, 83 insertions, 4 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php index 144a4880..e119098f 100644 --- a/src/Wallabag/ImportBundle/Controller/BrowserController.php +++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php | |||
@@ -39,7 +39,7 @@ abstract class BrowserController extends Controller | |||
39 | $wallabag = $this->getImportService(); | 39 | $wallabag = $this->getImportService(); |
40 | $wallabag->setUser($this->getUser()); | 40 | $wallabag->setUser($this->getUser()); |
41 | 41 | ||
42 | if ($form->isValid()) { | 42 | if ($form->isSubmitted() && $form->isValid()) { |
43 | $file = $form->get('file')->getData(); | 43 | $file = $form->get('file')->getData(); |
44 | $markAsRead = $form->get('mark_as_read')->getData(); | 44 | $markAsRead = $form->get('mark_as_read')->getData(); |
45 | $name = $this->getUser()->getId().'.json'; | 45 | $name = $this->getUser()->getId().'.json'; |
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php index 15de75ff..237c748e 100644 --- a/src/Wallabag/ImportBundle/Controller/ImportController.php +++ b/src/Wallabag/ImportBundle/Controller/ImportController.php | |||
@@ -42,6 +42,7 @@ class ImportController extends Controller | |||
42 | + $this->getTotalMessageInRabbitQueue('firefox') | 42 | + $this->getTotalMessageInRabbitQueue('firefox') |
43 | + $this->getTotalMessageInRabbitQueue('chrome') | 43 | + $this->getTotalMessageInRabbitQueue('chrome') |
44 | + $this->getTotalMessageInRabbitQueue('instapaper') | 44 | + $this->getTotalMessageInRabbitQueue('instapaper') |
45 | + $this->getTotalMessageInRabbitQueue('pinboard') | ||
45 | ; | 46 | ; |
46 | } catch (\Exception $e) { | 47 | } catch (\Exception $e) { |
47 | $rabbitNotInstalled = true; | 48 | $rabbitNotInstalled = true; |
@@ -57,6 +58,7 @@ class ImportController extends Controller | |||
57 | + $redis->llen('wallabag.import.firefox') | 58 | + $redis->llen('wallabag.import.firefox') |
58 | + $redis->llen('wallabag.import.chrome') | 59 | + $redis->llen('wallabag.import.chrome') |
59 | + $redis->llen('wallabag.import.instapaper') | 60 | + $redis->llen('wallabag.import.instapaper') |
61 | + $redis->llen('wallabag.import.pinboard') | ||
60 | ; | 62 | ; |
61 | } catch (\Exception $e) { | 63 | } catch (\Exception $e) { |
62 | $redisNotInstalled = true; | 64 | $redisNotInstalled = true; |
diff --git a/src/Wallabag/ImportBundle/Controller/InstapaperController.php b/src/Wallabag/ImportBundle/Controller/InstapaperController.php index c3fc8a39..0251acb9 100644 --- a/src/Wallabag/ImportBundle/Controller/InstapaperController.php +++ b/src/Wallabag/ImportBundle/Controller/InstapaperController.php | |||
@@ -26,7 +26,7 @@ class InstapaperController extends Controller | |||
26 | $instapaper->setProducer($this->get('wallabag_import.producer.redis.instapaper')); | 26 | $instapaper->setProducer($this->get('wallabag_import.producer.redis.instapaper')); |
27 | } | 27 | } |
28 | 28 | ||
29 | if ($form->isValid()) { | 29 | if ($form->isSubmitted() && $form->isValid()) { |
30 | $file = $form->get('file')->getData(); | 30 | $file = $form->get('file')->getData(); |
31 | $markAsRead = $form->get('mark_as_read')->getData(); | 31 | $markAsRead = $form->get('mark_as_read')->getData(); |
32 | $name = 'instapaper_'.$this->getUser()->getId().'.csv'; | 32 | $name = 'instapaper_'.$this->getUser()->getId().'.csv'; |
diff --git a/src/Wallabag/ImportBundle/Controller/PinboardController.php b/src/Wallabag/ImportBundle/Controller/PinboardController.php new file mode 100644 index 00000000..d0ad8aa8 --- /dev/null +++ b/src/Wallabag/ImportBundle/Controller/PinboardController.php | |||
@@ -0,0 +1,77 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Controller; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
7 | use Symfony\Component\HttpFoundation\Request; | ||
8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | ||
9 | |||
10 | class PinboardController extends Controller | ||
11 | { | ||
12 | /** | ||
13 | * @Route("/pinboard", name="import_pinboard") | ||
14 | */ | ||
15 | public function indexAction(Request $request) | ||
16 | { | ||
17 | $form = $this->createForm(UploadImportType::class); | ||
18 | $form->handleRequest($request); | ||
19 | |||
20 | $pinboard = $this->get('wallabag_import.pinboard.import'); | ||
21 | $pinboard->setUser($this->getUser()); | ||
22 | |||
23 | if ($this->get('craue_config')->get('import_with_rabbitmq')) { | ||
24 | $pinboard->setProducer($this->get('old_sound_rabbit_mq.import_pinboard_producer')); | ||
25 | } elseif ($this->get('craue_config')->get('import_with_redis')) { | ||
26 | $pinboard->setProducer($this->get('wallabag_import.producer.redis.pinboard')); | ||
27 | } | ||
28 | |||
29 | if ($form->isSubmitted() && $form->isValid()) { | ||
30 | $file = $form->get('file')->getData(); | ||
31 | $markAsRead = $form->get('mark_as_read')->getData(); | ||
32 | $name = 'pinboard_'.$this->getUser()->getId().'.json'; | ||
33 | |||
34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | ||
35 | $res = $pinboard | ||
36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | ||
37 | ->setMarkAsRead($markAsRead) | ||
38 | ->import(); | ||
39 | |||
40 | $message = 'flashes.import.notice.failed'; | ||
41 | |||
42 | if (true === $res) { | ||
43 | $summary = $pinboard->getSummary(); | ||
44 | $message = $this->get('translator')->trans('flashes.import.notice.summary', [ | ||
45 | '%imported%' => $summary['imported'], | ||
46 | '%skipped%' => $summary['skipped'], | ||
47 | ]); | ||
48 | |||
49 | if (0 < $summary['queued']) { | ||
50 | $message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [ | ||
51 | '%queued%' => $summary['queued'], | ||
52 | ]); | ||
53 | } | ||
54 | |||
55 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | ||
56 | } | ||
57 | |||
58 | $this->get('session')->getFlashBag()->add( | ||
59 | 'notice', | ||
60 | $message | ||
61 | ); | ||
62 | |||
63 | return $this->redirect($this->generateUrl('homepage')); | ||
64 | } else { | ||
65 | $this->get('session')->getFlashBag()->add( | ||
66 | 'notice', | ||
67 | 'flashes.import.notice.failed_on_file' | ||
68 | ); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [ | ||
73 | 'form' => $form->createView(), | ||
74 | 'import' => $pinboard, | ||
75 | ]); | ||
76 | } | ||
77 | } | ||
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php index d00e22c2..aa732ddd 100644 --- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php +++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php | |||
@@ -26,7 +26,7 @@ class ReadabilityController extends Controller | |||
26 | $readability->setProducer($this->get('wallabag_import.producer.redis.readability')); | 26 | $readability->setProducer($this->get('wallabag_import.producer.redis.readability')); |
27 | } | 27 | } |
28 | 28 | ||
29 | if ($form->isValid()) { | 29 | if ($form->isSubmitted() && $form->isValid()) { |
30 | $file = $form->get('file')->getData(); | 30 | $file = $form->get('file')->getData(); |
31 | $markAsRead = $form->get('mark_as_read')->getData(); | 31 | $markAsRead = $form->get('mark_as_read')->getData(); |
32 | $name = 'readability_'.$this->getUser()->getId().'.json'; | 32 | $name = 'readability_'.$this->getUser()->getId().'.json'; |
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php index 9c0cde80..e81c1ca9 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagController.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php | |||
@@ -40,7 +40,7 @@ abstract class WallabagController extends Controller | |||
40 | $wallabag = $this->getImportService(); | 40 | $wallabag = $this->getImportService(); |
41 | $wallabag->setUser($this->getUser()); | 41 | $wallabag->setUser($this->getUser()); |
42 | 42 | ||
43 | if ($form->isValid()) { | 43 | if ($form->isSubmitted() && $form->isValid()) { |
44 | $file = $form->get('file')->getData(); | 44 | $file = $form->get('file')->getData(); |
45 | $markAsRead = $form->get('mark_as_read')->getData(); | 45 | $markAsRead = $form->get('mark_as_read')->getData(); |
46 | $name = $this->getUser()->getId().'.json'; | 46 | $name = $this->getUser()->getId().'.json'; |