Render select options

@param array $options  Options array
@param mixed $selected Selected values ex: [value => !NULL]

@return string
343557
public static function options($options, $selected = []): string
    {
        $html     = '';
        $selected = array_flip($selected);

        foreach ($options as $value => $name) {
            $html .= is_array($name)
                ? self::tag('optgroup', ['label' => $value], self::options($name, $selected))
                : self::tag('option', ['value' => $value] + (isset($selected[$value]) ? ['selected' => 'selected'] : []), $name);
        }

        return $html;
    }
270018
public static function render($options = null)
	{
		$pagination = new static($options);

		if (!$links = $pagination->getLinks())
		{
			return '';
		}

		if (!$pagination->view)
		{
			return $pagination->autoRender($links);
		}

		return $pagination->renderView($links);

	}
772221
private static function getOptions(array $values, array $selected, int $level = 0): array
    {
        $options = [];
        foreach ($values as $k => $v) {
            if (\strpos((string)$k, 'OPTGROUP') !== false) {
                $label = \str_replace(['&amp;nbsp;', '&amp;'], [Tags::NBSP, '&'], \htmlspecialchars((string)$v['name']));
                $optAttributes = ['label' => $label];
                if ($level > 0) {
                    $optAttributes['style'] = 'padding-left: '.(10 * $level).'px';
                }
                $options[] = Tags::optgroup(self::getOptions($v['options'], $selected, $level + 1), $optAttributes);
            } else {
                $optAttributes = [
                    'value' => $k,
                    'class' => 'opt-'.\str_replace('/', '', $k),
                ];
                if ($level > 0) {
                    $optAttributes['style'] = 'padding-left: '.(10 * $level).'px';
                }
                if (\in_array($k, $selected)) {
                    $optAttributes['selected'] = 'selected';
                }
                $options[] = Tags::option(
                    \str_replace(['&amp;nbsp;', '&amp;'], [Tags::NBSP, '&'], \htmlspecialchars((string)$v)),
                    $optAttributes
                );
            }
        }
        return $options;
    }
989701
public static function generateSelectOptionsFromArray( $data, $selected = null ) {

		$options	= "";

		if( isset( $data ) ) {

			if( isset($selected) ) {

				foreach ( $data as $key => $value ) {

					if( $selected === $key ) {

						$options .= "<option value='$key' selected>$value</option>";
					}
					else {
						$options .= "<option value='$key'>$value</option>";
					}
				}
			}
			else {

				foreach ( $data as $key => $value ) {

					$options .= "<option value='$key'>$value</option>";
				}
			}
		}

		return $options;
	}
613493
protected function buildSelectOptions($options, $selectedValues = array())
    {
        $str = '';
        $inOptgroup = false;
        foreach ($options as $opt) {
            // $str = '';
            if (isset($opt['optgroup'])) {
                if ($inOptgroup) {
                    $str .= '</optgroup>'."\n";
                    $inOptgroup = false;
                }
                if ($opt['optgroup']) {
                    // open an optgroup
                    $attribs = $opt['attribs'];
                    $attribs['label'] = $opt['label'];
                    $str .= '<optgroup'.Html::buildAttribString($attribs).'>'."\n";
                    $inOptgroup = true;
                }
            } else {
                $optAttribs = \array_merge(array(
                    // 'cname' => 'option',
                    // 'innerhtml' => \htmlspecialchars($opt['label']),
                    'selected' => \in_array($opt['attribs']['value'], $selectedValues),
                ), $opt['attribs']);
                // unset($optAttribs['label']);
                $str .= Html::buildTag('option', $optAttribs, \htmlspecialchars($opt['label']))."\n";
            }
            // $this->props['attribs']['innerhtml'] .= $str;
        }
        if ($inOptgroup) {
            // $this->props['attribs']['innerhtml'] .= '</optgroup>';
            $str .= '</optgroup>'."\n";
        }
        return $str;
    }
740185
public static function options2html(array $options = [], $selectedValue = null){
        // buffer prepared html codes
        $buffer = [];
        // loop options
        foreach ($options as $key => $value) {
            // make optgroup
            if(is_array($value)){
                // turn optgroup options to html
                $optgroupOptions = static::options2html($value, $selectedValue);
                // append prepared group to buffer
                $buffer[] = "<optgroup label='$key'>$optgroupOptions</options>";
            } else {
            // make option
                // print selected='' if option value and selected value are equivalent
                $selected = static::selected($selectedValue, $value);
                // append prepared option to buffer
                $buffer[] = "<option value='$value' $selected>$key</option>";
            }
        }
        // make html
        $html = implode('', $buffer);
        // return result
        return $html;
    }
1052070
public function render(array $options, $name, $selected = array(), array $attrs = array(), $tpl = false)
    {
        $output = array();
        $this->_setTpl($tpl);

        foreach ($options as $value => $label) {
            $label = trim($label);
            $id    = Str::unique($this->_type . '-');
            $value = $this->_cleanValue($value);
            $text  = $this->_translate($label);
            $attrs = $this->_checkedOptions($value, $selected, $attrs);

            $output[] = $this->_elementTpl($name, $value, $id, $text, $attrs);
        }

        return implode(PHP_EOL, $output);
    }
