renders a component's (app) paramters as form fields

@param array attributes
@return html form fields
973561
protected function _paramsComponent($config)
    {
        $entity = $config->entity;
        $package = $entity->option;
        $config_file_path = ANPATH_SITE.DS.'components'.DS.$package.DS.'config.json';

        if(!file_exists($config_file_path)) {
           return AnTranslator::_('COM-SETTINGS-PROMPT-NO-CONFIGURATION-AVAILABLE');
        }

        $this->getService('anahita:language')->load($package);
        $app_config = json_decode(file_get_contents($config_file_path));

        return $this->_renderForm($app_config->fields, $entity);
    }
926587
public function render($attributes = null)
    {
        if($attributes)
            $this->setAttributes( $attributes );

        return '<textarea'
            . $this->renderAttributes()
            . '>'
            . htmlspecialchars($this->value, ENT_NOQUOTES, 'UTF-8')
            . '</textarea>';
    }
482047
public function renderButtons()
    {
        list($name, $id) = $this->resolveNameID();
        $buttons   = array();
        $checked   = $this->hasModel() ? (!$this->model->{$this->attribute}) : true;
        $buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_on', 'value' => 1));
        $buttons[] = \CHtml::label($this->offLabel, $id . '_on');
        $checked   = $checked ? false : true;
        $buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_off', 'value' => 1));
        $buttons[] = \CHtml::label($this->onLabel, $id . '_off');
        $buttons[] = '<span></span>';

        return \CHtml::tag('div', $this->htmlOptions, implode("\n", $buttons));
    }
115048
protected function generateAttributes(array $attributes)
	{
		if (isset($attributes['style']) && is_array($attributes['style']))
		{
			$attributes['style'] = $this->generateStyle($attributes['style']);
		}

		ksort($attributes);
		$xsl = '';
		foreach ($attributes as $attrName => $attrValue)
		{
			$innerXML = (strpos($attrValue, '<xsl:') !== false) ? $attrValue : AVTHelper::toXSL($attrValue);

			$xsl .= '<xsl:attribute name="' . htmlspecialchars($attrName, ENT_QUOTES, 'UTF-8') . '">' . $innerXML . '</xsl:attribute>';
		}

		return $xsl;
	}
568816
private function HtmlAttributes($attributes)
    {
        $formatted = join(' ', array_map(function ($key) use ($attributes) {
            if (is_bool($attributes[$key])) {
                return $attributes[$key] ? $key : '';
            }
            return $key . '="' . $attributes[$key] . '"';
        }, array_keys($attributes)));
        return $formatted;
    }
1219527
public function buildTagAttributes(array $attributes)
	{
		$html = array();

		foreach ($attributes as $key => $value)
		{
			if (is_null($value))
				continue;

			if (is_numeric($key))
				$key = $value;

			$html[] = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
		}

		return (count($html) > 0) ? ' ' . implode(' ', $html) : '';
	}
749145
public function getHtml(array $attributes = []): string
    {
        $result = '';
        foreach ($this->radioButtons as $radioButton) {
            $result .= $radioButton->getHtml($attributes) . htmlspecialchars($radioButton->getLabel());
        }

        return $result;
    }
85196
public function getHtml(array $attributes = []): string
    {
        return self::buildTag('input', null,
            array_merge(
                [
                    'type'    => 'radio',
                    'name'    => $this->name !== '' ? $this->name : false,
                    'value'   => $this->value,
                    'checked' => $this->isSelected,
                ],
                $attributes
            )
        );
    }
1329021
protected function renderAttributes()
    {
        return ArrayMap::of($this->attributes)
            ->map(function ($value, $name) {
                return $this->renderAttribute($name, $value);
            })
            ->join(' ');
    }
889087
public function js($attributes = null)
	{
		if( ! $this->js)
			return '';

		$assets = ($this->pipeline) ? array($this->jsPipeline()) : $this->js;

		if($attributes instanceof Closure)
			return $attributes->__invoke($assets);

		// Build attributes
		$attributes = (array) $attributes;
		unset($attributes['src']);

		if( ! array_key_exists('type', $attributes))
			$attributes['type'] = 'text/javascript';

		$attributes = $this->buildTagAttributes($attributes);

		// Build tags
		$output = '';
		foreach($assets as $asset)
			$output .= '<script src="' . $asset . '"' . $attributes . "></script>\n";

		return $output;
	}
430454
private static function buildHtmlAttribute($attributes)
    {
        $html = '';
        foreach ($attributes as $name => $value) {
            $html .= ' '.$name.'="'.$value.'"';
            $class_list = explode(' ', $value);
            foreach ($class_list as $class_name) {
                switch ($class_name) {
                    case 'class':
                        if (function_exists('hookAddClassHtmlTag')) {
                            hookAddClassHtmlTag($class_name);
                        }
                }
            }
        }

        return $html;
    }
