/** * Returns the input fields for this widget. * * @param Widget $widget Widget to initialize * @param array $fetchMethods Optional list of product fetch methods * * @return FieldList * * @author Sebastian Diel <*****@*****.**> * @since 13.03.2014 */ public static function getCMSFieldsForProductSliderWidget(Widget $widget, $fetchMethods = array()) { if (empty($fetchMethods)) { $fetchMethods = array('random' => $widget->fieldLabel('fetchMethodRandom'), 'sortOrderAsc' => $widget->fieldLabel('fetchMethodSortOrderAsc'), 'sortOrderDesc' => $widget->fieldLabel('fetchMethodSortOrderDesc')); } $fields = SilvercartDataObject::getCMSFields($widget, 'ExtraCssClasses', false); $productGroupDropdown = new TreeDropdownField('SilvercartProductGroupPageID', $widget->fieldLabel('SilvercartProductGroupPage'), 'SiteTree'); $productGroupDropdown->setTreeBaseID(SilvercartTools::PageByIdentifierCode('SilvercartProductGroupHolder')->ID); $toggleFields = array($fields->dataFieldByName('numberOfProductsToShow'), $fields->dataFieldByName('numberOfProductsToFetch'), $fields->dataFieldByName('fetchMethod'), SilvercartGroupViewHandler::getGroupViewDropdownField('GroupView', $widget->fieldLabel('GroupView'), $widget->GroupView)); $fields->dataFieldByName('fetchMethod')->setSource($fetchMethods); $fields->dataFieldByName('numberOfProductsToShow')->setDescription($widget->fieldLabel('numberOfProductsToShowInfo')); $fields->dataFieldByName('isContentView')->setDescription($widget->fieldLabel('isContentViewInfo')); if (is_object($fields->dataFieldByName('useSelectionMethod'))) { $fields->dataFieldByName('useSelectionMethod')->setSource(array('productGroup' => $widget->fieldLabel('SelectionMethodProductGroup'), 'products' => $widget->fieldLabel('SelectionMethodProducts'))); $toggleFields[] = $fields->dataFieldByName('useSelectionMethod'); $productGroupDropdown->setDescription($widget->fieldLabel('SilvercartProductGroupPageDescription')); } $toggleFields[] = $productGroupDropdown; $productDataToggle = ToggleCompositeField::create('ProductDataToggle', $widget->fieldLabel('ProductDataToggle'), $toggleFields)->setHeadingLevel(4); $productRelationToggle = ToggleCompositeField::create('ProductRelationToggle', $widget->fieldLabel('ProductRelationToggle'), array($fields->dataFieldByName('SilvercartProducts')))->setHeadingLevel(4); $fields->removeByName('numberOfProductsToShow'); $fields->removeByName('numberOfProductsToFetch'); $fields->removeByName('fetchMethod'); $fields->removeByName('useSelectionMethod'); $fields->removeByName('SilvercartProducts'); $fields->addFieldToTab("Root.Main", $productDataToggle); $fields->addFieldToTab("Root.Main", $productRelationToggle); $widget->getCMSFieldsSliderTab($fields); //$widget->getCMSFieldsRoundaboutTab($fields); return $fields; }
/** * Return all fields of the backend. * * @return FieldList Fields of the CMS */ public function getCMSFields() { $fields = parent::getCMSFields(); $useOnlydefaultGroupviewSource = array('inherit' => _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'), 'yes' => $this->fieldLabel('Yes'), 'no' => $this->fieldLabel('No')); $defaultGroupViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupView', $this->fieldLabel('DefaultGroupView'), $this->DefaultGroupView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT')); $useOnlyDefaultGroupViewField = new DropdownField('UseOnlyDefaultGroupView', $this->fieldLabel('UseOnlyDefaultGroupView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupView); $productGroupsPerPageField = new TextField('productGroupsPerPage', $this->fieldLabel('productGroupsPerPage')); $defaultGroupHolderViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupHolderView', $this->fieldLabel('DefaultGroupHolderView'), $this->DefaultGroupHolderView, $this->fieldLabel('DefaultGroupView')); $useOnlyDefaultGroupHolderViewField = new DropdownField('UseOnlyDefaultGroupHolderView', $this->fieldLabel('UseOnlyDefaultGroupHolderView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupHolderView); $fieldGroup = new SilvercartFieldGroup('FieldGroup', '', $fields); $redirectionFieldGroup = new SilvercartFieldGroup('RedirectionFieldGroup', '', $fields); $redirectToProductGroupField = new CheckboxField('RedirectToProductGroup', $this->fieldLabel('RedirectToProductGroup')); $linkToField = new TreeDropdownField('LinkToID', $this->fieldLabel('LinkTo'), 'SiteTree'); $productGroupsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT')); $fieldGroup->push($defaultGroupViewField); $fieldGroup->push($useOnlyDefaultGroupViewField); $fieldGroup->breakAndPush($productGroupsPerPageField); $fieldGroup->breakAndPush($defaultGroupHolderViewField); $fieldGroup->push($useOnlyDefaultGroupHolderViewField); $redirectionFieldGroup->push($redirectToProductGroupField); if ($this->exists()) { $linkToField->setTreeBaseID($this->ID); $redirectionFieldGroup->breakAndPush($linkToField); } $displaySettingsToggle = ToggleCompositeField::create('DisplaySettingsToggle', $this->fieldLabel('DisplaySettings'), array($fieldGroup))->setHeadingLevel(4)->setStartClosed(true); $redirectionSettingsToggle = ToggleCompositeField::create('RedirectionSettingsToggle', $this->fieldLabel('RedirectionSettings'), array($redirectionFieldGroup))->setHeadingLevel(4)->setStartClosed(true); $fields->insertAfter($redirectionSettingsToggle, 'Content'); $fields->insertAfter($displaySettingsToggle, 'Content'); $this->extend('extendCMSFields', $fields); return $fields; }
/** * Return all fields of the backend. * * @return FieldList Fields of the CMS */ public function getCMSFields() { $this->getCMSFieldsIsCalled = true; $fields = parent::getCMSFields(); $useOnlydefaultGroupviewSource = array('inherit' => _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'), 'yes' => _t('Silvercart.YES'), 'no' => _t('Silvercart.NO')); $useContentField = new CheckboxField('useContentFromParent', $this->fieldLabel('useContentFromParent')); $doNotShowProductsField = new CheckboxField('DoNotShowProducts', $this->fieldLabel('DoNotShowProducts')); $productsPerPageField = new TextField('productsPerPage', $this->fieldLabel('productsPerPage')); $defaultGroupViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupView', $this->fieldLabel('DefaultGroupView'), $this->DefaultGroupView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT')); $useOnlyDefaultGroupViewField = new DropdownField('UseOnlyDefaultGroupView', $this->fieldLabel('UseOnlyDefaultGroupView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupView); $productGroupsPerPageField = new TextField('productGroupsPerPage', $this->fieldLabel('productGroupsPerPage')); $defaultGroupHolderViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupHolderView', $this->fieldLabel('DefaultGroupHolderView'), $this->DefaultGroupHolderView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT')); $useOnlyDefaultGroupHolderViewField = new DropdownField('UseOnlyDefaultGroupHolderView', $this->fieldLabel('UseOnlyDefaultGroupHolderView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupHolderView); $fieldGroup = new SilvercartFieldGroup('FieldGroup', '', $fields); $productsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT')); $productGroupsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT')); $fieldGroup->push($useContentField); $fieldGroup->breakAndPush($doNotShowProductsField); $fieldGroup->breakAndPush($productsPerPageField); $fieldGroup->breakAndPush($defaultGroupViewField); $fieldGroup->push($useOnlyDefaultGroupViewField); $fieldGroup->breakAndPush($productGroupsPerPageField); $fieldGroup->breakAndPush($defaultGroupHolderViewField); $fieldGroup->push($useOnlyDefaultGroupHolderViewField); $displaySettingsToggle = ToggleCompositeField::create('DisplaySettingsToggle', $this->fieldLabel('DisplaySettings'), array($fieldGroup))->setHeadingLevel(4)->setStartClosed(true); $fields->insertAfter($displaySettingsToggle, 'Content'); $mirroredProductIdList = ''; $mirroredProductIDs = $this->getMirroredProductIDs(); foreach ($mirroredProductIDs as $mirroredProductID) { $mirroredProductIdList .= sprintf("'%s',", $mirroredProductID); } if (!empty($mirroredProductIdList)) { $mirroredProductIdList = substr($mirroredProductIdList, 0, -1); $filter = sprintf("SilvercartProductGroupID = %d OR\n \"SilvercartProduct\".\"ID\" IN (%s)", $this->ID, $mirroredProductIdList); } else { $filter = sprintf("SilvercartProductGroupID = %d", $this->ID); } if ($this->drawCMSFields()) { $config = GridFieldConfig_RecordViewer::create(100); $productsTableField = new GridField('SilvercartProducts', $this->fieldLabel('SilvercartProducts'), SilvercartProduct::get()->filter(array('SilvercartProductGroupID' => $this->ID)), $config); $tabPARAM = "Root." . _t('SilvercartProduct.TITLE', 'product'); $fields->addFieldToTab($tabPARAM, $productsTableField); $productAdminLink = Director::baseURL() . 'admin/silvercart-products'; $manageProductsButton = new LiteralField('ManageProductsButton', sprintf("<a href=\"%s\">%s</a>", $productAdminLink, _t('SilvercartProductGroupPage.MANAGE_PRODUCTS_BUTTON'))); $fields->addFieldToTab($tabPARAM, $manageProductsButton); $fields->addFieldToTab('Root.Main', new UploadField('GroupPicture', _t('SilvercartProductGroupPage.GROUP_PICTURE')), 'Content'); } $widgetSetContent = $fields->fieldByName('Root.Widgets.WidgetSetContent'); if ($widgetSetContent) { $widgetSetAdminLink = Director::baseURL() . 'admin/silvercart-widget-sets'; $manageWidgetsButton = new LiteralField('ManageWidgetsButton', sprintf("<a href=\"%s\">%s</a>", $widgetSetAdminLink, _t('SilvercartWidgetSet.MANAGE_WIDGETS_BUTTON'))); $fields->insertAfter($manageWidgetsButton, 'WidgetSetContent'); } $this->extend('extendCMSFields', $fields); return $fields; }
/** * Returns the input fields for this widget. * * @return FieldList * * @author Sebastian Diel <*****@*****.**> * @since 27.03.2012 */ public function getCMSFields() { $fields = SilvercartDataObject::getCMSFields($this, 'ExtraCssClasses', false); $fetchMethods = array('random' => $this->fieldLabel('fetchMethodRandom'), 'sortOrderAsc' => $this->fieldLabel('fetchMethodSortOrderAsc'), 'sortOrderDesc' => $this->fieldLabel('fetchMethodSortOrderDesc')); $fetchMethodsField = $fields->dataFieldByName('fetchMethod'); $fetchMethodsField->setSource($fetchMethods); $fields->replaceField('GroupView', SilvercartGroupViewHandler::getGroupViewDropdownField('GroupView', $this->fieldLabel('GroupView'))); // Temporary disabled slider functions. //SilvercartWidgetTools::getCMSFieldsSliderTabForProductSliderWidget($this, $fields); $fields->removeByName('numberOfProductsToShow'); return $fields; }