public function __construct($controller, $name, $show_actions = true)
 {
     $TempBasketID = Store_BasketController::get_temp_basket_id();
     $order_id = DB::Query("SELECT id FROM `order` WHERE (`TempBasketID`='" . $TempBasketID . "')")->value();
     /* Basket GridField */
     $config = new GridFieldConfig();
     $dataColumns = new GridFieldDataColumns();
     $dataColumns->setDisplayFields(array('getPhoto' => "Photo", 'Title' => 'Product', 'Price' => 'Item Price', 'Quantity' => 'Quantity', 'productPrice' => 'Total Price', 'getfriendlyTaxCalculation' => 'Tax Inc/Exc', 'TaxClassName' => 'Tax'));
     $config->addComponent($dataColumns);
     $config->addComponent(new GridFieldTitleHeader());
     $basket = GridField::create("BasketItems", "", DataObject::get("Order_Items", "(OrderID='" . $order_id . "')"), $config);
     /* Basket Subtotal */
     $subtotal = new Order();
     $subtotal = $subtotal->calculateSubTotal($order_id);
     $subtotal = ReadonlyField::create("SubTotal", "Basket Total (" . Product::getDefaultCurrency() . ")", $subtotal);
     /* Fields */
     $fields = FieldList::create($basket, $subtotal, ReadonlyField::create("Tax", "Tax", "Calculated on the Order Summary page."));
     /* Actions */
     $actions = FieldList::create(CompositeField::create(FormAction::create('continueshopping', 'Continue Shopping'), FormAction::create('placeorder', 'Place Order')));
     /* Required Fields */
     $required = new RequiredFields(array());
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $show_actions ? $actions : FieldList::create(), $required);
 }
Exemplo n.º 2
0
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Values');
     $values = new GridField("Values", "SubmittedFormField", $this->Values()->sort('Created', 'ASC'));
     $config = new GridFieldConfig();
     $config->addComponent(new GridFieldDataColumns());
     $config->addComponent(new GridFieldExportButton());
     $config->addComponent(new GridFieldPrintButton());
     $values->setConfig($config);
     $fields->addFieldToTab('Root.Main', $values);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $staff_config = GridFieldConfig::create()->addComponents(new GridFieldSortableRows('SortOrder'), new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(10), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fields->addFieldToTab('Root.Content.StaffMembers', new GridField('StaffMembers', 'Staff Members', $this->StaffMembers(), $staff_config));
     return $fields;
 }
 function updateCMSFields(FieldList $fields)
 {
     //prevent certain pages from having a Document tab in the CMS
     if (in_array($this->owner->ClassName, self::$noDocumentsList)) {
         return;
     }
     //javascript to customize the grid field for the DMS document (overriding entwine in FRAMEWORK_DIR.'/javascript/GridField.js'
     Requirements::javascript(DMS_DIR . '/javascript/DMSGridField.js');
     Requirements::css(DMS_DIR . '/css/DMSMainCMS.css');
     //javascript for the link editor pop-up in TinyMCE
     Requirements::javascript(DMS_DIR . "/javascript/DocumentHtmlEditorFieldToolbar.js");
     // Document listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldEditButton(), new DMSGridFieldDeleteAction(), new GridFieldDetailForm());
     if (class_exists('GridFieldPaginatorWithShowAll')) {
         $paginatorComponent = new GridFieldPaginatorWithShowAll(15);
     } else {
         $paginatorComponent = new GridFieldPaginator(15);
     }
     $gridFieldConfig->addComponent($paginatorComponent);
     if (class_exists('GridFieldSortableRows')) {
         $sortableComponent = new GridFieldSortableRows('DocumentSort');
         $sortableComponent->setUsePagination(false)->setForceRedraw(true);
         $gridFieldConfig->addComponent($sortableComponent);
     }
     // HACK: Create a singleton of DMSDocument to ensure extensions are applied before we try to get display fields.
     singleton('DMSDocument');
     $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(Config::inst()->get('DMSDocument', 'display_fields'))->setFieldCasting(array('LastChanged' => "Datetime->Ago"))->setFieldFormatting(array('FilenameWithoutID' => '<a target=\'_blank\' class=\'file-url\' href=\'$Link\'>$FilenameWithoutID</a>'));
     //override delete functionality with this class
     $gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest');
     $gridField = GridField::create('Documents', false, $this->owner->Documents()->Sort('DocumentSort'), $gridFieldConfig);
     $gridField->addExtraClass('documents');
     $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="add" href="%s">%s</a>', Controller::join_links(singleton('DMSDocumentAddController')->Link(), '?ID=' . $this->owner->ID), "Add Documents"));
     $fields->addFieldsToTab('Root.Documents (' . $this->owner->Documents()->Count() . ')', array($uploadBtn, $gridField));
 }
