本文整理汇总了PHP中SSViewer::get_templates_by_class方法的典型用法代码示例。如果您正苦于以下问题:PHP SSViewer::get_templates_by_class方法的具体用法?PHP SSViewer::get_templates_by_class怎么用?PHP SSViewer::get_templates_by_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSViewer
的用法示例。
在下文中一共展示了SSViewer::get_templates_by_class方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMappableMapContent
/**
* Renders the map info window for the DataObject.
*
* Be sure to define a template for that, named by the decorated class suffixed with _MapInfoWindow
* e.g. MyPage_MapInfoWindow
*
* You can change the suffix globally by editing the MapExtension.map_info_window_suffix config val
*
* @return string
*/
public function getMappableMapContent()
{
$defaultTemplate = 'MapInfoWindow';
$classTemplate = SSViewer::get_templates_by_class($this->owner->ClassName, Config::inst()->get('MapExtension', 'map_info_window_suffix'));
$template = count($classTemplate) ? $classTemplate : $defaultTemplate;
return MapUtil::sanitize($this->owner->renderWith($template));
}
示例2: show
/**
* action for showing a single news item
*/
public function show()
{
$templates = SSViewer::get_templates_by_class(__CLASS__, '_show');
$templates[] = 'Page';
//use this if you need e.g. different template for ajax
$this->extend('updateTemplatesForShowAction', $templates);
return $this->renderWith($templates);
}
示例3: LayoutSection
/**
* Render this Page for $LayoutSection
* @return \HTMLText
*/
public function LayoutSection()
{
$templates = SSViewer::get_templates_by_class(get_class($this), '', 'SiteTree');
foreach ($templates as &$template) {
$template = "Section/{$template}";
}
return $this->renderWith(new SSViewer($templates));
}
示例4: getTemplatesWithSuffix
/**
* Return a list of appropriate templates for this class, with the given suffix using
* {@link SSViewer::get_templates_by_class()}
*
* @return array
*/
public function getTemplatesWithSuffix($suffix)
{
return SSViewer::get_templates_by_class(get_class($this), $suffix, 'LeftAndMain');
}
示例5: testGetTemplatesByClass
/**
* @covers SSViewer::get_templates_by_class()
*/
public function testGetTemplatesByClass()
{
$self = $this;
$this->useTestTheme('layouttest', function () use($self) {
// Test passing a string
$templates = SSViewer::get_templates_by_class('SSViewerTest_Controller', '', 'Controller');
$self->assertCount(2, $templates);
// Test to ensure we're stopping at the base class.
$templates = SSViewer::get_templates_by_class('SSViewerTest_Controller', '', 'SSViewerTest_Controller');
$self->assertCount(1, $templates);
// Make sure we can filter our templates by suffix.
$templates = SSViewer::get_templates_by_class('SSViewerTest', '_Controller');
$self->assertCount(1, $templates);
// Test passing a valid object
$templates = SSViewer::get_templates_by_class("SSViewerTest_Controller", '', 'Controller');
// Test that templates are returned in the correct order
$self->assertEquals('SSViewerTest_Controller', array_shift($templates));
$self->assertEquals('Controller', array_shift($templates));
// Let's throw something random in there.
$self->setExpectedException('InvalidArgumentException');
$templates = SSViewer::get_templates_by_class(array());
$this->assertCount(0, $templates);
});
}
示例6: getViewer
/**
* Return an SSViewer object to render the template for the current page.
*
* @param $action string
*
* @return SSViewer
*/
public function getViewer($action)
{
// Manually set templates should be dealt with by Controller::getViewer()
if (isset($this->templates[$action]) && $this->templates[$action] || isset($this->templates['index']) && $this->templates['index'] || $this->template) {
return parent::getViewer($action);
}
// Prepare action for template search
if ($action == "index") {
$action = "";
} else {
$action = '_' . $action;
}
$templates = array_merge(SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"), SSViewer::get_templates_by_class(get_class($this), $action, "Controller"), SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"), SSViewer::get_templates_by_class(get_class($this), "", "Controller"));
return new SSViewer($templates);
}
示例7: getViewer
/**
* Return an SSViewer object to render the template for the current page.
*
* @param $action string
*
* @return SSViewer
*/
public function getViewer($action)
{
// Manually set templates should be dealt with by Controller::getViewer()
if (isset($this->templates[$action]) && $this->templates[$action] || isset($this->templates['index']) && $this->templates['index'] || $this->template) {
return parent::getViewer($action);
}
// Prepare action for template search
if ($action == "index") {
$action = "";
} else {
$action = '_' . $action;
}
// Find templates by dataRecord
$templates = SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree");
// Next, we need to add templates for all controllers
$templates += SSViewer::get_templates_by_class(get_class($this), $action, "Controller");
// Fail-over to the same for the "index" action
$templates += SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree");
$templates += SSViewer::get_templates_by_class(get_class($this), "", "Controller");
return new SSViewer($templates);
}
示例8: testGetTemplatesByClass
/**
* @covers SSViewer::get_templates_by_class()
*/
public function testGetTemplatesByClass()
{
$self = $this;
$this->useTestTheme(dirname(__FILE__), 'layouttest', function () use($self) {
// Test passing a string
$templates = SSViewer::get_templates_by_class('TestNamespace\\SSViewerTestModel_Controller', '', 'Controller');
$self->assertEquals(['TestNamespace\\SSViewerTestModel_Controller', 'Controller'], $templates);
// Test to ensure we're stopping at the base class.
$templates = SSViewer::get_templates_by_class('TestNamespace\\SSViewerTestModel_Controller', '', 'TestNamespace\\SSViewerTestModel_Controller');
$self->assertCount(1, $templates);
// Make sure we can filter our templates by suffix.
$templates = SSViewer::get_templates_by_class('TestNamespace\\SSViewerTestModel', '_Controller');
$self->assertCount(1, $templates);
// Let's throw something random in there.
$self->setExpectedException('InvalidArgumentException');
$templates = SSViewer::get_templates_by_class(array());
});
}
示例9: getOnePageContent
/**
* renders the current page using the ClassName_onepage template,
* e.g. Page_onepage
*
* The suffix is generated by @link getOnePageTemplateSuffix
*
* @return HTMLText
*/
public function getOnePageContent()
{
$templateName = SSViewer::get_templates_by_class($this->owner->Classname, $this->getOnePageTemplateSuffix(), 'SiteTree') ?: 'Page_onepage';
$controller = ModelAsController::controller_for($this->owner);
return $controller->renderWith($templateName);
}