Generates a second select

@param array $options The options to generate a second select with
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string
348012
protected function _secondSelect($options, $context)
    {
        $options += [
            'name' => '',
            'val' => null,
            'leadingZeroKey' => true,
            'leadingZeroValue' => true,
            'options' => $this->_generateNumbers(0, 59),
            'templateVars' => [],
        ];

        unset($options['leadingZeroKey'], $options['leadingZeroValue']);

        return $this->_select->render($options, $context);
    }
1211136
public function select($options = [])
    {
        $useClosure = false;

        if ($options instanceof \Closure) {
            $useClosure = true;
            $options = $options->call($this, $this->row);
        }

        $source = [];

        foreach ($options as $value => $text) {
            $source[] = compact('value', 'text');
        }

        if ($useClosure) {
            $this->addAttributes(['data-source' => json_encode($source)]);
        } else {
            $this->addOptions(compact('source'));
        }
    }
440443
public function select($options = [])
    {
        $source = [];

        foreach ($options as $key => $value) {
            $source[] = [
                'value' => $key,
                'text' => $value,
            ];
        }

        $this->addOptions(['source' => $source]);
    }
470977
public function init($options=[], $context=null)
    {
        $this->url=$options['url']??static::SG()->_SERVER['REQUEST_URI'];
        $this->key=$options['key']??$this->key;
        $this->page_size=$options['page_size']??$this->page_size;
        
        $this->handel_get_url=$options['rewrite']??$this->handel_get_url;
        
        $this->current_page=$options['current']??intval(static::SG()->_GET[$this->key]??1);
        $this->current_page=$this->current_page>1?$this->current_page:1;
    }
222204
public function getContext(TemplateContextInterface $context = null)
    {
        $context = new TemplateContext($context);
        $context->setData($this->getData());
        $context->setParameters($this->getParameters());

        return $context;
    }
92046
protected function printContext(array $context)
    {
        $res = '';
        foreach ($context as $name => $val) {
            // bypass internal context
            if (substr($name, 0, 2) === '__') {
                continue;
            }

            // concat contexts
            $res .= " $name: " . strval($val);
        }
        return $res ?: '';
    }
547886
protected function renderOptions(array $options, $selection)
	{
		$html = '';

		foreach($options as $key => $val) {
			if(is_array($val) === false) {
				$selected = ($key == $selection) ? ' selected' : null;
				$html .= '<option value="' . $key . '"' . $selected . '>' . $val . '</option>';
			} else {
				$html .= '<optgroup label="' . $key . '">' . $this->renderOptions($val, $selection) . '</optgroup>';
			}
		}

		return $html;
	}
638929
public function options($options)
    {
        return $this->addChildren($options, function ($text, $value) {
            if (is_array($text)) {
                return $this->optgroup($value, $text);
            }

            return Option::create()
                ->value($value)
                ->text($text)
                ->selectedIf($value === $this->value);
        });
    }
989158
public static function get_editor_options($context) {
        global $CFG;

        $editoroptions = [
                'subdirs'  => 0,
                'context'  => $context,
                'maxfiles' => EDITOR_UNLIMITED_FILES,
                'maxbytes' => $CFG->maxbytes,
                'noclean' => 0,
                'trusttext' => 0,
                'autosave' => false
        ];

        return $editoroptions;
    }
588833
private function contextToOptions(array $options)
    {
        $optionToBitMap = [
            self::OPTION_OBJECT                    => Yaml::DUMP_OBJECT,
            self::OPTION_EXCEPTION_ON_INVALID_TYPE => Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE,
            self::OPTION_OBJECT_FOR_MAP            => Yaml::DUMP_OBJECT_AS_MAP,
            self::OPTION_MULTI_LINE_LITERAL_BLOCK  => Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK,
        ];

        $bitMaskedOption = 0;

        foreach ($optionToBitMap as $option => $bitMask) {
            if ($options[ $option ]) {
                $bitMaskedOption = $bitMaskedOption | $bitMask;
            }
        }

        return $bitMaskedOption;
    }
