Merge pull request #5981 from ansavin/ticket/16366

[ticket/16366] Make viewtopic lang vars available in feed pages
This commit is contained in:
Marc Alexander 2020-08-23 16:49:36 +02:00
commit c1ce0153ea
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 22 additions and 3 deletions

View file

@ -12,11 +12,13 @@ services:
- '@user' - '@user'
- '@auth' - '@auth'
- '@dispatcher' - '@dispatcher'
- '@language'
- '%core.php_ext%' - '%core.php_ext%'
feed.helper: feed.helper:
class: phpbb\feed\helper class: phpbb\feed\helper
arguments: arguments:
- '@auth'
- '@config' - '@config'
- '@service_container' - '@service_container'
- '@path_helper' - '@path_helper'

View file

@ -25,6 +25,7 @@ use phpbb\feed\helper as feed_helper;
use phpbb\controller\helper as controller_helper; use phpbb\controller\helper as controller_helper;
use phpbb\symfony_request; use phpbb\symfony_request;
use phpbb\user; use phpbb\user;
use phpbb\language\language;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@ -87,6 +88,11 @@ class feed
*/ */
protected $php_ext; protected $php_ext;
/**
* @var language
*/
protected $language;
/** /**
* Constructor * Constructor
* *
@ -100,9 +106,10 @@ class feed
* @param user $user * @param user $user
* @param auth $auth * @param auth $auth
* @param dispatcher_interface $phpbb_dispatcher * @param dispatcher_interface $phpbb_dispatcher
* @param language $language
* @param string $php_ext * @param string $php_ext
*/ */
public function __construct(Environment $twig, symfony_request $request, controller_helper $controller_helper, config $config, driver_interface $db, ContainerInterface $container, feed_helper $feed_helper, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, $php_ext) public function __construct(Environment $twig, symfony_request $request, controller_helper $controller_helper, config $config, driver_interface $db, ContainerInterface $container, feed_helper $feed_helper, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, language $language, $php_ext)
{ {
$this->request = $request; $this->request = $request;
$this->controller_helper = $controller_helper; $this->controller_helper = $controller_helper;
@ -114,6 +121,7 @@ class feed
$this->auth = $auth; $this->auth = $auth;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->template = $twig; $this->template = $twig;
$this->language = $language;
$this->phpbb_dispatcher = $phpbb_dispatcher; $this->phpbb_dispatcher = $phpbb_dispatcher;
} }
@ -296,6 +304,7 @@ class feed
{ {
$feed_updated_time = 0; $feed_updated_time = 0;
$item_vars = array(); $item_vars = array();
$this->language->add_lang('viewtopic');
$board_url = $this->feed_helper->get_board_url(); $board_url = $this->feed_helper->get_board_url();

View file

@ -17,6 +17,7 @@ use phpbb\config\config;
use phpbb\path_helper; use phpbb\path_helper;
use phpbb\textformatter\s9e\renderer; use phpbb\textformatter\s9e\renderer;
use phpbb\user; use phpbb\user;
use phpbb\auth\auth;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
@ -39,17 +40,22 @@ class helper
/** @var user */ /** @var user */
protected $user; protected $user;
/** @var auth */
protected $auth;
/** /**
* Constructor * Constructor
* *
* @param auth $auth Auth object
* @param config $config Config object * @param config $config Config object
* @param ContainerInterface $container Service container object * @param ContainerInterface $container Service container object
* @param path_helper $path_helper Path helper object * @param path_helper $path_helper Path helper object
* @param renderer $renderer TextFormatter renderer object * @param renderer $renderer TextFormatter renderer object
* @param user $user User object * @param user $user User object
*/ */
public function __construct(config $config, ContainerInterface $container, path_helper $path_helper, renderer $renderer, user $user) public function __construct(auth $auth, config $config, ContainerInterface $container, path_helper $path_helper, renderer $renderer, user $user)
{ {
$this->auth = $auth;
$this->config = $config; $this->config = $config;
$this->container = $container; $this->container = $container;
$this->path_helper = $path_helper; $this->path_helper = $path_helper;
@ -120,6 +126,8 @@ class helper
$this->renderer->set_smilies_path($this->get_board_url() . '/' . $this->config['smilies_path']); $this->renderer->set_smilies_path($this->get_board_url() . '/' . $this->config['smilies_path']);
$this->renderer->configure_user($this->user, $this->config, $this->auth);
$content = generate_text_for_display($content, $uid, $bitfield, $options); $content = generate_text_for_display($content, $uid, $bitfield, $options);
// Remove "Select all" link and mouse events // Remove "Select all" link and mouse events

View file

@ -49,10 +49,10 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$this->get_test_case_helpers()->set_s9e_services($container); $this->get_test_case_helpers()->set_s9e_services($container);
$container->set('feed.quote_helper', new \phpbb\feed\quote_helper($user, $phpbb_root_path, 'php')); $container->set('feed.quote_helper', new \phpbb\feed\quote_helper($user, $phpbb_root_path, 'php'));
$feed_helper = new \phpbb\feed\helper($config, $container, $path_helper, $container->get('text_formatter.renderer'), $user);
$db = $this->new_dbal(); $db = $this->new_dbal();
$cache = new \phpbb_mock_cache(); $cache = new \phpbb_mock_cache();
$auth = new \phpbb\auth\auth(); $auth = new \phpbb\auth\auth();
$feed_helper = new \phpbb\feed\helper($auth, $config, $container, $path_helper, $container->get('text_formatter.renderer'), $user);
$content_visibility = new \phpbb\content_visibility( $content_visibility = new \phpbb\content_visibility(
$auth, $auth,
$config, $config,