Prepare the label depending on yes no mode.

@param IAttribute $objAttribute The metamodel attribute.

@return array

@SuppressWarnings(PHPMD.Superglobals)
496213
private function prepareLabel(IAttribute $objAttribute)
    {
        return ($this->get('ynmode') == 'radio' || $this->get('ynfield') ?
            array(
                ($this->get('label') ?: $objAttribute->getName()),
                ($this->get('ynmode') == 'yes'
                    ? $GLOBALS['TL_LANG']['MSC']['yes']
                    : $GLOBALS['TL_LANG']['MSC']['no']
                )
            )
            :
            array(
                ($this->get('label') ?: $objAttribute->getName()),
                ($this->get('ynmode') == 'no'
                    ? sprintf(
                        $GLOBALS['TL_LANG']['MSC']['extended_no'],
                        ($this->get('label') ?: $objAttribute->getName())
                    )
                    : ($this->get('label') ?: $objAttribute->getName())
                )
            )
        );
    }
249320
public function RenderLabel () {
		/** @var $this \MvcCore\Ext\Forms\IField */
		$renderMode = $this instanceof \MvcCore\Ext\Forms\Fields\ILabel
			? $this->GetRenderMode()
			: \MvcCore\Ext\Forms\IForm::FIELD_RENDER_MODE_NO_LABEL;
		if ($renderMode == \MvcCore\Ext\Forms\IForm::FIELD_RENDER_MODE_NO_LABEL) 
			return '';
		$attrsStr = $this->renderLabelAttrsWithFieldVars();
		$formViewClass = $this->form->GetViewClass();
		return $formViewClass::Format(static::$templates->label, [
			'id'		=> $this->id,
			'label'		=> $this->label,
			'attrs'		=> $attrsStr ? " $attrsStr" : '',
		]);
	}
973886
public function getSetterDeclarationLines(CPPAttribute $attribute)
    {
        $lines = [];

        if ('object' === $attribute->getType()) {
            $lines[] = $this->getEntity()->getProject()->getAutocodeProperty('base')
                ? $this->getEntity()->getNameBase() . ' ' . $attribute->getSetterName() . '(' . $attribute->getEntitySubtype()->getName() . ' ' . $attribute->getName() . ');'
                : $this->getEntity()->getName() . ' ' . $attribute->getSetterName() . '(' . $attribute->getEntitySubtype()->getName() . ' ' . $attribute->getName() . ');';
        } else {
            $lines[] = $this->getEntity()->getProject()->getAutocodeProperty('base')
                ? $this->getEntity()->getNameBase() . ' ' . $attribute->getSetterName() . '(' . $attribute->getType() . ');'
                : $this->getEntity()->getName() . ' ' . $attribute->getSetterName() . '(' . $attribute->getType() . ');';
        }

        return $lines;
    }
16952
function metaData( $contentObjectAttribute )
    {
        $selected = $this->objectAttributeContent( $contentObjectAttribute );
        $classContent = $this->classAttributeContent( $contentObjectAttribute->attribute( 'contentclass_attribute' ) );
        $return = '';
        if ( count( $selected ) == 0)
        {
            return '';
        }

        $count = 0;
        $optionArray = $classContent['options'];
        foreach ( $selected as $id )
        {
            if ( $count++ != 0 )
                $return .= ' ';
            foreach ( $optionArray as $option )
            {
                $optionID = $option['id'];
                if ( $optionID == $id )
                    $return .= $option['name'];
            }
        }
        return $return;
    }
