Generates a html attributes from the $values hash.
@param  array $options
@return string
968387
protected function arrayToHtmlAttributes(array $values)
    {
        $output = "";
        ksort($values);

        foreach ($values as $key => $value) {
            $output .=  sprintf('%s="%s" ', htmlentities($key), htmlentities($value));
        }

        return $output;
    }
156188
public static function generate(array $values) : string
    {
        $namespace = '__CustomDoctrineEnums';
        $className = 'CustomEnum__' . preg_replace('/[^a-zA-Z0-9_]/', '_', implode('__', $values));

        /** @var string|BaseEnumType $fullClassName */
        $fullClassName = $namespace . '\\' . $className;

        if (!class_exists($fullClassName, false)) {
            $class = strtr(self::$template, [
                    '{namespace}'  => $namespace,
                    '{class}'      => $className,
                    '{base_class}' => '\\' . BaseEnumType::class,
                    '{values}'     => var_export($values, true)
            ]);

            eval($class);
            Type::addType($fullClassName::getTypeName(), $fullClassName);
        }


        return $fullClassName::getTypeName();
    }
1256599
public function renderValue($object, array $options = []): string
    {
        $options = array_merge(
            ['column' => $this, 'object' => $object],
            $this->getFormattingOptions(),
            $options
        );
        $accessor = PropertyAccess::createPropertyAccessor();
        try {
            $value = $accessor->getValue($object, $this->getPropertyPath());
        } catch (UnexpectedTypeException $e) {
            return '';
        }

        return $this->getValueRenderer()->renderValue($value, $options);
    }
303247
public function renderLabel(array $options = [])
    {
        $attrs['id'] = $this->getAttribute('labelId', $this->getId() . '-label');
        $attrs['class'] = $this->getAttribute('labelClass');
        $attrs['for'] = $this->getAttribute('for', $this->getId());
        $attrs['title'] = $this->getAttribute('description');

        $attrs = array_merge($attrs, (array) $this->getAttribute('labelAttribs'));

        if ($this->form && $this->form->getRenderer()) {
            return $this->form->getRenderer()->renderLabel($this, $attrs, $options);
        }

        $label = $this->getLabel();

        if ($this->required) {
            $label = '<span class="windwalker-input-required-hint">*</span> ' . $label;
        }

        return (string) new HtmlElement('label', $label, $attrs);
    }
883930
protected function renderOptionTags($options)
    {
        $output = '';
        if ($this->hasArgument('prependOptionLabel')) {
            $value = $this->hasArgument('prependOptionValue') ? $this->arguments['prependOptionValue'] : '';
            if ($this->hasArgument('translate')) {
                $label = $this->getTranslatedLabel($value, $this->arguments['prependOptionLabel']);
            } else {
                $label = $this->arguments['prependOptionLabel'];
            }

            $output .= $this->renderOptionTag($value, $label) . chr(10);
        } elseif (empty($options)) {
            $options = array('' => '');
        }
        foreach ($options as $value => $label) {
            $output .= $this->renderOptionTag($value, $label) . chr(10);
        }
        return $output;
    }
154192
public static function render($options)
    {
        $jsExpressions = array();
        //Replace any js expression with random strings so we can switch
        //them back after json_encode the options
        $options = static::_replaceJsExpr($options, $jsExpressions);

        //TODO: Check for encoding errors
        $result = json_encode($options);

        //Replace any js expression on the json_encoded string
        foreach ($jsExpressions as $key => $expr) {
            $result = str_replace('"' . $key . '"', $expr, $result);
        }
        return $result;
    }
810692
public function ls($options = '')
	{
		$rows =
		[
			["option","description","example"],
			["pre","Preformats the value column","pre"],
			["wide","Sets the width of the table to be 100%","wide"],
			["class","Sets the table class attribute","class:fancy"],
			["style","Sets the table style attribute","style:color:blue"]
		];

		$keys   = array_shift($rows);
		$opts   = array_map(function($values) use ($keys) {
			return array_combine($keys, $values);
		}, $rows);

		foreach ($opts as $index => $value)
		{
			$example = $opts[$index]['example'];
			$opts[$index]['example'] = implode(' ', array_map(function($value){ return "<code>$value</code>";}, explode('|', $example)));
		}

		$data   = \App::make(Translator::class)->get('validation');

		return view('sketchpad::help/helpers/list', compact('data', 'opts', 'options'));
	}
