Generates HTML for a field
@param string $fieldKey
@param string $elementKey
@param string $table
@param string $datafield
@return string $html
@author Gernot Ploiner <gp@webprofil.at>
@author Benjamin Butschell <bb@webprofil.at>
186776
protected function generateFieldHtml($fieldKey, $elementKey, $table, $datafield = "data")
    {
        $html = "";
        $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
        switch ($fieldHelper->getFormType($fieldKey, $elementKey, $table)) {
            case "Check":
                $html .= "{f:if(condition: " . $datafield . "." . $fieldKey . ", then: 'On', else: 'Off')}<br />\n\n";
                break;
            case "Content":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n";
                $html .= '<f:cObject typoscriptObjectPath="lib.tx_mask.content">{' . $datafield . '_item.uid}</f:cObject><br />' . "\n";
                $html .= "</f:for>\n";
                $html .= "</f:if>\n\n";
                break;
            case "Date":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:format.date format="d.m.Y">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Datetime":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:format.date format="d.m.Y - H:i:s">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "File":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:for each="{' . $datafield . '.' . $fieldKey . '}" as="file">
  <f:image image="{file}" alt="{file.alternative}" title="{file.title}" width="200" /><br />
  {file.description} / {file.identifier}<br />
</f:for>' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Float":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{' . $datafield . '.' . $fieldKey . '}</f:format.number><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Inline":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= "<ul>\n";
                $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n<li>";
                $inlineFields = $this->storageRepository->loadInlineFields($fieldKey);
                if ($inlineFields) {
                    foreach ($inlineFields as $inlineField) {
                        $html .= $this->generateFieldHtml($inlineField["maskKey"], $elementKey, $fieldKey,
                                $datafield . "_item") . "\n";
                    }
                }
                $html .= "</li>\n</f:for>" . "\n";
                $html .= "</ul>\n";
                $html .= "</f:if>\n\n";
                break;
            case "Integer":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Link":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:link.typolink parameter="{' . $datafield . '.' . $fieldKey . '}">{' . $datafield . '.' . $fieldKey . '}</f:link.typolink><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Radio":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}">
  <f:case value="1">Value is: 1</f:case>
  <f:case value="2">Value is: 2</f:case>
  <f:case value="3">Value is: 3</f:case>
</f:switch><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Richtext":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:format.html parseFuncTSPath="lib.parseFunc_RTE">{' . $datafield . '.' . $fieldKey . '}</f:format.html><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Select":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}">
  <f:case value="1">Value is: 1</f:case>
  <f:case value="2">Value is: 2</f:case>
  <f:case value="3">Value is: 3</f:case>
</f:switch><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "String":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
            case "Text":
                $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
                $html .= '<f:format.nl2br>{' . $datafield . '.' . $fieldKey . '}</f:format.nl2br><br />' . "\n";
                $html .= "</f:if>\n\n";
                break;
        }
        return $html;
    }
450003
protected function showHtmlAction($key, $table)
    {
        $html = $this->htmlCodeGenerator->generateHtml($key, $table);
        $this->view->assign('html', $html);
    }
1104651
private function generateByLocals($webspaceKey, $locales, $flat = false)
    {
        return $this->contentQuery->execute(
            $webspaceKey,
            $locales,
            $this->contentQueryBuilder,
            $flat,
            -1,
            null,
            null,
            true
        );
    }
275029
public function render(): string
    {
        $elementKey = $this->arguments['elementKey'];
        $fieldKey = $this->arguments['fieldKey'];
        $field = $this->arguments['field'];
        $table = $this->arguments['table'];

        $this->fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
        // if we have the whole field configuration
        if ($field) {
            // check if this field is in an repeating field
            if ($field["inlineParent"]) {
                // if yes, the label is in the configuration
                $label = $field["label"];
            } else {
                // otherwise the type can only be tt_content or pages
                if ($table) {
                    // if we have table param, the type must be the table
                    $type = $table;
                } else {
                    // otherwise try to get the label, set param $excludeInlineFields to true
                    $type = $this->fieldHelper->getFieldType($fieldKey, $elementKey, true);
                }
                $label = $this->fieldHelper->getLabel($elementKey, $fieldKey, $type);
            }
        } else {
            // if we don't have the field configuration, try the best to fetch the type and the correct label
            $type = $this->fieldHelper->getFieldType($fieldKey, $elementKey, false);
            $label = $this->fieldHelper->getLabel($elementKey, $fieldKey, $type);
        }
        return $label;
    }
