本文整理汇总了PHP中GridField::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField::getConfig方法的具体用法?PHP GridField::getConfig怎么用?PHP GridField::getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridField
的用法示例。
在下文中一共展示了GridField::getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testThereIsNoPaginatorWhenOnlyOnePage
function testThereIsNoPaginatorWhenOnlyOnePage()
{
// We set the itemsPerPage to an reasonably big number so as to avoid test broke from small changes on the fixture YML file
$total = $this->list->count();
$this->gridField->getConfig()->getComponentByType("GridFieldPaginator")->setItemsPerPage($total);
$fieldHolder = $this->gridField->FieldHolder();
$content = new CSSContentParser($fieldHolder);
// Check that there is no paginator render into the footer
$this->assertEquals(0, count($content->getBySelector('.datagrid-pagination')));
// Check that there is still 'View 1 - 4 of 4' part on the left of the paginator
$this->assertEquals(1, count($content->getBySelector('.pagination-records-number')));
}
示例2: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// Payment Methods
$payment_table = GridField::create('PaymentMethods', _t("CheckoutAdmin.PaymentMethods", "Payment Methods"), $this->owner->PaymentMethods(), GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm()));
// setup compressed payment options
$payment_fields = ToggleCompositeField::create('PaymentSettings', _t("CheckoutAdmin.Payments", "Payment Settings"), array(TextField::create('PaymentNumberPrefix', _t("CheckoutAdmin.OrderPrefix", "Add prefix to order numbers"), null, 9)->setAttribute("placeholder", _t("CheckoutAdmin.OrderPrefixPlaceholder", "EG 'abc'")), TextAreaField::create('PaymentSuccessContent', _t("CheckoutAdmin.PaymentSuccessContent", "Payment successfull content"))->setRows(4)->setColumns(30)->addExtraClass('stacked'), TextAreaField::create('PaymentFailerContent', _t("CheckoutAdmin.PaymentFailerContent", "Payment failer content"))->setRows(4)->setColumns(30)->addExtraClass('stacked'), $payment_table));
// Add html description of how to edit contries
$country_html = "<div class=\"field\">";
$country_html .= "<p>First select valid countries using the 2 character ";
$country_html .= "shortcode (see http://fasteri.com/list/2/short-names-of-countries-and-iso-3166-codes).</p>";
$country_html .= "<p>You can add multiple countries seperating them with";
$country_html .= "a comma or use a '*' for all countries.</p>";
$country_html .= "</div>";
$country_html_field = LiteralField::create("CountryDescription", $country_html);
// Deal with product features
$postage_field = new GridField('PostageAreas', '', $this->owner->PostageAreas(), GridFieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldToolbarHeader(), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldDeleteAction(), new GridFieldAddNewInlineButton('toolbar-header-left')));
// Add country dropdown to inline editing
$postage_field->getConfig()->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array('Title' => array('title' => 'Title', 'field' => 'TextField'), 'Country' => array('title' => 'ISO 3166 codes', 'field' => 'TextField'), 'ZipCode' => array('title' => 'Zip/Post Codes', 'field' => 'TextField'), 'Calculation' => array('title' => 'Base unit', 'callback' => function ($record, $column, $grid) {
return DropdownField::create($column, "Based on", singleton('PostageArea')->dbObject('Calculation')->enumValues())->setValue("Weight");
}), 'Unit' => array('title' => 'Unit (equals or above)', 'field' => 'NumericField'), 'Cost' => array('title' => 'Cost', 'field' => 'NumericField'), 'Tax' => array('title' => 'Tax (percentage)', 'field' => 'NumericField')));
// Setup compressed postage options
$postage_fields = ToggleCompositeField::create('PostageFields', 'Postage Options', array($country_html_field, $postage_field));
// Setup compressed postage options
$discount_fields = ToggleCompositeField::create('DiscountFields', 'Discounts', array(GridField::create('Discounts', '', $this->owner->Discounts(), GridFieldConfig_RecordEditor::create())));
// Add config sets
$fields->addFieldToTab('Root.Checkout', $payment_fields);
$fields->addFieldToTab('Root.Checkout', $postage_fields);
$fields->addFieldToTab('Root.Checkout', $discount_fields);
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-checkout,代码行数:29,代码来源:CheckoutSiteConfigExtension.php
示例3: getCMSFields
/**
* Returns the input fields for this widget.
*
* @return FieldList
*
* @author Sebastian Diel <sdiel@pixeltricks.de>
* @since 23.02.2016
*/
public function getCMSFields()
{
$fields = SilvercartDataObject::getCMSFields($this, 'ExtraCssClasses', false);
$slideImagesTable = new GridField('slideImages', $this->fieldLabel('slideImages'), $this->slideImages(), SilvercartGridFieldConfig_RelationEditor::create());
$slideImagesTable->getConfig()->removeComponentsByType('GridFieldAddNewButton');
$slideImagesTable->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter');
$slideImagesTable->getConfig()->addComponent(new GridFieldDeleteAction());
$slideImagesUploadField = new SilvercartImageUploadField('UploadslideImages', $this->fieldLabel('AddImage'));
$slideImagesUploadField->setFolderName('Uploads/slider-images');
$slideImagesUploadField->setRelationClassName('SilvercartImageSliderImage');
$fields->findOrMakeTab('Root.slideImages', $this->fieldLabel('slideImages'));
$fields->addFieldToTab('Root.slideImages', $slideImagesUploadField);
$fields->addFieldToTab('Root.slideImages', $slideImagesTable);
$this->getCMSFieldsSliderTab($fields);
return $fields;
}
示例4: setupGridField
protected function setupGridField(GridField $gridfield, Config_ForClass $classConfig)
{
if (!$gridfield) {
return;
}
$config = $gridfield->getConfig();
$class = $gridfield->getModelClass();
// More item per page
$paginator = $config->getComponentByType('GridFieldPaginator');
$paginator->setItemsPerPage(50);
// Bulk manage
if ($classConfig->bulk_manage && class_exists('GridFieldBulkManager')) {
$already = $config->getComponentByType('GridFieldBulkManager');
if (!$already) {
$config->addComponent($bulkManager = new GridFieldBulkManager());
$bulkManager->removeBulkAction('unLink');
}
}
// Better export
if ($classConfig->export_csv) {
/* @var $export GridFieldExportButton */
$export = $config->getComponentByType('GridFieldExportButton');
$export->setExportColumns(ExcelImportExport::exportFieldsForClass($class));
} else {
$config->removeComponentsByType('GridFieldExportButton');
}
if ($classConfig->export_excel) {
if ($class == 'Group') {
$config->addComponent(new GridFieldButtonRow('after'));
}
$config->addComponent(new ExcelGridFieldExportButton('buttons-after-left'));
}
}
示例5: handleSave
public function handleSave(GridField $grid, DataObjectInterface $record)
{
$list = $grid->getList();
$value = $grid->Value();
if (!isset($value[__CLASS__]) || !is_array($value[__CLASS__])) {
return;
}
/** @var GridFieldOrderableRows $sortable */
$sortable = $grid->getConfig()->getComponentByType('GridFieldOrderableRows');
$form = $this->getForm($grid, $record);
foreach ($value[__CLASS__] as $id => $fields) {
if (!is_numeric($id) || !is_array($fields)) {
continue;
}
$item = $list->byID($id);
if (!$item || !$item->canEdit()) {
continue;
}
$extra = array();
$form->loadDataFrom($fields, Form::MERGE_CLEAR_MISSING);
$form->saveInto($item);
// Check if we are also sorting these records
if ($sortable) {
$sortField = $sortable->getSortField();
$item->setField($sortField, $fields[$sortField]);
}
if ($list instanceof ManyManyList) {
$extra = array_intersect_key($form->getData(), (array) $list->getExtraFields());
}
$item->write();
$list->add($item, $extra);
}
}
示例6: updateCMSFields
function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.MaxCarouselItems', $grid = new GridField('MaxCarouselItems', 'Carousel items', $this->owner->sortedMaxCarouselItems(), GridFieldConfig_RelationEditor::create(10)));
if (class_exists("GridFieldSortableRows")) {
$grid->getConfig()->addComponent(new GridFieldSortableRows('SortOrder'));
}
}
示例7: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
$pictures_per_page = $this->config()->get('picturesPerPage');
$conf = GridFieldConfig_RelationEditor::create($pictures_per_page);
$conf->getComponentByType('GridFieldPaginator')->setItemsPerPage($pictures_per_page);
$conf->addComponent(new GridFieldBulkUpload());
$conf->addComponent(new GridFieldSortableRows('Sort'));
$imageFolder = $this->config()->get('imageFolder');
if ($this->config()->get('usePageURLSegmentAsSubfolder')) {
$imageFolder = preg_replace("/^(.+?)\\/*\$/", '$1/', $imageFolder) . $this->URLSegment;
}
$conf->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $imageFolder);
$gridField = new GridField('Pictures', 'Pictures', $this->SortedPictures(), $conf);
$dataColumns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$imageFieldMapping = $this->config()->get('galleryImageListFieldMapping');
foreach ($imageFieldMapping as $key => $value) {
$imageFieldMapping[$key] = _t('GalleryPicture.' . $key, $value);
}
$dataColumns->setDisplayFields($imageFieldMapping);
if ($this->ID > 0) {
$fields->addFieldsToTab('Root.' . _t('GalleryPage.Photos', 'Photos'), array($gridField));
}
return $fields;
}
示例8: saveAllRecords
protected function saveAllRecords(\GridField $grid, $arguments, $data)
{
if (isset($data[$grid->Name])) {
$currValue = $grid->Value();
$grid->setValue($data[$grid->Name]);
$model = singleton($grid->List->dataClass());
foreach ($grid->getConfig()->getComponents() as $component) {
if ($component instanceof \GridField_SaveHandler) {
$component->handleSave($grid, $model);
}
}
if ($this->publish) {
// Only use the viewable list items, since bulk publishing can take a toll on the system
$list = ($paginator = $grid->getConfig()->getComponentByType('GridFieldPaginator')) ? $paginator->getManipulatedData($grid, $grid->List) : $grid->List;
$list->each(function ($item) {
if ($item->hasExtension('Versioned')) {
$item->writeToStage('Stage');
$item->publish('Stage', 'Live');
}
});
}
if ($model->exists()) {
$model->delete();
$model->destroy();
}
$grid->setValue($currValue);
if (\Controller::curr() && ($response = \Controller::curr()->Response)) {
if (!$this->completeMessage) {
$this->completeMessage = _t('GridField.DONE', 'Done.');
}
$response->addHeader('X-Status', rawurlencode($this->completeMessage));
}
}
}
示例9: testFieldFormatting
/**
* @covers GridFieldDataColumns::getFieldFormatting
* @covers GridFieldDataColumns::setFieldFormatting
*/
public function testFieldFormatting() {
$obj = new GridField('testfield', 'testfield');
$columns = $obj->getConfig()->getComponentByType('GridFieldDataColumns');
$this->assertEquals(array(), $columns->getFieldFormatting());
$columns->setFieldFormatting(array("myFieldName" => '<a href=\"custom-admin/$ID\">$ID</a>'));
$this->assertEquals(array("myFieldName" => '<a href=\"custom-admin/$ID\">$ID</a>'), $columns->getFieldFormatting());
}
示例10: updateCMSFields
function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.SkitterSlides', $grid = new GridField('MaxSkitterSlides', 'Skitter slides', $this->owner->MaxSkitterSlides(), GridFieldConfig_RelationEditor::create(10)));
if (class_exists("GridFieldSortableRows")) {
$grid->getConfig()->addComponent(new GridFieldSortableRows('SortOrder'));
}
}
示例11: testGetManipulatedData
public function testGetManipulatedData()
{
$list = new DataList('GridFieldSortableHeaderTest_Team');
$config = new GridFieldConfig_RecordEditor();
$gridField = new GridField('testfield', 'testfield', $list, $config);
// Test normal sorting
$state = $gridField->State->GridFieldSortableHeader;
$state->SortColumn = 'City';
$state->SortDirection = 'asc';
$compontent = $gridField->getConfig()->getComponentByType('GridFieldSortableHeader');
$listA = $compontent->getManipulatedData($gridField, $list);
$state->SortDirection = 'desc';
$listB = $compontent->getManipulatedData($gridField, $list);
$this->assertEquals(array('Auckland', 'Cologne', 'Melbourne', 'Wellington'), $listA->column('City'));
$this->assertEquals(array('Wellington', 'Melbourne', 'Cologne', 'Auckland'), $listB->column('City'));
// Test one relation 'deep'
$state->SortColumn = 'Cheerleader.Name';
$state->SortDirection = 'asc';
$relationListA = $compontent->getManipulatedData($gridField, $list);
$state->SortDirection = 'desc';
$relationListB = $compontent->getManipulatedData($gridField, $list);
$this->assertEquals(array('Wellington', 'Melbourne', 'Cologne', 'Auckland'), $relationListA->column('City'));
$this->assertEquals(array('Auckland', 'Cologne', 'Melbourne', 'Wellington'), $relationListB->column('City'));
// Test two relations 'deep'
$state->SortColumn = 'Cheerleader.Hat.Colour';
$state->SortDirection = 'asc';
$relationListC = $compontent->getManipulatedData($gridField, $list);
$state->SortDirection = 'desc';
$relationListD = $compontent->getManipulatedData($gridField, $list);
$this->assertEquals(array('Cologne', 'Auckland', 'Wellington', 'Melbourne'), $relationListC->column('City'));
$this->assertEquals(array('Melbourne', 'Wellington', 'Auckland', 'Cologne'), $relationListD->column('City'));
}
示例12: convertToReadonly
/**
* Converts a GridField into a read only one.
*
* @param GridField $gridField GridField to convert
*
* @return void
*
* @author Sebastian Diel <sdiel@pixeltricks.de>
* @since 08.03.2013
*/
public static function convertToReadonly(GridField $gridField)
{
$gridFieldConfig = $gridField->getConfig();
$gridFieldConfig->removeComponentsByType('GridFieldEditButton');
$gridFieldConfig->removeComponentsByType('GridFieldDeleteAction');
$gridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
$gridFieldConfig->removeComponentsByType('GridFieldAddExistingAutocompleter');
}
示例13: getPaginator
/**
* Retrieves an instance of a GridFieldPaginator attached to the same control
* @param GridField $gridField The parent gridfield
* @return GridFieldPaginator The attached GridFieldPaginator, if found.
* @throws LogicException
*/
protected function getPaginator($gridField)
{
$paginator = $gridField->getConfig()->getComponentByType('GridFieldPaginator');
if (!$paginator && Config::inst()->get('GridFieldPageCount', 'require_paginator')) {
throw new LogicException(get_class($this) . " relies on a GridFieldPaginator to be added " . "to the same GridField, but none are present.");
}
return $paginator;
}
示例14: getManipulatedData
public function getManipulatedData(GridField $grid, SS_List $data)
{
$config = $grid->getConfig();
$config->removeComponentsByType('GridFieldDeleteAction');
$config->removeComponentsByType('GridFieldEditButton');
$class = $data->dataClass;
return $class::get();
}
示例15: testGridFieldSetCustomConfig
/**
* @covers GridField::__construct
* @covers GridField::setComponents
*/
public function testGridFieldSetCustomConfig()
{
$config = GridFieldConfig::create();
$config->addComponent(new GridFieldSortableHeader());
$config->addComponent(new GridFieldDataColumns());
$obj = new GridField('testfield', 'testfield', ArrayList::create(array()), $config);
$expectedComponents = new ArrayList(array(0 => new GridFieldSortableHeader(), 1 => new GridFieldDataColumns(), 2 => new GridState_Component()));
$this->assertEquals($expectedComponents, $obj->getConfig()->getComponents(), 'Testing default Config');
}