256424
public function getSetterDeclarationLine(CPPAttribute $attribute)
    {
        if ('object' === $attribute->getType()) {
            return $this->getEntity()->getProject()->getAutocodeProperty('base')
                ? $this->getEntity()->getNameBase() . ' ' . $this->getEntity()->getNameBase() . '::' . $attribute->getSetterName() . '(' . $attribute->getEntitySubtype()->getName() . ' _' . $attribute->getName() . ')'
                : $this->getEntity()->getName() . ' ' . $this->getEntity()->getName() . '::' . $attribute->getSetterName() . '(' . $attribute->getEntitySubtype()->getName() . ' _' . $attribute->getName() . ')';
        } else {
            return $this->getEntity()->getProject()->getAutocodeProperty('base')
                ? $this->getEntity()->getNameBase() . ' ' . $this->getEntity()->getNameBase() . '::' . $attribute->getSetterName() . '(' . $attribute->getType() . ' _' . $attribute->getName() . ')'
                : $this->getEntity()->getName() . ' ' . $this->getEntity()->getName() . '::' . $attribute->getSetterName() . '(' . $attribute->getType() . ' _' . $attribute->getName() . ')';
        }
    }
670073
protected function prepareWidgetLabel($objAttribute)
    {
        $arrLabel = [
            $this->get('label') ?: $objAttribute->getName(),
            'GET: ' . $this->getParamName()
        ];

        $fromField = $this->get('fromfield');
        $toField   = $this->get('tofield');

        if ($fromField && $toField) {
            $arrLabel[0] .= ' ' . $GLOBALS['TL_LANG']['metamodels_frontendfilter']['fromto'];
            return $arrLabel;
        }
        if ($fromField && !$toField) {
            $arrLabel[0] .= ' ' . $GLOBALS['TL_LANG']['metamodels_frontendfilter']['from'];
            return $arrLabel;
        }

        $arrLabel[0] .= ' ' . $GLOBALS['TL_LANG']['metamodels_frontendfilter']['to'];

        return $arrLabel;
    }
1183405
private function formatHtmlAttribute($attributes = [])
    {
        $attrArr = [];
        foreach ($attributes as $name => $val) {
            $attrArr[] = "$name=\"$val\"";
        }

        return implode(' ', $attrArr);
    }
269675
protected function prepareAttributes()
    {

        // laod the callbacks for the actual attribute code
        $callbacks = $this->getCallbacksByType($this->attributeCode);

        // invoke the pre-cast callbacks
        foreach ($callbacks as $callback) {
            $this->attributeValue = $callback->handle($this);
        }

        // load the ID of the product that has been created recently
        $lastEntityId = $this->getPrimaryKey();

        // cast the value based on the backend type
        $castedValue = $this->castValueByBackendType($this->backendType, $this->attributeValue);

        // prepare the attribute values
        return $this->initializeEntity(
            array(
                $this->getPrimaryKeyMemberName() => $lastEntityId,
                MemberNames::ATTRIBUTE_ID       => $this->attributeId,
                MemberNames::VALUE              => $castedValue
            )
        );
    }
529404
public function initializeObjectAttribute($objectAttribute, $currentVersion, $originalContentObjectAttribute)
    {
        $value = $currentVersion != false ?
            $originalContentObjectAttribute->content() :
            $this->fieldType->getEmptyValue();

        $objectAttribute->setContent($value);
    }
578706
public function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
    {
        /** @var $domNodes DOMNodeList */
        $subTreeLimit = 0;
        $domNodes = $attributeParametersNode->getElementsByTagName( 'subtree-limit' );
        if ( $domNodes->length > 0 )
            $subTreeLimit = (int) $domNodes->item( 0 )->textContent;

        $maxTags = 0;
        $domNodes = $attributeParametersNode->getElementsByTagName( 'max-tags' );
        if ( $domNodes->length > 0 )
            $maxTags = (int) $domNodes->item( 0 )->textContent;

        $hideRootTag = 0;
        $domNodes = $attributeParametersNode->getElementsByTagName( 'hide-root-tag' );
        if ( $domNodes->length > 0 && $domNodes->item( 0 )->textContent === 'true' )
            $hideRootTag = 1;

        $editView = self::EDIT_VIEW_DEFAULT_VALUE;
        $domNodes = $attributeParametersNode->getElementsByTagName( 'edit-view' );
        if ( $domNodes->length > 0 )
        {
            $domNodeContent = trim( $domNodes->item( 0 )->textContent );
            if ( !empty( $domNodeContent ) )
            {
                $editView = $domNodeContent;
            }
        }

        $classAttribute->setAttribute( self::SUBTREE_LIMIT_FIELD, $subTreeLimit );
        $classAttribute->setAttribute( self::MAX_TAGS_FIELD, $maxTags );
        $classAttribute->setAttribute( self::HIDE_ROOT_TAG_FIELD, $hideRootTag );
        $classAttribute->setAttribute( self::EDIT_VIEW_FIELD, $editView );
    }
