additional_plugins/serendipity_event_oembed/OEmbedTemplater.php

37 lines
1.4 KiB
PHP
Raw Normal View History

2011-12-15 16:48:50 +01:00
<?php
class OEmbedTemplater {
/* 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;
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-15 16:48:50 +01:00
$inclusion = $serendipity['smarty']->security_settings[@INCLUDE_ANY];
$serendipity['smarty']->security_settings[@INCLUDE_ANY] = true;
2011-12-18 14:21:38 +01:00
if (version_compare($serendipity['version'], '1.7-alpha1')>=0) {
$serendipity['smarty']->disableSecurity();
}
/* in earlier versions this is not needed.
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
$content = @$serendipity['smarty']->fetch('file:'. $tfile);//, false
2011-12-15 16:48:50 +01:00
$serendipity['smarty']->security_settings[@INCLUDE_ANY] = $inclusion;
2011-12-15 16:48:50 +01:00
return $content;
}
}