Files
selima-perl/lib/perl5/Selima/Form/Guestbook/Public.pm
2026-03-10 21:31:43 +08:00

87 lines
2.8 KiB
Perl

# Selima Website Content Management System
# Public.pm: The base guestbook form.
# Copyright (c) 2004-2018 imacat.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: imacat <imacat@mail.imacat.idv.tw>
# First written: 2004-10-16
package Selima::Form::Guestbook::Public;
use 5.008;
use strict;
use warnings;
use base qw(Selima::Form::Guestbook);
use Selima::DataVars qw(:lninfo);
use Selima::GetLang;
use Selima::HTTP;
use Selima::ShortCut;
# new: Initialize the HTML form table displayer
sub new : method {
local ($_, %_);
my ($class, $status, $args, $self);
($class, $status, $args) = @_;
$args = {} if !defined $args;
# $args must be a hash reference
http_500 "type of argument 2 must be a hash reference"
if ref($args) ne "HASH";
# This should always be always a new form
$$args{"type"} = "new"
if !exists $$args{"type"};
$$args{"type_to_pass"} = undef
if !exists $$args{"type_to_pass"};
$$args{"valid_types"} = [qw(new)]
if !exists $$args{"valid_types"};
$$args{"table"} = "guestbook"
if !exists $$args{"table"};
$$args{"header_buttons"} = []
if !exists $$args{"header_buttons"};
$$args{"footer_buttons"} = [
{ "name" => "submit", "value" => h(C_("Leave a messsage")) } ]
if !exists $$args{"footer_buttons"};
$$args{"summary"} = C_("This table provides you a form to leave a message.")
if !exists $$args{"summary"};
$$args{"onsubmit"} = "return isGuestbookOK(this);"
if !exists $$args{"onsubmit"};
$$args{"cols"} = [qw(message name identity location email captcha url)]
if !exists $$args{"cols"};
$$args{"auto_referer2"} = 0
if !exists $$args{"auto_referer2"};
$self = $class->SUPER::new($status, $args);
return $self;
}
# _html_col_message: The message
sub _html_col_message : method {
local ($_, %_);
my ($self, $val, $label, $default, $colspan, $hdef);
$self = $_[0];
$colspan = $self->_colspan_full;
$default = C_("Fill in your message here.");
$val = $self->_val_textarea("message", $default);
$hdef = h($default);
print << "EOT";
<tr>
<td class="gbmessage"$colspan><textarea id="message" name="message" cols="50" rows="10"
onfocus="if (this.value == &quot;$hdef&quot;) this.value = &quot;&quot;;">$val</textarea></td>
</tr>
EOT
return;
}
return 1;