/** * Outputs an HTML form. * * @param string $childElements Child elements * @param array $options * * @return string */ public static function form($childElements, array $options) { $enctype = !empty($options['upload']) ? ' enctype="multipart/form-data"' : ''; unset($options['upload']); if (!isset($options['method'])) { $options['method'] = 'post'; } if (!isset($options['class'])) { $options['class'] = 'xenForm formOverlay'; } else { if (strpos(" {$options['class']} ", ' xenForm ') === false) { $options['class'] = 'xenForm formOverlay ' . $options['class']; } } if (strtolower($options['method']) == 'get' && ($questPos = strpos($options['action'], '?')) !== false) { $converted = XenForo_Template_Helper_Core::convertUrlToActionAndNamedParams($options['action']); $options['action'] = $converted['action']; $formHiddenElements = XenForo_Template_Helper_Core::getHiddenInputs($converted['params']); } else { $formHiddenElements = ''; } if (strtolower($options['method']) == 'get') { $hiddenToken = ''; } else { $visitor = XenForo_Visitor::getInstance(); $hiddenToken = '<input type="hidden" name="_xfToken" value="' . $visitor['csrf_token_page'] . '" />' . "\n"; } $attributes = ''; foreach ($options as $name => $value) { $attributes .= " {$name}=\"{$value}\""; } return ' <form' . $attributes . $enctype . '>' . $childElements . $formHiddenElements . $hiddenToken . '</form> '; }