called via ajax
generates all variants that where checked in the field matrix.

@return string
326410
public function generateVariants()
    {
        /**
         * @var array|null $aVariantParameters
         */
        $aVariantParameters = $this->getInputFilterUtil()->getFilteredInput('variantParameters');
        if (null === $aVariantParameters) {
            return '';
        }

        foreach ($aVariantParameters as $aVariant) {
            $oTableEditorManager = new TCMSTableEditorManager();
            $oTableEditorManager->sRestrictionField = 'variant_parent_id';
            $oTableEditorManager->sRestriction = $this->oTableRow->id;
            $oTableEditorManager->Init($this->oDefinition->fieldCmsTblConfId, $this->oTableRow->id);
            $oTableEditorManager->AllowEditByAll(true);
            $oTableEditorManager->Insert();
            $oTableEditorManager->oTableEditor->SaveFields($this->mapVariantArticleData($aVariant));

            foreach ($aVariant['variantIDs'] as $sVariantID) {
                $oTableEditorManager->AddMLTConnection($this->name, $sVariantID);
            }

            $nameList = $this->getProductVariantNameGenerator()->generateNamesForAllLanguages($oTableEditorManager->oTableEditor->oTable);
            $originalLanguageId = $oTableEditorManager->oTableEditor->oTableConf->GetLanguage();
            foreach ($nameList as $languageId => $name) {
                $oTableEditorManager->oTableEditor->oTableConf->SetLanguage($languageId);
                $oTableEditorManager->SaveField('name_variant_info', $name);
            }
            $oTableEditorManager->oTableEditor->oTableConf->SetLanguage($originalLanguageId);
        }

        return TGlobal::Translate('chameleon_system_shop.field_shop_variant_details.msg_created_variants', array('%generatedVariantsCount%' => count($aVariantParameters)));
    }
469339
protected function renderSelect()
    {
        $options = $this->getOptions();

        $selectedExtensionStyle = '';

        $renderedOptionTags = [];
        foreach ($options as $option) {
            if (isset($option['selected']) && $option['selected'] === 'selected') {
                $selectedExtensionStyle = $option['style'];
            }
            if ($option['value'] === \Tx_Phpunit_Testable::ALL_EXTENSIONS) {
                $optionValue = $this->translate('all_extensions');
            } else {
                $optionValue = $option['value'];
            }
            $renderedOptionTags[] = $this->renderTag('option', $option, $optionValue);
        }

        return $this->renderTag(
            'select',
            [
                'name' => \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
                    '[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']',
                'onchange' => 'document.location = \'' . $this->action . '&' .
                    \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
                    '[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']=' .
                    '\'+this.options[this.selectedIndex].value;',
                'style' => $selectedExtensionStyle,
            ],
            implode(LF, $renderedOptionTags)
        );
    }
815123
protected function generateChecksumForPostback()
    {
        return sha1(
                sprintf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", $this->_secretCode, $this->_merchantID, $this->data->status, $this->data->statusCode, $this->data->orderID, $this->data->paymentID, $this->data->reference, $this->data->transactionID, $this->data->amount, $this->data->currency, $this->data->duration, $this->data->consumerIPAddress
                )
        );
    }
884577
public function getJSData()
    {
        return [
            'name'          => $this->name,
            'title'         => $this->title,
            'description'   => $this->description,
            'column'        => $this->column,
            'extraColumn'   => $this->extraColumn,
            'columnFormat'  => $this->columnFormat,
            'addForm'       => $this->addForm,
            'editForm'      => $this->editForm,
            'inputType'     => $this->inputType,
            'actions'       => $this->actions,

            'deleteOption'      => $this->deleteOption,
            'editOption'        => $this->editOption,
            'addOption'         => $this->addOption,
            'orderOption'       => $this->orderOption,
            'exportOption'      => $this->exportOption,
            'microEditOption'   => $this->microEditOption,

            'modelDefaults' => $this->modelDefaults,
            'selectOptions' => $this->selectOptions,
            'filters'       => $this->filters,
            'richFilters'   => $this->richFilters,
            'showFilters'   => $this->showFilters,
            'trans'         => $this->trans,
            'moduleInPopup' => $this->moduleInPopup,
            'customActions' => $this->customActions,
            'panelView'     => $this->panelView,
            'orderParameters' => $this->orderParameters,
            'checkboxColumn' => $this->checkboxColumn,
            'defaultSortAttr' => $this->defaultSortAttr,
            'defaultSortOrder' => $this->defaultSortOrder,
            'interfaceTrans' => $this->getInterfaceTrans(),
            'thumbnailColumns' => $this->getThumbnailColumns(),
            'dateTimePickerOptions' => $this->getDateTimePickerOptions(),

            'config' => [
                'routePrefix'    => config('crude.routePrefix'),
                'numRowsOptions' => config('crude.numRowsOptions'),
                'iconClassName'  => config('crude.iconClassName'),
                'refreshAll'     => config('crude.refreshAll'),
                'mapCenter'      => config('crude.mapCenter'),
                'sortAttr'       => $this->getOrderAttribute(),
            ],
        ];
    }
