1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-10 02:36:38 +02:00

Merge pull request #1519 from cyberalien/ticket/11647

Fix INCLUDEJS URLs handling
This commit is contained in:
Nathan Guse
2013-07-13 08:46:46 -07:00
4 changed files with 205 additions and 34 deletions

View File

@@ -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({$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()}', '")
;