Exemplo n.º 5
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Hide the calendar locations tab
     $fields->removeByName('Locations');
     // Use the time picker field
     $fields->addFieldToTab('Root.Main', new TimePickerField('StartTime'), 'Description');
     $fields->addFieldToTab('Root.Main', new TimePickerField('EndTime'), 'Description');
     // Add a private flag
     $fields->addFieldToTab('Root.Main', new CheckboxField('Private', 'Private Booking'), 'Description');
     // Add the locations
     $fields->addFieldToTab('Root.Main', new CheckboxSetField('Locations', 'Locations', CalendarLocation::get()->map('ID', 'Name')), 'Description');
     // Create a default configuration for the new GridField, allowing record deletion
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldButtonRow('before'));
     $config->addComponent(new GridFieldToolbarHeader());
     $config->addComponent(new GridFieldEditableColumns());
     $config->addComponent(new GridFieldDeleteAction());
     $config->addComponent(new GridFieldAddNewInlineButton());
     // Create a gridfield to hold the dates
     $externalLinksGridField = new GridField('CalendarEventDatesGrid', 'Dates', $this->CalendarEventDates(), $config);
     $fields->addFieldToTab('Root.Main', $externalLinksGridField, 'Description');
     // Hide the calendar event date tab
     $fields->removeByName('CalendarEventDates');
     return $fields;
 }
 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);
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('LinkedFromCities');
     $grid = new GridField('LinkedToCities', $this->fieldLabel('LinkedToCities'), $this->LinkedToCities(), GridFieldConfig::create()->addComponent(new GridFieldDetailForm())->addComponent(new GridFieldButtonRow())->addComponent($GridFieldAddExistingSearchButton = new GridFieldAddExistingSearchButton('buttons-before-right'))->addComponent($GridFieldAddExistingAutocompleter = new GridFieldAddExistingAutocompleter('buttons-before-right'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent($comp = new GridFieldEditableColumns())->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction('unlinkrelation'))->addComponent(new GridFieldDeleteAction())->addComponent($GridFieldAddNewInlineButton = new GridFieldAddNewInlineButton()));
     $GridFieldAddNewInlineButton->setTitle(_t(__CLASS__ . '.AddNewCity', 'Add new city'));
     $GridFieldAddExistingSearchButton->setTitle(_t(__CLASS__ . '.SearchAndAddExistingCity', 'Search and add existing city'));
     $LinkTargetField = MapaelCountryPageExtension::getTargetField($this, 'LinkTarget');
     $LinkTargetField->setTitle(_t(__CLASS__ . '.LinkTarget', 'Link target'));
     $field_names = array_keys(array_merge($this->summaryFields(), self::$many_many_extraFields['LinkedToCities']));
     $arr = array();
     foreach ($field_names as $name) {
         preg_match('/(TooltipContent|Href|Target)$/', $name, $matches);
         $title = $this->fieldLabel($name);
         $arr[$name] = $title;
         if ($matches) {
             $arr[$name] = array('title' => $title, 'callback' => function ($record, $column, $grid) {
                 preg_match('/(TooltipContent|Href|Target)$/', $column, $matches);
                 return MapaelCountryPageExtension::getAttrField($record, $matches[1], $column);
             });
         }
     }
     $comp->setDisplayFields($arr);
     $fields->replaceField('LinkedToCities', $grid);
     $fields->replaceField('Target', MapaelCountryPageExtension::getTargetField($this));
     $fields->replaceField('Href', MapaelCountryPageExtension::getHrefField($this));
     $fields->replaceField('TooltipContent', MapaelCountryPageExtension::getTooltipContentField($this));
     return $fields;
 }