9636
function ElementDataSource(config) {
	var newData = [],
		newColumns = [];

	var headings = config.data.all('tr th');

	headings.each(function(th){
		newColumns.push(th.getHtml());
	});

	config.data.all('tr').each(function(tr){
		var newRow = {},
			populated = false;

		for (var i = 0, numCols = headings.size(); i < numCols; i++) {

			if (!tr.all('td').item(i)) { continue; }

			newRow[headings.item(i).getHtml()] = tr.all('td').item(i).getHtml();
			populated = true;
		}

		if (populated) {
			newData.push(newRow);
		}
	});

	config.columns = newColumns;
	config.data = newData;

	return new JSONDataSource(config);
}
987637
public static function renderField($el, $key = null)
    {
        if (!$key) {
            $key = $el->inputName();
        }

        $id = str_replace('|', '-', $key);

        switch ($el->type) {
            case 'text':
                return Former::text($key, $el->label)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'textarea':
                return Former::textarea($key, $el->label)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'wysiwyg':
                return Former::wysiwyg($key, $el->label)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'image':
                return Former::image($key, $el->label)
                    ->forElement($el)
                    ->id($id);

            case 'file':
                return Former::upload($key, $el->label)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'boolean':
                return Former::checkbox($key, false)
                    ->checkboxes([
                        "<b>{$el->label}</b>" => [
                            'name' => $key,
                            'value' => 1,
                        ],
                    ])
                    ->blockHelp($el->help)
                    ->id($id)
                    ->push();

            case 'select':
                return Former::select($key, $el->label)
                    ->options($el->options)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'radios':
                return Former::radiolist($key, $el->label)
                    ->from($el->options)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'checkboxes':
                return Former::checklist($key, $el->label)
                    ->from($el->options)
                    ->blockHelp($el->help)
                    ->id($id);

            case 'video-encoder':
                return Former::videoEncoder($key, $el->label)
                    ->blockHelp($el->help)
                    ->model($el)
                    ->preset($el->preset)
                    ->id($id);

            case 'model':
                return Former::belongsTo($key, $el->label)
                    ->parent($el->class)
                    ->blockHelp($el->help)
                    ->id($id);
        }
    }
162537
private function getColumnIndex(NodeElement $table, $fieldName)
    {
        $rows = $table->findAll('css', 'tr');
        Assert::notEmpty($rows, 'There are no rows!');

        /** @var NodeElement $headerRow */
        $headerRow = $rows[0];
        $headers = $headerRow->findAll('css', 'th,td');

        /** @var NodeElement $column */
        foreach ($headers as $index => $column) {
            $columnFieldName = $this->getColumnFieldName($column);
            if ($fieldName === $columnFieldName) {
                return $index;
            }
        }

        throw new \InvalidArgumentException(sprintf('Column with name "%s" not found!', $fieldName));
    }
878007
private static String tableElementToHtml( TableElement td ){
		StringBuilder result = new StringBuilder();

		result.append("Row: "+td.getRow()+" Col: "+td.getCol()+"\n");

		if( td.nrOfSections()==1 && td.getSection(0).getTitleElement()==null) {
			result.append( sectionCCLToHtml( td.getSection(0) ));
		}
		else {
			for( int i=0; i<td.nrOfSections(); i++) {
				result.append( sectionToHtml(td.getSection(i) ));
			}
		}

		return result.toString();
	}
350702
public function setTemplatefields($contentKey, $className)
    {
        if (!isset($this->contenttypes[$contentKey]['templatefields'])) {
            return;
        }

        $config = $this->contenttypes[$contentKey]['templatefields'];

        foreach ($config as &$template) {
            foreach ($template['fields'] as &$field) {
                $this->postProcessField($field);
            }
        }
        $mapping = [
            'fieldname' => 'templatefields',
            'type'      => 'json',
            'fieldtype' => $this->typemap['templatefields'],
            'config'    => $config,
        ];

        $this->metadata[$className]['fields']['templatefields'] = $mapping;
    }
