aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle')
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php10
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig8
3 files changed, 7 insertions, 13 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index 1f92c182..56be5cbf 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -44,7 +44,7 @@ class PocketController extends Controller
44 44
45 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [ 45 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
46 'import' => $this->getPocketImportService(), 46 'import' => $this->getPocketImportService(),
47 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true, 47 'has_consumer_key' => '' === trim($this->getUser()->getConfig()->getPocketConsumerKey()) ? false : true,
48 'form' => $form->createView(), 48 'form' => $form->createView(),
49 ]); 49 ]);
50 } 50 }
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index cc6faf1f..40603c90 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -13,16 +13,14 @@ use Craue\ConfigBundle\Util\Config;
13class PocketImport extends AbstractImport 13class PocketImport extends AbstractImport
14{ 14{
15 private $client; 15 private $client;
16 private $consumerKey;
17 private $accessToken; 16 private $accessToken;
18 17
19 const NB_ELEMENTS = 5000; 18 const NB_ELEMENTS = 5000;
20 19
21 public function __construct(EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) 20 public function __construct(EntityManager $em, ContentProxy $contentProxy)
22 { 21 {
23 $this->em = $em; 22 $this->em = $em;
24 $this->contentProxy = $contentProxy; 23 $this->contentProxy = $contentProxy;
25 $this->consumerKey = $craueConfig->get('pocket_consumer_key');
26 $this->logger = new NullLogger(); 24 $this->logger = new NullLogger();
27 } 25 }
28 26
@@ -72,7 +70,7 @@ class PocketImport extends AbstractImport
72 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/request', 70 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/request',
73 [ 71 [
74 'body' => json_encode([ 72 'body' => json_encode([
75 'consumer_key' => $this->consumerKey, 73 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
76 'redirect_uri' => $redirectUri, 74 'redirect_uri' => $redirectUri,
77 ]), 75 ]),
78 ] 76 ]
@@ -102,7 +100,7 @@ class PocketImport extends AbstractImport
102 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/authorize', 100 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/authorize',
103 [ 101 [
104 'body' => json_encode([ 102 'body' => json_encode([
105 'consumer_key' => $this->consumerKey, 103 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
106 'code' => $code, 104 'code' => $code,
107 ]), 105 ]),
108 ] 106 ]
@@ -131,7 +129,7 @@ class PocketImport extends AbstractImport
131 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/get', 129 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/get',
132 [ 130 [
133 'body' => json_encode([ 131 'body' => json_encode([
134 'consumer_key' => $this->consumerKey, 132 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
135 'access_token' => $this->accessToken, 133 'access_token' => $this->accessToken,
136 'detailType' => 'complete', 134 'detailType' => 'complete',
137 'state' => 'all', 135 'state' => 'all',
diff --git a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig
index aa5941b7..6195fa07 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig
@@ -12,11 +12,7 @@
12 <div class="card-panel red white-text"> 12 <div class="card-panel red white-text">
13 {{ 'import.pocket.config_missing.description'|trans }} 13 {{ 'import.pocket.config_missing.description'|trans }}
14 14
15 {% if is_granted('ROLE_SUPER_ADMIN') %} 15 {{ 'import.pocket.config_missing.admin_message'|trans({'%keyurls%': '<a href="' ~ path('config') ~ '">', '%keyurle%':'</a>'})|raw }}
16 {{ 'import.pocket.config_missing.admin_message'|trans({'%keyurls%': '<a href="' ~ path('craue_config_settings_modify') ~ '#set-import">', '%keyurle%':'</a>'})|raw }}
17 {% else %}
18 {{ 'import.pocket.config_missing.user_message'|trans }}
19 {% endif %}
20 </div> 16 </div>
21 {% endif %} 17 {% endif %}
22 18
@@ -31,7 +27,7 @@
31 {{ form_label(form.mark_as_read) }} 27 {{ form_label(form.mark_as_read) }}
32 </div> 28 </div>
33 </div> 29 </div>
34 <button class="btn waves-effect waves-light" type="submit" name="action"> 30 <button class="btn waves-effect waves-light" type="submit" name="action" {% if not has_consumer_key %}disabled="disabled"{% endif %}>
35 {{ 'import.pocket.connect_to_pocket'|trans }} 31 {{ 'import.pocket.connect_to_pocket'|trans }}
36 </button> 32 </button>
37 </form> 33 </form>