mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-19 15:01:33 +02:00
Merge branch 'develop' of github.com:phpbb/phpbb3 into ticket/11628
# By Bruno Ais (42) and others # Via Joas Schilling (39) and others * 'develop' of github.com:phpbb/phpbb3: (157 commits) [ticket/11803] Revert POLL_MAX_OPTIONS min value to 0 [ticket/11799] Send anti abuse headers in "new password" emails. [ticket/11792] Add functional test for var lang_set_ext of core.user_setup [ticket/11804] Remove </li> from overall_header which was not open [ticket/11802] replace $browser with $user->browser [ticket/11801] removed some whitespace and added missing semi colon's in css [ticket/11792] Add performance remark to core.user_setup event PHPDoc [ticket/11792] Add variable 'lang_set_ext' to event core.user_setup [ticket/11789] Remove inline color in memberlist_view [ticket/11800] Fix scripts variable in subsilver simple_footer [ticket/11800] Fix JavaScript in simple_footer.html [ticket/11800] Remove forum_fn from memberlist_search.html [ticket/11796] Replace pagination with pagination.html [ticket/11794] Add missing array element commas to docs/coding-guidelines.html [ticket/11775] Fix doc blocks syntax [ticket/11775] Remove spaces at line ends [ticket/11789] Remove colors from HTML code [ticket/11784] Remove naming redundancy for event listeners [ticket/11775] Split test into multiple steps [ticket/11777] Fix new test for loop variables in extension template listeners ... Conflicts: phpBB/install/index.php phpBB/install/install_update.php
This commit is contained in:
@@ -191,20 +191,18 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
// Recursive...fix any child nodes
|
||||
$body = $parent_class->fix_begin_tokens($body, $parent_nodes);
|
||||
|
||||
// Rename loopname vars (to prevent collisions, loop children are named (loop name)_loop_element)
|
||||
$body = str_replace($name . '.', $name . '_loop_element.', $body);
|
||||
|
||||
// Need the parent variable name
|
||||
array_pop($parent_nodes);
|
||||
$parent = (!empty($parent_nodes)) ? end($parent_nodes) . '_loop_element.' : '';
|
||||
$parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : '';
|
||||
|
||||
if ($subset !== '')
|
||||
{
|
||||
$subset = '|subset(' . $subset . ')';
|
||||
}
|
||||
|
||||
// Turn into a Twig for loop, using (loop name)_loop_element for each child
|
||||
return "{% for {$name}_loop_element in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
||||
$parent = ($parent) ?: 'loops.';
|
||||
// Turn into a Twig for loop
|
||||
return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
||||
};
|
||||
|
||||
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
|
||||
@@ -227,8 +225,11 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
// Replace $TEST with definition.TEST
|
||||
$inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner);
|
||||
|
||||
// Replace .test with test|length
|
||||
$inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner);
|
||||
// Replace .foo with loops.foo|length
|
||||
$inner = preg_replace('#\s\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', ' loops.$1|length$2', $inner);
|
||||
|
||||
// Replace .foo.bar with foo.bar|length
|
||||
$inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', ' $1|length$2', $inner);
|
||||
|
||||
return "<!-- {$matches[1]}IF{$inner}-->";
|
||||
};
|
||||
|
@@ -18,6 +18,12 @@ if (!defined('IN_PHPBB'))
|
||||
|
||||
class phpbb_template_twig_node_event extends Twig_Node
|
||||
{
|
||||
/**
|
||||
* The subdirectory in which all template listener files must be placed
|
||||
* @var string
|
||||
*/
|
||||
protected $listener_directory = 'event/';
|
||||
|
||||
/** @var Twig_Environment */
|
||||
protected $environment;
|
||||
|
||||
@@ -37,7 +43,7 @@ class phpbb_template_twig_node_event extends Twig_Node
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$location = $this->getNode('expr')->getAttribute('name');
|
||||
$location = $this->listener_directory . $this->getNode('expr')->getAttribute('name');
|
||||
|
||||
foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path)
|
||||
{
|
||||
|
@@ -470,15 +470,15 @@ class phpbb_template_twig implements phpbb_template
|
||||
|
||||
$vars = array_merge(
|
||||
$context_vars['.'][0], // To get normal vars
|
||||
$context_vars, // To get loops
|
||||
array(
|
||||
'definition' => new phpbb_template_twig_definition(),
|
||||
'user' => $this->user,
|
||||
'loops' => $context_vars, // To get loops
|
||||
)
|
||||
);
|
||||
|
||||
// cleanup
|
||||
unset($vars['.']);
|
||||
unset($vars['loops']['.']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
Reference in New Issue
Block a user