本文整理汇总了PHP中BackendTemplate::getCompileDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendTemplate::getCompileDirectory方法的具体用法?PHP BackendTemplate::getCompileDirectory怎么用?PHP BackendTemplate::getCompileDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackendTemplate
的用法示例。
在下文中一共展示了BackendTemplate::getCompileDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse the JS, CSS files and meta-info into the head of the HTML-document
*/
public function parse()
{
$cssFiles = array();
$jsFiles = array();
// get last modified time for the header template
$lastModifiedTime = @filemtime($this->tpl->getCompileDirectory() . '/' . md5(realpath(BACKEND_CORE_PATH . '/layout/templates/header.tpl')) . '_header.tpl.php');
// reset lastmodified time if needed (SPOON_DEBUG is enabled or we don't get a decent timestamp)
if ($lastModifiedTime === false || SPOON_DEBUG) {
$lastModifiedTime = time();
}
// if there aren't any CSS-files added we don't need to do something
if (!empty($this->cssFiles)) {
// loop the CSS-files and add the modified-time
foreach ($this->cssFiles as $file) {
// add lastmodified time
if ($file['add_timestamp'] !== false) {
$file['path'] .= strpos($file['path'], '?') !== false ? '&m=' . $lastModifiedTime : '?m=' . $lastModifiedTime;
}
// add
$cssFiles[] = array('path' => $file['path']);
}
}
// assign CSS-files
$this->tpl->assign('cssFiles', $cssFiles);
// if there aren't any JS-files added we don't need to do something
if (!empty($this->jsFiles)) {
// some files should be cached, even if we don't want cached (mostly libraries)
$ignoreCache = array('/backend/core/js/jquery/jquery.js', '/backend/core/js/jquery/jquery.ui.js', '/backend/core/js/ckeditor/jquery.ui.dialog.patch.js', '/backend/core/js/jquery/jquery.tools.js', '/backend/core/js/jquery/jquery.backend.js', '/backend/core/js/ckeditor/ckeditor.js', '/backend/core/js/ckeditor/adapters/jquery.js', '/backend/core/js/ckfinder/ckfinder.js');
foreach ($this->jsFiles as $file) {
// some files shouldn't be uncachable
if (in_array($file['path'], $ignoreCache) || $file['add_timestamp'] === false) {
$jsFiles[] = array('path' => $file['path']);
} else {
// if the file is processed by PHP we don't want any caching
if (substr($file['path'], 0, 11) == '/backend/js') {
$jsFiles[] = array('path' => $file['path'] . '&m=' . time());
} else {
if (strpos($file['path'], '?') !== false) {
$path = $file['path'] . '&m=' . $lastModifiedTime;
} else {
$path = $file['path'] . '?m=' . $lastModifiedTime;
}
$jsFiles[] = array('path' => $path);
}
}
}
}
// assign JS-files
$this->tpl->assign('jsFiles', $jsFiles);
}