本文整理汇总了PHP中TabSet::addExtraClass方法的典型用法代码示例。如果您正苦于以下问题:PHP TabSet::addExtraClass方法的具体用法?PHP TabSet::addExtraClass怎么用?PHP TabSet::addExtraClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabSet
的用法示例。
在下文中一共展示了TabSet::addExtraClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ItemEditForm
function ItemEditForm()
{
$form = parent::ItemEditForm();
$actions = $form->Actions();
$majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
$rootTabSet = new TabSet('ActionMenus');
$moreOptions = new Tab('MoreOptions', _t('SiteTree.MoreOptions', 'More options', 'Expands a view for more buttons'));
$rootTabSet->push($moreOptions);
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
// Render page information into the "more-options" drop-up, on the top.
$baseClass = ClassInfo::baseDataClass($this->record->class);
$live = Versioned::get_one_by_stage($this->record->class, 'Live', "\"{$baseClass}\".\"ID\"='{$this->record->ID}'");
$existsOnLive = $this->record->getExistsOnLive();
$published = $this->record->isPublished();
$moreOptions->push(new LiteralField('Information', $this->record->customise(array('Live' => $live, 'ExistsOnLive' => $existsOnLive))->renderWith('SiteTree_Information')));
$actions->removeByName('action_doSave');
$actions->removeByName('action_doDelete');
if ($this->record->canEdit()) {
if ($this->record->IsDeletedFromStage) {
if ($existsOnLive) {
$majorActions->push(FormAction::create('revert', _t('CMSMain.RESTORE', 'Restore')));
if ($this->record->canDelete() && $this->record->canDeleteFromLive()) {
$majorActions->push(FormAction::create('unpublish', _t('CMSMain.DELETEFP', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
}
} else {
if (!$this->record->isNew()) {
$majorActions->push(FormAction::create('restore', _t('CMSMain.RESTORE', 'Restore'))->setAttribute('data-icon', 'decline'));
} else {
$majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
$majorActions->push(FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true));
}
}
} else {
if ($this->record->canDelete() && !$published) {
$moreOptions->push(FormAction::create('delete', _t('SiteTree.BUTTONDELETE', 'Delete draft'))->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
}
$majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
}
}
$publish = FormAction::create('publish', $published ? _t('SiteTree.BUTTONPUBLISHED', 'Published') : _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true);
if (!$published || $this->record->stagesDiffer('Stage', 'Live') && $published) {
$publish->addExtraClass('ss-ui-alternate');
}
if ($this->record->canPublish() && !$this->record->IsDeletedFromStage) {
$majorActions->push($publish);
}
if ($published && $this->record->canPublish() && !$this->record->IsDeletedFromStage && $this->record->canDeleteFromLive()) {
$moreOptions->push(FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
}
if ($this->record->stagesDiffer('Stage', 'Live') && !$this->record->IsDeletedFromStage && $this->record->isPublished() && $this->record->canEdit()) {
$moreOptions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'))->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))->setUseButtonTag(true));
}
$actions->push($majorActions);
$actions->push($rootTabSet);
if ($this->record->hasMethod('getCMSValidator')) {
$form->setValidator($this->record->getCMSValidator());
}
return $form;
}
开发者ID:helpfulrobot,项目名称:studiobonito-silverstripe-publishable,代码行数:59,代码来源:PublishableGridFieldDetailForm.php
示例2: MediaForm
/**
* Return a {@link Form} instance allowing a user to
* add images and flash objects to the TinyMCE content editor.
*
* @return Form
*/
public function MediaForm()
{
// TODO Handle through GridState within field - currently this state set too late to be useful here (during
// request handling)
$parentID = $this->getAttachParentID();
$fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldDeleteAction(), new GridFieldDetailForm());
$fileField = new GridField('Files', false, null, $fileFieldConfig);
$fileField->setList($this->getFiles($parentID));
$fileField->setAttribute('data-selectable', true);
$fileField->setAttribute('data-multiselect', true);
$columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array('CMSThumbnail' => false, 'Name' => _t('File.Name')));
$numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
$fromCMS = new CompositeField(new LiteralField('headerSelect', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')) . '</h4>'), $select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
$fromCMS->addExtraClass('content ss-uploadfield');
$select->addExtraClass('content-select');
$fromWeb = new CompositeField(new LiteralField('headerURL', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
$remoteURL->addExtraClass('remoteurl');
$fromWeb->addExtraClass('content ss-uploadfield');
Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
$computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
$computerUploadField->setConfig('previewMaxWidth', 40);
$computerUploadField->setConfig('previewMaxHeight', 30);
$computerUploadField->addExtraClass('ss-assetuploadfield');
$computerUploadField->removeExtraClass('ss-uploadfield');
$computerUploadField->setTemplate('HtmlEditorField_UploadField');
$computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
$tabSet = new TabSet("MediaFormInsertMediaTabs", Tab::create('FromComputer', _t('HtmlEditorField.FROMCOMPUTER', 'From your computer'), $computerUploadField)->addExtraClass('htmleditorfield-from-computer'), Tab::create('FromWeb', _t('HtmlEditorField.FROMWEB', 'From the web'), $fromWeb)->addExtraClass('htmleditorfield-from-web'), Tab::create('FromCms', _t('HtmlEditorField.FROMCMS', 'From the CMS'), $fromCMS)->addExtraClass('htmleditorfield-from-cms'));
$tabSet->addExtraClass('cms-tabset-primary');
$allFields = new CompositeField($tabSet, new LiteralField('headerEdit', '<h4 class="field noborder header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.ADJUSTDETAILSDIMENSIONS', 'Details & dimensions')) . '</h4>'), $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
$allFields->addExtraClass('ss-insert-media');
$headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update Media'))));
$headings->addExtraClass('cms-content-header');
$editComposite->addExtraClass('ss-assetuploadfield');
$fields = new FieldList($headings, $allFields);
$actions = new FieldList(FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))->addExtraClass('ss-ui-action-constructive media-insert')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONUpdate', 'Update'))->addExtraClass('ss-ui-action-constructive media-update')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
$form = new Form($this->controller, "{$this->name}/MediaForm", $fields, $actions);
$form->unsetValidator();
$form->disableSecurityToken();
$form->loadDataFrom($this);
$form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
// TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
// $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
// Allow other people to extend the fields being added to the imageform
$this->extend('updateMediaForm', $form);
return $form;
}
示例3: getCMSActions
/**
* Get the actions available in the CMS for this page - eg Save, Publish.
*
* Frontend scripts and styles know how to handle the following FormFields:
* - top-level FormActions appear as standalone buttons
* - top-level CompositeField with FormActions within appear as grouped buttons
* - TabSet & Tabs appear as a drop ups
* - FormActions within the Tab are restyled as links
* - major actions can provide alternate states for richer presentation (see ssui.button widget extension)
*
* @return FieldList The available actions for this page.
*/
public function getCMSActions()
{
$existsOnLive = $this->getExistsOnLive();
// Major actions appear as buttons immediately visible as page actions.
$majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
// Minor options are hidden behind a drop-up and appear as links (although they are still FormActions).
$rootTabSet = new TabSet('ActionMenus');
$moreOptions = new Tab('MoreOptions', _t('SiteTree.MoreOptions', 'More options', 'Expands a view for more buttons'));
$rootTabSet->push($moreOptions);
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
// Render page information into the "more-options" drop-up, on the top.
$live = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\"='{$this->ID}'");
$moreOptions->push(new LiteralField('Information', $this->customise(array('Live' => $live, 'ExistsOnLive' => $existsOnLive))->renderWith('SiteTree_Information')));
// "readonly"/viewing version that isn't the current version of the record
$stageOrLiveRecord = Versioned::get_one_by_stage($this->class, Versioned::current_stage(), sprintf('"SiteTree"."ID" = %d', $this->ID));
if ($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
$moreOptions->push(FormAction::create('email', _t('CMSMain.EMAIL', 'Email')));
$moreOptions->push(FormAction::create('rollback', _t('CMSMain.ROLLBACK', 'Roll back to this version')));
$actions = new FieldList(array($majorActions, $rootTabSet));
// getCMSActions() can be extended with updateCMSActions() on a extension
$this->extend('updateCMSActions', $actions);
return $actions;
}
if ($this->isPublished() && $this->canPublish() && !$this->IsDeletedFromStage && $this->canDeleteFromLive()) {
// "unpublish"
$moreOptions->push(FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')->setDescription(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'))->addExtraClass('ss-ui-action-destructive'));
}
if ($this->stagesDiffer('Stage', 'Live') && !$this->IsDeletedFromStage) {
if ($this->isPublished() && $this->canEdit()) {
// "rollback"
$moreOptions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'), 'delete')->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page')));
}
}
if ($this->canEdit()) {
if ($this->IsDeletedFromStage) {
// The usual major actions are not available, so we provide alternatives here.
if ($existsOnLive) {
// "restore"
$majorActions->push(FormAction::create('revert', _t('CMSMain.RESTORE', 'Restore')));
if ($this->canDelete() && $this->canDeleteFromLive()) {
// "delete from live"
$majorActions->push(FormAction::create('deletefromlive', _t('CMSMain.DELETEFP', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
}
} else {
// "restore"
$majorActions->push(FormAction::create('restore', _t('CMSMain.RESTORE', 'Restore'))->setAttribute('data-icon', 'decline'));
}
} else {
if ($this->canDelete()) {
// "delete"
$moreOptions->push(FormAction::create('delete', _t('CMSMain.DELETE', 'Delete draft'))->addExtraClass('delete ss-ui-action-destructive'));
}
// "save", supports an alternate state that is still clickable, but notifies the user that the action is not needed.
$majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft')));
}
}
if ($this->canPublish() && !$this->IsDeletedFromStage) {
// "publish", as with "save", it supports an alternate state to show when action is needed.
$majorActions->push($publish = FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish')));
// Set up the initial state of the button to reflect the state of the underlying SiteTree object.
if ($this->stagesDiffer('Stage', 'Live')) {
$publish->addExtraClass('ss-ui-alternate');
}
}
$actions = new FieldList(array($majorActions, $rootTabSet));
// Hook for extensions to add/remove actions.
$this->extend('updateCMSActions', $actions);
return $actions;
}
示例4: createActionMenu
protected function createActionMenu()
{
$rootTabSet = new TabSet('ActionMenus');
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
return $rootTabSet;
}
示例5: getCMSFields
/**
* Show the configuration fields for each subsite
*
* @return FieldList
*/
public function getCMSFields()
{
if ($this->ID != 0) {
$domainTable = new GridField("Domains", _t('Subsite.DomainsListTitle', "Domains"), $this->Domains(), GridFieldConfig_RecordEditor::create(10));
} else {
$domainTable = new LiteralField('Domains', '<p>' . _t('Subsite.DOMAINSAVEFIRST', 'You can only add domains after saving for the first time') . '</p>');
}
$languageSelector = new DropdownField('Language', $this->fieldLabel('Language'), i18n::get_common_locales());
$pageTypeMap = array();
$pageTypes = SiteTree::page_type_classes();
foreach ($pageTypes as $pageType) {
$pageTypeMap[$pageType] = singleton($pageType)->i18n_singular_name();
}
asort($pageTypeMap);
$fields = new FieldList($subsiteTabs = new TabSet('Root', new Tab('Configuration', _t('Subsite.TabTitleConfig', 'Configuration'), new HeaderField($this->getClassName() . ' configuration', 2), new TextField('Title', $this->fieldLabel('Title'), $this->Title), new HeaderField(_t('Subsite.DomainsHeadline', "Domains for this subsite")), $domainTable, $languageSelector, new CheckboxField('DefaultSite', $this->fieldLabel('DefaultSite'), $this->DefaultSite), new CheckboxField('IsPublic', $this->fieldLabel('IsPublic'), $this->IsPublic), new DropdownField('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme), new LiteralField('PageTypeBlacklistToggle', sprintf('<div class="field"><a href="#" id="PageTypeBlacklistToggle">%s</a></div>', _t('Subsite.PageTypeBlacklistField', 'Disallow page types?'))), new CheckboxSetField('PageTypeBlacklist', false, $pageTypeMap))), new HiddenField('ID', '', $this->ID), new HiddenField('IsSubsite', '', 1));
$subsiteTabs->addExtraClass('subsite-model');
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例6: getCMSFields
/**
* Show the configuration fields for each subsite
*
* @return FieldList
*/
public function getCMSFields()
{
if ($this->ID != 0) {
$domainTable = new GridField("Domains", _t('Subsite.DomainsListTitle', "Domains"), $this->Domains(), GridFieldConfig_RecordEditor::create(10));
} else {
$domainTable = new LiteralField('Domains', '<p>' . _t('Subsite.DOMAINSAVEFIRST', 'You can only add domains after saving for the first time') . '</p>');
}
$languageSelector = new TextField('Language', $this->fieldLabel('Language'));
$pageTypeMap = array();
$pageTypes = SiteTree::page_type_classes();
foreach ($pageTypes as $pageType) {
$pageTypeMap[$pageType] = singleton($pageType)->i18n_singular_name();
}
asort($pageTypeMap);
$fields = new FieldList($subsiteTabs = new TabSet('Root', new Tab('Configuration', _t('Subsite.TabTitleConfig', 'Configuration'), new HeaderField($this->getClassName() . ' configuration', 2), new TextField('Title', $this->fieldLabel('Title'), $this->Title), new HeaderField(_t('Subsite.DomainsHeadline', "Domains for this subsite")), $domainTable, $languageSelector, new DropdownField('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme))), new HiddenField('ID', '', $this->ID), new HiddenField('IsSubsite', '', 1));
$subsiteTabs->addExtraClass('subsite-model');
$this->extend('updateCMSFields', $fields);
return $fields;
}