518975
public static function build_editor_options(\context $context) {
        global $CFG;

        return [
            'context' => $context,
            'maxfiles' => EDITOR_UNLIMITED_FILES,
            'maxbytes' => $CFG->maxbytes,
            'noclean' => true,
            'autosave' => false
        ];
    }
25283
protected function createRemoveResourceForm(Context $context, $message = null, $footer = true, array $options = [])
    {
        if (null === $message) {
            $message = 'ekyna_core.message.remove_confirm';
        }

        $resource = $context->getResource();

        $action = $this->generateResourcePath($resource, 'remove');

        $form = $this
            ->createFormBuilder(null, array_merge([
                'action' => $action,
                'attr' => ['class' => 'form-horizontal'],
                'method' => 'POST',
                'admin_mode' => true,
                '_redirect_enabled' => true,
            ], $options))
            ->add('confirm', 'checkbox', [
                'label' => $message,
                'attr' => ['align_with_widget' => true],
                'required' => true,
                'constraints' => [
                    new Constraints\IsTrue(),
                ]
            ])
            ->getForm()
        ;

        if ($footer) {
            $referer = $context->getRequest()->headers->get('referer');
            if (0 < strlen($referer) && false === strpos($referer, $action)) {
                $cancelPath = $referer;
            } else {
                if ($this->hasParent()) {
                    $cancelPath = $this->generateUrl(
                        $this->getParent()->getConfiguration()->getRoute('show'),
                        $context->getIdentifiers()
                    );
                } else {
                    $cancelPath = $this->generateResourcePath($resource);
                }
            }

            $form->add('actions', 'form_actions', [
                'buttons' => [
                    'remove' => [
                        'type' => 'submit',
                        'options' => [
                            'button_class' => 'danger',
                            'label' => 'ekyna_core.button.remove',
                            'attr' => ['icon' => 'trash'],
                        ],
                    ],
                    'cancel' => [
                        'type' => 'button',
                        'options' => [
                            'label' => 'ekyna_core.button.cancel',
                            'button_class' => 'default',
                            'as_link' => true,
                            'attr' => [
                                'class' => 'form-cancel-btn',
                                'icon' => 'remove',
                                'href' => $cancelPath,
                            ],
                        ],
                    ],
                ],
            ]);
        }

        return $form;
    }
642045
protected function createNewResourceForm(Context $context, $footer = true, array $options = [])
    {
        $resource = $context->getResource();

        $action = $this->generateResourcePath($resource, 'new');

        $form = $this->createForm($this->config->getFormType(), $resource, array_merge([
            'action' => $action,
            'method' => 'POST',
            'attr' => ['class' => 'form-horizontal form-with-tabs'],
            'admin_mode' => true,
            '_redirect_enabled' => true,
        ], $options));

        if ($footer) {
            $referer = $context->getRequest()->headers->get('referer');
            if (0 < strlen($referer) && false === strpos($referer, $action)) {
                $cancelPath = $referer;
            } else {
                if ($this->hasParent()) {
                    $cancelRoute = $this->getParent()->getConfiguration()->getRoute('show');
                } else {
                    $cancelRoute = $this->config->getRoute('list');
                }
                $cancelPath = $this->generateUrl($cancelRoute, $context->getIdentifiers());
            }

            $form->add('actions', 'form_actions', [
                'buttons' => [
                    'saveAndList' => [
                        'type' => 'submit',
                        'options' => [
                            'button_class' => 'primary',
                            'label' => 'ekyna_core.button.save_and_list',
                            'attr' => ['icon' => 'list'],
                        ],
                    ],
                    'save' => [
                        'type' => 'submit',
                        'options' => [
                            'button_class' => 'primary',
                            'label' => 'ekyna_core.button.save',
                            'attr' => ['icon' => 'ok'],
                        ],
                    ],
                    'cancel' => [
                        'type' => 'button',
                        'options' => [
                            'label' => 'ekyna_core.button.cancel',
                            'button_class' => 'default',
                            'as_link' => true,
                            'attr' => [
                                'class' => 'form-cancel-btn',
                                'icon' => 'remove',
                                'href' => $cancelPath,
                            ],
                        ],
                    ],
                ],
            ]);
        }

        return $form;
    }
