+ html_tag('select', $code, %attributes, name => $name);
+}
+
+sub checkbox_tag {
+ my ($name, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $name);
+
+ $attributes{value} = 1 unless defined $attributes{value};
+ my $label = delete $attributes{label};
+ my $checkall = delete $attributes{checkall};
+ my $for_submit = delete $attributes{for_submit};
+
+ if ($attributes{checked}) {
+ $attributes{checked} = 'checked';
+ } else {
+ delete $attributes{checked};
+ }
+
+ my $code = '';
+ $code .= hidden_tag($name, 0, %attributes, id => $attributes{id} . '_hidden') if $for_submit;
+ $code .= html_tag('input', undef, %attributes, name => $name, type => 'checkbox');
+ $code .= html_tag('label', $label, for => $attributes{id}) if $label;
+ $code .= javascript(qq|\$('#$attributes{id}').checkall('$checkall');|) if $checkall;
+
+ return $code;
+}
+
+sub button_tag {
+ my ($onclick, $value, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $attributes{name}) if $attributes{name};
+ $attributes{type} ||= 'button';
+
+ $onclick = 'if (!confirm("'. _J(delete($attributes{confirm})) .'")) return false; ' . $onclick if $attributes{confirm};
+
+ html_tag('input', undef, %attributes, value => $value, onclick => $onclick);
+}
+
+sub submit_tag {
+ my ($name, $value, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $attributes{name}) if $attributes{name};
+
+ if ( $attributes{confirm} ) {
+ $attributes{onclick} = 'return confirm("'. _J(delete($attributes{confirm})) .'");';
+ }
+
+ input_tag($name, $value, %attributes, type => 'submit', class => 'submit');
+}
+
+sub ajax_submit_tag {
+ my ($url, $form_selector, $text, %attributes) = @_;
+
+ $url = _J($url);
+ $form_selector = _J($form_selector);
+ my $onclick = qq|kivi.submit_ajax_form('${url}', '${form_selector}')|;
+
+ button_tag($onclick, $text, %attributes);
+}
+
+sub input_number_tag {
+ my ($name, $value, %params) = @_;
+
+ _set_id_attribute(\%params, $name);
+ my @onchange = $params{onchange} ? (onChange => delete $params{onchange}) : ();
+ my @classes = ('numeric');
+ push @classes, delete($params{class}) if $params{class};
+ my %class = @classes ? (class => join(' ', @classes)) : ();
+
+ $::request->layout->add_javascripts('kivi.Validator.js');
+ $::request->presenter->need_reinit_widgets($params{id});
+
+ input_tag(
+ $name, $::form->format_amount(\%::myconfig, $value, $params{precision}),
+ "data-validate" => "number",
+ %params,
+ %class, @onchange,
+ );
+}
+
+
+sub javascript {
+ my ($data) = @_;
+ html_tag('script', $data, type => 'text/javascript');
+}
+
+sub _set_id_attribute {
+ my ($attributes, $name, $unique) = @_;
+
+ if (!delete($attributes->{no_id}) && !$attributes->{id}) {
+ $attributes->{id} = name_to_id($name);
+ $attributes->{id} .= '_' . $attributes->{value} if $unique;
+ }
+
+ %{ $attributes };
+}
+
+my $html_restricter;
+
+sub restricted_html {
+ my ($value) = @_;
+
+ $html_restricter ||= SL::HTML::Restrict->create;
+ return $html_restricter->process($value);
+}
+
+sub textarea_tag {
+ my ($name, $content, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $name);
+ $attributes{rows} *= 1; # required by standard
+ $attributes{cols} *= 1; # required by standard
+
+ html_tag('textarea', $content, %attributes, name => $name);
+}
+
+sub link_tag {
+ my ($href, $content, %params) = @_;
+
+ $href ||= '#';
+
+ html_tag('a', $content, %params, href => $href);
+}
+# alias for compatibility
+sub link { goto &link_tag }
+
+sub date_tag {
+ my ($name, $value, %params) = @_;
+
+ _set_id_attribute(\%params, $name);
+ my @onchange = $params{onchange} ? (onChange => delete $params{onchange}) : ();
+ my @classes = $params{no_cal} || $params{readonly} ? () : ('datepicker');
+ push @classes, delete($params{class}) if $params{class};
+ my %class = @classes ? (class => join(' ', @classes)) : ();
+
+ $::request->layout->add_javascripts('kivi.Validator.js');
+ $::request->presenter->need_reinit_widgets($params{id});
+
+ input_tag(
+ $name, blessed($value) ? $value->to_lxoffice : $value,
+ size => 11,
+ "data-validate" => "date",
+ %params,
+ %class, @onchange,
+ );
+}
+
+sub div_tag {
+ my ($content, %params) = @_;
+ return html_tag('div', $content, %params);