From e0f9010ec2a558f6cf7d16fb96a2c4cdb34e3f37 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 15 Jun 2017 09:43:48 +0200 Subject: Notifications Signed-off-by: Thomas Citharel --- .../static/themes/material/css/index.scss | 1 + app/Resources/static/themes/material/css/nav.scss | 4 + .../static/themes/material/css/notifications.scss | 38 +++ .../static/themes/material/css/sidenav.scss | 11 + .../static/themes/material/css/various.scss | 6 + app/Resources/static/themes/material/index.js | 3 +- app/Resources/static/themes/material/js/tools.js | 9 +- app/config/services.yml | 9 + app/config/wallabag.yml | 1 + .../Command/AbstractNotificationCommand.php | 41 +++ .../Command/AdminNotificationCommand.php | 103 +++++++ .../Command/ReleaseNotificationCommand.php | 88 ++++++ .../Controller/NotificationsController.php | 96 +++++++ .../DependencyInjection/Configuration.php | 3 + .../DependencyInjection/WallabagCoreExtension.php | 1 + src/Wallabag/CoreBundle/Entity/Notification.php | 308 +++++++++++++++++++++ src/Wallabag/CoreBundle/Notifications/Action.php | 91 ++++++ .../CoreBundle/Notifications/ActionInterface.php | 42 +++ .../CoreBundle/Notifications/InfoAction.php | 13 + src/Wallabag/CoreBundle/Notifications/NoAction.php | 13 + .../Notifications/NotificationInterface.php | 103 +++++++ src/Wallabag/CoreBundle/Notifications/OkAction.php | 13 + .../CoreBundle/Notifications/YesAction.php | 13 + .../Repository/NotificationRepository.php | 26 ++ .../CoreBundle/Resources/config/services.yml | 6 + .../CoreBundle/Resources/translations/date.da.yml | 9 + .../CoreBundle/Resources/translations/date.de.yml | 9 + .../CoreBundle/Resources/translations/date.en.yml | 9 + .../CoreBundle/Resources/translations/date.es.yml | 9 + .../CoreBundle/Resources/translations/date.fa.yml | 9 + .../CoreBundle/Resources/translations/date.fr.yml | 9 + .../CoreBundle/Resources/translations/date.it.yml | 9 + .../CoreBundle/Resources/translations/date.oc.yml | 9 + .../CoreBundle/Resources/translations/date.pl.yml | 9 + .../CoreBundle/Resources/translations/date.pt.yml | 9 + .../CoreBundle/Resources/translations/date.ro.yml | 9 + .../CoreBundle/Resources/translations/date.tr.yml | 9 + .../Resources/translations/messages.da.yml | 12 + .../Resources/translations/messages.de.yml | 12 + .../Resources/translations/messages.en.yml | 11 + .../Resources/translations/messages.es.yml | 12 + .../Resources/translations/messages.fa.yml | 12 + .../Resources/translations/messages.fr.yml | 12 + .../Resources/translations/messages.it.yml | 11 + .../Resources/translations/messages.oc.yml | 12 + .../Resources/translations/messages.pl.yml | 12 + .../Resources/translations/messages.pt.yml | 12 + .../Resources/translations/messages.ro.yml | 12 + .../Resources/translations/messages.tr.yml | 12 + .../views/themes/common/Developer/client.html.twig | 1 + .../views/themes/common/Developer/index.html.twig | 1 + .../views/themes/common/Static/about.html.twig | 2 +- .../views/themes/common/Static/howto.html.twig | 2 +- .../themes/common/Static/quickstart.html.twig | 2 +- .../views/themes/material/Config/index.html.twig | 2 +- .../views/themes/material/Entry/entries.html.twig | 1 + .../material/Notification/notifications.html.twig | 56 ++++ .../views/themes/material/Tag/tags.html.twig | 1 + .../views/themes/material/layout.html.twig | 54 ++++ src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 41 ++- src/Wallabag/UserBundle/Entity/User.php | 21 ++ .../UserBundle/Resources/views/manage.html.twig | 2 +- .../Command/AdminNotificationCommandTest.php | 101 +++++++ .../Command/ReleaseNotificationCommandTest.php | 96 +++++++ .../Controller/NotificationControllerTest.php | 32 +++ .../CoreBundle/Twig/WallabagExtensionTest.php | 6 +- web/bundles/wallabagcore/material.css | 2 +- web/bundles/wallabagcore/material.js | 2 +- 68 files changed, 1701 insertions(+), 16 deletions(-) create mode 100644 app/Resources/static/themes/material/css/notifications.scss create mode 100644 src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php create mode 100644 src/Wallabag/CoreBundle/Command/AdminNotificationCommand.php create mode 100644 src/Wallabag/CoreBundle/Command/ReleaseNotificationCommand.php create mode 100644 src/Wallabag/CoreBundle/Controller/NotificationsController.php create mode 100644 src/Wallabag/CoreBundle/Entity/Notification.php create mode 100644 src/Wallabag/CoreBundle/Notifications/Action.php create mode 100644 src/Wallabag/CoreBundle/Notifications/ActionInterface.php create mode 100644 src/Wallabag/CoreBundle/Notifications/InfoAction.php create mode 100644 src/Wallabag/CoreBundle/Notifications/NoAction.php create mode 100644 src/Wallabag/CoreBundle/Notifications/NotificationInterface.php create mode 100644 src/Wallabag/CoreBundle/Notifications/OkAction.php create mode 100644 src/Wallabag/CoreBundle/Notifications/YesAction.php create mode 100644 src/Wallabag/CoreBundle/Repository/NotificationRepository.php create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.da.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.de.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.en.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.es.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.fa.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.fr.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.it.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.oc.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.pl.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.pt.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.ro.yml create mode 100644 src/Wallabag/CoreBundle/Resources/translations/date.tr.yml create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig create mode 100644 tests/Wallabag/CoreBundle/Command/AdminNotificationCommandTest.php create mode 100644 tests/Wallabag/CoreBundle/Command/ReleaseNotificationCommandTest.php create mode 100644 tests/Wallabag/CoreBundle/Controller/NotificationControllerTest.php diff --git a/app/Resources/static/themes/material/css/index.scss b/app/Resources/static/themes/material/css/index.scss index 285a6504..8300e430 100644 --- a/app/Resources/static/themes/material/css/index.scss +++ b/app/Resources/static/themes/material/css/index.scss @@ -8,6 +8,7 @@ @import 'layout'; @import 'nav'; @import 'sidenav'; +@import 'notifications'; @import 'various'; /* Tools */ diff --git a/app/Resources/static/themes/material/css/nav.scss b/app/Resources/static/themes/material/css/nav.scss index 1a25a5be..601aada2 100644 --- a/app/Resources/static/themes/material/css/nav.scss +++ b/app/Resources/static/themes/material/css/nav.scss @@ -104,3 +104,7 @@ nav { #button_export { display: none; } + +#button_notifications a.nav-panel-menu { + max-height: 65px; +} diff --git a/app/Resources/static/themes/material/css/notifications.scss b/app/Resources/static/themes/material/css/notifications.scss new file mode 100644 index 00000000..60114ce4 --- /dev/null +++ b/app/Resources/static/themes/material/css/notifications.scss @@ -0,0 +1,38 @@ +@mixin notification { + .notifications-area { + flex-grow: 1; + + .collection { + margin: auto; + } + } + + .no-notifications { + position: absolute; + top: 40%; + left: 50%; + transform: translate(-40%, -50%); + } + + .view-more { + display: block; + margin: auto 5px 10px; + flex: 0 1 2.5em; + } + + .btn.notification-action-button { + display: block; + line-height: 25px; + height: auto; + } +} + +.notifications-page { + @include notification; + + .pagination { + float: none; + text-align: center; + margin-top: 30px; + } +} diff --git a/app/Resources/static/themes/material/css/sidenav.scss b/app/Resources/static/themes/material/css/sidenav.scss index 416dc1c7..a86eed17 100644 --- a/app/Resources/static/themes/material/css/sidenav.scss +++ b/app/Resources/static/themes/material/css/sidenav.scss @@ -2,6 +2,8 @@ Side-nav ========================================================================== */ +@import 'notifications'; + .side-nav { width: 240px; @@ -36,6 +38,15 @@ } } +#notifications { + width: 300px; + display: flex; + flex-flow: column; + justify-content: space-between; + + @include notification; +} + .bold > a { font-weight: bold; } diff --git a/app/Resources/static/themes/material/css/various.scss b/app/Resources/static/themes/material/css/various.scss index 7daf40ec..300015ab 100644 --- a/app/Resources/static/themes/material/css/various.scss +++ b/app/Resources/static/themes/material/css/various.scss @@ -30,3 +30,9 @@ nav .input-field input { .tab { flex: 1; } + +#notifications-count { + position: relative; + top: -50px; + left: 15px; +} diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index d6afbb8a..435cd02f 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js @@ -8,7 +8,7 @@ import 'materialize-css/dist/js/materialize'; import '../_global/index'; /* Tools */ -import { initExport, initFilters } from './js/tools'; +import { initExport, initFilters, initNotifications } from './js/tools'; /* Import shortcuts */ import './js/shortcuts/main'; @@ -34,6 +34,7 @@ $(document).ready(() => { }); initFilters(); initExport(); + initNotifications(); $('#nav-btn-add-tag').on('click', () => { $('.nav-panel-add-tag').toggle(100); diff --git a/app/Resources/static/themes/material/js/tools.js b/app/Resources/static/themes/material/js/tools.js index 39398fd8..492640a0 100644 --- a/app/Resources/static/themes/material/js/tools.js +++ b/app/Resources/static/themes/material/js/tools.js @@ -21,4 +21,11 @@ function initExport() { } } -export { initExport, initFilters }; +function initNotifications() { + if ($('div').is('#notifications')) { + $('#button_notifications').show(); + $('.js-notifications-action').sideNav({ edge: 'right' }); + } +} + +export { initExport, initFilters, initNotifications }; diff --git a/app/config/services.yml b/app/config/services.yml index 7b85d846..3b454760 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -13,14 +13,23 @@ services: tags: - { name: twig.extension } + twig.extension.date: + class: Twig_Extensions_Extension_Date + arguments: + - "@translator" + tags: + - { name: twig.extension } + wallabag.twig_extension: class: Wallabag\CoreBundle\Twig\WallabagExtension public: false arguments: - "@wallabag_core.entry_repository" - "@wallabag_core.tag_repository" + - "@wallabag_core.notification_repository" - "@security.token_storage" - "%wallabag_core.cache_lifetime%" + - "%wallabag_core.notifications_nb%" - "@translator" tags: - { name: twig.extension } diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml index b45934e4..ab12d68a 100644 --- a/app/config/wallabag.yml +++ b/app/config/wallabag.yml @@ -22,6 +22,7 @@ wallabag_core: cache_lifetime: 10 action_mark_as_read: 1 list_mode: 0 + notifications_nb: 5 fetching_error_message_title: 'No title found' fetching_error_message: | wallabag can't retrieve contents for this article. Please troubleshoot this issue. diff --git a/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php b/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php new file mode 100644 index 00000000..b40b589a --- /dev/null +++ b/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php @@ -0,0 +1,41 @@ +addArgument( + 'username', + InputArgument::OPTIONAL, + 'User to send the notification to' + ) + ; + } + + /** + * Fetches a user from its username. + * + * @param string $username + * + * @return \Wallabag\UserBundle\Entity\User + */ + protected function getUser($username) + { + return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username); + } + + protected function getDoctrine() + { + return $this->getContainer()->get('doctrine'); + } +} diff --git a/src/Wallabag/CoreBundle/Command/AdminNotificationCommand.php b/src/Wallabag/CoreBundle/Command/AdminNotificationCommand.php new file mode 100644 index 00000000..cfde714b --- /dev/null +++ b/src/Wallabag/CoreBundle/Command/AdminNotificationCommand.php @@ -0,0 +1,103 @@ +setName('wallabag:notification:send') + ->setDescription('Emits a notification to all users') + ->setHelp('This command helps you send notifications to all of the users instance, or just for one user.') + ->addArgument( + 'title', + InputArgument::REQUIRED, + 'Title of your notification. This is required if if the type of notification is an admin one.' + ) + ->addArgument( + 'message', + InputArgument::REQUIRED, + 'Message of your notification. This is required if the type of notification is an admin one.' + ) + ->addOption( + 'link', + 'l', + InputOption::VALUE_REQUIRED, + 'A link to display with the notification' + ) + ; + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->output = $output; + + $username = $input->getArgument('username'); + + $message = $input->getArgument('message'); + $title = $input->getArgument('title'); + + $link = $input->getOption('link'); + + if ($username) { + try { + $user = $this->getUser($username); + $this->sendNotification($user, $title, $message, $link); + } catch (NoResultException $e) { + $output->writeln(sprintf('User "%s" not found.', $username)); + + return 1; + } + } else { + $users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll(); + + $output->writeln(sprintf('Sending notifications to %d user accounts. This can take some time.', count($users))); + + foreach ($users as $user) { + $output->writeln(sprintf('Processing user %s', $user->getUsername())); + $this->sendNotification($user, $title, $message, $link); + } + $output->writeln('Finished sending notifications.'); + } + + return 0; + } + + /** + * @param User $user + * @param $title + * @param $message + * @param null $link + */ + private function sendNotification(User $user, $title, $message, $link = null) + { + $em = $this->getContainer()->get('doctrine.orm.entity_manager'); + + $notification = new Notification($user); + $notification->setTitle($title) + ->setDescription($message) + ->setType(Notification::TYPE_ADMIN); + + if ($link) { + $action = new InfoAction($link); + + $notification->addAction($action); + } + + $em->persist($notification); + $em->flush(); + + $this->output->writeln(sprintf('Sent notification for user %s', $user->getUserName())); + } +} diff --git a/src/Wallabag/CoreBundle/Command/ReleaseNotificationCommand.php b/src/Wallabag/CoreBundle/Command/ReleaseNotificationCommand.php new file mode 100644 index 00000000..cd9c61a3 --- /dev/null +++ b/src/Wallabag/CoreBundle/Command/ReleaseNotificationCommand.php @@ -0,0 +1,88 @@ +setName('wallabag:notification:release') + ->setDescription('Emits a notification to all users to let them know of a new release') + ->setHelp('This command helps you send a release notification to all of the users instance, or just for one user.') + ->addArgument( + 'link', + InputArgument::OPTIONAL, + 'A link to display with the notification' + ) + ; + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->output = $output; + + $username = $input->getArgument('username'); + + $link = $input->getArgument('link'); + + if ($username) { + try { + $user = $this->getUser($username); + $this->sendNotification($user, $link); + } catch (NoResultException $e) { + $output->writeln(sprintf('User "%s" not found.', $username)); + + return 1; + } + } else { + $users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll(); + + $output->writeln(sprintf('Sending notifications to %d user accounts. This can take some time.', count($users))); + + foreach ($users as $user) { + $output->writeln(sprintf('Processing user %s', $user->getUsername())); + $this->sendNotification($user, $link); + } + $output->writeln('Finished sending notifications.'); + } + + return 0; + } + + /** + * @param User $user + */ + private function sendNotification(User $user, $link) + { + $em = $this->getContainer()->get('doctrine.orm.entity_manager'); + + $notification = new Notification($user); + $notification->setTitle('notifications.release.title') + ->addParameter('%version%', $this->getContainer()->getParameter('wallabag_core.version')) + ->setType(Notification::TYPE_RELEASE); + if ($link) { + $details = new Action(); + $details->setType(Action::TYPE_INFO) + ->setLabel('notifications.release.details') + ->setLink($link); + $notification->addAction($details); + } + $em->persist($notification); + $em->flush(); + + $this->output->writeln(sprintf('Sent notification for user %s', $user->getUserName())); + } +} diff --git a/src/Wallabag/CoreBundle/Controller/NotificationsController.php b/src/Wallabag/CoreBundle/Controller/NotificationsController.php new file mode 100644 index 00000000..17e576cd --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/NotificationsController.php @@ -0,0 +1,96 @@ +getDoctrine()->getRepository('WallabagCoreBundle:Notification')->getBuilderForNotificationsByUser($this->getUser()->getId()); + $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); + + $notifications = new Pagerfanta($pagerAdapter); + $notifications->setMaxPerPage($this->getParameter('wallabag_core.notifications_nb')); + + try { + $notifications->setCurrentPage($page); + } catch (OutOfRangeCurrentPageException $e) { + if ($page > 1) { + return $this->redirect($this->generateUrl('notifications-all', ['page' => $notifications->getNbPages()]), 302); + } + } + + return $this->render('WallabagCoreBundle:Notification:notifications.html.twig', [ + 'notifications' => $notifications, + 'currentPage' => $page, + ]); + } + + /** + * @Route("/notifications/readall", name="notification-archive-all") + * + * @param Request $request + * + * @return Response + */ + public function markAllNotificationsAsReadAction(Request $request) + { + $this->getDoctrine()->getRepository('WallabagCoreBundle:Notification')->markAllAsReadForUser($this->getUser()->getId()); + + return $this->redirectToRoute('notifications-all'); + } + + /** + * @Route("/notifications/read/{notification}", name="notification-archive") + * + * @param Notification $notification + * + * @return Response + */ + public function markNotificationsAsReadAction(Notification $notification) + { + $em = $this->getDoctrine()->getManager(); + + $notification->setRead(true); + + $em->persist($notification); + $em->flush(); + + return $this->redirectToRoute('notifications-all'); + } + + /** + * @Route("/notifications/read/{notification}/redirect", name="notification-archive-redirect", requirements={"notification" = "\d+"}) + * + * @param Request $request + * @param Notification $notification + */ + public function markNotificationAsReadAndRedirectAction(Request $request, Notification $notification) + { + $em = $this->getDoctrine()->getManager(); + + $notification->setRead(true); + + $em->persist($notification); + $em->flush(); + + $redirection = $request->get('redirection'); + $this->redirect($redirection); + } +} diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index a9791f6b..478e4cba 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -49,6 +49,9 @@ class Configuration implements ConfigurationInterface ->scalarNode('list_mode') ->defaultValue(1) ->end() + ->scalarNode('notifications_nb') + ->defaultValue(5) + ->end() ->scalarNode('api_limit_mass_actions') ->defaultValue(10) ->end() diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 532ce238..f8b5c7fe 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -25,6 +25,7 @@ class WallabagCoreExtension extends Extension $container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']); $container->setParameter('wallabag_core.action_mark_as_read', $config['action_mark_as_read']); $container->setParameter('wallabag_core.list_mode', $config['list_mode']); + $container->setParameter('wallabag_core.notifications_nb', $config['notifications_nb']); $container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']); $container->setParameter('wallabag_core.fetching_error_message_title', $config['fetching_error_message_title']); $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); diff --git a/src/Wallabag/CoreBundle/Entity/Notification.php b/src/Wallabag/CoreBundle/Entity/Notification.php new file mode 100644 index 00000000..6b30b044 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Notification.php @@ -0,0 +1,308 @@ + + * + * @ORM\Column(name="actions", type="array", nullable=true) + */ + protected $actions; + + protected $actionTypes = []; + + const TYPE_ADMIN = 0; + const TYPE_USER = 1; + const TYPE_RELEASE = 2; + + public function __construct(User $user = null) + { + $this->logger = new NullLogger(); + $this->timestamp = new \DateTime(); + $this->actions = new ArrayCollection(); + $this->parameters = []; + $this->read = false; + $this->user = $user; + } + + /** + * @param LoggerInterface $logger + * + * @return NotificationInterface + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + + return $this; + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @return mixed + */ + public function getType() + { + return $this->type; + } + + /** + * @param mixed $type + * + * @return NotificationInterface + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @param User $user + * + * @return NotificationInterface + */ + public function setUser(User $user) + { + $this->user = $user; + + return $this; + } + + /** + * @return \DateTime + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * @param \DateTime $timestamp + * + * @return NotificationInterface + */ + public function setTimestamp(\DateTime $timestamp) + { + $this->timestamp = $timestamp; + + return $this; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + * + * @return NotificationInterface + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return bool + */ + public function isRead() + { + return $this->read; + } + + /** + * @param bool $read + * + * @return NotificationInterface + */ + public function setRead($read) + { + $this->read = $read; + + return $this; + } + + /** + * @param ActionInterface $action + * + * @return NotificationInterface + * + * @throws \InvalidArgumentException + */ + public function addAction(ActionInterface $action) + { + if (isset($this->actionTypes[$action->getType()])) { + throw new \InvalidArgumentException('The notification already has a primary action'); + } + $this->actionTypes[$action->getType()] = true; + $this->actions->add($action); + + return $this; + } + + /** + * @return ArrayCollection + */ + public function getActions() + { + return $this->actions; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * + * @return Notification + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * @return array + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * @param array $parameters + * + * @return Notification + */ + public function setParameters($parameters) + { + $this->parameters = $parameters; + + return $this; + } + + /** + * @param string $key + * @param string $value + * + * @return Notification + * + * @throws \InvalidArgumentException + */ + public function addParameter($key, $value) + { + if (in_array($key, $this->parameters, true)) { + throw new \InvalidArgumentException('This parameter already is set'); + } + + $this->parameters[$key] = $value; + + return $this; + } +} diff --git a/src/Wallabag/CoreBundle/Notifications/Action.php b/src/Wallabag/CoreBundle/Notifications/Action.php new file mode 100644 index 00000000..d032adf9 --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/Action.php @@ -0,0 +1,91 @@ +label; + } + + /** + * @param string $label + * + * @return ActionInterface + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * @param int $type + * + * @return ActionInterface + * + * @throws \InvalidArgumentException + */ + public function setType($type) + { + if ($type <= 0 || $type > 4) { + throw new \InvalidArgumentException('The given type option is invalid'); + } + $this->type = $type; + + return $this; + } + + /** + * @return string + */ + public function getLink() + { + return $this->link; + } + + /** + * @param string $link + * + * @return ActionInterface + */ + public function setLink($link) + { + $this->link = $link; + + return $this; + } +} diff --git a/src/Wallabag/CoreBundle/Notifications/ActionInterface.php b/src/Wallabag/CoreBundle/Notifications/ActionInterface.php new file mode 100644 index 00000000..e166e45b --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/ActionInterface.php @@ -0,0 +1,42 @@ +link = $link; + $this->label = 'Info'; + $this->type = Action::TYPE_INFO; + } +} diff --git a/src/Wallabag/CoreBundle/Notifications/NoAction.php b/src/Wallabag/CoreBundle/Notifications/NoAction.php new file mode 100644 index 00000000..606372b6 --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/NoAction.php @@ -0,0 +1,13 @@ +link = $link; + $this->label = 'No'; + $this->type = Action::TYPE_NO; + } +} diff --git a/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php b/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php new file mode 100644 index 00000000..4a3c2759 --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php @@ -0,0 +1,103 @@ +link = $link; + $this->label = 'OK'; + $this->type = Action::TYPE_OK; + } +} diff --git a/src/Wallabag/CoreBundle/Notifications/YesAction.php b/src/Wallabag/CoreBundle/Notifications/YesAction.php new file mode 100644 index 00000000..9b48eca5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/YesAction.php @@ -0,0 +1,13 @@ +link = $link; + $this->label = 'Yes'; + $this->type = Action::TYPE_YES; + } +} diff --git a/src/Wallabag/CoreBundle/Repository/NotificationRepository.php b/src/Wallabag/CoreBundle/Repository/NotificationRepository.php new file mode 100644 index 00000000..6d6938ae --- /dev/null +++ b/src/Wallabag/CoreBundle/Repository/NotificationRepository.php @@ -0,0 +1,26 @@ +getEntityManager()->createQueryBuilder() + ->update('WallabagCoreBundle:Notification', 'n') + ->set('n.read', true) + ->where('n.user = :userId')->setParameter('userId', $userId) + ->getQuery() + ->getResult(); + } + + public function getBuilderForNotificationsByUser($userId) + { + return $this->createQueryBuilder('n') + ->andWhere('n.user = :userId')->setParameter('userId', $userId) + ->orderBy('n.timestamp', 'desc') + ; + } +} diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index e09b0f18..183b6690 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -129,6 +129,12 @@ services: calls: - [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ] + wallabag_core.notification_repository: + class: Wallabag\CoreBundle\Repository\NotificationRepository + factory: [ "@doctrine.orm.default_entity_manager", getRepository ] + arguments: + - WallabagCoreBundle:Notification + wallabag_core.helper.entries_export: class: Wallabag\CoreBundle\Helper\EntriesExport arguments: diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.da.yml b/src/Wallabag/CoreBundle/Resources/translations/date.da.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.da.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.de.yml b/src/Wallabag/CoreBundle/Resources/translations/date.de.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.de.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.en.yml b/src/Wallabag/CoreBundle/Resources/translations/date.en.yml new file mode 100644 index 00000000..7bcd6d0c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.en.yml @@ -0,0 +1,9 @@ +diff: + ago: + empty: 'Now' + second: 'One second ago|%count% seconds ago' + minute: 'One minute ago|%count% minutes ago' + hour: 'One hour ago|%count% hours ago' + day: 'One day ago|%count% days ago' + month: 'One month ago|%count% months ago' + year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.es.yml b/src/Wallabag/CoreBundle/Resources/translations/date.es.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.es.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/date.fa.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.fa.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/date.fr.yml new file mode 100644 index 00000000..02eb96b0 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.fr.yml @@ -0,0 +1,9 @@ +diff: + ago: + empty: 'Maintenant' + second: 'Il y a une seconde|il y a %count% secondes' + minute: 'Il y a une minute|il y a %count% minutes' + hour: 'Il y a une heure|il y a %count% heures' + day: 'Il y a un jour|Il y a %count% jours' + month: 'Il y a un mois|il y a %count% mois' + year: 'Il y a un an|il y a %count% ans' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.it.yml b/src/Wallabag/CoreBundle/Resources/translations/date.it.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.it.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/date.oc.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.oc.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/date.pl.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.pl.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/date.pt.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.pt.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/date.ro.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.ro.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/date.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/date.tr.yml new file mode 100644 index 00000000..3797b6bf --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/translations/date.tr.yml @@ -0,0 +1,9 @@ +diff: + ago: + # empty: 'Now' + # second: 'One second ago|%count% seconds ago' + # minute: 'One minute ago|%count% minutes ago' + # hour: 'One hour ago|%count% hours ago' + # day: 'One day ago|%count% days ago' + # month: 'One month ago|%count% months ago' + # year: 'One year ago|%count% years ago' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 5229ac73..ad03fa91 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -38,6 +38,7 @@ menu: search: 'Søg' filter_entries: 'Filtrer artikler' # export: 'Export' + # notifications: 'Notifications' search_form: input_label: 'Indtast søgning' @@ -250,6 +251,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'Om' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 996f173a..f2d75a62 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -38,6 +38,7 @@ menu: search: 'Suche' filter_entries: 'Artikel filtern' export: 'Exportieren' + # notifications: 'Notifications' search_form: input_label: 'Suchbegriff hier eingeben' @@ -250,6 +251,17 @@ entry: delete: "Bist du sicher, dass du diesen Artikel löschen möchtest?" delete_tag: "Bist du sicher, dass du diesen Tag vom Artikel entfernen möchtest?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'Über' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index aa1cd1a9..228dd87e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -38,6 +38,7 @@ menu: search: 'Search' filter_entries: 'Filter entries' export: 'Export' + notifications: 'Notifications' search_form: input_label: 'Enter your search here' @@ -250,6 +251,16 @@ entry: delete: "Are you sure you want to remove that article?" delete_tag: "Are you sure you want to remove that tag from that article?" +notifications: + sidebar: + view_more: 'View more' + list: + page_title: 'Notifications' + mark_all_as_read: 'Mark all as read' + none: "No notifications yet :'(" + release: + title: "wallabag has been updated to version %version%" + details: "View update's details" about: page_title: 'About' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 96998f53..28f064c7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -38,6 +38,7 @@ menu: search: 'Buscar' filter_entries: 'Filtrar los artículos' export: 'Exportar' + # notifications: 'Notifications' search_form: input_label: 'Introduzca su búsqueda aquí' @@ -250,6 +251,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'Acerca de' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 57e6c029..4496a2f2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -38,6 +38,7 @@ menu: search: 'جستجو' filter_entries: 'فیلترکردن مقاله‌ها' export: 'برون‌بری' + # notifications: 'Notifications' search_form: input_label: 'جستجوی خود را این‌جا بنویسید:' @@ -250,6 +251,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'درباره' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 6eac4c36..8bccc8a4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -38,6 +38,7 @@ menu: search: "Rechercher" filter_entries: "Filtrer les articles" export: "Exporter" + notifications: 'Notifications' search_form: input_label: "Saisissez votre terme de recherche" @@ -250,6 +251,17 @@ entry: delete: "Voulez-vous vraiment supprimer cet article ?" delete_tag: "Voulez-vous vraiment supprimer ce tag de cet article ?" +notifications: + sidebar: + view_more: 'Voir plus' + list: + page_title: 'Notifications' + mark_all_as_read: 'Marquer tout comme lu' + none: "Aucune notification pour le moment :'(" + release: + title: "wallabag a été mis à jour vers la version %version%" + details: "Voir les détails de la mise à jour" + about: page_title: "À propos" top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 4e26f38c..c404b3e5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -38,6 +38,7 @@ menu: search: 'Cerca' filter_entries: 'Filtra contenuti' export: 'Esporta' + # notifications: 'Notifications' search_form: input_label: 'Inserisci qui la tua ricerca' @@ -250,6 +251,16 @@ entry: delete: "Vuoi veramente rimuovere quell'articolo?" delete_tag: "Vuoi veramente rimuovere quell'etichetta da quell'articolo?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" about: page_title: 'A proposito' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index be57e903..af9d85c3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -38,6 +38,7 @@ menu: search: 'Cercar' filter_entries: 'Filtrar los articles' export: 'Exportar' + # notifications: 'Notifications' search_form: input_label: 'Picatz vòstre mot-clau a cercar aquí' @@ -250,6 +251,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'A prepaus' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 00c559ed..78464162 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -38,6 +38,7 @@ menu: search: 'Szukaj' filter_entries: 'Filtruj wpisy' export: 'Eksportuj' + # notifications: 'Notifications' search_form: input_label: 'Wpisz swoje zapytanie tutaj' @@ -250,6 +251,17 @@ entry: delete: "Czy jesteś pewien, że chcesz usunąć ten artykuł?" delete_tag: "Czy jesteś pewien, że chcesz usunąć ten tag, z tego artykułu?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'O nas' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 4ab5f144..07eeefc2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -38,6 +38,7 @@ menu: search: 'Pesquisa' filter_entries: 'Filtrar entradas' export: 'Exportar' + # notifications: 'Notifications' search_form: input_label: 'Digite aqui sua pesquisa' @@ -250,6 +251,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'Sobre' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index f16504ed..ba7b11d5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -38,6 +38,7 @@ menu: search: 'Căutare' filter_entries: 'Filtrează articolele' # export: 'Export' + # notifications: 'Notifications' search_form: input_label: 'Introdu căutarea ta' @@ -250,6 +251,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'Despre' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 90a140cd..6cbe6dcd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -38,6 +38,7 @@ menu: search: 'Ara' filter_entries: 'Filtrele' export: 'Dışa Aktar' + # notifications: 'Notifications' search_form: input_label: 'Aramak istediğiniz herhangi bir şey yazın' @@ -248,6 +249,17 @@ entry: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" +# notifications: +# sidebar: +# view_more: 'View more' +# list: +# page_title: 'Notifications' +# mark_all_as_read: 'Mark all as read' +# none: "No notifications yet :'(" +# release: +# title: "wallabag has been updated to version %version%" +# details: "View update's details" + about: page_title: 'Hakkımızda' top_menu: diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/client.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/client.html.twig index 8a5da71a..d566795d 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/client.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/client.html.twig @@ -3,6 +3,7 @@ {% block title %}{{ 'developer.client.page_title'|trans }}{% endblock %} {% block content %} +{{ parent() }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/index.html.twig index 528b055c..53210688 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Developer/index.html.twig @@ -3,6 +3,7 @@ {% block title %}{{ 'developer.page_title'|trans }}{% endblock %} {% block content %} +{{ parent() }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig index 1cd3485c..ffd9b1b8 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig @@ -3,7 +3,7 @@ {% block title %}{{ 'about.page_title'|trans }}{% endblock %} {% block content %} - + {{ parent() }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/howto.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/howto.html.twig index 231f9bdf..4c598b85 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/howto.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/howto.html.twig @@ -3,7 +3,7 @@ {% block title %}{{ 'howto.page_title'|trans }}{% endblock %} {% block content %} - + {{ parent() }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/quickstart.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/quickstart.html.twig index 4580813c..70265be2 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/quickstart.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/quickstart.html.twig @@ -3,7 +3,7 @@ {% block title %}{{ 'quickstart.page_title'|trans }}{% endblock %} {% block content %} - + {{ parent() }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index a8143315..bd5932b0 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -3,7 +3,7 @@ {% block title %}{{ 'config.page_title'|trans }}{% endblock %} {% block content %} - + {{ parent() }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index 0c4dc80b..1cc5489f 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig @@ -19,6 +19,7 @@ {% endblock %} {% block content %} + {{ parent() }} {% set listMode = app.user.config.listMode %} {% set currentRoute = app.request.attributes.get('_route') %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig new file mode 100644 index 00000000..49cc0d40 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig @@ -0,0 +1,56 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'notifications.list.page_title' | trans }}{% endblock %} + +{% block content %} + {{ parent() }} +
+
+ {% if app.user.notifications is not empty %} + +
    + {% for notification in notifications | slice(0, 10) %} +
  • + {% spaceless %} + {% if notification.type == constant('TYPE_ADMIN', notification) %} + build + {% elseif notification.type == constant('TYPE_USER', notification) %} + person + {% elseif notification.type == constant('TYPE_RELEASE', notification) %} + new_releases + {% endif %} + {% endspaceless %} + {{ notification.title | trans(notification.parameters) }} +

    {{ notification.description | trans | trans(notification.parameters) }}

    + +
    + {% if not notification.read %} + {% for action in notification.actions %} + {{ action.label | trans(notification.parameters) }} + {% endfor %} + check + {% endif %} +
    +
  • + {% endfor %} +
+ {% else %} + {{ 'notifications.list.none' | trans }} + {% endif %} + {% if notifications.getNbPages > 1 %} + {{ pagerfanta(notifications, 'twitter_bootstrap_translated', {'proximity': 1}) }} + {% endif %} +
+
+{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig index 97ddedc9..7a0f793c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig @@ -3,6 +3,7 @@ {% block title %}{{ 'tag.page_title'|trans }}{% endblock %} {% block content %} + {{ parent() }}
{{ 'tag.list.number_on_the_page'|transchoice(tags|length) }}
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 60907e11..ccc44931 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -110,6 +110,13 @@ search +
  • + {% set unreadNotifs = get_notifications() | unread_notif | length %} + + notifications{% if unreadNotifs == 0 %}_none{% endif %} + {% if unreadNotifs > 0 %}{{ unreadNotifs }}{% endif %} + +
  • filter_list @@ -135,6 +142,53 @@ {% endblock %} +{% block content %} + + +{% endblock %} + {% block footer %}