469511
public function prepareForView()
    {
        $fields = [];
        foreach ($this->fields as $groups) {
            foreach ($groups as $field) {
                if (null !== $field->getLabel()) {
                    $labelFor = $field->getName() . (($field->getNodeName() == 'fieldset') ? '1' : '');
                    $label    = new Child('label', $field->getLabel());
                    $label->setAttribute('for', $labelFor);
                    if (null !== $field->getLabelAttributes()) {
                        $label->setAttributes($field->getLabelAttributes());
                    }
                    if ($field->isRequired()) {
                        if ($label->hasAttribute('class')) {
                            $label->setAttribute('class', $label->getAttribute('class') . ' required');
                        } else {
                            $label->setAttribute('class', 'required');
                        }
                    }
                    $fields[$field->getName() . '_label'] = $label->render();
                }
                if (null !== $field->getHint()) {
                    $hint = new Child('span', $field->getHint());
                    if (null !== $field->getHintAttributes()) {
                        $hint->setAttributes($field->getHintAttributes());
                    }
                    $fields[$field->getName() . '_hint'] = $hint->render();
                }
                if ($field->hasErrors()) {
                    $fields[$field->getName() . '_errors'] = $field->getErrors();
                }
                $fields[$field->getName()] = $field->render();
            }
        }
        return $fields;
    }
1150986
function createContentObjectAttributeDOMNode( $objectAttribute )
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );

        $node = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:attribute' );

        $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:id', $objectAttribute->attribute( 'id' ) );
        $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:identifier', $objectAttribute->contentClassAttributeIdentifier() );
        $node->setAttribute( 'name', $objectAttribute->contentClassAttributeName() );
        $node->setAttribute( 'type', $this->isA() );

        return $node;
    }
308958
public function prepare(&$attrs)
    {
        $value = $this->getValue();

        $attrs['type'] = 'checkbox';
        $attrs['name'] = $this->getFieldName();
        $attrs['id'] = $this->getAttribute('id', $this->getId());
        $attrs['class'] = $this->getAttribute('class');
        $attrs['readonly'] = $this->getAttribute('readonly');
        $attrs['disabled'] = $this->getAttribute('disabled');
        $attrs['onchange'] = $this->getAttribute('onchange');
        $attrs['value'] = $this->getAttribute('value');
        $attrs['checked'] = $value ? 'true' : null;
        $attrs['required'] = $this->required;
    }
956697
protected function renderAttribs()
    {
        // Element name
        $aHtml = ['name="' . $this->strName . '"'];

        // Default value
        if ($this->mValue && empty($this->aOptions))
            $aHtml[] = 'value="' . $this->mValue . '"';

        // Misc attribs
        foreach ($this->aAttribs as $strKey => $mValue) {
            $aHtml[] = is_bool($mValue)
                ? ($mValue ? $strKey : '') // just the attribute name for booleans
                : $strKey . '="' . $mValue . '"'; // otherwise key="value"
        }

        return implode(' ', $aHtml);
    }
1316334
public function createLabel($textContent = null, array $attributes = [])
    {
        $label = new Form\Elements\Label($attributes);
        $label->attributes->addAttributeClass('col-form-label');

        if (isset($textContent)) {
            $label->textContent->push($textContent);
        }

        $this->childNodes->push($label);

        return $this->childNodes->last();
    }