205730
public function render($options = array()) {
        $options = array_merge($this->_defaults, $options);
        $markers = $this->getMarkersAsString($options);
        $img = '';

        $img .= '<img src="http://maps.google.com/maps/api/staticmap';
        $img .= '?center=' . $options['location']['lat'] . ',' . $options['location']['lng'];
        $img .= '&amp;zoom=' . $options['zoomLevel'];
        $img .= '&amp;size=' . $options['width'] . 'x' . $options['height'];
        $img .= '&amp;maptype=' . $options['mapType'];
        $img .= ($markers ? '&amp;markers=' . $markers : '');
        $img .= '&amp;sensor=' . ($options['sensor'] ? 'true' : 'false') . '" ';
        $img .= 'width="' . $options['width'] . '" height="' . $options['height'] . '" alt="';
        $img .= $options['altText'] . '" class="g-googlemap" />';

        $this->view->script()->src(
            'https://www.google.com/maps/api/js?sensor=' . ($options['sensor'] ? 'true' : 'false')
        );
        return $img;
    }
22265
public function createOptions(array $options, $selected = null)
    {
        foreach ($options as $label => $value) {
            $option = $this->createOption($label, $value);

            if (is_array($selected) && in_array($value, $selected)) {
                $option->selected();
            } elseif ($selected === $value) {
                $option->selected();
            }
        }

        return $this;
    }
1061930
protected function getControllerOptions( array $selected )
	{
		$html = '';
		$aimeos = Base::getAimeos();
		$context = Scheduler\Base::getContext();
		$cntlPaths = $aimeos->getCustomPaths( 'controller/jobs' );

		$langid = 'en';
		if( isset( $GLOBALS['BE_USER']->uc['lang'] ) && $GLOBALS['BE_USER']->uc['lang'] != '' ) {
			$langid = $GLOBALS['BE_USER']->uc['lang'];
		}

		$localeItem = \Aimeos\MShop::create( $context, 'locale' )->createItem();
		$localeItem->setLanguageId( $langid );
		$context->setLocale( $localeItem );

		$controllers = \Aimeos\Controller\Jobs::get( $context, $aimeos, $cntlPaths );

		foreach( $controllers as $name => $controller )
		{
			$active = ( in_array( $name, $selected ) ? 'selected="selected"' : '' );
			$title = htmlspecialchars( $controller->getDescription(), ENT_QUOTES, 'UTF-8' );
			$cntl = htmlspecialchars( $controller->getName(), ENT_QUOTES, 'UTF-8' );
			$name = htmlspecialchars( $name, ENT_QUOTES, 'UTF-8' );

			$html .= sprintf( '<option value="%1$s" title="%2$s" %3$s>%4$s</option>', $name, $title, $active, $cntl );
		}

		return $html;
	}
1152937
public function render($options = [ ])
    {
        $mergedOptions = array_merge($this->config['options'], $options);

        $data = [
            'public_key' => value($this->config['public_key']),
            'options'    => $mergedOptions,
            'dataParams' => $this->extractDataParams($mergedOptions),
        ];

        if (array_key_exists('lang', $mergedOptions) && "" !== trim($mergedOptions['lang'])) {
            $data['lang'] = $mergedOptions['lang'];
        }

        $view = $this->getView($options);

        return app('view')->make($view, $data);
    }
539070
public function render($options = array())
    {
        $alert = $this->alertManager->getAlert();
        $options['alerts'] = $alert ? $alert->all() : array();

        return $this->alertHelper->render($options, $this->getTemplate($options));
    }
459169
private function renderSelect($select, $data = [])
    {
        // Check for tag name
        if ($select->tagName != 'select') {
            return $this;
        }

        // Set select groups
        SelectHelper::setGroups($this->getHTMLDocument()->getHTMLFactory(), $select, $data['groups'], $data['checked_value']);

        // Set select options
        SelectHelper::setOptions($this->getHTMLDocument()->getHTMLFactory(), $select, $data['options'], $data['checked_value']);

        return $this;
    }
616108
public function selectOption($select, $option)
    {
        $select = $this->fixStepArgument($select);
        $option = $this->fixStepArgument($option);
        $this->getSession()->getPage()->selectFieldOption($select, $option);
    }
1243822
public function createSelect(array $options = [], $selected = null, array $attributes = [])
    {
        $field = new Form\Elements\Select();

        if (count($options)) {
            $field->createOptions($options, $selected);
        }

        if (count($attributes)) {
            foreach ($attributes as $name => $value) {
                $field->attributes->addAttribute($name, $value);

                if ($name === 'name') {
                    $this->entity->setEntityName('input-' . $value);

                    if ( ! array_key_exists('id', $attributes)) {
                        $field->attributes->setAttributeId('input-' . $value);
                    }
                }
            }
        }

        return $this->input = $field;
    }
1013167
private function getSelectOptions($options, $selected)
    {
        $select = '';

        foreach ($options as $key => $value) {
            $isSelected = ($selected == $key) ? 'selected="selected"' : '';
            $select .= "<option $isSelected value='".$key."'>".$value.'</option>'.PHP_EOL;
        }

        return $select;
    }
536579
public function render(array $options = []) {
		$id = $this->_getId();

		$html = $this->control($options);
		$html .= $this->Form->control('captcha_id', ['type' => 'hidden', 'value' => $id]);

		$html .= $this->passive();

		return $html;
	}