894841
protected function getContextOption($option, $default = null)
    {
        $options    = $this->getContextOptions();
        if (array_key_exists($option, $options)) {
            return $options[$option];
        } else {
            return $default;
        }
    }
626798
public function create($options, Context $context = null)
    {
        $validators = [];
        if (!empty($options['required'])) {
            $validators[] = new PresenceOf();
        }
        $type = ArrayHelper::fetch($options, 'type');
        if (isset($type)) {
            if ($type == 'datetime') {
                $validators[] = new Datetime([
                    'pattern' => ArrayHelper::fetch($options, 'pattern')
                ]);
            } elseif (isset(self::$TYPES[$type])) {
                $validators[] = (new self::$TYPES[$type]([]))->getValidator($this->form);
            } elseif ($type == 'array') {
                $validators[] = (new IsArray([
                    'element' => ArrayHelper::fetch($options, 'element')
                ], $context))->getValidator($this->form);
            } else {
                if ($context) {
                    $type = (new ClassResolver($this->form->getCache()))
                           ->resolve($type, $context->getDeclaringClass());
                }
                if (class_exists($type)) {
                    if (is_subclass_of($type, ValidatorInterface::class)) {
                        $validators[] = new $type($options);
                    } else {
                        $validators[] = new IsA($this->form, ['class' => $type]);
                    }
                } else {
                    if ($this->logger) {
                        $this->logger->warning("unknown validator type {$type}");
                    }
                }
            }
        }
        if (isset($options['min']) || isset($options['max'])) {
            $validators[] = new Range([
                'min' => ArrayHelper::fetch($options, 'min'),
                'max' => ArrayHelper::fetch($options, 'max'),
                'exclusiveMinimum' => ArrayHelper::fetch($options, 'exclusiveMinimum'),
                'exclusiveMaximum' => ArrayHelper::fetch($options, 'exclusiveMaximum')
            ]);
        }
        if (isset($options['minLength']) || isset($options['maxLength'])) {
            $validators[] = new StringLength([
                'min' => ArrayHelper::fetch($options, 'minLength'),
                'max' => ArrayHelper::fetch($options, 'maxLength')
            ]);
        }
        if (isset($options['enum'])) {
            if (is_array($options['enum'])) {
                $validators[] = new InclusionIn(['domain' => $options['enum']]);
            } else {
                $validators[] = (new Enum([
                    'model' => $options['enum'],
                    'attribute' => ArrayHelper::fetch($options, 'attribute'),
                ], $context))->getValidator($this->form);
            }
        }
        if (isset($options['pattern']) && $type != 'datetime') {
            $validators[] = new Regex([ 'pattern' => $options['pattern'] ]);
        }
        return $validators;
    }
235709
public function select2($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'debug' => JFactory::getApplication()->getCfg('debug')
        ));

        return parent::select2($config);
    }
1367208
public function generate(array $options = array())
    {
        $this->setOptions($options);

        $this->terra = new SplFixedArray($this->size);
        for ($x = 0; $x < $this->size; $x++) {
            $this->terra[$x] = new SplFixedArray($this->size);
        }

        mt_srand($this->getInternalMapSeed());

        $last = $this->size - 1;
        $this->terra[0][0] = $this->getOffset($this->size);
        $this->terra[0][$last] = $this->getOffset($this->size);
        $this->terra[$last][0] = $this->getOffset($this->size);
        $this->terra[$last][$last] = $this->getOffset($this->size);

        $this->divide($this->size);

        return $this->terra;
    }