Exemplo n.º 8
0
 function getCMSFields()
 {
     if ($this->ID != 0) {
         $totalCount = $this->getTotalVotes();
     } else {
         $totalCount = 0;
     }
     $fields = new FieldList($rootTab = new TabSet("Root", new Tab("Main", new TextField('Title', 'Poll title (maximum 50 characters)', null, 50), new OptionsetField('MultiChoice', 'Single answer (radio buttons)/multi-choice answer (tick boxes)', array(0 => 'Single answer', 1 => 'Multi-choice answer')), new OptionsetField('IsActive', 'Poll state', array(1 => 'Active', 0 => 'Inactive')), $embargo = new DatetimeField('Embargo', 'Embargo'), $expiry = new DatetimeField('Expiry', 'Expiry'), new HTMLEditorField('Description', 'Description'))));
     $embargo->getDateField()->setConfig('showcalendar', true);
     $embargo->getTimeField()->setConfig('showdropdown', true);
     $embargo->getDateField()->setConfig('dateformat', 'dd/MM/YYYY');
     $embargo->getTimeField()->setConfig('timeformat', 'h:m a');
     $expiry->getDateField()->setConfig('showcalendar', true);
     $expiry->getTimeField()->setConfig('showdropdown', true);
     $expiry->getDateField()->setConfig('dateformat', 'dd/MM/YYYY');
     $expiry->getTimeField()->setConfig('timeformat', 'h:m a');
     // Add the fields that depend on the poll being already saved and having an ID
     if ($this->ID != 0) {
         $config = GridFieldConfig::create();
         $config->addComponent(new GridFieldToolbarHeader());
         $config->addComponent(new GridFieldAddNewButton('toolbar-header-right'));
         $config->addComponent(new GridFieldDataColumns());
         $config->addComponent(new GridFieldEditButton());
         $config->addComponent(new GridFieldDeleteAction());
         $config->addComponent(new GridFieldDetailForm());
         $config->addComponent(new GridFieldSortableHeader());
         $pollChoicesTable = new GridField('Choices', 'Choices', $this->Choices(), $config);
         $fields->addFieldToTab('Root.Data', $pollChoicesTable);
         $fields->addFieldToTab('Root.Data', new ReadonlyField('Total', 'Total votes', $totalCount));
     } else {
         $fields->addFieldToTab('Root.Choices', new ReadOnlyField('ChoicesPlaceholder', 'Choices', 'You will be able to add options once you have saved the poll for the first time.'));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Exemplo n.º 9
0
 public function tasklist()
 {
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fields = new FieldList($gridField = new GridField('TaskGrid', 'Example grid', new DataList('Task'), $gridFieldConfig));
     $actions = new FieldList();
     return new Form($this, 'tasklist', $fields, $actions);
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Capacity');
     $fields->removeByName('Registrations');
     $fields->removeByName('Tickets');
     $fields->removeByName('EmailReminder');
     $fields->removeByName('RemindDays');
     $fields->removeByName('PaymentID');
     $fields->removeByName('ReminderJobID');
     if (!$this->isInDB()) {
         $fields->push(new LiteralField('RegistrationNote', '<p>You can configure registration once ' . 'you save for the first time.</p>'));
         return $fields;
     }
     $fields->push(new GridField('Tickets', _t('EventManagement.AVAILABLE_TICKETS', 'Available Tickets'), $this->Tickets(), GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent($add = new GridFieldAddExistingSearchButton())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($editable = new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction(true))));
     $fields->push($capacity = new NumericField('Capacity', _t('EventManagement.CAPACITY', 'Capacity')));
     $editable->setDisplayFields(array('Title' => array('title' => 'Title', 'field' => 'ReadonlyField'), 'StartSummary' => 'Sales Start', 'PriceSummary' => 'Price', 'Available' => array('field' => 'NumericField')));
     $add->setTitle(_t('EventManagement.ADD_TICKET_TYPE', 'Add Ticket Type'));
     $capacity->setDescription('Set to 0 for unlimited capacity.');
     if (class_exists('AbstractQueuedJob')) {
         if ($this->ReminderJobID && $this->ReminderJob()->StepsProcessed) {
             $fields->push(new LiteralField('RemindersAlreadySent', '<p>Reminder emails have already been sent out.</p>'));
         } else {
             $fields->push(new CheckboxField('EmailReminder', _t('EventManagement.SEND_REMINDER_EMAIL', 'Send the registered attendees a reminder email?')));
             $fields->push($remindDays = new NumericField('RemindDays', _t('EventManagement.SEND_REMINDER', 'Send reminder')));
             $remindDays->setDescription(_t('EventManagement.DAYS_BEFORE_EVENT', 'Days before the event starts.'));
         }
     }
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     // check if the insertbefore field is present (may be added later, in which case the above
     // fields never get added
     //$insertOnTab = $this->owner->getFilterableArchiveConfigValue('pagination_control_tab');
     //$insertBefore = $this->owner->getFilterableArchiveConfigValue('pagination_insert_before');
     $insertOnTab = Config::inst()->get($this->owner->className, 'pagination_control_tab');
     $insertBefore = Config::inst()->get($this->owner->className, 'pagination_insert_before');
     if (!$fields->fieldByName("{$insertOnTab}.{$insertBefore}")) {
         $insertBefore = null;
     }
     //if($this->owner->getFilterableArchiveConfigValue('datearchive_active')){
     if (Config::inst()->get($this->owner->className, 'datearchive_active')) {
         //$fields->addFieldToTab($this->owner->getFilterableArchiveConfigValue('pagination_control_tab'),
         $fields->addFieldToTab(Config::inst()->get($this->owner->className, 'pagination_control_tab'), DropdownField::create('ArchiveUnit', _t('filterablearchive.ARCHIVEUNIT', 'Archive unit'), array('year' => _t('filterablearchive.YEAR', 'Year'), 'month' => _t('filterablearchive.MONTH', 'Month'), 'day' => _t('filterablearchive.DAY', 'Day'))), $insertBefore);
     }
     $pagerField = NumericField::create("ItemsPerPage", _t("filterablearchive.ItemsPerPage", "Pagination: items per page"))->setRightTitle(_t("filterablearchive.LeaveEmptyForNone", "Leave empty or '0' for no pagination"));
     $fields->addFieldToTab($insertOnTab, $pagerField, $insertBefore);
     //
     // Create categories and tag config
     //
     //		$config = GridFieldConfig_RecordEditor::create();
     //		$config->removeComponentsByType("GridFieldAddNewButton");
     //		$config->addComponent(new GridFieldAddByDBField("buttons-before-left"));
     // Lets just use what others have made already...
     $config = GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldAddNewInlineButton('toolbar-header-right'));
     //if($this->owner->getFilterableArchiveConfigValue('categories_active')){
     if (Config::inst()->get($this->owner->className, 'categories_active')) {
         $fields->addFieldToTab($insertOnTab, $categories = GridField::create("Categories", _t("FilterableArchive.Categories", "Categories"), $this->owner->Categories(), $config), $insertBefore);
     }
     //if($this->owner->getFilterableArchiveConfigValue('tags_active')){
     if (Config::inst()->get($this->owner->className, 'tags_active')) {
         $fields->addFieldToTab($insertOnTab, $tags = GridField::create("Tags", _t("FilterableArchive.Tags", "Tags"), $this->owner->Tags(), $config), $insertBefore);
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     // Add config sets
     $fields->addFieldToTab('Root.Catalogue', UploadField::create('DefaultProductImage', _t("Catalogue.DefaultProductImage", 'Default product image')));
     // Add config sets
     $fields->addFieldToTab('Root.Catalogue', GridField::create('TaxRates', _t("Catalogue.TaxRates", "Tax Rates"), TaxRate::get(), GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm())));
 }
Exemplo n.º 13
0
	public function setUp() {
		parent::setUp();
		$this->list = new DataList('GridFieldAction_Edit_Team');
		$config = GridFieldConfig::create()->addComponent(new GridFieldEditButton());
		$this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
		$this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
	}
 public function Form()
 {
     $player = DataObject::get('GridFieldTest_Player')->find('Email', '*****@*****.**');
     $config = GridFieldConfig::create()->addComponents($relationComponent = new GridFieldAddExistingAutocompleter('before', 'Name'), new GridFieldDataColumns());
     $field = new GridField('testfield', 'testfield', $player->Teams(), $config);
     return new Form($this, 'Form', new FieldList($field), new FieldList());
 }
Exemplo n.º 15
0
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Create a default configuration for the new GridField, allowing record deletion
     $config = GridFieldConfig_RecordEditor::create();
     // Set the names and data for our gridfield columns
     $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Title' => 'Title', 'StartTime' => 'Start Time', 'EndTime' => 'End Time'));
     // Create a gridfield to hold the calendar event relationship
     $calendarEventsGridField = new GridField('CalendarEvents', 'Calendar Events', $this->CalendarEvents(), $config);
     // Create a tab named "Calendar" and add our field to it
     $fields->addFieldToTab('Root.Calendar', $calendarEventsGridField);
     // Create a default configuration for the location GridField, allowing record deletion
     $locationsConfig = GridFieldConfig::create();
     $locationsConfig->addComponent(new GridFieldButtonRow('before'));
     $locationsConfig->addComponent(new GridFieldToolbarHeader());
     $locationsConfig->addComponent(new GridFieldTitleHeader());
     $locationsConfig->addComponent(new GridFieldEditableColumns());
     $locationsConfig->addComponent(new GridFieldDeleteAction());
     $locationsConfig->addComponent(new GridFieldAddNewInlineButton());
     // Create a gridfield to hold the locations
     $locationsGridField = new GridField('CalendarLocations', 'Calendar Locations', $this->CalendarLocations(), $locationsConfig);
     // Create a tab named "Locations" and add our field to it
     $fields->addFieldToTab('Root.Locations', $locationsGridField);
     return $fields;
 }
