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


PHP Tab::addExtraClass方法代码示例

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


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

示例1: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     // TODO Duplicate record fetching (see parent implementation)
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     // TODO Duplicate record fetching (see parent implementation)
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     $memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldButtonRow('after'))->addComponent(new GridFieldExportButton('buttons-after-left')))->addExtraClass("members_grid");
     if ($record && method_exists($record, 'getValidator')) {
         $validator = $record->getValidator();
     } else {
         $validator = Injector::inst()->get('Member')->getValidator();
     }
     $memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
     $groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
     $columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('Breadcrumbs' => singleton('Group')->fieldLabel('Title')));
     $columns->setFieldFormatting(array('Breadcrumbs' => function ($val, $item) {
         return Convert::raw2xml($item->getBreadcrumbs(' > '));
     }));
     $fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the' . ' database')))), $groupsTab = new Tab('Groups', singleton('Group')->i18n_plural_name(), $groupList)), new HiddenField('ID', false, 0));
     // Add import capabilities. Limit to admin since the import logic can affect assigned permissions
     if (Permission::check('ADMIN')) {
         $fields->addFieldsToTab('Root.Users', array(new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('memberimport')))));
         $fields->addFieldsToTab('Root.Groups', array(new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('groupimport')))));
     }
     // Tab nav in CMS is rendered through separate template
     $root->setTemplate('CMSTabSet');
     // Add roles editing interface
     if (Permission::check('APPLY_ROLES')) {
         $rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
         $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
         $rolesTab->push($rolesField);
     }
     $actionParam = $this->getRequest()->param('Action');
     if ($actionParam == 'groups') {
         $groupsTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'users') {
         $usersTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'roles') {
         $rolesTab->addExtraClass('ui-state-active');
     }
     $actions = new FieldList();
     $form = Form::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Tab nav in CMS is rendered through separate template
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:60,代码来源:SecurityAdmin.php

示例2: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // vars
     $config = SiteConfig::current_site_config();
     $owner = $this->owner;
     // decode data into array
     $data = json_decode($owner->OpenGraphData, true);
     // @todo Add repair method if data is missing / corrupt ~ for fringe cases
     // tab
     $tab = new Tab('OpenGraph');
     // add disabled/error state if `off`
     if ($data['og:type'] === 'off') {
         $tab->addExtraClass('error');
     }
     // add the tab
     $fields->addFieldToTab('Root.Metadata', $tab, 'FullOutput');
     // new identity
     $tab = 'Root.Metadata.OpenGraph';
     // add description
     // type always visible
     $fields->addFieldsToTab($tab, array(LabelField::create('OpenGraphHeader', '@todo Information</a>')->addExtraClass('information'), DropdownField::create('OpenGraphType', '<a href="http://ogp.me/#types">og:type</a>', self::$types, $data['og:type'])));
     if ($data['og:type'] !== 'off') {
         $fields->addFieldsToTab($tab, array(ReadonlyField::create('OpenGraphURL', 'Canonical URL', $owner->AbsoluteLink()), TextField::create('OpenGraphSiteName', 'Site Name', $data['og:site_name'])->setAttribute('placeholder', $config->Title), TextField::create('OpenGraphTitle', 'Page Title', $data['og:title'])->setAttribute('placeholder', $owner->Title), TextareaField::create('OpenGraphDescription', 'Description', $data['og:description'])->setAttribute('placeholder', $owner->GenerateDescription()), UploadField::create('OpenGraphImage', 'Image<pre>type: png/jpg/gif</pre><pre>size: variable *</pre>', $owner->OpenGraphImage)->setAllowedExtensions(array('png', 'jpg', 'jpeg', 'gif'))->setFolderName(self::$SEOOpenGraphUpload . $owner->Title)->setDescription('* <a href="https://developers.facebook.com/docs/sharing/best-practices#images" target="_blank">Facebook image best practices</a>, or use any preferred Open Graph guide.')));
     }
 }
开发者ID:graphiques-digitale,项目名称:silverstripe-seo-open-graph,代码行数:25,代码来源:SEO_OpenGraph_SiteTree_DataExtension.php

