mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-26 20:08:55 +00:00
Compare commits
45 commits
a55478cd28
...
8fbffe37c5
Author | SHA1 | Date | |
---|---|---|---|
|
8fbffe37c5 | ||
|
5e9d616f57 | ||
|
de1f6329ff | ||
|
954bc07de1 | ||
|
75c5fe9459 | ||
|
a229797cd7 | ||
|
044536dffb | ||
|
6ccc6f0383 | ||
|
4f10e6e212 | ||
|
3b03f3a8f9 | ||
|
e47ba9e81d | ||
|
8d016bafa2 | ||
|
6d6f4fdeba | ||
|
35221f8ba5 | ||
|
03031e846d | ||
|
9219c03b36 | ||
|
72c3745868 | ||
|
579b4a8287 | ||
|
b8c49f9711 | ||
|
2f43c1facd | ||
|
9c49a2b86b | ||
|
d017eff8f1 | ||
|
d4a3311b76 | ||
|
bc470285fc | ||
|
1d7543c778 | ||
|
8411da1819 | ||
|
b6c42b3768 | ||
|
da2733a7d8 | ||
|
b8204d24f9 | ||
|
ccbdfb49c7 | ||
|
43cf7b73bd | ||
|
3a5247d01b | ||
|
5e0dc9ef2e | ||
|
8338ff9e56 | ||
|
84e7e34a66 | ||
|
18bae795f0 | ||
|
09fd86ffb0 | ||
|
4a00212f2d | ||
|
cb47d78d26 | ||
|
0eb98d51e2 | ||
|
82a5e20f3e | ||
|
71fe9d60c4 | ||
|
59b482a222 | ||
|
d934c8c4b7 | ||
|
d07aeb00d8 |
31 changed files with 470 additions and 48 deletions
|
@ -20,7 +20,7 @@
|
|||
<form method="post" action="#" id="language_selector">
|
||||
<fieldset class="nobg">
|
||||
<label for="language">{L_SELECT_LANG}{L_COLON}</label>
|
||||
<select id="language" name="language">
|
||||
<select id="language" name="language">
|
||||
<!-- BEGIN language_select_item -->
|
||||
<option value="{language_select_item.VALUE}"<!-- IF language_select_item.SELECTED --> selected="selected"<!-- ENDIF -->>{language_select_item.NAME}</option>
|
||||
<!-- END language_select_item -->
|
||||
|
|
|
@ -1681,6 +1681,18 @@ switch ($mode)
|
|||
$memberrow = array_merge($memberrow, $cp_row['row']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the memberrow data before template variables are assigned.
|
||||
*
|
||||
* @event core.memberlist_modify_memberrow
|
||||
* @var int user_id The current user ID.
|
||||
* @var array row Array of raw user data.
|
||||
* @var array memberrow Array of member template variables.
|
||||
* @since 3.3.16-RC1
|
||||
*/
|
||||
$vars = ['user_id', 'row', 'memberrow'];
|
||||
extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow', compact($vars)));
|
||||
|
||||
$template->assign_block_vars('memberrow', $memberrow);
|
||||
|
||||
if (isset($cp_row['blockrow']) && count($cp_row['blockrow']))
|
||||
|
|
|
@ -127,14 +127,15 @@ class table_helper
|
|||
* Maps short table names for the purpose of prefixing tables' index names.
|
||||
*
|
||||
* @param array $additional_tables Additional table names without prefix to add to the map.
|
||||
* @param array $table_prefix Tables prefix.
|
||||
* @param string $table_prefix Tables prefix.
|
||||
*
|
||||
* @return array<string, string> Pairs of table names and their short name representations.
|
||||
* @psalm-return array{string, string}
|
||||
*/
|
||||
public static function map_short_table_names(array $additional_tables = [], string $table_prefix = ''): array
|
||||
{
|
||||
$short_table_names_map = [
|
||||
"{$table_prefix}acl_groups" => 'aclgrps',
|
||||
"{$table_prefix}acl_groups" => 'aclgrps',
|
||||
"{$table_prefix}acl_options" => 'aclopts',
|
||||
"{$table_prefix}acl_roles" => 'aclrls',
|
||||
"{$table_prefix}acl_roles_data" => 'aclrlsdt',
|
||||
|
@ -197,12 +198,13 @@ class table_helper
|
|||
"{$table_prefix}sessions_keys" => 'ssnkeys',
|
||||
"{$table_prefix}sitelist" => 'sitelst',
|
||||
"{$table_prefix}smilies" => 'smls',
|
||||
"{$table_prefix}sphinx" => 'sphnx',
|
||||
"{$table_prefix}storage" => 'strg',
|
||||
"{$table_prefix}styles" => 'stls',
|
||||
"{$table_prefix}teampage" => 'teampg',
|
||||
"{$table_prefix}topics" => 'tpcs',
|
||||
"{$table_prefix}topics_posted" => 'tpcspstd',
|
||||
"{$table_prefix}topics_track" => 'tpcstrk',
|
||||
"{$table_prefix}topics_track" => 'tpcstrck',
|
||||
"{$table_prefix}topics_watch" => 'tpkswtch',
|
||||
"{$table_prefix}user_group" => 'usrgrp',
|
||||
"{$table_prefix}user_notifications" => 'usrntfs',
|
||||
|
@ -213,7 +215,7 @@ class table_helper
|
|||
];
|
||||
|
||||
// Add table prefix to additional tables
|
||||
if (!empty($table_prefix && !empty($additional_tables)))
|
||||
if (!empty($table_prefix) && !empty($additional_tables))
|
||||
{
|
||||
foreach ($additional_tables as $key => $value)
|
||||
{
|
||||
|
|
|
@ -28,12 +28,11 @@ class rename_duplicated_index_names extends migration
|
|||
public function update_schema()
|
||||
{
|
||||
$rename_index = $table_keys = [];
|
||||
$db_table_schema = json_decode(file_get_contents($this->phpbb_root_path . 'store/schema.json'), true);
|
||||
$db_table_schema = $this->get_schema();
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
if (isset($table_data['KEYS']))
|
||||
{
|
||||
$table_name = $this->table_prefix . $table_name;
|
||||
foreach ($table_data['KEYS'] as $key_name => $key_data)
|
||||
{
|
||||
$table_keys[$table_name][] = $key_name;
|
||||
|
@ -66,4 +65,27 @@ class rename_duplicated_index_names extends migration
|
|||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
protected function get_schema()
|
||||
{
|
||||
$self_classname = '\\' . str_replace('/', '\\', self::class);
|
||||
$finder_factory = new \phpbb\finder\factory(null, false, $this->phpbb_root_path, $this->php_ext);
|
||||
$finder = $finder_factory->get();
|
||||
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
|
||||
$self_class_index = array_search($self_classname, $migrator_classes);
|
||||
unset($migrator_classes[$self_class_index]);
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator(
|
||||
$migrator_classes,
|
||||
$this->config,
|
||||
$this->db,
|
||||
$this->db_tools,
|
||||
$this->phpbb_root_path,
|
||||
$this->php_ext,
|
||||
$this->table_prefix,
|
||||
$this->tables
|
||||
);
|
||||
|
||||
return $schema_generator->get_schema();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -339,6 +339,14 @@ class helper
|
|||
protected function render_language_select($selected_language = null)
|
||||
{
|
||||
$langs = $this->lang_helper->get_available_languages();
|
||||
|
||||
// The first language will be selected by default. Unless a user has consciously included
|
||||
// other languages in the installation process, it will be British English anyway.
|
||||
if ($selected_language === null && count($langs))
|
||||
{
|
||||
$selected_language = $langs[0]['iso'];
|
||||
}
|
||||
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
$this->template->assign_block_vars('language_select_item', array(
|
||||
|
|
|
@ -145,31 +145,29 @@ class check_filesystem extends \phpbb\install\task_base
|
|||
// Try to create file if it does not exists
|
||||
if (!file_exists($path))
|
||||
{
|
||||
$fp = @fopen($path, 'w');
|
||||
@fclose($fp);
|
||||
try
|
||||
if (!is_resource($fp = @fopen($path, 'w')))
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($path,
|
||||
\phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE
|
||||
);
|
||||
$exists = true;
|
||||
$exists = $writable = false;
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
else
|
||||
{
|
||||
// Do nothing
|
||||
@fclose($fp);
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($path,
|
||||
\phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE
|
||||
);
|
||||
$exists = true;
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
$writable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($path))
|
||||
else if (!$this->filesystem->is_writable($path))
|
||||
{
|
||||
if (!$this->filesystem->is_writable($path))
|
||||
{
|
||||
$writable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = $writable = false;
|
||||
$writable = false;
|
||||
}
|
||||
|
||||
$this->set_test_passed(($exists && $writable) || $failable);
|
||||
|
|
|
@ -65,6 +65,8 @@ class language_file_helper
|
|||
$available_languages[] = $this->get_language_data_from_json($data);
|
||||
}
|
||||
|
||||
usort($available_languages, [$this, 'sort_by_local_name']);
|
||||
|
||||
return $available_languages;
|
||||
}
|
||||
|
||||
|
@ -123,4 +125,16 @@ class language_file_helper
|
|||
'turnstile_lang' => $data['extra']['turnstile-lang'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the languages by their name instead of iso code
|
||||
*
|
||||
* @param mixed $a First language data
|
||||
* @param mixed $b Second language data
|
||||
* @return int
|
||||
*/
|
||||
private static function sort_by_local_name(mixed $a, mixed $b): int
|
||||
{
|
||||
return $a['local_name'] <=> $b['local_name'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,6 +161,16 @@ class environment extends \Twig\Environment
|
|||
return $this->assets_bag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the event dispatcher instance
|
||||
*
|
||||
* @return dispatcher_interface
|
||||
*/
|
||||
public function get_phpbb_dispatcher()
|
||||
{
|
||||
return $this->phpbb_dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the namespace look up order
|
||||
*
|
||||
|
|
|
@ -24,9 +24,13 @@ class event extends \Twig\Node\Node
|
|||
/** @var \phpbb\template\twig\environment */
|
||||
protected $environment;
|
||||
|
||||
public function __construct(\Twig\Node\Expression\AbstractExpression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null)
|
||||
/** @var array */
|
||||
protected $template_event_priority_array;
|
||||
|
||||
public function __construct(\Twig\Node\Expression\AbstractExpression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null, $template_event_priority_array = [])
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$this->template_event_priority_array = $template_event_priority_array;
|
||||
|
||||
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
||||
}
|
||||
|
@ -42,10 +46,20 @@ class event extends \Twig\Node\Node
|
|||
|
||||
$location = $this->listener_directory . $this->getNode('expr')->getAttribute('name');
|
||||
|
||||
$template_event_listeners = [];
|
||||
|
||||
// Group and sort extension template events in according to their priority (0 by default if not set)
|
||||
foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path)
|
||||
{
|
||||
$ext_namespace = str_replace('/', '_', $ext_namespace);
|
||||
$priority_key = intval($this->template_event_priority_array[$ext_namespace][$location] ?? 0);
|
||||
$template_event_listeners[$priority_key][] = $ext_namespace;
|
||||
}
|
||||
krsort($template_event_listeners);
|
||||
|
||||
$template_event_listeners = array_merge(...$template_event_listeners);
|
||||
foreach ($template_event_listeners as $ext_namespace)
|
||||
{
|
||||
if ($this->environment->isDebug())
|
||||
{
|
||||
// If debug mode is enabled, lets check for new/removed EVENT
|
||||
|
@ -54,8 +68,7 @@ class event extends \Twig\Node\Node
|
|||
// purge the cache when a new event template file is added)
|
||||
$compiler
|
||||
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
|
||||
->indent()
|
||||
;
|
||||
->indent();
|
||||
}
|
||||
|
||||
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
|
||||
|
@ -66,16 +79,14 @@ class event extends \Twig\Node\Node
|
|||
// We set the namespace lookup order to be this extension first, then the main path
|
||||
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
|
||||
->write("\$this->env->loadTemplate(\$this->env->getTemplateClass('@{$ext_namespace}/{$location}.html'), '@{$ext_namespace}/{$location}.html')->display(\$context);\n")
|
||||
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
|
||||
;
|
||||
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n");
|
||||
}
|
||||
|
||||
if ($this->environment->isDebug())
|
||||
{
|
||||
$compiler
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
;
|
||||
->write("}\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ class event extends \Twig\TokenParser\AbstractTokenParser
|
|||
/** @var \phpbb\template\twig\environment */
|
||||
protected $environment;
|
||||
|
||||
/** @var array */
|
||||
protected $template_event_priority_array;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -26,6 +29,25 @@ class event extends \Twig\TokenParser\AbstractTokenParser
|
|||
public function __construct(\phpbb\template\twig\environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$phpbb_dispatcher = $this->environment->get_phpbb_dispatcher();
|
||||
|
||||
$template_event_priority_array = [];
|
||||
/**
|
||||
* Allows assigning priority to template event listeners
|
||||
*
|
||||
* @event core.twig_event_tokenparser_constructor
|
||||
* @var array template_event_priority_array Array with template event priority assignments per extension namespace
|
||||
*
|
||||
* @since 4.0.0-a1
|
||||
*/
|
||||
if ($phpbb_dispatcher)
|
||||
{
|
||||
$vars = ['template_event_priority_array'];
|
||||
extract($phpbb_dispatcher->trigger_event('core.twig_event_tokenparser_constructor', compact($vars)));
|
||||
}
|
||||
|
||||
$this->template_event_priority_array = $template_event_priority_array;
|
||||
unset($template_event_priority_array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +64,7 @@ class event extends \Twig\TokenParser\AbstractTokenParser
|
|||
$stream = $this->parser->getStream();
|
||||
$stream->expect(\Twig\Token::BLOCK_END_TYPE);
|
||||
|
||||
return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag());
|
||||
return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag(), $this->template_event_priority_array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -88,7 +88,10 @@ class twig extends \phpbb\template\base
|
|||
|
||||
foreach ($extensions as $extension)
|
||||
{
|
||||
$this->twig->addExtension($extension);
|
||||
if (!$this->twig->hasExtension(get_class($extension)))
|
||||
{
|
||||
$this->twig->addExtension($extension);
|
||||
}
|
||||
}
|
||||
|
||||
// Add admin namespace
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
to hide visually and `aria-hidden="true"` to hide from screen-readers; using
|
||||
`hidden` or `display: none` would prevent the task from running.
|
||||
#}
|
||||
<img class="sr-only" aria-hidden="true" src="{{ CRON_TASK_URL|e('url') }}" width="1" height="1" alt="">
|
||||
<img class="sr-only" aria-hidden="true" src="{{ CRON_TASK_URL|e('html_attr') }}" width="1" height="1" alt="">
|
||||
|
|
|
@ -60,7 +60,7 @@ class phpbb_cron_wrapper_test extends phpbb_template_template_test_case
|
|||
$this->template
|
||||
);
|
||||
|
||||
$this->assertEquals('<img class="sr-only" aria-hidden="true" src="app.php%2Fcron%2Ffoo%3Ff%3D5" width="1" height="1" alt="">', str_replace(["\n", "\t"], '', $this->wrapper->get_html_tag()));
|
||||
$this->assertEquals('<img class="sr-only" aria-hidden="true" src="app.php/cron/foo?f=5" width="1" height="1" alt="">', str_replace(["\n", "\t"], '', $this->wrapper->get_html_tag()));
|
||||
}
|
||||
|
||||
public function test_is_parametrized_false()
|
||||
|
|
|
@ -440,4 +440,62 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
|||
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar1'));
|
||||
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar2'));
|
||||
}
|
||||
|
||||
public function test_schema_generator(): array
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$finder_factory = new \phpbb\finder\factory(null, false, $phpbb_root_path, $phpEx);
|
||||
$finder = $finder_factory->get();
|
||||
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator(
|
||||
$migrator_classes,
|
||||
$this->config,
|
||||
$this->db,
|
||||
$this->db_tools,
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
'phpbb_',
|
||||
self::get_core_tables()
|
||||
);
|
||||
$db_table_schema = $schema_generator->get_schema();
|
||||
|
||||
$this->assertNotEmpty($db_table_schema);
|
||||
|
||||
return $db_table_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_schema_generator
|
||||
*/
|
||||
public function test_table_indexes(array $db_table_schema)
|
||||
{
|
||||
$table_keys = [];
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
if (isset($table_data['KEYS']))
|
||||
{
|
||||
foreach ($table_data['KEYS'] as $key_name => $key_data)
|
||||
{
|
||||
$table_keys[$table_name][] = $key_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNotEmpty($table_keys);
|
||||
|
||||
$short_table_names = \phpbb\db\doctrine\table_helper::map_short_table_names(['custom_table' => 'cstmtbl'], 'phpbb_');
|
||||
$this->assertEquals('phpbb_custom_table', array_search('cstmtbl', $short_table_names));
|
||||
$this->assertEquals($short_table_names['phpbb_custom_table'], 'cstmtbl');
|
||||
|
||||
foreach ($table_keys as $table_name => $key_names)
|
||||
{
|
||||
$index_prefix = $short_table_names[$table_name] . '_';
|
||||
foreach ($key_names as $key_name)
|
||||
{
|
||||
$this->assertEquals(0, strpos($key_name, $index_prefix), "$key_name does not contain $index_prefix");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_controller_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -17,8 +17,6 @@ require_once __DIR__ . '/../../phpBB/includes/acp/acp_modules.php';
|
|||
*/
|
||||
class phpbb_functional_extension_module_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_permission_lang_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
105
tests/functional/extension_template_event_order_test.php
Normal file
105
tests/functional/extension_template_event_order_test.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_extension_template_event_order_test extends phpbb_functional_test_case
|
||||
{
|
||||
static private $helper;
|
||||
|
||||
static protected $fixtures = [
|
||||
'./',
|
||||
];
|
||||
|
||||
static public function setUpBeforeClass(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$helper = new phpbb_test_case_helpers(__CLASS__);
|
||||
self::$helper->copy_ext_fixtures(__DIR__ . '/fixtures/ext/', self::$fixtures);
|
||||
}
|
||||
|
||||
static public function tearDownAfterClass(): void
|
||||
{
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
self::$helper->restore_original_ext_dir();
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->uninstall_ext('foo/bar');
|
||||
$this->uninstall_ext('foo/foo');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected static function setup_extensions()
|
||||
{
|
||||
return ['foo/bar', 'foo/foo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check extensions template event listener prioritizing
|
||||
*/
|
||||
public function test_different_template_event_priority()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
$quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0);
|
||||
$quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count();
|
||||
// Ensure foo/foo template event goes before foo/bar one
|
||||
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text());
|
||||
|
||||
// Change template events order to default, put foo/bar event before foo/foo one
|
||||
$this->disable_ext('foo/bar');
|
||||
$this->disable_ext('foo/foo');
|
||||
|
||||
$this->assertTrue(copy(__DIR__ . '/fixtures/ext/foo/bar/event/template_event_order_higher.php', $phpbb_root_path . 'ext/foo/bar/event/template_event_order.php'));
|
||||
$this->assertTrue(copy(__DIR__ . '/fixtures/ext/foo/foo/event/template_event_order_lower.php', $phpbb_root_path . 'ext/foo/foo/event/template_event_order.php'));
|
||||
|
||||
$this->install_ext('foo/bar');
|
||||
$this->install_ext('foo/foo');
|
||||
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
$quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0);
|
||||
$quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count();
|
||||
// Ensure foo/foo template event goes before foo/bar one
|
||||
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check extensions template event listener equal (default - 0) priority rendering
|
||||
* Should render in the order of reading listener files from the filesystem
|
||||
*/
|
||||
public function test_same_template_event_priority()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
// Ensure foo/bar template event goes before foo/foo one (assuming they have been read from the filesystem in alphabetical order)
|
||||
$this->assertStringContainsString('FOO_BAR_FORUMLIST_BODY_BEFORE', $crawler->filter('p[id*="forumlist_body_before"]')->eq(0)->text());
|
||||
$this->assertStringContainsString('FOO_FOO_FORUMLIST_BODY_BEFORE', $crawler->filter('p[id*="forumlist_body_before"]')->eq(1)->text());
|
||||
}
|
||||
}
|
|
@ -14,7 +14,13 @@ services:
|
|||
class: foo\bar\event\permission
|
||||
tags:
|
||||
- { name: event.listener }
|
||||
|
||||
foo_bar.listener.user_setup:
|
||||
class: foo\bar\event\user_setup
|
||||
tags:
|
||||
- { name: event.listener }
|
||||
|
||||
foo_bar.listener.template_event_order:
|
||||
class: foo\bar\event\template_event_order
|
||||
tags:
|
||||
- { name: event.listener }
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\bar\event;
|
||||
|
||||
/**
|
||||
* Event listener
|
||||
*/
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class template_event_order implements EventSubscriberInterface
|
||||
{
|
||||
static public function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
|
||||
);
|
||||
}
|
||||
|
||||
public function set_template_event_priority($event)
|
||||
{
|
||||
$template_event_priority_array = $event['template_event_priority_array'];
|
||||
$template_event_priority_array['foo_bar'] = [
|
||||
'event/navbar_header_quick_links_after' => -1,
|
||||
];
|
||||
$event['template_event_priority_array'] = $template_event_priority_array;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\bar\event;
|
||||
|
||||
/**
|
||||
* Event listener
|
||||
*/
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class template_event_order implements EventSubscriberInterface
|
||||
{
|
||||
static public function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
|
||||
);
|
||||
}
|
||||
|
||||
public function set_template_event_priority($event)
|
||||
{
|
||||
$template_event_priority_array = $event['template_event_priority_array'];
|
||||
$template_event_priority_array['foo_bar'] = [
|
||||
'event/navbar_header_quick_links_after' => 1,
|
||||
];
|
||||
$event['template_event_priority_array'] = $template_event_priority_array;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<p id="foo_bar_forumlist_body_before">{{ lang('FOO_BAR_FORUMLIST_BODY_BEFORE') }}</p>
|
|
@ -0,0 +1 @@
|
|||
<li><span>{{ lang('FOO_BAR_QUICK_LINK') }}</span></li>
|
|
@ -1,3 +1,8 @@
|
|||
services:
|
||||
foo_foo.controller:
|
||||
class: foo\foo\controller\controller
|
||||
|
||||
foo_foo.listener.template_event_order:
|
||||
class: foo\foo\event\template_event_order
|
||||
tags:
|
||||
- { name: event.listener }
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\foo\event;
|
||||
|
||||
/**
|
||||
* Event listener
|
||||
*/
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class template_event_order implements EventSubscriberInterface
|
||||
{
|
||||
static public function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
|
||||
);
|
||||
}
|
||||
|
||||
public function set_template_event_priority($event)
|
||||
{
|
||||
$template_event_priority_array = $event['template_event_priority_array'];
|
||||
$template_event_priority_array['foo_foo'] = [
|
||||
'event/navbar_header_quick_links_after' => 1,
|
||||
];
|
||||
$event['template_event_priority_array'] = $template_event_priority_array;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace foo\foo\event;
|
||||
|
||||
/**
|
||||
* Event listener
|
||||
*/
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class template_event_order implements EventSubscriberInterface
|
||||
{
|
||||
static public function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
|
||||
);
|
||||
}
|
||||
|
||||
public function set_template_event_priority($event)
|
||||
{
|
||||
$template_event_priority_array = $event['template_event_priority_array'];
|
||||
$template_event_priority_array['foo_foo'] = [
|
||||
'event/navbar_header_quick_links_after' => -1,
|
||||
];
|
||||
$event['template_event_priority_array'] = $template_event_priority_array;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<p id="foo_foo_forumlist_body_before">{{ lang('FOO_FOO_FORUMLIST_BODY_BEFORE') }}</p>
|
|
@ -0,0 +1 @@
|
|||
<li><span>{{ lang('FOO_FOO_QUICK_LINK') }}</span></li>
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -644,7 +644,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
|
||||
$meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
|
||||
|
||||
// Wait for extension to be fully enabled
|
||||
// Wait for extension to be fully disabled
|
||||
while (count($meta_refresh))
|
||||
{
|
||||
preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
|
||||
|
|
Loading…
Add table
Reference in a new issue