297082
public static function Html ($value, $targets, $options = []) {
		$encoding	= $options['encoding'] ?? mb_internal_encoding();

		$result = [];

		$html = sprintf('<?xml version="1.0" encoding="%s"?><root>%s</root>', $encoding, $value);

		$dom = new \DOMDocument;

		libxml_use_internal_errors(true);
		$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
		libxml_clear_errors();

		$elements_cache = [];

		if (isset($targets['*'])) {
			$elements = $dom->getElementsByTagName('*');
			foreach ($elements as $element) {
				if (!isset($elements_cache[$element->tagName])) {
					$elements_cache[$element->tagName] = $elements;
				}
				foreach ((array) $targets['*'] as $attr) {
					if ($element->hasAttribute($attr)) {
						$result['attr'][$attr] = $attr;
					}
				}
			}
			unset($targets['*']);
		}

		foreach ($targets as $tag => $attrs) {
			if (is_int($tag)) {
				foreach ((array) $attrs as $tag) {
					$elements_cache[$tag] = $elements_cache[$tag] ?? $dom->getElementsByTagName($tag);
					if ($elements_cache[$tag]->length> 0) {
						$result['tag'][$tag] = $tag;
					}
				}

				continue;
			}

			$elements_cache[$tag] = $elements_cache[$tag] ?? $dom->getElementsByTagName($tag);
			if ($elements_cache[$tag]->length > 0) {
				foreach ((array) $attrs as $attr) {
					foreach ($elements_cache[$tag] as $element) {
						if ($element->hasAttribute($attr)) {
							$result['html'][$tag][$attr] = $attr;
						}
					}
				}
			}
		}

		$string = [];
		if (isset($result['html'])) {
			foreach ($result['html'] as $tag => $attrs) {
				$result['html'][$tag] = sprintf('%s => %s', $tag, implode(', ', $attrs));
			}
			$string['html'] = sprintf('HTML要素と属性の組み合わせ %s', implode(', ', $result['html']));
		}

		if (isset($result['tag'])) {
			$string['tag'] = sprintf('HTML要素 %s', implode(', ', $result['tag']));
		}

		if (isset($result['attr'])) {
			$string['attr'] = sprintf('HTML属性 %s', implode(', ', $result['attr']));
		}

		return empty($result) ?: implode(', ', $string);
	}
1363494
public function toXHTML($options = array(), &$filtered = array()){

        $template = static::getTemplatePath().'/xhtml.item.tpl.php';

        // get the variables to use in the template
        $variables = $this->getAttributeValues();
        $variables['stylesheets'] = array();
        foreach($this->getStylesheets() as $stylesheet){
            $variables['stylesheets'][] = $stylesheet->getAttributeValues();
        }
        //additional css:
        if(isset($options['css'])){
            foreach($options['css'] as $css){
                $variables['stylesheets'][] = array('href' => $css, 'media' => 'all');
            }
        }

        //additional js:
        $variables['javascripts'] = array();
        $variables['js_variables'] = array();
        if(isset($options['js'])){
            foreach($options['js'] as $js){
                $variables['javascripts'][] = array('src' => $js);
            }
        }
        if(isset($options['js_var'])){
            foreach($options['js_var'] as $name => $value){
                $variables['js_variables'][$name] = $value;
            }
        }

        //user scripts
        $variables['user_scripts'] = $this->getUserScripts();

        $dataForDelivery = $this->getDataForDelivery();
        $variables['itemData'] = $dataForDelivery['core'];

        //copy all variable data into filtered array
        foreach($dataForDelivery['variable'] as $serial => $data){
            $filtered[$serial] = $data;
        }

        $variables['contentVariableElements'] = isset($options['contentVariableElements']) && is_array($options['contentVariableElements']) ? $options['contentVariableElements'] : array();
        $variables['tao_lib_path'] = isset($options['path']) && isset($options['path']['tao']) ? $options['path']['tao'] : '';
        $variables['taoQtiItem_lib_path'] = isset($options['path']) && isset($options['path']['taoQtiItem']) ? $options['path']['taoQtiItem'] : '';
        $variables['client_config_url'] = isset($options['client_config_url']) ? $options['client_config_url'] : '';

        $tplRenderer = new taoItems_models_classes_TemplateRenderer($template, $variables);

        $returnValue = $tplRenderer->render();

        return (string) $returnValue;
    }