示例3: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     $fields = $form->Fields();
     $title = _t('AssetAdmin.FILES', 'Files');
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPaginator(self::config()->page_length), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $gridField = GridField::create('CloudinaryFile', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'NameForSummaryField' => _t('File.Name'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'getSize' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'Date->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')));
         $tabList->addExtraClass("content-listview cms-tabset-icon list");
         $fields->push($tabs);
     }
     $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="drive-upload" href="%s">%s</a>', Controller::join_links(singleton('CloudinaryFileAddController')->Link()), _t('Folder.UploadFilesButton', 'Upload')));
     $actionButtonsComposite = CompositeField::create()->addExtraClass('cms-actions-row');
     $actionButtonsComposite->push($uploadBtn);
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create($actionButtonsComposite)->addExtraClass('cms-content-toolbar field'), $gridField));
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->addExtraClass('cms-edit-form center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:mademedia-silverstripe-cloudinary,代码行数:28,代码来源:CloudinaryAdmin.php

示例4: getCMSFields

 public function getCMSFields()
 {
     $existing_customer = $this->config()->existing_customer_class;
     // Manually inject HTML for totals as Silverstripe refuses to
     // render Currency.Nice any other way.
     $subtotal_html = '<div id="SubTotal" class="field readonly">';
     $subtotal_html .= '<label class="left" for="Form_ItemEditForm_SubTotal">';
     $subtotal_html .= _t("Orders.SubTotal", "Sub Total");
     $subtotal_html .= '</label>';
     $subtotal_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_SubTotal" class="readonly">';
     $subtotal_html .= $this->SubTotal->Nice();
     $subtotal_html .= '</span></div></div>';
     $discount_html = '<div id="Discount" class="field readonly">';
     $discount_html .= '<label class="left" for="Form_ItemEditForm_Discount">';
     $discount_html .= _t("Orders.Discount", "Discount");
     $discount_html .= '</label>';
     $discount_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Discount" class="readonly">';
     $discount_html .= $this->dbObject("DiscountAmount")->Nice();
     $discount_html .= '</span></div></div>';
     $postage_html = '<div id="Postage" class="field readonly">';
     $postage_html .= '<label class="left" for="Form_ItemEditForm_Postage">';
     $postage_html .= _t("Orders.Postage", "Postage");
     $postage_html .= '</label>';
     $postage_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Postage" class="readonly">';
     $postage_html .= $this->Postage->Nice();
     $postage_html .= '</span></div></div>';
     $tax_html = '<div id="TaxTotal" class="field readonly">';
     $tax_html .= '<label class="left" for="Form_ItemEditForm_TaxTotal">';
     $tax_html .= _t("Orders.Tax", "Tax");
     $tax_html .= '</label>';
     $tax_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_TaxTotal" class="readonly">';
     $tax_html .= $this->TaxTotal->Nice();
     $tax_html .= '</span></div></div>';
     $total_html = '<div id="Total" class="field readonly">';
     $total_html .= '<label class="left" for="Form_ItemEditForm_Total">';
     $total_html .= _t("Orders.Total", "Total");
     $total_html .= '</label>';
     $total_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Total" class="readonly">';
     $total_html .= $this->Total->Nice();
     $total_html .= '</span></div></div>';
     $fields = new FieldList($tab_root = new TabSet("Root", $tab_main = new Tab('Main', new OrderItemGridField("Items", "", $this->Items(), $config = GridFieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldDeleteAction(), new GridFieldAddOrderItem())), new HeaderField("PostageDetailsHeader", _t("Orders.PostageDetails", "Postage Details")), TextField::create("PostageType"), TextField::create("PostageCost"), TextField::create("PostageTax"), new HeaderField("DiscountDetailsHeader", _t("Orders.DiscountDetails", "Discount")), TextField::create("Discount"), TextField::create("DiscountAmount"), OrderSidebar::create(ReadonlyField::create("QuoteNumber", "#")->setValue($this->ID), LiteralField::create("SubTotal", $subtotal_html), LiteralField::create("Discount", $discount_html), LiteralField::create("Postage", $postage_html), LiteralField::create("TaxTotal", $tax_html), LiteralField::create("Total", $total_html))->setTitle("Details")), $tab_customer = new Tab('Customer', TextField::create("Company"), TextField::create("FirstName"), TextField::create("Surname"), TextField::create("Address1"), TextField::create("Address2"), TextField::create("City"), TextField::create("PostCode"), TextField::create("Country"), TextField::create("Email"), TextField::create("PhoneNumber"))));
     if ($this->canEdit()) {
         // Sidebar
         $tab_customer->insertBefore(CustomerSidebar::create(new GridField("ExistingCustomers", "", $existing_customer::get(), $config = GridFieldConfig_Base::create()->addComponents($map_extension = new GridFieldMapExistingAction())))->setTitle("Use Existing Customer"), "Company");
         if (is_array($this->config()->existing_customer_fields)) {
             $columns = $config->getComponentByType("GridFieldDataColumns");
             if ($columns) {
                 $columns->setDisplayFields($this->config()->existing_customer_fields);
             }
         }
         // Set the record ID
         $map_extension->setMapFields($this->config()->existing_customer_map);
     }
     $tab_main->addExtraClass("order-admin-items");
     $tab_customer->addExtraClass("order-admin-customer");
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-orders,代码行数:58,代码来源:Estimate.php

示例5: updateMediaForm

 /**
  * Don't pass $form in by reference, as doing so and adding a field creates both a div and an 
  * input with identical IDs - which is both invalid HTML and breaks the ability to click on the
  * label and focus on the input
  */
 public function updateMediaForm($form)
 {
     Requirements::javascript(HTMLEDITORIFRAME_BASE . '/javascript/HtmlEditorField_Iframe.js');
     Requirements::css(HTMLEDITORIFRAME_BASE . '/css/HtmlEditorField_Iframe.css');
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $fromIframe = new CompositeField(new LiteralField('headerIframe', '<h4>' . sprintf($numericLabelTmpl, '1', "Iframe URL") . '</h4>'), $iframeURL = new TextField('IframeURL', 'http://'), new LiteralField('addIframeImage', '<button class="action ui-action-constructive ui-button field add-iframe" data-icon="addMedia">Add url</button>'));
     $iframeURL->addExtraClass('iframeurl');
     $fromIframe->addExtraClass('content ss-uploadfield from-web');
     // $fields->dataFieldByName() doesn't appear to work
     $fields = $form->Fields();
     $tabset = $fields[1]->fieldByName("MediaFormInsertMediaTabs");
     $tabset->push($iFrameTab = new Tab('From an Iframe', $fromIframe));
     $iFrameTab->addExtraClass('htmleditorfield-from-iframe');
     return $form;
 }
开发者ID:kinglozzer,项目名称:htmleditoriframe,代码行数:20,代码来源:HtmlEditorField_Iframe.php

示例6: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     // TODO Duplicate record fetching (see parent implementation)
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     // TODO Duplicate record fetching (see parent implementation)
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     $memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldExportButton()))->addExtraClass("members_grid");
     $memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
     $groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
     $columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('Breadcrumbs' => singleton('Group')->fieldLabel('Title')));
     $fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the database'))), new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" border="0"></iframe>', $this->Link('memberimport')))), $groupsTab = new Tab('Groups', singleton('Group')->plural_name(), $groupList, new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" border="0"></iframe>', $this->Link('groupimport'))))), new HiddenField('ID', false, 0));
     $root->setTemplate('CMSTabSet');
     // Add roles editing interface
     if (Permission::check('APPLY_ROLES')) {
         $rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
         $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
         $rolesTab->push($rolesField);
     }
     $actionParam = $this->request->param('Action');
     if ($actionParam == 'groups') {
         $groupsTab->addExtraClass('ui-state-selected');
     } elseif ($actionParam == 'users') {
         $usersTab->addExtraClass('ui-state-selected');
     } elseif ($actionParam == 'roles') {
         $rolesTab->addExtraClass('ui-state-selected');
     }
     $actions = new FieldList();
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:45,代码来源:SecurityAdmin.php

示例7: getEditForm

 /**
  * The content of the main section of the page
  * List current form fields and allow user to modify their data
  *
  * @see LeftAndMain::getEditForm()
  */
 public function getEditForm($id = null, $fields = null)
 {
     // Save button
     $actions = new FieldList(FormAction::create('save', _t('CMSMain.SAVE', 'Save'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
     // Form tabs
     $fieldsTab = new Tab('Fields', _t('EditableFieldAdmin.Fields', 'Fields'));
     $groupsTab = new Tab('Groups', singleton('Group')->i18n_plural_name());
     // Form tab container
     $tabSet = new TabSet('Root', $fieldsTab, $groupsTab);
     $tabSet->setTemplate('CMSTabSet');
     // Activate tab based on request param
     $actionParam = $this->request->param('Action');
     if ($actionParam == 'fields') {
         $fieldsTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'groups') {
         $groupsTab->addExtraClass('ui-state-active');
     }
     // Form field list
     $fields = new FieldList([$tabSet]);
     // Add field to first tab
     $fields->addFieldToTab('Root.Fields', new EditableFieldEditor("Fields", 'Fields', ""));
     // Add field to second tab
     $groupsConfig = GridFieldConfig_RecordEditor::create();
     $groupsField = GridField::create('EditableFieldGroup', singleton('Group')->i18n_plural_name(), EditableFieldGroup::get(), $groupsConfig);
     $component = $groupsConfig->getComponentByType('GridFieldAddNewButton');
     $component->setButtonName(_t('EditableFieldAdmin.AddGroup', 'Add Group'));
     $fields->addFieldToTab('Root.Groups', $groupsField);
     // The edit form
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->loadDataFrom($this);
     // Render correct responses on validation errors
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->disableDefaultAction();
     // Form layout
     $form->addExtraClass('cms-content cms-edit-form center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     // Allow decorators to modify the form
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:satrun77-editablefield,代码行数:47,代码来源:EditableFieldAdmin.php

示例8: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     $folder = $id && is_numeric($id) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
     $fields = $form->Fields();
     $title = $folder && $folder->exists() ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
     $fields->push(new HiddenField('ID', false, $folder ? $folder->ID : null));
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPaginator(self::config()->page_length), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d'));
     $gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Title' => _t('File.Title', 'Title'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'Size' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if ($folder->canCreate()) {
         $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="drive-upload" href="%s">%s</a>', Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $folder->ID), _t('Folder.UploadFilesButton', 'Upload')));
     } else {
         $uploadBtn = null;
     }
     if (!$folder->hasMethod('canAddChildren') || $folder->hasMethod('canAddChildren') && $folder->canAddChildren()) {
         // TODO Will most likely be replaced by GridField logic
         $addFolderBtn = new LiteralField('AddFolderButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>', Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array('action_doAdd' => 1, 'ParentID' => $folder->ID, 'SecurityID' => $form->getSecurityToken()->getValue()))), Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID), _t('Folder.AddFolderButton', 'Add folder')));
     } else {
         $addFolderBtn = '';
     }
     if ($folder->canEdit()) {
         $syncButton = new LiteralField('SyncButton', sprintf('<a class="ss-ui-button ss-ui-action ui-button-text-icon-primary ss-ui-button-ajax" data-icon="arrow-circle-double" title="%s" href="%s">%s</a>', _t('AssetAdmin.FILESYSTEMSYNCTITLE', 'Update the CMS database entries of files on the filesystem. Useful when new files have been uploaded outside of the CMS, e.g. through FTP.'), $this->Link('doSync'), _t('AssetAdmin.FILESYSTEMSYNC', 'Sync files')));
     } else {
         $syncButton = null;
     }
     // Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
     // Required to keep Folder->getCMSFields() simple and reuseable,
     // without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')), $tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View')));
         $tabList->addExtraClass("content-listview cms-tabset-icon list");
         $tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
         if ($fields->Count() && $folder->exists()) {
             $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
             $tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
             foreach ($fields as $field) {
                 $fields->removeByName($field->getName());
                 $tabDetails->push($field);
             }
         }
         $fields->push($tabs);
     }
     // we only add buttons if they're available. User might not have permission and therefore
     // the button shouldn't be available. Adding empty values into a ComposteField breaks template rendering.
     $actionButtonsComposite = CompositeField::create()->addExtraClass('cms-actions-row');
     if ($uploadBtn) {
         $actionButtonsComposite->push($uploadBtn);
     }
     if ($addFolderBtn) {
         $actionButtonsComposite->push($addFolderBtn);
     }
     if ($syncButton) {
         $actionButtonsComposite->push($syncButton);
     }
     // List view
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create($actionButtonsComposite)->addExtraClass('cms-content-toolbar field'), $gridField));
     $treeField = new LiteralField('Tree', '');
     // Tree view
     $fields->addFieldsToTab('Root.TreeView', array(clone $actionsComposite, new LiteralField('Tree', FormField::create_tag('div', array('class' => 'cms-tree', 'data-url-tree' => $this->Link('getsubtree'), 'data-url-savetreenode' => $this->Link('savetreenode')), $this->SiteTreeAsUL()))));
     // Move actions to "details" tab (they don't make sense on list/tree view)
     $actions = $form->Actions();
     $saveBtn = $actions->fieldByName('action_save');
     $deleteBtn = $actions->fieldByName('action_delete');
     $actions->removeByName('action_save');
     $actions->removeByName('action_delete');
     if (($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
         $fields->addFieldToTab('Root.DetailsView', CompositeField::create($saveBtn, $deleteBtn)->addExtraClass('Actions'));
     }
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // TODO Can't merge $FormAttributes in template at the moment
     $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:82,代码来源:AssetAdmin.php

示例9: getEditForm

 /**
  * Returns a GridField of messages
  * @return CMSForm
  */
 public function getEditForm($id = null, $fields = null)
 {
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     // Build gridfield
     $messageListConfig = GridFieldConfig::create()->addComponents(new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldFooter());
     $messages = $this->Messages();
     if (is_string($messages)) {
         // The api returned an error
         $messagesList = new LiteralField("MessageAlert", '<div class="message bad">' . $messages . '</div>');
     } else {
         $messagesList = GridField::create('Messages', false, $messages, $messageListConfig)->addExtraClass("messages_grid");
         $columns = $messageListConfig->getComponentByType('GridFieldDataColumns');
         $columns->setDisplayFields(['transmission_id' => _t('SparkPostAdmin.EventTransmissionId', 'Id'), 'timestamp' => _t('SparkPostAdmin.EventDate', 'Date'), 'type' => _t('SparkPostAdmin.EventType', 'Type'), 'rcpt_to' => _t('SparkPostAdmin.EventRecipient', 'Recipient'), 'subject' => _t('SparkPostAdmin.EventSubject', 'Subject'), 'friendly_from' => _t('SparkPostAdmin.EventSender', 'Sender')]);
         $columns->setFieldFormatting(['timestamp' => function ($value, &$item) {
             return date('Y-m-d H:i:s', strtotime($value));
         }]);
         // Validator setup
         $validator = null;
         if ($record && method_exists($record, 'getValidator')) {
             $validator = $record->getValidator();
         }
         if ($validator) {
             $messageListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
         }
     }
     // Create tabs
     $messagesTab = new Tab('Messages', _t('SparkPostAdmin.Messages', 'Messages'), $messagesList, new HiddenField('ID', false, 0));
     $fields = new FieldList($root = new TabSet('Root', $messagesTab));
     if ($this->CanConfigureApi()) {
         $settingsTab = new Tab('Settings', _t('SparkPostAdmin.Settings', 'Settings'));
         $webhookTabData = $this->WebhookTab();
         $settingsTab->push($webhookTabData);
         $domainTabData = $this->DomainTab();
         $settingsTab->push($domainTabData);
         $fields->addFieldToTab('Root', $settingsTab);
     }
     // Tab nav in CMS is rendered through separate template
     $root->setTemplate('CMSTabSet');
     // Manage tabs state
     $actionParam = $this->getRequest()->param('Action');
     if ($actionParam == 'setting') {
         $settingsTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'messages') {
         $messagesTab->addExtraClass('ui-state-active');
     }
     $actions = new FieldList();
     // Create cms form
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Tab nav in CMS is rendered through separate template
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:lekoala,项目名称:silverstripe-sparkpost,代码行数:71,代码来源:SparkPostAdmin.php

示例10: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $form = parent::getEditForm($id, $fields);
     $folder = $id && is_numeric($id) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
     $fields = $form->Fields();
     $title = $folder && $folder->exists() ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
     $fields->push(new HiddenField('ID', false, $folder ? $folder->ID : null));
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPaginator(self::config()->page_length), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d'));
     $gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Title' => _t('File.Title', 'Title'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'Size' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if (!$folder->hasMethod('canAddChildren') || $folder->hasMethod('canAddChildren') && $folder->canAddChildren()) {
         // TODO Will most likely be replaced by GridField logic
         $addFolderBtn = new LiteralField('AddFolderButton', sprintf('<a class="ss-ui-button font-icon-folder-add no-text cms-add-folder-link" title="%s" data-icon="add" data-url="%s" href="%s"></a>', _t('Folder.AddFolderButton', 'Add folder'), Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array('action_doAdd' => 1, 'ParentID' => $folder->ID, 'SecurityID' => $form->getSecurityToken()->getValue()))), Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID)));
     } else {
         $addFolderBtn = '';
     }
     // Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
     // Required to keep Folder->getCMSFields() simple and reuseable,
     // without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')), $tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View')));
         $tabList->addExtraClass("content-listview cms-tabset-icon list");
         $tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
         if ($fields->Count() && $folder->exists()) {
             $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
             $tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
             foreach ($fields as $field) {
                 $fields->removeByName($field->getName());
                 $tabDetails->push($field);
             }
         }
         $fields->push($tabs);
     }
     // we only add buttons if they're available. User might not have permission and therefore
     // the button shouldn't be available. Adding empty values into a ComposteField breaks template rendering.
     $actionButtonsComposite = CompositeField::create()->addExtraClass('cms-actions-row');
     if ($addFolderBtn) {
         $actionButtonsComposite->push($addFolderBtn);
     }
     // Add the upload field for new media
     if ($currentPageID = $this->currentPageID()) {
         Session::set("{$this->class}.currentPage", $currentPageID);
     }
     $folder = $this->currentPage();
     $uploadField = UploadField::create('AssetUploadField', '');
     $uploadField->setConfig('previewMaxWidth', 40);
     $uploadField->setConfig('previewMaxHeight', 30);
     $uploadField->setConfig('changeDetection', false);
     $uploadField->addExtraClass('ss-assetuploadfield');
     $uploadField->removeExtraClass('ss-uploadfield');
     $uploadField->setTemplate('AssetUploadField');
     if ($folder->exists()) {
         $path = $folder->getFilename();
         $uploadField->setFolderName($path);
     } else {
         $uploadField->setFolderName('/');
         // root of the assets
     }
     $exts = $uploadField->getValidator()->getAllowedExtensions();
     asort($exts);
     $uploadField->Extensions = implode(', ', $exts);
     // List view
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create($actionButtonsComposite)->addExtraClass('cms-content-toolbar field'), $uploadField, new HiddenField('ID'), $gridField));
     // Tree view
     $fields->addFieldsToTab('Root.TreeView', array(clone $actionsComposite, new LiteralField('Tree', FormField::create_tag('div', array('class' => 'cms-tree', 'data-url-tree' => $this->Link('getsubtree'), 'data-url-savetreenode' => $this->Link('savetreenode')), $this->SiteTreeAsUL()))));
     // Move actions to "details" tab (they don't make sense on list/tree view)
     $actions = $form->Actions();
     $saveBtn = $actions->fieldByName('action_save');
     $deleteBtn = $actions->fieldByName('action_delete');
     $actions->removeByName('action_save');
     $actions->removeByName('action_delete');
     if (($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
         $fields->addFieldToTab('Root.DetailsView', CompositeField::create($saveBtn, $deleteBtn)->addExtraClass('Actions'));
     }
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // TODO Can't merge $FormAttributes in template at the moment
     $form->addExtraClass('cms-edit-form ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:89,代码来源:AssetAdmin.php

示例11: getEditForm

	public function getEditForm($id = null, $fields = null) {
		$form = parent::getEditForm($id, $fields);
		$folder = ($id && is_numeric($id)) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
		$fields = $form->Fields();

		$fields->push(new HiddenField('ID', false, $folder->ID));

		// File listing
		$gridFieldConfig = GridFieldConfig::create()->addComponents(
			new GridFieldSortableHeader(),
			new GridFieldDataColumns(),
			new GridFieldPaginator(15),
			new GridFieldEditButton(),
			new GridFieldDeleteAction(),
			new GridFieldDetailForm()
		);
		$gridField = new GridField('File','Files', $this->getList(), $gridFieldConfig);
		$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
		$columns->setDisplayFields(array(
			'StripThumbnail' => '',
			// 'Parent.FileName' => 'Folder',
			'Title' => _t('File.Name'),
			'Created' => _t('AssetAdmin.CREATED', 'Date'),
			'Size' => _t('AssetAdmin.SIZE', 'Size'),
		));
		$columns->setFieldCasting(array(
			'Created' => 'Date->Nice'
		));
		$gridField->setAttribute(
			'data-url-folder-template', 
			Controller::join_links($this->Link('show'), '%s')
		);

		if($folder->canCreate()) {
			$uploadBtn = new LiteralField(
				'UploadButton', 
				sprintf(
					'<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-target-panel=".cms-content" data-icon="drive-upload" href="%s">%s</a>',
					Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $folder->ID),
					_t('Folder.UploadFilesButton', 'Upload')
				)
			);	
		} else {
			$uploadBtn = null;
		}

		if(!$folder->hasMethod('canAddChildren') || ($folder->hasMethod('canAddChildren') && $folder->canAddChildren())) {
			// TODO Will most likely be replaced by GridField logic
			$addFolderBtn = new LiteralField(
				'AddFolderButton', 
				sprintf(
					'<a class="ss-ui-button ss-ui-action-constructive cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>',
					Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array(
						'action_doAdd' => 1,
						'ParentID' => $folder->ID,
						'SecurityID' => $form->getSecurityToken()->getValue()
					))),
					Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID),
					_t('Folder.AddFolderButton', 'Add folder')
				)
			);
		} else {
			$addFolderBtn = '';
		}

		if($folder->canEdit()) {
			$syncButton = new LiteralField(
				'SyncButton',
				sprintf(
					'<a class="ss-ui-button ss-ui-action ui-button-text-icon-primary ss-ui-button-ajax" title="%s" href="%s">%s</a>',
					_t('AssetAdmin.FILESYSTEMSYNCTITLE', 'Update the CMS database entries of files on the filesystem. Useful when new files have been uploaded outside of the CMS, e.g. through FTP.'),
					$this->Link('doSync'),
					_t('FILESYSTEMSYNC','Sync files')
				)
			);
		} else {
			$syncButton = null;
		}
		
		// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
		// Required to keep Folder->getCMSFields() simple and reuseable,
		// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
		if(!$fields->hasTabset()) {
			$tabs = new TabSet('Root', 
				$tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')),
				$tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View'))
			);
			$tabList->addExtraClass("content-listview");
			$tabTree->addExtraClass("content-treeview");
			if($fields->Count() && $folder->exists()) {
				$tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
				$tabDetails->addExtraClass("content-galleryview");
				foreach($fields as $field) {
					$fields->removeByName($field->getName());
					$tabDetails->push($field);
				}
			}
			$fields->push($tabs);
		}

//.........这里部分代码省略.........
开发者ID:redema,项目名称:silverstripe-cms,代码行数:101,代码来源:AssetAdmin.php


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