add method footerjs() which deliveres a temp. js file

This commit is contained in:
Uwe Steinmann 2017-01-09 10:57:07 +01:00
parent 60dd7f8516
commit b78a730f82

View File

@ -124,22 +124,32 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
echo '<script src="../styles/'.$this->theme.'/select2/js/select2.min.js"></script>'."\n"; echo '<script src="../styles/'.$this->theme.'/select2/js/select2.min.js"></script>'."\n";
echo '<script src="../styles/'.$this->theme.'/application.js"></script>'."\n"; echo '<script src="../styles/'.$this->theme.'/application.js"></script>'."\n";
if($this->footerjs) { if($this->footerjs) {
echo "<script type=\"text/javascript\"> $jscode = "$(document).ready(function () {\n";
//<![CDATA[
$(document).ready(function () {
";
foreach($this->footerjs as $script) { foreach($this->footerjs as $script) {
echo $script."\n"; $jscode .= $script."\n";
} }
echo "}); $jscode .= "});\n";
//]]> $hashjs = md5($jscode);
</script>"; if(!is_dir($this->params['cachedir'].'/js')) {
SeedDMS_Core_File::makeDir($this->params['cachedir'].'/js');
}
if(is_dir($this->params['cachedir'].'/js')) {
file_put_contents($this->params['cachedir'].'/js/'.$hashjs.'.js', $jscode);
}
echo '<script src="../out/out.'.$this->params['class'].'.php?action=footerjs&hash='.$hashjs.'"></script>'."\n";
} }
if(method_exists($this, 'js')) if(method_exists($this, 'js'))
echo '<script src="../out/out.'.$this->params['class'].'.php?action=js&'.$_SERVER['QUERY_STRING'].'"></script>'."\n"; echo '<script src="../out/out.'.$this->params['class'].'.php?action=js&'.$_SERVER['QUERY_STRING'].'"></script>'."\n";
echo "</body>\n</html>\n"; echo "</body>\n</html>\n";
} /* }}} */ } /* }}} */
function footerjs() { /* {{{ */
header('Content-Type: application/javascript');
if(file_exists($this->params['cachedir'].'/js/'.$_GET['hash'].'.js')) {
readfile($this->params['cachedir'].'/js/'.$_GET['hash'].'.js');
}
} /* }}} */
function missingḺanguageKeys() { /* {{{ */ function missingḺanguageKeys() { /* {{{ */
global $MISSING_LANG, $LANG; global $MISSING_LANG, $LANG;
if($MISSING_LANG) { if($MISSING_LANG) {