Exemplo n.º 16
0
	public function testRemoveComponents() {
		$config = GridFieldConfig::create()
			->addComponent($c1 = new GridFieldConfigTest_MyComponent())
			->addComponent($c2 = new GridFieldConfigTest_MyComponent())
			->addComponent($c3 = new GridFieldConfigTest_MyOtherComponent())
			->addComponent($c4 = new GridFieldConfigTest_MyOtherComponent());

		$this->assertEquals(
			4, 
			$config->getComponents()->count()
		);
		
		$config->removeComponent($c1);
		$this->assertEquals(
			3, 
			$config->getComponents()->count()
		);
		
		$config->removeComponentsByType("GridFieldConfigTest_MyComponent");
		$this->assertEquals(
			2, 
			$config->getComponents()->count()
		);
		
		$config->removeComponentsByType("GridFieldConfigTest_MyOtherComponent");
		$this->assertEquals(
			0, 
			$config->getComponents()->count()
		);
	}
Exemplo n.º 17
0
 /**
  * @return Form
  */
 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);
     }
     $commentsConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldSortableHeader(), new GridFieldPaginator(25), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldExportButton(), new GridFieldEditButton(), new GridFieldDetailForm());
     $needs = new GridField('Comments', _t('CommentsAdmin.NeedsModeration', 'Needs Moderation'), Comment::get()->where('Moderated = 0'), $commentsConfig);
     $moderated = new GridField('CommentsModerated', _t('CommentsAdmin.CommentsModerated'), Comment::get()->where('Moderated = 1'), $commentsConfig);
     $fields = new FieldList($root = new TabSet('Root', new Tab('NeedsModeration', _t('CommentAdmin.NeedsModeration', 'Needs Moderation'), $needs), new Tab('Comments', _t('CommentAdmin.Moderated', 'Moderated'), $moderated)));
     $root->setTemplate('CMSTabSet');
     $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());
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
Exemplo n.º 18
0
 /**
  * Gets the field editor, for adding and removing EditableFormFields.
  *
  * @return GridField
  */
 public function getFieldEditorGrid()
 {
     Requirements::javascript(USERFORMS_DIR . '/javascript/FieldEditor.js');
     $fields = $this->Fields();
     $editableColumns = new GridFieldEditableColumns();
     $fieldClasses = singleton('EditableFormField')->getEditableFieldClasses();
     $editableColumns->setDisplayFields(array('ClassName' => function ($record, $column, $grid) use($fieldClasses) {
         if ($record instanceof EditableFormField) {
             return $record->getInlineClassnameField($column, $fieldClasses);
         }
     }, 'Title' => function ($record, $column, $grid) {
         if ($record instanceof EditableFormField) {
             return $record->getInlineTitleField($column);
         }
     }));
     $config = GridFieldConfig::create()->addComponents($editableColumns, new GridFieldButtonRow(), GridFieldAddClassesButton::create('EditableTextField')->setButtonName(_t('UserFormFieldEditorExtension.ADD_FIELD', 'Add Field'))->setButtonClass('ss-ui-action-constructive'), GridFieldAddClassesButton::create('EditableFormStep')->setButtonName(_t('UserFormFieldEditorExtension.ADD_PAGE_BREAK', 'Add Page Break')), GridFieldAddClassesButton::create(array('EditableFieldGroup', 'EditableFieldGroupEnd'))->setButtonName(_t('UserFormFieldEditorExtension.ADD_FIELD_GROUP', 'Add Field Group')), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldToolbarHeader(), new GridFieldDetailForm());
     $fieldEditor = GridField::create('Fields', _t('UserDefinedForm.FIELDS', 'Fields'), $fields, $config)->addExtraClass('uf-field-editor');
     if (Config::inst()->get('UserFormFieldEditorExtension', 'showAddEdit')) {
         $addFieldAction->setTitle(_t('UserFormFieldEditorExtension.ADD_EDIT_FIELD', 'Add & Edit Field'));
         $fields = $addFieldAction->getClasses($fieldEditor);
         $fields = array_diff_key($fields, array_flip(array('EditableFormStep', 'EditableFieldGroup', 'EditableFieldGroupEnd')));
         asort($fields);
         $addFieldAction->setClasses($fields);
     }
     return $fieldEditor;
 }
 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;
 }