437436
protected function getInput()
	{
		$html = array();
		$attr = '';

		// Initialize some field attributes.
		$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';

		// To avoid user's confusion, readonly="true" should imply disabled="true".
		if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true')
		{
			$attr .= ' disabled="disabled"';
		}

		$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
		$attr .= $this->multiple ? ' multiple="multiple"' : '';

		// Initialize JavaScript field attributes.
		$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		// Get the field options.
		$options = (array) $this->getOptions();

		// Create a read-only list (no name) with a hidden input to store the value.
		if ((string) $this->element['readonly'] == 'true')
		{
			$html[] = HtmlSelect::genericlist($options, '', trim($attr), 'value', 'text', $this->value, $this->id);
			$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
		}
		else
		// Create a regular list.
		{
			$html[] = HtmlSelect::genericlist($options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
		}

		return implode($html);
	}
985704
protected function parseCols()
    {
        if (!isset($this->parts['cols']) || !is_array($this->parts['cols']) || count($this->parts['cols']) < 1) {
            return '*';
        } else {
            $selectParts = [];

            foreach ($this->parts['cols'] as $itemSelect) {
                if (is_array($itemSelect)) {
                    $field = isset($itemSelect[0]) ? $itemSelect[0] : false;
                    $alias = isset($itemSelect[1]) ? $itemSelect[1] : false;
                    $protected = isset($itemSelect[2]) ? $itemSelect[2] : true;

                    $selectParts[] = ($protected ? $this->protect($field) : $field).(!empty($alias) ? ' AS '.$this->protect($alias) : '');
                } else {
                    $selectParts[] = $itemSelect;
                }
            }

            return implode(', ', $selectParts);
        }
    }
1307956
public function process()
    {
        $this->_setEscaper();
        $comparison = $this->getConfig('comparison');
        $valueMode = $this->getConfig('valueMode');
        $value = $this->value();
        $isMultiValue = is_array($value);

        $conditions = [];
        foreach ($this->fields() as $field) {
            $left = $field . ' ' . $comparison;
            if ($isMultiValue) {
                $valueConditions = [];
                foreach ($value as $val) {
                    $right = $this->_wildcards($val);
                    if ($right !== false) {
                        $valueConditions[] = [$left => $right];
                    }
                }
                if (!empty($valueConditions)) {
                    $conditions[] = [$valueMode => $valueConditions];
                }
            } else {
                $right = $this->_wildcards($value);
                if ($right !== false) {
                    $conditions[] = [$left => $right];
                }
            }
        }

        if (!empty($conditions)) {
            $colTypes = $this->getConfig('colType');
            if ($colTypes) {
                $colTypes = $this->_aliasColTypes($colTypes);
            }

            $this->getQuery()->andWhere([$this->getConfig('fieldMode') => $conditions], $colTypes);

            return true;
        }

        return false;
    }
490533
public function getCMSFields() {
        $fields=new FieldList(
                            new TextField('Name', _t('SnippetLanguage.NAME', '_Name'), null, 100),
                            new TextField('FileExtension', _t('SnippetLanguage.FILE_EXTENSION', '_File Extension'), null, 45),
                            new CheckboxField('Hidden', _t('SnippetLanguage.HIDDEN', '_Hidden'))
                        );
        
        if($this->UserLanguage==false) {
            $fields->replaceField('Name', $fields->dataFieldByName('Name')->performReadonlyTransformation());
            $fields->replaceField('FileExtension', $fields->dataFieldByName('FileExtension')->performReadonlyTransformation());
        }
        
        return $fields;
    }
1373774
protected function getVarsForDB()
  {
    if (!$fields = $this->getFields()) {
      return $this->vars;
    }

    return array_intersect_key($this->vars, array_flip($fields));
  }
620504
protected function getDefaultRow()
    {
        $results = array();
        foreach ($this->getFields() as $name => $field) {
            $results[$name] = $field->getDefault();
        }
        return $results;
    }
1067928
public function getChangedFields() {
        if($this->isAfterSave() && method_exists($this->getEntity(), 'getUpdatedFields')) {
            if($this->getEntity()->hasSnapshotData()) {
                $actualChangedFields = $this->getEntity()->getUpdatedFields();
            } else {
                $actualChangedFields = $this->getSnapshotData();
            }
        } else { //Legacy
            $actualChangedFields = $this->getEntity()->getChangedFields();
        }
        $model = $this->getEntity();
        foreach($actualChangedFields as $index => $changedField) {
            $newValue = $model->readAttribute($changedField);
            if(is_array($newValue)) {
                $newValue = json_encode($newValue);
            }
            $oldValue = $this->getSnapshotData()[$changedField] ?? null ?? null;
            if(is_object($oldValue)) {
                $oldValue = (string)$oldValue;
            }
            if(is_object($newValue)) {
                $newValue = (string)$newValue;
            }
            if(is_bool($oldValue) || is_bool($newValue)){
                $oldValue = (bool) $oldValue;
                $newValue = (bool) $newValue;
            }
            if($oldValue === $newValue) {
                unset($actualChangedFields[$index]);
            }

        }
        return array_values($actualChangedFields);
    }
549368
public function getInlineJavaScript()
    {
        if (count($this->view->model) < 2) {
            return '';
        }

        // set the controller of the check-all widget
        return sprintf(
            "%s_obj.setController(%s);",
            $this->check_all->id,
            $this->list_id
        );
    }
282811
public function getFieldsActivationJavaScriptCode()
    {
        $javaScriptBlocks = [];
        $formConfiguration = $this->getFormObject()->getConfiguration();

        foreach ($formConfiguration->getFields() as $field) {
            $fieldConditionExpression = [];
            $javaScriptTree = $this->getConditionTreeForField($field)->getJavaScriptConditions();

            if (false === empty($javaScriptTree)) {
                foreach ($javaScriptTree as $node) {
                    $fieldConditionExpression[] = 'flag = flag || (' . $node . ');';
                }

                $javaScriptBlocks[] = $this->getSingleFieldActivationConditionFunction($field, $fieldConditionExpression);
            }
        }

        $javaScriptBlocks = implode(CRLF, $javaScriptBlocks);
        $formName = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());

        return <<<JS
(function() {
    Fz.Form.get(
        $formName,
        function(form) {
            var field = null;

$javaScriptBlocks
        }
    );
})();
JS;
    }