391484
protected function generateSitesRootFusion($packageKey, $siteName)
    {
        $templatePathAndFilename = 'resource://Neos.SiteKickstarter/Private/Generator/Fusion/Root.fusion';

        $contextVariables = [
            'packageKey' => $packageKey,
            'siteName' => $siteName,
            'siteNodeName' => $this->generateSiteNodeName($packageKey)
        ];

        $fileContent = $this->renderSimpleTemplate($templatePathAndFilename, $contextVariables);

        $sitesRootFusionPathAndFilename = $this->packageManager->getPackage($packageKey)->getResourcesPath() . 'Private/Fusion/Root.fusion';
        $this->generateFile($sitesRootFusionPathAndFilename, $fileContent);
    }
752082
private function createMailTemplate(string $mailKey, array $mailVars = [])
    {

        /**
         * @var $mailTemplate Template
         */
        $mailTemplate = \Yii::$app->get('emailTemplates')
            ->getTemplate($mailKey, Language::getCurrent()->id);
        if (!empty($mailVars) && !empty($mailTemplate)) {
            $mailTemplate->parseSubject($mailVars);
            $mailTemplate->parseBody($mailVars);
        }

        return $mailTemplate;
    }
686200
protected function wasListFieldSubmitted($fieldName, $dataKey)
	{
		if (!is_array(\Input::post('FORM_FIELDS'))) {
			return false;
		}

		if (strpos($fieldName, '__rsce_dummy__') !== false) {
			return false;
		}

		$formFields = array_unique(\StringUtil::trimsplit(
			'[,;]',
			implode(',', \Input::post('FORM_FIELDS'))
		));

		$fieldPrefix = $fieldName . '__' . $dataKey . '__';

		foreach ($formFields as $field) {
			if (substr($field, 0, strlen($fieldPrefix)) === $fieldPrefix) {
				return true;
			}
		}

		return false;
	}
375308
public static function make_textarea( $id, $key, $value = '', $attr = array() ) 
	{
		$element = HTML::tag( 'textarea', _e( $value ), array_merge( array( 
			'id' => $id, 
			'name' => $key,
		), $attr ));

		if ( !static::$builder_enabled )
		{
			 return $element;
		}

		return Builder::handle( 'form_textarea', $element );
	}
1272039
private function generateField($column, $dbType, $htmlType)
    {
        $field = new GeneratorField();
        $field->name = $column->getName();
        $field->parseDBType($dbType);
        $field->parseHtmlInput($htmlType);

        return $this->checkForPrimary($field);
    }
631711
private static void generateParserOnXmlEndElement(BindTypeContext context, MethodSpec.Builder methodBuilder,
			String instanceName, String parserName, BindEntity entity) {
		methodBuilder.beginControlFlow("if (elementName.equals($L.getName()))", parserName);
		methodBuilder.addStatement("currentTag = elementName");
		methodBuilder.addStatement("elementName = null");
		methodBuilder.endControlFlow();

	}