Exemplo n.º 20
0
	public function setUp() {
		parent::setUp();

		$this->list = new DataList('GridFieldExportButtonTest_Team');
		$config = GridFieldConfig::create()->addComponent(new GridFieldExportButton());
		$this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
	}
 public function getCMSFields()
 {
     $DefaultAlbumCoverField = UploadField::create('DefaultAlbumCover');
     $DefaultAlbumCoverField->folderName = "PhotoGallery";
     $DefaultAlbumCoverField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     $fields = parent::getCMSFields();
     $AlbumsGridField = new GridField("PhotoAlbums", "Album", $this->PhotoAlbums(), GridFieldConfig::create()->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldAddNewButton('toolbar-header-right'))->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldDataColumns())->addComponent(new GridFieldPaginator(50))->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm())->addComponent(new GridFieldFilterHeader())->addComponent($sortable = new GridFieldSortableRows('SortID')));
     if ($this->AlbumDefaultTop == true) {
         $sortable->setAppendToTop(true);
     }
     $fields->addFieldToTab("Root.Albums", $AlbumsGridField);
     $fields->addFieldToTab("Root.Config", HeaderField::create("Album Settings"));
     $fields->addFieldToTab("Root.Config", $DefaultAlbumCoverField);
     $fields->addFieldToTab("Root.Config", SliderField::create('AlbumsPerPage', 'Number of Albums Per Page', 1, 25));
     $fields->addFieldToTab("Root.Config", SliderField::create("AlbumThumbnailWidth", "Album Cover Thumbnail Width", 50, 400));
     $fields->addFieldToTab("Root.Config", SliderField::create("AlbumThumbnailHeight", "Album Cover Thumbnail Height", 50, 400));
     $fields->addFieldToTab("Root.Config", CheckboxField::create("ShowAllPhotoAlbums")->setTitle("Show photo album even if it's empty"));
     $fields->addFieldToTab("Root.Config", CheckboxField::create("AlbumDefaultTop")->setTitle("Sort new albums to the top by default"));
     $fields->addFieldToTab("Root.Config", HeaderField::create("Photo Settings"));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotosPerPage", "Number of Photos Per Page", 1, 50));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoThumbnailWidth", "Photo Thumbnail Width", 50, 400));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoThumbnailHeight", "Photo Thumbnail Height", 50, 400));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoFullWidth", "Photo Fullsize Width", 400, 1200));
     $fields->addFieldToTab("Root.Config", SliderField::create("PhotoFullHeight", "Photo Fullsize Height", 400, 1200));
     $fields->addFieldToTab("Root.Config", CheckboxField::create("PhotoDefaultTop")->setTitle("Sort new photos to the top by default"));
     return $fields;
 }
 public function Form()
 {
     $gridConfig = GridFieldConfig::create();
     $gridConfig->addComponent(new GridField_URLHandlerTest_Component());
     $gridData = new ArrayList();
     $gridField = new GridField('Grid', 'My grid', $gridData, $gridConfig);
     return new Form($this, 'Form', new FieldList($gridField), new FieldList());
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $fields->removeByName('Values');
         $fields->dataFieldByName('SubmittedByID')->setDisabled(true);
         $values = new GridField('Values', 'SubmittedFormField', $self->Values()->sort('Created', 'ASC'));
         $config = new GridFieldConfig();
         $config->addComponent(new GridFieldDataColumns());
         $config->addComponent(new GridFieldExportButton());
         $config->addComponent(new GridFieldPrintButton());
         $values->setConfig($config);
         $fields->addFieldToTab('Root.Main', $values);
     });
     $fields = parent::getCMSFields();
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     if (in_array($this->owner->qClassName, Link::$classesToAddLinksTo)) {
         $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(10), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
         $gridField = new GridField('Links', 'List of Links:', $this->Links(), $gridFieldConfig);
         $fields->addFieldToTab('Root.Links', $gridField);
     }
 }