298206
protected function getFakeColumnsAsArray() {

		$this->prepareFields();

		$fake_field_columns_to_encode = [];

		foreach ($this->crud['fields'] as $k => $field) {
			// if it's a fake field
			if (isset($this->crud['fields'][$k]['fake']) && $this->crud['fields'][$k]['fake']==true) {
				// add it to the request in its appropriate variable - the one defined, if defined
				if (isset($this->crud['fields'][$k]['store_in'])) {
					if(!in_array($this->crud['fields'][$k]['store_in'], $fake_field_columns_to_encode, true)){
				        array_push($fake_field_columns_to_encode, $this->crud['fields'][$k]['store_in']);
				    }
				}
				else //otherwise in the one defined in the $crud variable
				{
					if(!in_array('extras', $fake_field_columns_to_encode, true)){
				        array_push($fake_field_columns_to_encode, 'extras');
				    }
				}
			}
		}

		if (!count($fake_field_columns_to_encode)) {
			return ['extras'];
		}

		return $fake_field_columns_to_encode;
	}
1180565
public function getRoundDefaults()
    {
        $defaults = parent::getRoundDefaults();

        // Now check if the valid for depends on the same round
        if (count($defaults) > 1) {
            $lastRound = end($this->_rounds);   // We need the ID to compare
            if ($defaults['gro_valid_for_source']     == 'tok' &&
                    $defaults['gro_valid_for_field']  == 'gto_valid_from' &&
                    $defaults['gro_valid_for_id']     == $lastRound['gro_id_round']) {
                $defaults['gro_valid_for_id'] = 0;  // Will be updated on save
            }
        } else {
            $defaults['gro_valid_after_source'] = 'rtr';
        }

        return $defaults;
    }
348764
public function VersionsForm()
    {
        $id = $this->currentPageID();
        $page = $this->getRecord($id);
        $versionsHtml = '';

        $action = $this->getRequest()->param('Action');
        $versionID = $this->getRequest()->param('VersionID');
        $otherVersionID = $this->getRequest()->param('OtherVersionID');

        $showUnpublishedChecked = 0;
        $compareModeChecked = ($action == "compare");

        if ($page) {
            $versions = $page->allVersions();
            $versionID = (!$versionID) ? $page->Version : $versionID;

            if ($versions) {
                foreach ($versions as $k => $version) {
                    $active = false;

                    if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                        $active = true;

                        if (!$version->WasPublished) {
                            $showUnpublishedChecked = 1;
                        }
                    }

                    $version->Active = ($active);
                }
            }

            $vd = new ViewableData();

            $versionsHtml = $vd->customise(array(
                'Versions' => $versions
            ))->renderWith($this->getTemplatesWithSuffix('_versions'));
        }

        $fields = new FieldList(
            new CheckboxField(
                'ShowUnpublished',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'),
                $showUnpublishedChecked
            ),
            new CheckboxField(
                'CompareMode',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'),
                $compareModeChecked
            ),
            new LiteralField('VersionsHtml', $versionsHtml),
            $hiddenID = new HiddenField('ID', false, "")
        );

        $form = Form::create(
            $this,
            'VersionsForm',
            $fields,
            new FieldList()
        )->setHTMLID('Form_VersionsForm');
        $form->loadDataFrom($this->getRequest()->requestVars());
        $hiddenID->setValue($id);
        $form->unsetValidator();

        $form
            ->addExtraClass('cms-versions-form') // placeholder, necessary for $.metadata() to work
            ->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))
            ->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));

        return $form;
    }
809532
public function getFilteredFields()
    {
        $filteredFields = array();
        foreach ($this->_fields as $fieldName => $data) {
            $filteredFields[$fieldName] = $data['value'];
        }
        return $filteredFields;
    }