当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldList::setTabPathRewrites方法代码示例

本文整理汇总了PHP中FieldList::setTabPathRewrites方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::setTabPathRewrites方法的具体用法?PHP FieldList::setTabPathRewrites怎么用?PHP FieldList::setTabPathRewrites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldList的用法示例。


在下文中一共展示了FieldList::setTabPathRewrites方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCMSFields

 /**
  * Returns a FieldList with which to create the main editing form.
  *
  * You can override this in your child classes to add extra fields - first get the parent fields using
  * parent::getCMSFields(), then use addFieldToTab() on the FieldList.
  *
  * See {@link getSettingsFields()} for a different set of fields concerned with configuration aspects on the record,
  * e.g. access control.
  *
  * @return FieldList The fields to be displayed in the CMS
  */
 public function getCMSFields()
 {
     require_once "forms/Form.php";
     // Status / message
     // Create a status message for multiple parents
     if ($this->ID && is_numeric($this->ID)) {
         $linkedPages = $this->VirtualPages();
         $parentPageLinks = array();
         if ($linkedPages->Count() > 0) {
             foreach ($linkedPages as $linkedPage) {
                 $parentPage = $linkedPage->Parent;
                 if ($parentPage) {
                     if ($parentPage->ID) {
                         $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/{$linkedPage->ID}\">{$parentPage->Title}</a>";
                     } else {
                         $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/{$linkedPage->ID}\">" . _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') . "</a>";
                     }
                 }
             }
             $lastParent = array_pop($parentPageLinks);
             $parentList = "'{$lastParent}'";
             if (count($parentPageLinks) > 0) {
                 $parentList = "'" . implode("', '", $parentPageLinks) . "' and " . $parentList;
             }
             $statusMessage[] = _t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the {title} sections.", array('title' => $parentList));
         }
     }
     if ($this->HasBrokenLink || $this->HasBrokenFile) {
         $statusMessage[] = _t('SiteTree.HASBROKENLINKS', "This page has broken links.");
     }
     $dependentNote = '';
     $dependentTable = new LiteralField('DependentNote', '<p></p>');
     // Create a table for showing pages linked to this one
     $dependentPages = $this->DependentPages();
     $dependentPagesCount = $dependentPages->Count();
     if ($dependentPagesCount) {
         $dependentColumns = array('Title' => $this->fieldLabel('Title'), 'AbsoluteLink' => _t('SiteTree.DependtPageColumnURL', 'URL'), 'DependentLinkType' => _t('SiteTree.DependtPageColumnLinkType', 'Link type'));
         if (class_exists('Subsite')) {
             $dependentColumns['Subsite.Title'] = singleton('Subsite')->i18n_singular_name();
         }
         $dependentNote = new LiteralField('DependentNote', '<p>' . _t('SiteTree.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>');
         $dependentTable = GridField::create('DependentPages', false, $dependentPages);
         $dependentTable->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields($dependentColumns)->setFieldFormatting(array('Title' => function ($value, &$item) {
             return sprintf('<a href="admin/pages/edit/show/%d">%s</a>', (int) $item->ID, Convert::raw2xml($item->Title));
         }, 'AbsoluteLink' => function ($value, &$item) {
             return sprintf('<a href="%s" target="_blank">%s</a>', Convert::raw2xml($value), Convert::raw2xml($value));
         }));
     }
     $baseLink = Controller::join_links(Director::absoluteBaseURL(), self::config()->nested_urls && $this->ParentID ? $this->Parent()->RelativeLink(true) : null);
     $urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment'));
     $urlsegment->setURLPrefix($baseLink);
     $helpText = self::config()->nested_urls && count($this->Children()) ? $this->fieldLabel('LinkChangeNote') : '';
     if (!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
         $helpText .= $helpText ? '<br />' : '';
         $helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
     }
     $urlsegment->setHelpText($helpText);
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', new TextField("Title", $this->fieldLabel('Title')), $urlsegment, new TextField("MenuTitle", $this->fieldLabel('MenuTitle')), $htmlField = new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", 'HTML editor title')), ToggleCompositeField::create('Metadata', _t('SiteTree.MetadataToggle', 'Metadata'), array($metaFieldDesc = new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4)), $tabDependent = new Tab('Dependent', $dependentNote, $dependentTable)));
     $htmlField->addExtraClass('stacked');
     // Help text for MetaData on page content editor
     $metaFieldDesc->setRightTitle(_t('SiteTree.METADESCHELP', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help');
     $metaFieldExtra->setRightTitle(_t('SiteTree.METAEXTRAHELP', "HTML tags for additional meta information. For example &lt;meta name=\"customName\" content=\"your custom content here\" /&gt;"))->addExtraClass('help');
     // Conditional dependent pages tab
     if ($dependentPagesCount) {
         $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ({$dependentPagesCount})");
     } else {
         $fields->removeFieldFromTab('Root', 'Dependent');
     }
     $tabMain->setTitle(_t('SiteTree.TABCONTENT', "Main Content"));
     if ($this->ObsoleteClassName) {
         $obsoleteWarning = _t('SiteTree.OBSOLETECLASS', "This page is of obsolete type {type}. Saving will reset its type and you may lose data", array('type' => $this->ObsoleteClassName));
         $fields->addFieldToTab("Root.Main", new LiteralField("ObsoleteWarningHeader", "<p class=\"message warning\">{$obsoleteWarning}</p>"), "Title");
     }
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     // Backwards compat: Rewrite nested "Content" tabs to toplevel
     $fields->setTabPathRewrites(array('/^Root\\.Content\\.Main$/' => 'Root.Main', '/^Root\\.Content\\.([^.]+)$/' => 'Root.\\1'));
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:94,代码来源:SiteTree.php

示例2: testRewriteTabPathFindOrMakeTab

 public function testRewriteTabPathFindOrMakeTab()
 {
     $originalDeprecation = Deprecation::dump_settings();
     Deprecation::notification_version('2.4');
     $fields = new FieldList(new Tabset("Root", $tab1Level1 = new Tab("Tab1Level1Renamed", $tab1Level2 = new Tab("Tab1Level2"), $tab2Level2 = new Tab("Tab2Level2")), $tab2Level1 = new Tab("Tab2Level1")));
     $fields->setTabPathRewrites(array('/Root\\.Tab1Level1\\.([^.]+)$/' => 'Root.Tab1Level1Renamed.\\1', '/Root\\.Tab1Level1$/' => 'Root.Tab1Level1Renamed'));
     $this->assertEquals($tab1Level1, $fields->findOrMakeTab('Root.Tab1Level1'), 'findOrMakeTab() with toplevel tab under old name');
     $this->assertEquals($tab1Level1, $fields->findOrMakeTab('Root.Tab1Level1Renamed'), 'findOrMakeTab() with toplevel tab under new name');
     $this->assertEquals($tab1Level2, $fields->findOrMakeTab('Root.Tab1Level1.Tab1Level2'), 'findOrMakeTab() with nested tab under old parent tab name');
     $this->assertEquals($tab1Level2, $fields->findOrMakeTab('Root.Tab1Level1Renamed.Tab1Level2'), 'findOrMakeTab() with nested tab under new parent tab name');
     Deprecation::restore_settings($originalDeprecation);
 }
开发者ID:normann,项目名称:sapphire,代码行数:12,代码来源:FieldListTest.php

示例3: getCMSFields

 /**
  * Returns a FieldList with which to create the main editing form.
  *
  * You can override this in your child classes to add extra fields - first
  * get the parent fields using parent::getCMSFields(), then use
  * addFieldToTab() on the FieldList.
  * 
  * See {@link getSettingsFields()} for a different set of fields
  * concerned with configuration aspects on the record, e.g. access control
  *
  * @return FieldList The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     require_once "forms/Form.php";
     // Status / message
     // Create a status message for multiple parents
     if ($this->ID && is_numeric($this->ID)) {
         $linkedPages = $this->VirtualPages();
         $parentPageLinks = array();
         if ($linkedPages->Count() > 0) {
             foreach ($linkedPages as $linkedPage) {
                 $parentPage = $linkedPage->Parent;
                 if ($parentPage) {
                     if ($parentPage->ID) {
                         $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">{$parentPage->Title}</a>";
                     } else {
                         $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">" . _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') . "</a>";
                     }
                 }
             }
             $lastParent = array_pop($parentPageLinks);
             $parentList = "'{$lastParent}'";
             if (count($parentPageLinks) > 0) {
                 $parentList = "'" . implode("', '", $parentPageLinks) . "' and " . $parentList;
             }
             $statusMessage[] = _t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the {title} sections.", array('title' => $parentList));
         }
     }
     if ($this->HasBrokenLink || $this->HasBrokenFile) {
         $statusMessage[] = _t('SiteTree.HASBROKENLINKS', "This page has broken links.");
     }
     $dependentNote = '';
     $dependentTable = new LiteralField('DependentNote', '<p></p>');
     // Create a table for showing pages linked to this one
     $dependentPagesCount = $this->DependentPagesCount();
     if ($dependentPagesCount) {
         $dependentColumns = array('Title' => $this->fieldLabel('Title'), 'AbsoluteLink' => _t('SiteTree.DependtPageColumnURL', 'URL'), 'DependentLinkType' => _t('SiteTree.DependtPageColumnLinkType', 'Link type'));
         if (class_exists('Subsite')) {
             $dependentColumns['Subsite.Title'] = singleton('Subsite')->i18n_singular_name();
         }
         $dependentNote = new LiteralField('DependentNote', '<p>' . _t('SiteTree.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>');
         $dependentTable = GridField::create('DependentPages', false, $this->DependentPages());
         $dependentTable->getConfig()->getComponentByType('GridFieldDataColumns')->setFieldFormatting(array('Title' => '<a href=\\"admin/show/$ID\\">$Title</a>', 'AbsoluteLink' => '<a href=\\"$value\\">$value</a>'));
     }
     $baseLink = Controller::join_links(Director::absoluteBaseURL(), self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null);
     $url = strlen($baseLink) > 36 ? "..." . substr($baseLink, -32) : $baseLink;
     $urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment'));
     $urlsegment->setURLPrefix($url);
     $helpText = self::nested_urls() && count($this->Children()) ? $this->fieldLabel('LinkChangeNote') : '';
     if (!URLSegmentFilter::$default_allow_multibyte) {
         $helpText .= $helpText ? '<br />' : '';
         $helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
     }
     $urlsegment->setHelpText($helpText);
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', new TextField("Title", $this->fieldLabel('Title')), $urlsegment, new TextField("MenuTitle", $this->fieldLabel('MenuTitle')), $htmlField = new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", 'HTML editor title')), ToggleCompositeField::create('Metadata', _t('SiteTree.MetadataToggle', 'Metadata'), array(new TextField("MetaTitle", $this->fieldLabel('MetaTitle')), new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1), new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')), new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4)), $tabDependent = new Tab('Dependent', $dependentNote, $dependentTable)));
     $htmlField->addExtraClass('stacked');
     // Conditional dependent pages tab
     if ($dependentPagesCount) {
         $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ({$dependentPagesCount})");
     } else {
         $fields->removeFieldFromTab('Root', 'Dependent');
     }
     $tabMain->setTitle(_t('SiteTree.TABCONTENT', "Main Content"));
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     // Backwards compat: Rewrite nested "Content" tabs to toplevel
     $fields->setTabPathRewrites(array('/^Root\\.Content\\.Main$/' => 'Root.Main', '/^Root\\.Content\\.([^.]+)$/' => 'Root.\\1'));
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }
开发者ID:normann,项目名称:silverstripe-cms,代码行数:84,代码来源:SiteTree.php


注:本文中的FieldList::setTabPathRewrites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。