1132485
private function appendTableNode(Table $table, \DOMNode $parentNode)
    {
        $tableNode = $parentNode->appendChild($this->document->createElement('table'));
        $tableNode->setAttribute('name', $table->getCommonName());

        $database = $table->getDatabase();
        $schema = $table->getSchema();
        if ($schema && $schema !== $database->getSchema()) {
            $tableNode->setAttribute('schema', $schema);
        }

        if (IdMethod::NO_ID_METHOD !== ($idMethod = $table->getIdMethod())) {
            $tableNode->setAttribute('idMethod', $idMethod);
        }

        if ($phpName = $table->getPhpName()) {
            $tableNode->setAttribute('phpName', $phpName);
        }

        $package = $table->getPackage();
        if ($package && !$table->isPackageOverriden()) {
            $tableNode->setAttribute('package', $package);
        }

        if ($namespace = $table->getNamespace()) {
            $tableNode->setAttribute('namespace', $namespace);
        }

        if ($table->isSkipSql()) {
            $tableNode->setAttribute('skipSql', 'true');
        }

        if ($table->isAbstract()) {
            $tableNode->setAttribute('abstract', 'true');
        }

        if ($interface = $table->getInterface()) {
            $tableNode->setAttribute('interface', $interface);
        }

        if ($table->isCrossRef()) {
            $tableNode->setAttribute('isCrossRef', 'true');
        }

        $phpNamingMethod = $table->getPhpNamingMethod();
        if ($phpNamingMethod && $phpNamingMethod !== $database->getDefaultPhpNamingMethod()) {
            $tableNode->setAttribute('phpNamingMethod', $phpNamingMethod);
        }

        if ($baseClass = $table->getBaseClass()) {
            $tableNode->setAttribute('baseClass', $baseClass);
        }

        if ($baseQueryClass = $table->getBaseQueryClass()) {
            $tableNode->setAttribute('baseQueryClass', $baseQueryClass);
        }

        if ($table->isReadOnly()) {
            $tableNode->setAttribute('readOnly', 'true');
        }

        if ($table->isReloadOnInsert()) {
            $tableNode->setAttribute('reloadOnInsert', 'true');
        }

        if ($table->isReloadOnUpdate()) {
            $tableNode->setAttribute('reloadOnUpdate', 'true');
        }

        if (null !== ($referenceOnly = $table->isForReferenceOnly())) {
            $tableNode->setAttribute('forReferenceOnly', $referenceOnly ? 'true' : 'false');
        }

        if ($alias = $table->getAlias()) {
            $tableNode->setAttribute('alias', $alias);
        }

        if ($description = $table->getDescription()) {
            $tableNode->setAttribute('description', $description);
        }

        $defaultStringFormat = $table->getDefaultStringFormat();
        if (Table::DEFAULT_STRING_FORMAT !== $defaultStringFormat) {
            $tableNode->setAttribute('defaultStringFormat', $defaultStringFormat);
        }

        $defaultAccessorVisibility = $table->getDefaultAccessorVisibility();
        if ($defaultAccessorVisibility !== Table::VISIBILITY_PUBLIC) {
            $tableNode->setAttribute('defaultAccessorVisibility', $defaultAccessorVisibility);
        }

        $defaultMutatorVisibility = $table->getDefaultMutatorVisibility();
        if ($defaultMutatorVisibility !== Table::VISIBILITY_PUBLIC) {
            $tableNode->setAttribute('defaultMutatorVisibility', $defaultMutatorVisibility);
        }

        foreach ($table->getColumns() as $column) {
            $this->appendColumnNode($column, $tableNode);
        }

        foreach ($table->getForeignKeys() as $foreignKey) {
            $this->appendForeignKeyNode($foreignKey, $tableNode);
        }

        foreach ($table->getIdMethodParameters() as $parameter) {
            $this->appendIdMethodParameterNode($parameter, $tableNode);
        }

        foreach ($table->getIndices() as $index) {
            $this->appendIndexNode($index, $tableNode);
        }

        foreach ($table->getUnices() as $index) {
            $this->appendUniqueIndexNode($index, $tableNode);
        }

        foreach ($table->getVendorInformation() as $vendorInformation) {
            $this->appendVendorInformationNode($vendorInformation, $tableNode);
        }

        foreach ($table->getBehaviors() as $behavior) {
            $this->appendBehaviorNode($behavior, $tableNode);
        }
    }