578649
public function __toHtml($submitted = false, $blnSimpleLayout = false, $blnLabel = true, $blnDisplayError = true, $intCount = 0)
    {
        // *** Conditional meta should be set before all other meta. Otherwise the set meta is being reset.
        $this->setConditionalMeta();

        // Do nothing if multifield has no child fields.
        if ($this->__fields->count() == 0) {
            return "";
        }

        $blnError = false;
        $arrError = array();

        $blnRequired = false;

        /* @var $field Element */
        foreach ($this->__fields as $field) {
            $objValidator = $field->getValidator();
            if (is_object($objValidator)) {
                // *** Check if this multifield should have required styling.
                if ($objValidator->getRequired()) {
                    $blnRequired = true;
                }

                if ($submitted && ! $objValidator->validate($intCount) && $blnDisplayError) {
                    $blnError = true;

                    $strError = $field->getValidator()->getError($intCount);
                    if (! in_array($strError, $arrError)) {
                        $arrError[] = $strError;
                    }
                }
            }
        }

        // *** We asume that all dynamic fields greater than 0 are never required.
        if ($blnRequired && $intCount == 0) {
            $this->setMeta("class", "vf__required");
        } else {
            $this->setMeta("class", "vf__optional");
        }

        // *** Set custom meta.
        if ($blnError) {
            $this->setMeta("class", "vf__error");
        }

        $this->setMeta("class", "vf__multifield");

        if ($this->isRemovable()) {
            $this->setMeta("class", "vf__removable");
        }

        //*** Add data-dynamic="original" or data-dynamic="clone" attributes to dynamic fields
        if ($this->isDynamic()) {
            if ($intCount === 0) {
                // This is the first, original element. Make sure to define that.
                $this->setMeta('data-dynamic', 'original', true);
            } else {
                $this->setMeta('data-dynamic', 'clone', true);
                $this->setMeta("class", "vf__clone");
            }
        }

        $strId = ($intCount == 0) ? $this->getId() : $this->getId() . "_{$intCount}";
        $strOutput = "<div{$this->__getMetaString()} id=\"{$strId}\">\n";

        if ($blnError) {
            $strOutput .= "<p class=\"vf__error\">" . implode("</p><p class=\"vf__error\">", $arrError) . "</p>";
        }

        $strLabel = (! empty($this->__requiredstyle) && $blnRequired) ? sprintf($this->__requiredstyle, $this->__label) : $this->__label;
        if (! empty($this->__label)) {
            $strOutput .= "<label for=\"{$strId}\"{$this->__getLabelMetaString()}>{$strLabel}</label>\n";
        }

        foreach ($this->__fields as $field) {
            // Skip the hidden dynamic counter fields.
            if (($intCount > 0) && (get_class($field) == "ValidFormBuilder\\Hidden") && $field->isDynamicCounter()) {
                continue;
            }

            $strOutput .= $field->__toHtml($submitted, true, $blnLabel, $blnDisplayError, $intCount);
        }

        if (! empty($this->__tip)) {
            $strOutput .= "<small class=\"vf__tip\"{$this->__getTipMetaString()}>{$this->__tip}</small>\n";
        }

        if ($this->isRemovable()) {
            $this->setMeta("dynamicRemoveLabelClass", "vf__removeLabel");

            $strOutput .= $this->getRemoveLabelHtml();
        }

        $strOutput .= "</div>\n";

        if ($intCount == $this->getDynamicCount()) {
            $strOutput .= $this->getDynamicHtml();
        }

        return $strOutput;
    }
523735
public function title($objectAttribute, $name = null)
    {
        $value = $objectAttribute->content();
        if (!$value instanceof Value) {
            return '';
        }

        return $this->fieldType->getName($value);
    }