Also normalizes the javascript inclusion, moving the common ones to PlPage implementations (prepares the upcoming javascript minimization).
Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
. " actuellement désactivée, en particulier aucune donnée ne sera sauvegardée");
}
$this->register_prefilter('at_to_globals');
- $this->addJsLink('jquery.js');
}
// }}}
if (S::i('auth') <= AUTH_PUBLIC) {
$this->register_outputfilter('hide_emails');
}
- $this->addJsLink('wiki.js');
header("Accept-Charset: utf-8");
if (Env::v('forceXml')) {
pl_content_headers("text/xml");
// }}}
// {{{ function addJsLink
- public function addJsLink($path)
+ public function addJsLink($filename)
{
- $this->append('pl_js', $path);
+ $this->append('pl_js', pl_static_content_path("javascript/", $filename));
}
// }}}
}
/**
+ * Returns the path of a static content, including, when appropriate, the
+ * version number. This is used to avoid cross-version cache issues, by ensuiring
+ * that all static resources are served on a unique path.
+ */
+function pl_static_content_path($path, $filename)
+{
+ global $globals;
+ if (isset($globals) && isset($globals->version)) {
+ return $path . $globals->version . '/' . $filename;
+ } else {
+ return $path . $filename;
+ }
+}
+
+/**
* Adds content type headers; by default the encoding used is utf-8.
*/
function pl_content_headers($content_type, $encoding = 'utf-8')
header("Cache-Control: max-age=$cache_duration");
header("Expires: " . gmdate('D, d M Y H:i:s', time() + $cache_duration) . " GMT");
+ header("Pragma: ");
pl_content_headers($content_type, $encoding);
}
$text = "'Changer'";
}
- return '?><script type="text/javascript" src="javascript/jquery.color.js" ></script>
+ return '?><script type="text/javascript" src="' . pl_static_content_path("javascript/", "jquery.color.js") . '" ></script>
<script type="text/javascript">//<![CDATA[
var passwordprompt_name = '. $prompt . ';
var passwordprompt_submit = ' . $submit . ';
function smarty_compiler_javascript($tag_attrs, &$compiler)
{
extract($compiler->_parse_attrs($tag_attrs));
-
if (!isset($name)) {
return null;
}
- $name = pl_entities(trim($name, '\'"'), ENT_QUOTES);
- $name = "javascript/$name.js";
- if (isset($full) && $full) {
- global $globals;
- $name = $globals->baseurl . '/' . $name;
- }
- return "?><script type='text/javascript' src='$name'></script><?php";
+ $name = pl_entities(trim($name, '\'"'), ENT_QUOTES);
+ $name = pl_static_content_path("javascript/", "$name.js");
+ return '?><script type="text/javascript" src="' . $name . "\"></script>\n<?php";
}
-/* vim: set expandtab enc=utf-8: */
-
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
</script>
{if t($pl_js)}
{foreach from=$pl_js item=js}
-<script type="text/javascript" src="javascript/{$js}"></script>
+<script type="text/javascript" src="{$js}"></script>
{/foreach}
{/if}
{if t($pl_rss)}
{if t($pl_extra_header)}
{$pl_extra_header|smarty:nodefaults}
{/if}
-{if t($pl_title)}<title>{$pl_title}</title>{/if}
+{if t($pl_title)}
+<title>{$pl_title}</title>
+{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}