1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #6376 from lionel-rowe/ticket/16977

[ticket/16977] Fix cron-job img tag layout and accessibility
This commit is contained in:
Marc Alexander
2022-04-10 21:21:47 +02:00
12 changed files with 64 additions and 25 deletions

View File

@@ -363,8 +363,8 @@ class helper
if ($task)
{
$url = $task->get_url();
$this->template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
$cron_task_tag = $task->get_html_tag();
$this->template->assign_var('RUN_CRON_TASK', $cron_task_tag);
}
else
{

View File

@@ -59,6 +59,11 @@ class manager
*/
protected $php_ext;
/**
* @var \phpbb\template\template
*/
protected $template;
/**
* Constructor. Loads all available tasks.
*
@@ -66,13 +71,15 @@ class manager
* @param helper $routing_helper Routing helper
* @param string $phpbb_root_path Relative path to phpBB root
* @param string $php_ext PHP file extension
* @param \phpbb\template\template $template
*/
public function __construct(ContainerInterface $phpbb_container, helper $routing_helper, $phpbb_root_path, $php_ext)
public function __construct(ContainerInterface $phpbb_container, helper $routing_helper, $phpbb_root_path, $php_ext, $template)
{
$this->phpbb_container = $phpbb_container;
$this->routing_helper = $routing_helper;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->template = $template;
}
/**
@@ -193,6 +200,6 @@ class manager
*/
public function wrap_task(\phpbb\cron\task\task $task)
{
return new wrapper($task, $this->routing_helper);
return new wrapper($task, $this->routing_helper, $this->template);
}
}

View File

@@ -31,6 +31,11 @@ class wrapper
*/
protected $task;
/**
* @var \phpbb\template\template
*/
protected $template;
/**
* Constructor.
*
@@ -38,11 +43,13 @@ class wrapper
*
* @param task $task The cron task to wrap.
* @param helper $routing_helper Routing helper for route generation
* @param \phpbb\template\template $template
*/
public function __construct(task $task, helper $routing_helper)
public function __construct(task $task, helper $routing_helper, $template)
{
$this->task = $task;
$this->routing_helper = $routing_helper;
$this->template = $template;
}
/**
@@ -92,6 +99,23 @@ class wrapper
return $this->routing_helper->route('phpbb_cron_run', $params);
}
/**
* Returns HTML for an invisible `img` tag that can be displayed on page
* load to trigger a request to the relevant cron task endpoint.
*
* @return string HTML to render to trigger cron task
*/
public function get_html_tag()
{
$this->template->set_filenames([
'cron_html_tag' => 'cron.html',
]);
$this->template->assign_var('CRON_TASK_URL', $this->get_url());
return $this->template->assign_display('cron_html_tag');
}
/**
* Forwards all other method calls to the wrapped task implementation.
*