com web/shared: added option to avoid including the common JS (seems to be necessary for wiki): templates/footer.inc
| From: | Christoph Michael Becker | Date: | Sun, 22 Mar 2015 14:49:35 +0000 |
| Subject: | com web/shared: added option to avoid including the common JS (seems to be necessary for wiki): templates/footer.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-20944@lists.php.net to get a copy of this message | ||
Commit: 65940f791d7f97257d3a38c8595f9330f3a4f7dc
Author: Christoph M. Becker <cmbecker69@gmx.de> Sun, 22 Mar 2015 15:49:35 +0100
Parents: 14b3486d1c1490369ed14348666b86b0df01f57c
Branches: master
Link: http://git.php.net/?p=web/shared.git;a=commitdiff;h=65940f791d7f97257d3a38c8595f9330f3a4f7dc
Log:
added option to avoid including the common JS (seems to be necessary for wiki)
Changed paths:
M templates/footer.inc
Diff:
diff --git a/templates/footer.inc b/templates/footer.inc
index ab902ca..81e9cab 100644
--- a/templates/footer.inc
+++ b/templates/footer.inc
@@ -6,6 +6,9 @@
*
* // Relative to /share, or prefixed with // for external js
* $JS = array("//example.com/external.js", "/js/local.js");
+ *
+ * or, to avoid including the common JS altogether:
+ * $JS = false;
*/
isset($JS) || $JS = array();
@@ -29,20 +32,22 @@ $ROOT = substr($_SERVER["SERVER_NAME"], -8) == ".php.net" ?
"//shared.php.net" :
</footer>
<?php
-$current_time = time();
-$scripts = array_merge(array(
- '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
- '/js/external/mousetrap.min.js',
- '/js/common.js'
-), $JS);
-foreach ($scripts as $script):
- if (strncmp($script, "//", 2) == 0) {
- echo "<script src='$script'></script>\n";
- } else {
- $filemtime = filemtime(__DIR__ . "/..{$script}") ?: $current_time;
- echo "<script
src='{$ROOT}{$script}?filemtime=$filemtime'></script>\n";
- }
-endforeach ?>
+if ($JS !== false) {
+ $current_time = time();
+ $scripts = array_merge(array(
+ '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
+ '/js/external/mousetrap.min.js',
+ '/js/common.js'
+ ), $JS);
+ foreach ($scripts as $script):
+ if (strncmp($script, "//", 2) == 0) {
+ echo "<script src='$script'></script>\n";
+ } else {
+ $filemtime = filemtime(__DIR__ . "/..{$script}") ?: $current_time;
+ echo "<script
src='{$ROOT}{$script}?filemtime=$filemtime'></script>\n";
+ }
+ endforeach;
+} ?>
</div><!-- .wrap -->
</body>
</html>