Exemplo n.º 25
0
 public function setUp()
 {
     parent::setUp();
     $this->list = new DataList('GridFieldTest_Team');
     $config = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldPaginator(2), new GridFieldPageCount('toolbar-header-right'));
     $this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
     $this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
 }
 public function __construct($name, $title, $parent)
 {
     $this->record = $parent->{$name}();
     $this->parent = $parent;
     $config = GridFieldConfig::create()->addComponent(new GridFieldDetailForm())->addComponent(new GridFieldHasOneEditButton());
     $list = new HasOneButtonRelationList($this->record, $name, $parent);
     parent::__construct($name, $title, $list, $config);
 }
 public function updateCMSFields(FieldList $fields)
 {
     // Deal with product features
     $add_button = new GridFieldAddNewInlineButton('toolbar-header-left');
     $add_button->setTitle(_t("CommerceBulkPrice.AddDiscount", "Add Discount"));
     $bulk_field = new GridField('BulkPrices', '', $this->owner->BulkPrices(), GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction())->addComponent($add_button));
     $fields->addFieldToTab('Root.BulkPrices', $bulk_field);
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $audios_config = GridFieldConfig::create()->addComponents(new GridFieldSortableRows('SortOrder'), new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(10), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fields->addFieldToTab('Root.Content.AudioFiles', new GridField('Audios', 'Audios', $this->Audios(), $audios_config));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $VideosGridField = new GridField('Videos', 'Video', $this->Videos(), GridFieldConfig::create()->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldAddNewButton('toolbar-header-right'))->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldDataColumns())->addComponent(new GridFieldPaginator(50))->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm())->addComponent(new GridFieldSortableRows('SortOrder')));
     $fields->addFieldToTab("Root.Videos", $VideosGridField);
     $fields->addFieldToTab("Root.Config", TextField::create('SublimeJS')->setTitle('Sublime JS URL')->setDescription('For example //cdn.sublimevideo.net/js/yourid.js'));
     return $fields;
 }
 public function setUp()
 {
     parent::setUp();
     $this->list = GridFieldAction_SortOrder_Player::get();
     $config = GridFieldConfig::create()->addComponent(new GridFieldSortableRows('SortOrder'));
     $this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
     $this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
 }