142587
protected function renderAttributes()
    {
        $output = '';

        foreach($this->_attr as $key => $value) {
            $output .= $key.' = "'.$value.'" ';
        }

        return $output;
    }
1335338
public function RenderBegin () {
		$this->form->PreDispatch();
		$result = "<form";
		$attrs = [];
		$form = & $this->form;
		// standard attributes
		$formProperties = ['id', 'action', 'method', 'enctype', 'target'];
		foreach ($formProperties as $property) {
			$getter = 'Get'.ucfirst($property);
			$formPropertyValue = $form->$getter();
			if ($formPropertyValue !== NULL)
				$attrs[$property] = $formPropertyValue;
		}
		// css classes
		$formCssClasses = $form->GetCssClasses();
		if ($formCssClasses)
			$attrs['class'] = gettype($formCssClasses) == 'array'
				? implode(' ', (array) $formCssClasses)
				: $formCssClasses;
		// additional custom attributes completing
		foreach ($form->GetAttributes() as $key => $value) {
			if (!in_array($key, $formProperties))
				$attrs[$key] = $value;
		}
		// pseudo-boolean attributes completing
		$formAutoComplete = $form->GetAutoComplete();
		if ($formAutoComplete !== NULL) 
			$attrs['autocomplete'] = $formAutoComplete ? 'on' : 'off';
		$formNoValidate = $form->GetNoValidate();
		if ($formNoValidate === TRUE)
			$attrs['novalidate'] = 'novalidate';
		$formAcceptCharsets = $form->GetAcceptCharsets();
		if (count($formAcceptCharsets) > 0) 
			$attrs['accept-charset'] = implode(' ', $formAcceptCharsets);
		// boolean and additional attributes
		$attrsStr = self::RenderAttrs($attrs);
		if ($attrsStr) $result .= ' ' . $attrsStr;
		$result .= '>';
		$this->form->SetFormTagRenderingStatus(TRUE);
		$result .= $this->RenderCsrf();
		return $result;
	}
1312449
protected function componentAttributes()
    {
        $function = function ($widget) {
            $classname = array_get($widget['attributes'], 'attributes.classname');
            if (is_null($classname)) {
                return '';
            }
            $instance = null;
            $widgets  = Registry::get('ui-components');
            if (empty($widgets)) {
                return '';
            }
            foreach ($widgets as $widget) {
                if (get_class($widget) == $classname) {
                    $instance = $widget;
                    break;
                }
            }
            if (is_null($instance)) {
                return '';
            }
            return serialize($instance->getShared());
        };
        return new Twig_SimpleFunction(
                'component_attributes', $function
        );
    }
1082304
public static function createAttributes($attributes = [])
    {
        $list = [];

        foreach ($attributes as $key => $value)
        {
            $list[] = sprintf('%s="%s"', $key, is_array($value) ? implode(' ', $value) : $value);
        }

        return implode(' ', $list);
    }
969467
private function createAttributes()
        {
            $return = [];
            foreach ($this->attributes as $key => $value) {
                if ('data' === $key && is_array($value)) {
                    foreach ($value as $k => $v) {
                        $return[] = 'data-'.$k.'="'.htmlentities(is_array($v)
                                ? implode(' ', $v)
                                : $v, ENT_QUOTES, 'UTF-8', false).'"';
                    }
                } else {
                    $return[] = $key.'="'.htmlentities(is_array($value)
                            ? implode(' ', $value)
                            : $value, ENT_QUOTES, 'UTF-8', false).'"';
                }
            }
            return count($return)
                ? ' '.implode(' ', $return)
                : false;
        }
675161
public function Field($properties = array())
    {
        $source = ArrayLib::flatten($this->getSource());
        $values = $this->getValueArray();

        // Get selected values
        $mapped = [];
        foreach ($values as $value) {
            if (isset($source[$value])) {
                $mapped[] = Convert::raw2xml($source[$value]);
            }
        }

        // Don't check if string arguments are matching against the source,
        // as they might be generated HTML diff views instead of the actual values
        if ($this->value && is_string($this->value) && empty($mapped)) {
            $mapped[] = Convert::raw2xml(trim($this->value));
            $values = [];
        }

        if ($mapped) {
            $attrValue = implode(', ', array_values($mapped));
            $inputValue = implode(', ', array_values($values));
        } else {
            $attrValue = '<i>(' . _t('SilverStripe\\Forms\\FormField.NONE', 'none') . ')</i>';
            $inputValue = '';
        }

        $properties = array_merge($properties, array(
            'AttrValue' => DBField::create_field('HTMLFragment', $attrValue),
            'InputValue' => $inputValue
        ));

        return parent::Field($properties);
    }