本文整理汇总了PHP中SSViewer::hasTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP SSViewer::hasTemplate方法的具体用法?PHP SSViewer::hasTemplate怎么用?PHP SSViewer::hasTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSViewer
的用法示例。
在下文中一共展示了SSViewer::hasTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrapify
/**
* Transforms all fields in the FieldList to use Bootstrap templates
* @return FieldList
*/
public function bootstrapify()
{
foreach ($this->owner as $f) {
if (isset($this->ignores[$f->getName()])) {
continue;
}
// If we have a Tabset, bootstrapify all Tabs
if ($f instanceof TabSet) {
$f->Tabs()->bootstrapify();
}
// If we have a Tab, bootstrapify all its Fields
if ($f instanceof Tab) {
$f->Fields()->bootstrapify();
}
$template = "Bootstrap{$f->class}_holder";
if (SSViewer::hasTemplate($template)) {
$f->setFieldHolderTemplate($template);
} else {
$f->setFieldHolderTemplate("BootstrapFieldHolder");
}
foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
$bootstrapCandidate = "Bootstrap{$className}";
$nativeCandidate = $className;
if (SSViewer::hasTemplate($bootstrapCandidate)) {
$f->setTemplate($bootstrapCandidate);
break;
} elseif (SSViewer::hasTemplate($nativeCandidate)) {
$f->setTemplate($nativeCandidate);
break;
}
}
}
return $this->owner;
}
示例2: BlockArea
/**
* Called from templates to get rendered blocks for the given area
* @param string $area
* @param integer $limit Limit the items to this number, or null for no limit
*/
public function BlockArea($area, $limit = null)
{
if ($this->owner->ID <= 0) {
return;
}
// blocks break on fake pages ie Security/login
$list = $this->getBlockList($area);
foreach ($list as $block) {
if (!$block->canView()) {
$list->remove($block);
}
}
if ($limit !== null) {
$list = $list->limit($limit);
}
$data = array();
$data['HasBlockArea'] = $this->owner->canEdit() && isset($_REQUEST['block_preview']) && $_REQUEST['block_preview'] || $list->Count() > 0;
$data['BlockArea'] = $list;
$data['AreaID'] = $area;
$data = $this->owner->customise($data);
$template = array('BlockArea_' . $area);
if (SSViewer::hasTemplate($template)) {
return $data->renderWith($template);
} else {
return $data->renderWith('BlockArea');
}
}
示例3: BlockArea
/**
* Called from templates to get rendered blocks for the given area
* @param string $area
* @param integer $limit Limit the items to this number, or null for no limit
*/
public function BlockArea($area, $limit = null)
{
if ($this->owner->ID <= 0) {
return;
}
// blocks break on fake pages ie Security/login
$list = $this->getBlockList($area);
foreach ($list as $block) {
if (!$block->canView()) {
$list->remove($block);
}
}
if ($limit !== null) {
$list = $list->limit($limit);
}
$data['BlockArea'] = $list;
$data['AreaID'] = $area;
$data = $this->owner->customise($data);
$template[] = 'BlockArea_' . $area;
if (SSViewer::hasTemplate($template)) {
return $data->renderWith($template);
} else {
return $data->renderWith('BlockArea');
}
}
示例4: apply_bootstrap_to_fieldlist
/**
* Changes the templates of all the {@link FormField}
* objects in a given {@link FieldList} object to those
* that work the Bootstrap framework
*
* @param FieldList $fields
*/
public static function apply_bootstrap_to_fieldlist($fields)
{
foreach ($fields as $f) {
// If we have a Tabset, bootstrapify all Tabs
if ($f instanceof TabSet) {
self::apply_bootstrap_to_fieldlist($f->Tabs());
}
// If we have a Tab, bootstrapify all its Fields
if ($f instanceof Tab) {
self::apply_bootstrap_to_fieldlist($f->Fields());
}
$template = "Bootstrap{$f->class}_holder";
if (SSViewer::hasTemplate($template)) {
$f->setFieldHolderTemplate($template);
} else {
$f->setFieldHolderTemplate("BootstrapFieldHolder");
}
foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
$bootstrapCandidate = "Bootstrap{$className}";
$nativeCandidate = $className;
if (SSViewer::hasTemplate($bootstrapCandidate)) {
$f->setTemplate($bootstrapCandidate);
break;
} elseif (SSViewer::hasTemplate($nativeCandidate)) {
$f->setTemplate($nativeCandidate);
break;
}
}
}
}
示例5: bootstrapify
public function bootstrapify()
{
$inline_fields = Config::inst()->get('BootstrapForm', 'inline_fields');
foreach ($this->owner as $f) {
if (isset($this->ignores[$f->getName()])) {
continue;
}
if ($f instanceof CompositeField) {
$f->getChildren()->bootstrapify();
continue;
}
if (!in_array($f->class, $inline_fields)) {
$f->addExtraClass('form-control');
}
$template = "Bootstrap{$f->class}_holder";
if (SSViewer::hasTemplate($template)) {
$f->setFieldHolderTemplate($template);
} else {
$f->setFieldHolderTemplate("BootstrapFieldHolder");
}
foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
$bootstrapCandidate = "Bootstrap{$className}";
$nativeCandidate = $className;
if (SSViewer::hasTemplate($bootstrapCandidate)) {
$f->setTemplate($bootstrapCandidate);
break;
} elseif (SSViewer::hasTemplate($nativeCandidate)) {
$f->setTemplate($nativeCandidate);
break;
}
}
}
return $this->owner;
}
示例6: getPreviewLayout
public function getPreviewLayout()
{
$templateName = "Preview_" . $this->URLSegment;
if (!SSViewer::hasTemplate($templateName)) {
$templateName = "Preview_" . $this->ClassName;
}
$template = array($templateName, 'Preview');
return $this->renderWith($template);
}
示例7: bootstrapify
/**
* Transforms all fields in the FieldList to use Foundation templates
* @return FieldList
*/
public function bootstrapify()
{
foreach ($this->owner as $f) {
$sng = Injector::inst()->get($f->class, true, ['dummy', '']);
if (isset($this->ignores[$f->getName()])) {
continue;
}
// if we have a CompositeField, bootstrapify its children
if ($f instanceof CompositeField) {
$f->getChildren()->bootstrapify();
continue;
}
// If we have a Tabset, bootstrapify all Tabs
if ($f instanceof TabSet) {
$f->Tabs()->bootstrapify();
}
// If we have a Tab, bootstrapify all its Fields
if ($f instanceof Tab) {
$f->Fields()->bootstrapify();
}
// If the user has customised the holder template already, don't apply the default one.
if ($sng->getFieldHolderTemplate() == $f->getFieldHolderTemplate()) {
$template = "Foundation{$f->class}_holder";
if (SSViewer::hasTemplate($template)) {
$f->setFieldHolderTemplate($template);
} else {
$f->setFieldHolderTemplate("FoundationFieldHolder");
}
}
// If the user has customised the field template already, don't apply the default one.
if ($sng->getTemplate() == $f->getTemplate()) {
foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
$bootstrapCandidate = "Foundation{$className}";
$nativeCandidate = $className;
if (SSViewer::hasTemplate($bootstrapCandidate)) {
$f->setTemplate($bootstrapCandidate);
break;
} elseif (SSViewer::hasTemplate($nativeCandidate)) {
$f->setTemplate($nativeCandidate);
break;
}
}
}
}
return $this->owner;
}
示例8: transform
public function transform(FormField $field)
{
Requirements::css(FOUNDATIONFORMS_DIR . '/css/foundationforms.css');
// tab
if ($field instanceof Tab) {
$field->Fields()->transform(new FoundationFormTransformation());
}
// tabset
if ($field instanceof TabSet) {
$field->Tabs()->transform(new FoundationFormTransformation());
}
// fieldgroup
if ($field instanceof FieldGroup) {
$field->FieldList()->transform(new FoundationFormTransformation());
}
// compositefield
if ($field instanceof CompositeField) {
$field->FieldList()->transform(new FoundationFormTransformation());
}
$holder = "Foundation{$field->class}_holder";
if (SSViewer::hasTemplate($holder)) {
$field->setFieldHolderTemplate($holder);
} else {
$field->setFieldHolderTemplate("FoundationFieldHolder");
}
$holder_small = "Foundation{$field->class}_holder_small";
if (SSViewer::hasTemplate($holder_small)) {
$field->setSmallFieldHolderTemplate($holder_small);
} else {
$field->setSmallFieldHolderTemplate("FoundationFieldHolderMinimal");
}
foreach (array_reverse(ClassInfo::ancestry($field)) as $className) {
$foundationCandidate = "Foundation{$className}";
$nativeCandidate = $className;
if (SSViewer::hasTemplate($foundationCandidate)) {
$field->setTemplate($foundationCandidate);
break;
} elseif (SSViewer::hasTemplate($nativeCandidate)) {
$field->setTemplate($nativeCandidate);
break;
}
}
return $field;
}
开发者ID:helpfulrobot,项目名称:rywa-silverstripe-foundation-forms,代码行数:44,代码来源:FoundationFormTransformation.php
示例9: FeatureBannersHTML
/**
* Render the FeatureBanners
* @return String
*/
public function FeatureBannersHTML()
{
// Check if there are any FeatureBanners, before doing further checks
if (!$this->FeatureBanners()->Count()) {
return false;
}
if (static::$includeCSS) {
Requirements::css(FEATURE_BANNERS_FOLDER . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'feature-banners.min.css');
}
$templates = array('FeatureBanners');
$classes = array_reverse(ClassInfo::ancestry($this->owner->ClassName));
foreach ($classes as $class) {
$template = sprintf('FeatureBanners_%s', $class);
if (SSViewer::hasTemplate($template)) {
$templates[] = $template;
}
if ($class == 'SiteTree') {
break;
}
}
return $this->owner->renderWith($templates);
}
示例10: get_templates_by_class
/**
* Traverses the given the given class context looking for templates with the relevant name.
*
* @param $className string - valid class name
* @param $suffix string
* @param $baseClass string
*
* @return array
*/
public static function get_templates_by_class($className, $suffix = '', $baseClass = null)
{
// Figure out the class name from the supplied context.
if (!is_string($className) || !class_exists($className)) {
throw new InvalidArgumentException('SSViewer::get_templates_by_class() expects a valid class name as ' . 'its first parameter.');
return array();
}
$templates = array();
$classes = array_reverse(ClassInfo::ancestry($className));
foreach ($classes as $class) {
$template = $class . $suffix;
if (SSViewer::hasTemplate($template)) {
$templates[] = $template;
}
// If the class is "Page_Controller", look for Page.ss
if (stripos($class, '_controller') !== false) {
$template = str_ireplace('_controller', '', $class) . $suffix;
if (SSViewer::hasTemplate($template)) {
$templates[] = $template;
}
}
if ($baseClass && $class == $baseClass) {
break;
}
}
return $templates;
}
示例11: login
/**
* Show the "login" page
*
* @return string Returns the "login" page as HTML code.
*/
public function login()
{
$customCSS = project() . '/css/tabs.css';
if (Director::fileExists($customCSS)) {
Requirements::css($customCSS);
}
$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOGIN', 'Log in');
$tmpPage->URLSegment = "Security";
$tmpPage->ID = -1;
// Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
//Controller::$currentController = $controller;
$content = '';
$forms = $this->GetLoginForms();
if (!count($forms)) {
user_error('No login-forms found, please use Authenticator::register_authenticator() to add one', E_USER_ERROR);
}
// only display tabs when more than one authenticator is provided
// to save bandwidth and reduce the amount of custom styling needed
if (count($forms) > 1) {
Requirements::javascript("jsparty/loader.js");
Requirements::javascript("jsparty/prototype.js");
Requirements::javascript("jsparty/behaviour.js");
Requirements::javascript("jsparty/prototype_improvements.js");
Requirements::javascript("jsparty/tabstrip/tabstrip.js");
Requirements::javascript("jsparty/scriptaculous/effects.js");
Requirements::css("jsparty/tabstrip/tabstrip.css");
Requirements::css("sapphire/css/Form.css");
// Needed because the <base href=".."> in the template makes problems
// with the tabstrip library otherwise
$link_base = Director::absoluteURL($this->Link("login"));
$content = '<div id="Form_EditForm">';
$content .= '<ul class="tabstrip">';
$content_forms = '';
foreach ($forms as $form) {
$content .= "<li><a href=\"{$link_base}#{$form->FormName()}_tab\">{$form->getAuthenticator()->get_name()}</a></li>\n";
$content_forms .= '<div class="tab" id="' . $form->FormName() . '_tab">' . $form->forTemplate() . "</div>\n";
}
$content .= "</ul>\n" . $content_forms . "\n</div>\n";
} else {
$content .= $forms[0]->forTemplate();
}
if (strlen($message = Session::get('Security.Message.message')) > 0) {
$message_type = Session::get('Security.Message.type');
if ($message_type == 'bad') {
$message = "<p class=\"message {$message_type}\">{$message}</p>";
} else {
$message = "<p>{$message}</p>";
}
$customisedController = $controller->customise(array("Content" => $message, "Form" => $content));
} else {
$customisedController = $controller->customise(array("Content" => $content));
}
// custom processing
if (SSViewer::hasTemplate("Security_login")) {
return $customisedController->renderWith(array("Security_login", "Page"));
} else {
return $customisedController->renderWith("Page");
}
}
示例12: getTemplatesWithSuffix
/**
* Return a list of appropriate templates for this class, with the given suffix
*/
public function getTemplatesWithSuffix($suffix)
{
$templates = array();
$classes = array_reverse(ClassInfo::ancestry($this->class));
foreach ($classes as $class) {
$template = $class . $suffix;
if (SSViewer::hasTemplate($template)) {
$templates[] = $template;
}
if ($class == 'LeftAndMain') {
break;
}
}
return $templates;
}
示例13: forTemplate
/**
* Renders this block with appropriate templates
* looks for templates that match BlockClassName_AreaName
* falls back to BlockClassName
* @return string
**/
public function forTemplate()
{
$controller = $this->getController();
if ($this->BlockArea) {
$template = array($this->class . '_' . $this->BlockArea);
if (SSViewer::hasTemplate($template)) {
return $controller->renderWith($template);
}
}
return $controller->renderWith($this->ClassName);
}
示例14: hasActionTemplate
/**
* Returns TRUE if this controller has a template that is specifically designed to handle a specific action.
*
* @param string $action
* @return bool
*/
public function hasActionTemplate($action)
{
if (isset($this->templates[$action])) {
return true;
}
$parentClass = $this->class;
$templates = array();
while ($parentClass != 'Controller') {
$templates[] = strtok($parentClass, '_') . '_' . $action;
$parentClass = get_parent_class($parentClass);
}
return SSViewer::hasTemplate($templates);
}
示例15: forTemplate
/**
* Renders this block with appropriate templates
* looks for templates that match BlockClassName_AreaName
* falls back to BlockClassName
* @return string
**/
public function forTemplate()
{
if ($this->BlockArea) {
$template[] = $this->class . '_' . $this->BlockArea;
if (SSViewer::hasTemplate($template)) {
return $this->renderWith($template);
}
}
return $this->renderWith($this->ClassName);
}