mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/11647] New assets handling
PHPBB-11647
This commit is contained in:
@@ -33,26 +33,21 @@ class phpbb_template_twig_node_includeasset extends Twig_Node
|
||||
->write("\$asset_file = ")
|
||||
->subcompile($this->getNode('expr'))
|
||||
->raw(";\n")
|
||||
->write("\$argument_string = \$anchor_string = '';\n")
|
||||
->write("if ((\$argument_string_start = strpos(\$asset_file, '?')) !== false) {\n")
|
||||
->write("\$asset = new phpbb_template_asset(\$asset_file);\n")
|
||||
->write("if (\$asset->is_relative()) {\n")
|
||||
->indent()
|
||||
->write("\$argument_string = substr(\$asset_file, \$argument_string_start);\n")
|
||||
->write("\$asset_file = substr(\$asset_file, 0, \$argument_string_start);\n")
|
||||
->write("if ((\$anchor_string_start = strpos(\$argument_string, '#')) !== false) {\n")
|
||||
->write("\$asset_path = \$asset->get_path();")
|
||||
->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")
|
||||
->write("if (!file_exists(\$local_file)) {\n")
|
||||
->indent()
|
||||
->write("\$anchor_string = substr(\$argument_string, \$anchor_string_start);\n")
|
||||
->write("\$argument_string = substr(\$argument_string, 0, \$anchor_string_start);\n")
|
||||
->write("\$local_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_path);\n")
|
||||
->write("\$asset->set_path(\$local_file, true);\n")
|
||||
->outdent()
|
||||
->write("\$asset->add_assets_version(\$this->getEnvironment()->get_phpbb_config()['assets_version']);\n")
|
||||
->write("\$asset_file = \$asset->get_url();\n")
|
||||
->write("}\n")
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
->write("if (strpos(\$asset_file, '//') !== 0 && strpos(\$asset_file, 'http://') !== 0 && strpos(\$asset_file, 'https://') !== 0 && !file_exists(\$asset_file)) {\n")
|
||||
->indent()
|
||||
->write("\$asset_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_file);\n")
|
||||
->write("\$argument_string .= ((\$argument_string) ? '&' : '?') . 'assets_version={$config['assets_version']}';\n")
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
->write("\$asset_file .= \$argument_string . \$anchor_string;\n")
|
||||
->write("\$context['definition']->append('{$this->get_definition_name()}', '")
|
||||
;
|
||||
|
||||
|
Reference in New Issue
Block a user