From 0a082566c76cdfa0821bdc6555f846dc03083c79 Mon Sep 17 00:00:00 2001
From: Ilia Ross
Date: Sat, 20 Jul 2024 19:57:38 +0300
Subject: [PATCH] Fix to drop the `ui_element` API, which has never been used
for real
---
authentic-funcs.pl | 117 ---------------------------------------------
authentic.pl | 8 ++--
session_login.cgi | 12 ++---
3 files changed, 9 insertions(+), 128 deletions(-)
diff --git a/authentic-funcs.pl b/authentic-funcs.pl
index 0781e5004..9784ecc90 100644
--- a/authentic-funcs.pl
+++ b/authentic-funcs.pl
@@ -53,123 +53,6 @@ sub ui_button_group_local
return $rv;
}
-sub ui_element
-{
- my ($e, $c) = @_;
-
- # Allowed elements to use 'type' attr
- if ($e =~ /^(a|button|embed|input|link|menu|object|script|source|style)$/) {
-
- # Set default `type` for common elements
- if ($e eq 'input') {
- $c->{'type'} = "text" if (!$c->{'type'});
- } elsif ($e eq 'button') {
- $c->{'type'} = "button" if (!$c->{'type'});
- }
- $c->{'type'} = " type=\"@{[quote_escape($c->{'type'})]}\"" if ($c->{'type'});
- } else {
- delete $c->{'type'};
- }
-
- # Allowed elements to use 'name' attr
- if ($e =~ /^(button|fieldset|form|iframe|input|map|meta|object|output|param|select|textarea)$/) {
- $c->{'name'} = " name=\"@{[quote_escape($c->{'name'})]}\"" if ($c->{'name'});
- } else {
- delete $c->{'name'};
- }
-
- # Allowed elements to use 'value' attr
- if ($e =~ /^(button|input|meter|li|option|progress|param)$/) {
- $c->{'value'} = " value=\"@{[quote_escape($c->{'value'})]}\"" if ($c->{'value'});
- } else {
- delete $c->{'value'};
- }
-
- # Trigger `autofocus` or remove it
- if ($e =~ /^(button|input|select|textarea)$/) {
- if ($c->{'autofocus'} =~ /^(false|0)$/) {
- delete $c->{'autofocus'};
- }
-
- # If element is empty trigger autofocus
- elsif ($e =~ /input|textarea/ && !$c->{'value'}) {
- $c->{'autofocus'} = " autofocus";
- }
- }
-
- # Set default `class` for common elements
- if (!$c->{'class'}) {
- my $c_;
- if ($e eq 'input') {
- $c_ = "form-control";
- if ($c->{'type'} =~ /password/) {
- $c_ .= " ui_password";
- } else {
- $c_ .= " ui_textbox";
- }
- } elsif ($e eq 'textarea') {
- $c_ = "form-control ui_textarea";
- }
- $c->{'class'} = " class=\"$c_\"";
- } else {
- $c->{'class'} = " class=\"@{[quote_escape($c->{'class'})]}\"";
- }
-
- # Collect all other independent attributes
- my $attrs;
- foreach my $attr (keys %{$c}) {
- if ($attr ne "class" &&
- $attr ne "value" &&
- $attr ne "name" &&
- $attr ne "type")
- {
-
- # Parse and add data attributes passed as reference
- if ($attr eq "data") {
- if (ref($c->{$attr})) {
- foreach my $dattr (keys %{ $c->{$attr} }) {
- $attrs .= " data-$dattr=\"@{[quote_escape($c->{$attr}->{$dattr})]}\"";
- }
- }
-
- # Add all other attributes to the tag
- } else {
- $attrs .= " $attr=\"@{[quote_escape($c->{$attr})]}\"";
- }
- }
- }
-
- # Check if a tag must be closed
- my $e_c;
- if ($e !~ /^(area|base|br|hr|input|link|meta|param|source|circle|track|wbr)$/) {
- $e_c = "$e>";
- }
- return "<$e$c->{'type'}$c->{'name'}$c->{'value'}$c->{'class'}$attrs>@{[html_escape($c->{'_'})]}$e_c\n";
-}
-
-sub ui_input
-{
- my ($c, $v, $s, $d, $m, $t) = @_;
-
- # If old type input used, support it as well
- if (!ref($c)) {
- $c = { 'name' => $c,
- 'value' => $v,
- 'size' => $s };
- $c->{'disabled'} = "true" if ($d);
- $c->{'maxlength'} = $m if ($m);
- if ($t) {
- my @t = split(/\s+/, $t);
- foreach my $t (@t) {
- my ($t, $v) = ($t =~ /(.*?)=(.*)/);
- $v =~ s/^("|')|("|')$//g;
- $c->{$t} = "@{[quote_escape($v)]}";
- }
- }
- }
- return ui_element('input', $c);
-}
-
sub ui_span_local
{
my ($data, $extra_class) = @_;
diff --git a/authentic.pl b/authentic.pl
index 4e052af0c..73c3eed02 100644
--- a/authentic.pl
+++ b/authentic.pl
@@ -674,14 +674,16 @@ sub theme_ui_form_end
sub theme_ui_textbox
{
- my ($name, $value, $size, $dis, $max, $tags) = @_;
+ my ($name, $value, $size, $dis, $max, $tags, $class, $nostyle) = @_;
my $rv;
my $ids;
$ids = "_i_$main::ui_textbox_tcalled" if ($main::ui_textbox_tcalled++);
-
+ $class = $class ? " $class" : "";
+ my $style = ' style="display: inline; width: auto; max-width: 100%; height: 28px; padding-top: 0; padding-bottom: 2px; vertical-align: middle"';
+ $style = '' if ($nostyle);
$rv .=
-'' . &theme_text('login_message') . ' ' . $host . '
' . "\n";
print '' . "\n";
- print ui_input(
- { 'name' => 'user',
- 'value' => $in{"failed"},
- 'class' => 'form-control session_login',
- "autocomplete" => $gconfig{'noremember'} ? "off" : "username",
- "autocorrect" => "off",
- "autocapitalize" => "none",
- "placeholder" => $theme_text{'theme_xhred_login_user'} });
+ my $autocomplete = $gconfig{'noremember'} ? "off" : "username";
+ print &ui_textbox("user", $in{'failed'}, 20, 0, undef,
+ "autocomplete='$autocomplete' autocorrect='off' autocapitalize='none' ".
+ "placeholder='$theme_text{'theme_xhred_login_user'}'", 'session_login', 1);
print '' . "\n";
print '
' . "\n";