mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
Merge branch 'develop' of github.com:phpbb/phpbb3 into ticket/11816
# By Joseph Warner (187) and others # Via Nathan Guse (6) and others * 'develop' of github.com:phpbb/phpbb3: (195 commits) [ticket/11828] Fix greedy operators in lexer [ticket/11835] Fix ucp_auth_link adding in migration [prep-release-3.0.12] Remove changelog entry for ticket that was not resolved. [ticket/develop/11832] Fix path detection [feature/oauth] Fix tabindex [ticket/9550] Add the core.viewtopic_post_rowset_data event to viewtopic.php [ticket/11829] Use report_closed to determine status in MCP report_details [feature/oauth] Fix bug on ucp_auth_link related to error display [feature/oauth] More small fixes [feature/oauth] More minor changes from review [feature/oauth] Fix small bug introduced by update in OAuth library [feature/oauth] Fix small issues on ucp pages [feature/oauth] Fix typo in OAuth logout method [feature/oauth] Make token storage service ignorant [feature/oauth] Update oauth::logout() to use clearAllTokens() [feature/oauth] Update storage implementation due to inteface change [feature/oauth] Update lusitanian/oauth to stable branch [ticket/11822] Use namespace lookup order for asset loading [feature/oauth] Update comment on oauth service exception [feature/oauth] Forgot to remove placeholder comment ... Conflicts: phpBB/phpbb/template/twig/lexer.php tests/template/template_test.php
This commit is contained in:
@@ -137,4 +137,39 @@ class phpbb_template_twig_environment extends Twig_Environment
|
||||
return parent::loadTemplate($name, $index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a template by name.
|
||||
*
|
||||
* @param string $name The template name
|
||||
* @return string
|
||||
*/
|
||||
public function findTemplate($name)
|
||||
{
|
||||
if (strpos($name, '@') === false)
|
||||
{
|
||||
foreach ($this->getNamespaceLookUpOrder() as $namespace)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($namespace === '__main__')
|
||||
{
|
||||
return parent::getLoader()->getCacheKey($name);
|
||||
}
|
||||
|
||||
return parent::getLoader()->getCacheKey('@' . $namespace . '/' . $name);
|
||||
}
|
||||
catch (Twig_Error_Loader $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// We were unable to load any templates
|
||||
throw $e;
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::getLoader()->getCacheKey($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
|
||||
// Fix tokens that may have inline variables (e.g. <!-- DEFINE $TEST = '{FOO}')
|
||||
$code = $this->fix_inline_variable_tokens(array(
|
||||
'DEFINE.+=',
|
||||
'DEFINE \$[a-zA-Z0-9]+ =',
|
||||
'INCLUDE',
|
||||
'INCLUDEPHP',
|
||||
'INCLUDEJS',
|
||||
@@ -240,7 +240,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
return "<!-- {$matches[1]}IF{$inner}-->";
|
||||
};
|
||||
|
||||
return preg_replace_callback('#<!-- (ELSE)?IF((.*) \(?!?[\$|\.]([^\s]+)(.*))-->#', $callback, $code);
|
||||
return preg_replace_callback('#<!-- (ELSE)?IF((.*?) \(?!?[\$|\.]([^\s]+)(.*?))-->#', $callback, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,10 +264,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
*/
|
||||
|
||||
// Replace <!-- DEFINE $NAME with {% DEFINE definition.NAME
|
||||
$code = preg_replace('#<!-- DEFINE \$(.*)-->#', '{% DEFINE $1 %}', $code);
|
||||
$code = preg_replace('#<!-- DEFINE \$(.*?) -->#', '{% DEFINE $1 %}', $code);
|
||||
|
||||
// Changing UNDEFINE NAME to DEFINE NAME = null to save from creating an extra token parser/node
|
||||
$code = preg_replace('#<!-- UNDEFINE \$(.*)-->#', '{% DEFINE $1= null %}', $code);
|
||||
$code = preg_replace('#<!-- UNDEFINE \$(.*?)-->#', '{% DEFINE $1= null %}', $code);
|
||||
|
||||
// Replace all of our variables, {$VARNAME}, with Twig style, {{ definition.VARNAME }}
|
||||
$code = preg_replace('#{\$([a-zA-Z0-9_\.]+)}#', '{{ definition.$1 }}', $code);
|
||||
|
@@ -40,10 +40,10 @@ abstract class phpbb_template_twig_node_includeasset extends Twig_Node
|
||||
->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")
|
||||
->write("if (!file_exists(\$local_file)) {\n")
|
||||
->indent()
|
||||
->write("\$local_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_path);\n")
|
||||
->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n")
|
||||
->write("\$asset->set_path(\$local_file, true);\n")
|
||||
->outdent()
|
||||
->write("\$asset->add_assets_version({$config['assets_version']});\n")
|
||||
->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
|
||||
->write("\$asset_file = \$asset->get_url();\n")
|
||||
->write("}\n")
|
||||
->outdent()
|
||||
|
Reference in New Issue
Block a user