function updateCMSFields(FieldList $fields)
 {
     $fields->insertAfter($tabset = new TabSet('ColoredImages'), 'Image');
     $tabset->push($uploadtab = new Tab('UploadImages'));
     $tabset->push($attributetab = new Tab('AssignAttribute'));
     $uploadtab->push($uf = new UploadField('Images', 'Images'));
     $uf->setDescription('Note: The product must be saved before attributes can be assigned to new uploaded images.');
     $attributetab->push($gf = GridField::create("ImageAttributes", "Images", $this->owner->Images(), GridFieldConfig_RelationEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldEditButton")->removeComponentsByType("GridFieldDataColumns")->removeComponentsByType("GridFieldDeleteAction")->addComponent($cols = new GridFieldEditableColumns())->addComponent(new GridFieldOrderableRows('Sort'))));
     $displayfields = array('Title' => array('title' => 'Title', 'field' => new ReadonlyField("Name")));
     //add drop-down color selection
     $colors = $this->owner->getColors();
     if ($colors->exists()) {
         $displayfields['ColorID'] = function ($record, $col, $grid) use($colors) {
             return DropdownField::create($col, "Color", $colors->map('ID', 'Value')->toArray())->setHasEmptyDefault(true);
         };
     }
     $cols->setDisplayFields($displayfields);
 }
 /**
  * Adds the CMS fields for the ColorScheme setting.
  * 
  * @param FieldList $fields Fields to update
  * 
  * @return void
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 26.09.2014
  */
 public function getCMSFieldsForColorScheme(FieldList $fields)
 {
     $colorSchemePath = Director::baseFolder() . '/silvercart/css';
     if (is_dir($colorSchemePath)) {
         if ($handle = opendir($colorSchemePath)) {
             $colorSchemes = new ArrayList();
             while (false !== ($entry = readdir($handle))) {
                 if (substr($entry, -4) != '.css') {
                     continue;
                 }
                 if (substr($entry, 0, 6) != 'color_') {
                     continue;
                 }
                 $colorSchemeName = substr($entry, 6, -4);
                 $colorSchemeFile = $colorSchemePath . '/' . $entry;
                 $lines = file($colorSchemeFile);
                 $backgroundColors = array();
                 $fontColors = array();
                 foreach ($lines as $line) {
                     if (strpos(strtolower($line), 'background-color') !== false && preg_match('/#[a-z|A-Z|0-9]{3,6}/', $line, $matches)) {
                         $backgroundColors[$matches[0]] = new ArrayData(array('Color' => $matches[0]));
                     } elseif (strpos(strtolower(trim($line)), 'color') === 0 && preg_match('/#[a-z|A-Z|0-9]{3,6}/', $line, $matches)) {
                         $fontColors[$matches[0]] = new ArrayData(array('Color' => $matches[0]));
                     }
                 }
                 $colorSchemes->push(new ArrayData(array('Name' => $colorSchemeName, 'Title' => _t('SilvercartConfig.ColorScheme_' . $colorSchemeName, ucfirst($colorSchemeName)), 'BackgroundColors' => new ArrayList($backgroundColors), 'FontColors' => new ArrayList($fontColors), 'IsActive' => $this->owner->ColorScheme == $colorSchemeName)));
             }
             closedir($handle);
         }
         $colorSchemes->sort('Title');
         $fields->removeByName('ColorScheme');
         $logoField = new UploadField('SilvercartLogo', $this->owner->fieldLabel('SilvercartLogo'));
         $logoField->setDescription($this->owner->fieldLabel('SilvercartLogoDesc'));
         // Build color scheme toggle group
         $colorSchemeConfigurationField = ToggleCompositeField::create('ColorSchemeConfiguration', $this->owner->fieldLabel('ColorSchemeConfiguration'), array($fields->dataFieldByName('Title'), $fields->dataFieldByName('Tagline'), $fields->dataFieldByName('Theme'), $logoField, new LiteralField('ColorScheme', $this->owner->customise(array('ColorSchemes' => $colorSchemes))->renderWith('ColorSchemeField'))))->setHeadingLevel(4)->setStartClosed(true);
         $fields->removeByName('Title');
         $fields->removeByName('Tagline');
         $fields->removeByName('Theme');
         $fields->addFieldToTab('Root.Main', $colorSchemeConfigurationField);
     } else {
         $fields->removeByName('ColorScheme');
     }
 }