851910
public function generateTabularFormField($attribute, $fk, $tableSchema = null)
    {
        if (is_null($tableSchema)) {
            $tableSchema = $this->getTableSchema();
        }
        if (in_array($attribute, $this->hiddenColumns)) {
            return "\"$attribute\" => ['type' => TabularForm::INPUT_HIDDEN, 'columnOptions' => ['hidden'=>true]]"; //fixes #91 https://github.com/mootensai/yii2-enhanced-gii/issues/91
        }
        $humanize = Inflector::humanize($attribute, true);
        if ($tableSchema === false || !isset($tableSchema->columns[$attribute])) {
            if (preg_match('/^(password|pass|passwd|passcode)$/i', $attribute)) {
                return "\"$attribute\" => ['type' => TabularForm::INPUT_PASSWORD]";
            } else {
                return "\"$attribute\" => ['type' => TabularForm::INPUT_TEXT]";
            }
        }
        $column = $tableSchema->columns[$attribute];
        if ($column->autoIncrement) {
            return "'$attribute' => ['type' => TabularForm::INPUT_HIDDEN]";
        } elseif ($column->phpType === 'boolean' || $column->dbType === 'tinyint(1)') {
            return "'$attribute' => ['type' => TabularForm::INPUT_CHECKBOX,
            'options' => [
                'style' => 'position : relative; margin-top : -9px'
            ]
        ]";
        } elseif ($column->type === 'text' || $column->dbType === 'tinytext') {
            return "'$attribute' => ['type' => TabularForm::INPUT_TEXTAREA]";
        } elseif ($column->dbType === 'date') {
            return "'$attribute' => ['type' => TabularForm::INPUT_WIDGET,
            'widgetClass' => \\kartik\\datecontrol\\DateControl::classname(),
            'options' => [
                'type' => \\kartik\\datecontrol\\DateControl::FORMAT_DATE,
                'saveFormat' => 'php:Y-m-d',
                'ajaxConversion' => true,
                'options' => [
                    'pluginOptions' => [
                        'placeholder' => " . $this->generateString('Choose ' . $humanize) . ",
                        'autoclose' => true
                    ]
                ],
            ]
        ]";
        } elseif ($column->dbType === 'time') {
            return "'$attribute' => ['type' => TabularForm::INPUT_WIDGET,
            'widgetClass' => \\kartik\\datecontrol\\DateControl::classname(),
            'options' => [
                'type' => \\kartik\\datecontrol\\DateControl::FORMAT_TIME,
                'saveFormat' => 'php:H:i:s',
                'ajaxConversion' => true,
                'options' => [
                    'pluginOptions' => [
                        'placeholder' => " . $this->generateString('Choose ' . $humanize) . ",
                        'autoclose' => true
                    ]
                ]
            ]
        ]";
        } elseif ($column->dbType === 'datetime') {
            return "'$attribute' => ['type' => TabularForm::INPUT_WIDGET,
            'widgetClass' => \\kartik\\datecontrol\\DateControl::classname(),
            'options' => [
                'type' => \\kartik\\datecontrol\\DateControl::FORMAT_DATETIME,
                'saveFormat' => 'php:Y-m-d H:i:s',
                'ajaxConversion' => true,
                'options' => [
                    'pluginOptions' => [
                        'placeholder' => " . $this->generateString('Choose ' . $humanize) . ",
                        'autoclose' => true,
                    ]
                ],
            ]
        ]";
        } elseif (array_key_exists($column->name, $fk)) {
            $rel = $fk[$column->name];
            $labelCol = $this->getNameAttributeFK($rel[self::REL_TABLE]);
            $humanize = Inflector::humanize($rel[self::REL_TABLE]);
//            $pk = empty($this->tableSchema->primaryKey) ? $this->tableSchema->getColumnNames()[0] : $this->tableSchema->primaryKey[0];
            $fkClassFQ = "\\" . $this->nsModel . "\\" . $rel[self::REL_CLASS];
            $output = "'$attribute' => [
            'label' => '$humanize',
            'type' => TabularForm::INPUT_WIDGET,
            'widgetClass' => \\kartik\\widgets\\Select2::className(),
            'options' => [
                'data' => \\yii\\helpers\\ArrayHelper::map($fkClassFQ::find()->orderBy('$labelCol')->asArray()->all(), '{$rel[self::REL_PRIMARY_KEY]}', '$labelCol'),
                'options' => ['placeholder' => " . $this->generateString('Choose ' . $humanize) . "],
            ],
            'columnOptions' => ['width' => '200px']
        ]";
            return $output;
        } else {
            if (preg_match('/^(password|pass|passwd|passcode)$/i', $column->name)) {
                $input = 'INPUT_PASSWORD';
            } else {
                $input = 'INPUT_TEXT';
            }
            if (is_array($column->enumValues) && count($column->enumValues) > 0) {
                $dropDownOptions = [];
                foreach ($column->enumValues as $enumValue) {
                    $dropDownOptions[$enumValue] = Inflector::humanize($enumValue);
                }
                return "'$attribute' => ['type' => TabularForm::INPUT_DROPDOWN_LIST,
                    'items' => " . preg_replace("/\n\s*/", ' ', VarDumper::export($dropDownOptions)) . ",
                    'options' => [
                        'columnOptions' => ['width' => '185px'],
                        'options' => ['placeholder' => " . $this->generateString('Choose ' . $humanize) . "],
                    ]
        ]";
            } elseif ($column->phpType !== 'string' || $column->size === null) {
                return "'$attribute' => ['type' => TabularForm::$input]";
            } else {
                return "'$attribute' => ['type' => TabularForm::$input]"; //max length??
            }
        }
    }