2011-12-15 16:48:50 +01:00
|
|
|
<?php
|
|
|
|
class OEmbedTemplater {
|
2011-12-18 00:44:57 +01:00
|
|
|
/* get the right template (s9y template path, then plugin path) and expand it */
|
2011-12-15 16:48:50 +01:00
|
|
|
function fetchTemplate($filename, $oembed, $url) {
|
|
|
|
global $serendipity;
|
|
|
|
|
2011-12-18 00:44:57 +01:00
|
|
|
if (!is_object($serendipity['smarty']))
|
|
|
|
serendipity_smarty_init();
|
|
|
|
|
2011-12-15 16:48:50 +01:00
|
|
|
// Declare the oembed to smarty
|
|
|
|
$serendipity['smarty']->assign('oembedurl',$url);
|
|
|
|
$serendipity['smarty']->assign('oembed',(array)$oembed);
|
|
|
|
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
|
|
|
|
if (!$tfile || $filename == $tfile) {
|
|
|
|
$tfile = dirname(__FILE__) . '/' . $filename;
|
|
|
|
}
|
2011-12-18 00:44:57 +01:00
|
|
|
|
2011-12-15 16:48:50 +01:00
|
|
|
$inclusion = $serendipity['smarty']->security_settings[@INCLUDE_ANY];
|
|
|
|
$serendipity['smarty']->security_settings[@INCLUDE_ANY] = true;
|
2011-12-18 00:44:57 +01:00
|
|
|
|
|
|
|
if (version_compare($serendipity['version'], '1.7-alpha1','>=')) {
|
|
|
|
$serendipity['smarty']->disableSecurity();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$serendipity['smarty']->security = false;
|
|
|
|
}
|
|
|
|
|
2011-12-15 16:48:50 +01:00
|
|
|
// be smarty 3 compat including the serendipity_smarty class wrappers ->fetch and ->display methods and remove changed parameter number 4
|
2011-12-18 00:44:57 +01:00
|
|
|
$content = @$serendipity['smarty']->fetch('file:'. $tfile);//, false
|
|
|
|
|
2011-12-15 16:48:50 +01:00
|
|
|
$serendipity['smarty']->security_settings[@INCLUDE_ANY] = $inclusion;
|
2011-12-18 00:44:57 +01:00
|
|
|
|
2011-12-15 16:48:50 +01:00
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
}
|