327268
public function extractAttributes($options = [])
    {
        if (!is_array($options)) {
            $options = [];
        }

        if (count($this->groupStack) > 0) {
            $options = $this->mergeWithLastGroup($options);
        }

        return Arr::except($options, $this->reserved);
    }
1245809
public function setOptions(array $options)
    {
        foreach ($options as $key => $val) {
            switch ($key) {
                case 'name':
                    $this->setName($val);
                    break;
                case 'doc_root':
                    $this->setDocRoot($val);
                    break;
                case 'bypass':
                    $this->setBypass($val);
                    break;
                case 'force':
                    $this->setForce($val);
                    break;
                case 'render_as_xhtml':
                    $this->setRenderAsXhtml($val);
                    break;
                case 'css_filter':
                    $this->setCssFilter($val);
                    break;
                case 'js_filter':
                    $this->setJsFilter($val);
                    break;
                case 'css_cache_path':
                    $this->setCssCachePath($val);
                    break;
                case 'js_cache_path':
                    $this->setJsCachePath($val);
                    break;
                case 'css_cache_url':
                    $this->setCssCacheUrl($val);
                    break;
                case 'js_cache_url':
                    $this->setJsCacheUrl($val);
                    break;
                case 'css_template':
                    $this->setCssTemplate($val);
                    break;
                case 'js_template':
                    $this->setJsTemplate($val);
                    break;
            }
        }

        return $this;
    }
906919
public static function generate($options)
    {
        if (isset($options['keywords'])) {
            $options['keywords'] = static::printWords($options['keywords']);
        }

        return sprintf(
            static::TEMPLATE,
            $options['name'],
            $options['class'],
            $options['link'],
            $options['keywords']
        );
    }
633315
public static function renderCss($options = []) {
		$result = '';
		$list = [];
		$css = Application::get(array('layout', 'css'));
		if (!empty($css)) {
			asort($css);
			foreach ($css as $k=>$v) {
				$script = $k . (strpos($k, '?') !== false ? '&' : '?') . self::getVersion();
				$list[] = $script;
				$result.= '<link href="' . $script . '" rel="stylesheet" type="text/css" />';
			}
		}
		// list is needed for ajax form reloads
		if (!empty($options['return_list'])) {
			return $list;
		}
		return $result;
	}
825491
protected function generateTextinput($options, $currentValue = null)
    {
        $value = is_null($currentValue) ? $options['value'] : $currentValue;

        if (!is_string($value)) {
            $value = "";
        }

        if (!array_key_exists("type", $options)) {
            $options["type"] = "text";
        }

        unset($options["value"]);

        return sprintf('<input %s value="%s">', $this->arrayToHtmlAttributes($options), $value);
    }
722559
protected function option($display, $value, array $attributes = [])
    {
        $options = ['value' => $value] + $attributes;

        return $this->toHtmlString('<option'.$this->attributes($options).'>'.e($display).'</option>');
    }
352549
public function filter($value, $options = [])
    {
        $value    = (string) $value;
        $filtered = htmlentities(
            $value,
            $this->getQuoteStyle(),
            $this->getEncoding(),
            $this->getDoubleQuote()
        );

        if (strlen($value) && !strlen($filtered)) {
            if (!function_exists('iconv')) {
                $ex = new \Exception('Encoding mismatch has resulted in htmlentities errors.');
                throw $ex;
            }

            $enc      = $this->getEncoding();
            $value    = iconv('', $enc . '//IGNORE', $value);
            $filtered = htmlentities($value, $this->getQuoteStyle(), $enc, $this->getDoubleQuote());

            if (!strlen($filtered)) {
                $ex = new \Exception('Encoding mismatch has resulted in htmlentities errors.');
                throw $ex;
            }
        }

        return $filtered;
    }
81947
protected function _renderAttributes(array $attributes = [])
    {
        $attributeStrings = [];
        foreach ($attributes as $attribute => $value) {
            $attributeStrings[] = $attribute . '="' . htmlentities($value) . '"';
        }

        if (empty($attributeStrings)) {
            return '';
        }

        return ' ' . join(' ', $attributeStrings);
    }