From 63e40f2d7c4074aff0be587c828eb511a6b7c878 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 21 Jan 2016 08:53:09 +0100 Subject: Add CraueConfig for internal settings --- .../CoreBundle/Controller/ConfigController.php | 1 + .../CoreBundle/Controller/StaticController.php | 5 ++++- .../DependencyInjection/Configuration.php | 4 ++++ .../DependencyInjection/WallabagCoreExtension.php | 2 ++ src/Wallabag/CoreBundle/Helper/EntriesExport.php | 7 +++--- .../CoreBundle/Resources/config/services.yml | 4 ++-- .../Resources/translations/messages.fr.yml | 1 + .../views/themes/baggy/Entry/entry.html.twig | 19 ++++++++-------- .../Resources/views/themes/baggy/layout.html.twig | 3 +++ .../views/themes/material/Entry/entry.html.twig | 25 +++++++++++----------- .../views/themes/material/layout.html.twig | 3 +++ src/Wallabag/ImportBundle/Import/PocketImport.php | 5 +++-- .../ImportBundle/Resources/config/services.yml | 2 +- .../ImportBundle/Tests/Import/PocketImportTest.php | 11 +++++++++- src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | 10 ++++----- .../UserBundle/Resources/config/services.yml | 3 +-- 16 files changed, 65 insertions(+), 40 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 4ece6431..c7513f79 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -163,6 +163,7 @@ class ConfigController extends Controller 'username' => $user->getUsername(), 'token' => $config->getRssToken(), ), + 'twofactor_auth' => $this->getParameter('twofactor_auth'), )); } diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php index 9ada371b..5b7bd56e 100644 --- a/src/Wallabag/CoreBundle/Controller/StaticController.php +++ b/src/Wallabag/CoreBundle/Controller/StaticController.php @@ -25,7 +25,10 @@ class StaticController extends Controller { return $this->render( 'WallabagCoreBundle:Static:about.html.twig', - array() + array( + 'version' => $this->getParameter('wallabag_core.version'), + 'paypal_url' => $this->getParameter('wallabag_core.paypal_url'), + ) ); } diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 4d5a63f8..bc405fdc 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -29,6 +29,10 @@ class Configuration implements ConfigurationInterface ->integerNode('rss_limit') ->defaultValue(50) ->end() + ->scalarNode('version') + ->end() + ->scalarNode('paypal_url') + ->end() ->end() ; diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 73bbffe1..9b4703e4 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -19,6 +19,8 @@ class WallabagCoreExtension extends Extension $container->setParameter('wallabag_core.theme', $config['theme']); $container->setParameter('wallabag_core.language', $config['language']); $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); + $container->setParameter('wallabag_core.version', $config['version']); + $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 31a80d6e..965a40b6 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -8,6 +8,7 @@ use JMS\Serializer\SerializerBuilder; use PHPePub\Core\EPub; use PHPePub\Core\Structure\OPF\DublinCore; use Symfony\Component\HttpFoundation\Response; +use Craue\ConfigBundle\Util\Config; /** * This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest. @@ -27,12 +28,12 @@ class EntriesExport wallabagUrl = $wallabagUrl; + $this->wallabagUrl = $craueConfig->get('wallabag_url'); $this->logoPath = $logoPath; } diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 6a1afcc0..813f8a96 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -3,7 +3,7 @@ services: class: Wallabag\CoreBundle\Helper\DetectActiveTheme arguments: - "@security.token_storage" - - %theme% # default theme from parameters.yml + - %wallabag_core.theme% # custom form type wallabag_core.form.type.config: @@ -86,7 +86,7 @@ services: wallabag_core.helper.entries_export: class: Wallabag\CoreBundle\Helper\EntriesExport arguments: - - %wallabag_url% + - "@craue_config" - src/Wallabag/CoreBundle/Resources/public/themes/_global/img/appicon/apple-touch-icon-152.png wallabag.operator.array.matches: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 20f4352b..cc814cc4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -13,6 +13,7 @@ archive: 'Lus' all: 'Tous les articles' tags: 'Tags' config: 'Configuration' +internal settings: 'Configuration interne' import: 'Importer' howto: 'Aide' logout: 'Déconnexion' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig index c23d0e27..27a88287 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig @@ -11,16 +11,15 @@
  • {% if entry.isArchived == 0 %}{% trans %}Mark as read{% endtrans %}{% else %}{% trans %}Mark as unread{% endtrans %}{% endif %}
  • {% trans %}Toggle favorite{% endtrans %}
  • {% trans %}Delete{% endtrans %}
  • - {% if share_twitter %}
  • {% endif %} - {% if share_mail %}
  • {% endif %} - {% if share_shaarli %}
  • {% trans %}shaarli{% endtrans %}
  • {% endif %} - {% if share_diaspora %}
  • {% trans %}diaspora{% endtrans %}
  • {% endif %} - {# {% if flattr %}{% if flattr.status == flattrable %}
  • {% trans %}flattr{% endtrans %}
  • {% elseif flattr.status == flattred %}
  • Carrot
  • {% endif %} - {% if show_printlink %}
  • {% trans %}Print{% endtrans %}
  • {% endif %} - {% if export_epub %}
  • EPUB
  • {% endif %} - {% if export_mobi %}
  • MOBI
  • {% endif %} - {% if export_pdf %}
  • PDF
  • {% endif %} + {% if craue_setting('share_twitter') %}
  • {% endif %} + {% if craue_setting('share_mail') %}
  • {% endif %} + {% if craue_setting('share_shaarli') %}
  • {% trans %}shaarli{% endtrans %}
  • {% endif %} + {% if craue_setting('share_diaspora') %}
  • {% trans %}diaspora{% endtrans %}
  • {% endif %} + {% if craue_setting('carrot') %}
  • Carrot
  • {% endif %} + {% if craue_setting('show_printlink') %}
  • {% trans %}Print{% endtrans %}
  • {% endif %} + {% if craue_setting('export_epub') %}
  • EPUB
  • {% endif %} + {% if craue_setting('export_mobi') %}
  • MOBI
  • {% endif %} + {% if craue_setting('export_pdf') %}
  • PDF
  • {% endif %}
  • {% trans %}Does this article appear wrong?{% endtrans %}
  • diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig index 3aead497..b630070c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig @@ -51,6 +51,9 @@
  • {% trans %}config{% endtrans %}
  • + {% if is_granted('ROLE_SUPER_ADMIN') %} +
  • {% trans %}internal settings{% endtrans %}
  • + {% endif %}
  • {% trans %}import{% endtrans %}
  • {% trans %}howto{% endtrans %}
  • {% trans %}about{% endtrans %}
  • diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig index 31963ae8..dad96187 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig @@ -97,12 +97,11 @@
    @@ -114,13 +113,13 @@
    diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index a8b6dc3f..dff9e612 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -45,6 +45,9 @@
  • {% trans %}all{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • {% trans %}config{% endtrans %}
  • + {% if is_granted('ROLE_SUPER_ADMIN') %} +
  • {% trans %}internal settings{% endtrans %}
  • + {% endif %}
  • {% trans %}import{% endtrans %}
  • {% trans %}howto{% endtrans %}
  • {% trans %}logout{% endtrans %}
  • diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 72b9047c..0463a739 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -11,6 +11,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Helper\ContentProxy; +use Craue\ConfigBundle\Util\Config; class PocketImport implements ImportInterface { @@ -25,12 +26,12 @@ class PocketImport implements ImportInterface protected $accessToken; private $translator; - public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, $consumerKey) + public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) { $this->user = $tokenStorage->getToken()->getUser(); $this->em = $em; $this->contentProxy = $contentProxy; - $this->consumerKey = $consumerKey; + $this->consumerKey = $craueConfig->get('pocket_consumer_key'); $this->logger = new NullLogger(); } diff --git a/src/Wallabag/ImportBundle/Resources/config/services.yml b/src/Wallabag/ImportBundle/Resources/config/services.yml index e4dde100..dc536808 100644 --- a/src/Wallabag/ImportBundle/Resources/config/services.yml +++ b/src/Wallabag/ImportBundle/Resources/config/services.yml @@ -17,7 +17,7 @@ services: - "@security.token_storage" - "@doctrine.orm.entity_manager" - "@wallabag_core.content_proxy" - - %pocket_consumer_key% + - "@craue_config" calls: - [ setClient, [ "@wallabag_import.pocket.client" ] ] - [ setLogger, [ "@logger" ]] diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php index 76225fe4..25359d56 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php @@ -55,11 +55,20 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config') + ->disableOriginalConstructor() + ->getMock(); + + $config->expects($this->any()) + ->method('get') + ->with('pocket_consumer_key') + ->willReturn($consumerKey); + $pocket = new PocketImportMock( $this->tokenStorage, $this->em, $this->contentProxy, - $consumerKey + $config ); $this->logHandler = new TestHandler(); diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index 6b108dd3..4ab6051b 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php @@ -4,6 +4,7 @@ namespace Wallabag\UserBundle\Mailer; use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; +use Craue\ConfigBundle\Util\Config; /** * Custom mailer for TwoFactorBundle email. @@ -60,17 +61,16 @@ class AuthCodeMailer implements AuthCodeMailerInterface * @param \Twig_Environment $twig * @param string $senderEmail * @param string $senderName - * @param string $supportUrl - * @param string $wallabagUrl + * @param Config $craueConfig Craue\Config instance to get wallabag support url from database */ - public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl, $wallabagUrl) + public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, Config $craueConfig) { $this->mailer = $mailer; $this->twig = $twig; $this->senderEmail = $senderEmail; $this->senderName = $senderName; - $this->supportUrl = $supportUrl; - $this->wallabagUrl = $wallabagUrl; + $this->supportUrl = $craueConfig->get('wallabag_support_url'); + $this->wallabagUrl = $craueConfig->get('wallabag_url'); } /** diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index bf9e036a..d79d8fa2 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -6,8 +6,7 @@ services: - "@twig" - "%scheb_two_factor.email.sender_email%" - "%scheb_two_factor.email.sender_name%" - - "%wallabag_support_url%" - - "%wallabag_url%" + - "@craue_config" wallabag_user.password_resetting: class: Wallabag\UserBundle\EventListener\PasswordResettingListener -- cgit v1.2.3