1
0

spartacus: only set template fullsize preview if existing, cached

This commit is contained in:
onli
2013-06-23 21:13:45 +02:00
parent 52a24d511e
commit 6d3404c763

View File

@ -803,6 +803,7 @@ class serendipity_event_spartacus extends serendipity_event
}
function &buildTemplateList(&$tree) {
global $serendipity;
$pluginstack = array();
$i = 0;
$gitloc = '';
@ -877,7 +878,19 @@ class serendipity_event_spartacus extends serendipity_event
$plugname = $pluginstack[$i]['template'];
$pluginstack[$i]['previewURL'] = $this->fixUrl($mirror . '/additional_themes/' . $gitloc . $plugname . '/preview.png?revision=1.9999');
$pluginstack[$i]['preview_fullsizeURL'] = $this->fixUrl($mirror . '/additional_themes/' . $gitloc . $plugname . '/preview_fullsize.jpg?revision=1.9999');
$preview_fullsizeURL = $this->fixUrl($mirror . '/additional_themes/' . $gitloc . $plugname . '/preview_fullsize.jpg?revision=1.9999');
if (! file_exists($serendipity['serendipityPath'] . '/templates_c/template_cache')) {
mkdir($serendipity['serendipityPath'] . '/templates_c/template_cache');
}
if (! file_exists($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname .'.jpg')) {
$file = @fopen($preview_fullsizeURL, 'r');
if ($file) {
file_put_contents($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname .'.jpg', $file);
}
}
if (file_exists($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname .'.jpg')) {
$pluginstack[$i]['preview_fullsizeURL'] = $preview_fullsizeURL;
}
$pluginstack[$i]['customURI'] = '&serendipity[spartacus_fetch]=' . $plugname;
$pluginstack[$i]['customIcon'] = '_spartacus';