1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-14 19:45:21 +02:00

[feature/twig] INCLUDEJS behavior now supports local relative paths

This was done because T_TEMPLATE_PATH is not always correct for js files
(e.g. the inheriting style does not include these). Now we use the Twig
Loader to find the correct file to link to (most specific file first, then
parent styles). Also allows using @namespace convention

PHPBB3-11598
This commit is contained in:
Nathaniel Guse 2013-07-02 11:02:55 -05:00
parent 156d5c671f
commit 59d13d0535
9 changed files with 20 additions and 12 deletions

View File

@ -31,9 +31,17 @@ class phpbb_template_twig_node_includejs extends Twig_Node
$config = $this->environment->get_phpbb_config(); $config = $this->environment->get_phpbb_config();
$compiler $compiler
->write("\$context['definition']->append('SCRIPTS', '<script type=\"text/javascript\" src=\"' . ") ->write("\$js_file = ")
->subcompile($this->getNode('expr')) ->subcompile($this->getNode('expr'))
->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>');\n") ->raw(";\n")
->write("if (!file_exists(\$js_file)) {\n")
->indent()
->write("\$js_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$js_file);\n")
->outdent()
->write("}\n")
->write("\$context['definition']->append('SCRIPTS', '<script type=\"text/javascript\" src=\"' . ")
->raw("\$js_file")
->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>\n');\n")
; ;
} }
} }

View File

@ -38,7 +38,7 @@ function insert_single(user)
// ]]> // ]]>
</script> </script>
<!-- ENDIF --> <!-- ENDIF -->
<!-- INCLUDEJS {T_TEMPLATE_PATH}/forum_fn.js --> <!-- INCLUDEJS forum_fn.js -->
<h2 class="solo">{L_FIND_USERNAME}</h2> <h2 class="solo">{L_FIND_USERNAME}</h2>
<form method="post" action="{S_MODE_ACTION}" id="search_memberlist"> <form method="post" action="{S_MODE_ACTION}" id="search_memberlist">

View File

@ -53,9 +53,9 @@
<script type="text/javascript" src="{T_JQUERY_LINK}"></script> <script type="text/javascript" src="{T_JQUERY_LINK}"></script>
<!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js?assets_version={T_ASSETS_VERSION}" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF --> <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js?assets_version={T_ASSETS_VERSION}" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF -->
<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js?assets_version={T_ASSETS_VERSION}"></script> <!-- INCLUDEJS forum_fn.js -->
<script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script> <!-- INCLUDEJS {T_ASSETS_PATH}/javascript/core.js -->
<!-- INCLUDEJS {T_TEMPLATE_PATH}/ajax.js --> <!-- INCLUDEJS ajax.js -->
{$SCRIPTS} {$SCRIPTS}
<!-- EVENT overall_footer_after --> <!-- EVENT overall_footer_after -->

View File

@ -52,7 +52,7 @@
// ]]> // ]]>
</script> </script>
<!-- INCLUDEJS {T_TEMPLATE_PATH}/editor.js --> <!-- INCLUDEJS editor.js -->
<!-- IF S_BBCODE_ALLOWED --> <!-- IF S_BBCODE_ALLOWED -->
<div id="colour_palette" style="display: none;"> <div id="colour_palette" style="display: none;">

View File

@ -15,6 +15,6 @@
{S_TZ_OPTIONS} {S_TZ_OPTIONS}
</select> </select>
<!-- INCLUDEJS {T_TEMPLATE_PATH}/timezone.js --> <!-- INCLUDEJS timezone.js -->
</dd> </dd>
</dl> </dl>

View File

@ -47,4 +47,4 @@
</div> </div>
</div> </div>
<!-- INCLUDEJS {T_TEMPLATE_PATH}/avatars.js --> <!-- INCLUDEJS avatars.js -->

View File

@ -15,6 +15,6 @@
{S_TZ_OPTIONS} {S_TZ_OPTIONS}
</select> </select>
<!-- INCLUDEJS {T_TEMPLATE_PATH}/timezone.js --> <!-- INCLUDEJS timezone.js -->
</td> </td>
</tr> </tr>

View File

@ -95,7 +95,7 @@
</tr> </tr>
</table> </table>
<!-- INCLUDEJS {T_TEMPLATE_PATH}/avatars.js --> <!-- INCLUDEJS avatars.js -->
<!-- ELSEIF S_LIST --> <!-- ELSEIF S_LIST -->

View File

@ -48,6 +48,6 @@
</tr> </tr>
</table> </table>
<!-- INCLUDEJS {T_TEMPLATE_PATH}/avatars.js --> <!-- INCLUDEJS avatars.js -->
<!-- INCLUDE ucp_footer.html --> <!-- INCLUDE ucp_footer.html -->