NEW Disable shortcodes in $Layout and $Content in SSViewer

This commit is contained in:
Hamish Friedlander 2013-03-12 09:53:00 +13:00 committed by Sam Minnee
parent cd41a536b9
commit d2650bbc44
5 changed files with 45 additions and 2 deletions

View File

@ -898,6 +898,41 @@ after')
);
}
protected function useTestTheme($theme, $callback) {
global $project;
$themeBaseDir = dirname(__FILE__);
$manifest = new SS_TemplateManifest($themeBaseDir, $project, true, true);
SS_TemplateLoader::instance()->pushManifest($manifest);
$origTheme = SSViewer::current_theme();
SSViewer::set_theme($theme);
$e = null;
try { $callback(); }
catch (Exception $e) { /* NOP for now, just save $e */ }
// Remove all the test themes we created
SS_TemplateLoader::instance()->popManifest();
SSViewer::set_theme($origTheme);
if ($e) throw $e;
}
public function testLayout() {
$self = $this;
$this->useTestTheme('layouttest', function() use ($self) {
$template = new SSViewer(array('Page'));
$self->assertEquals('Foo', $template->process(new ArrayData(array())));
$template = new SSViewer(array('Shortcodes', 'Page'));
$self->assertEquals('[file_link]', $template->process(new ArrayData(array())));
});
}
/**
* @covers SSViewer::get_themes()
*/
@ -929,7 +964,7 @@ after')
// Remove all the test themes we created
Filesystem::removeFolder($testThemeBaseDir);
}
public function testRewriteHashlinks() {
$oldRewriteHashLinks = SSViewer::getOption('rewriteHashlinks');
SSViewer::setOption('rewriteHashlinks', true);

View File

@ -0,0 +1 @@
Foo

View File

@ -0,0 +1 @@
[file_link]

View File

@ -0,0 +1 @@
$Layout

View File

@ -909,7 +909,12 @@ class SSViewer {
$subtemplateViewer->includeRequirements(false);
$subtemplateViewer->setPartialCacheStore($this->getPartialCacheStore());
$underlay[$subtemplate] = $subtemplateViewer->process($item, $arguments);
$underlay[$subtemplate] = DBField::create_field(
'HTMLText',
$subtemplateViewer->process($item, $arguments),
$subtemplate,
array('shortcodes' => false)
);
}
}