117 lines
3.9 KiB
Perl
117 lines
3.9 KiB
Perl
# Selima Website Content Management System
|
|
# Guestbook.pm: The base administrative 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;
|
|
use 5.008;
|
|
use strict;
|
|
use warnings;
|
|
use base qw(Selima::Form);
|
|
|
|
use Selima::FormFunc;
|
|
use Selima::HTTP;
|
|
use Selima::MarkAbbr;
|
|
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";
|
|
$$args{"type"} = form_type
|
|
if !exists $$args{"type"};
|
|
$$args{"table"} = "guestbook"
|
|
if !exists $$args{"table"};
|
|
$$args{"deltext"} = C_("Delete this message")
|
|
if !exists $$args{"deltext"};
|
|
if (!exists $$args{"summary"}) {
|
|
# A form to create a new item
|
|
if ($$args{"type"} eq "new") {
|
|
$$args{"summary"} = C_("This table provides you a form to add a new message.");
|
|
# A form to edit a current item
|
|
} elsif ($$args{"type"} eq "cur") {
|
|
$$args{"summary"} = C_("This table provides you a form to edit a current message.");
|
|
# A form to delete a current item
|
|
} elsif ($$args{"type"} eq "del") {
|
|
$$args{"summary"} = C_("This table provides you a form to delete a message.");
|
|
}
|
|
}
|
|
if (!exists $$args{"cols"}) {
|
|
# A form to create a new item
|
|
if ($$args{"type"} eq "new") {
|
|
$$args{"cols"} = [qw(name identity location email url message hid)];
|
|
# A form to edit a current item
|
|
# A form to delete a current item
|
|
} elsif ($$args{"type"} eq "cur" || $$args{"type"} eq "del") {
|
|
$$args{"cols"} = [qw(sn name identity location email url message hid
|
|
ip host ct pageno oldpageno
|
|
created createdby updated updatedby)];
|
|
}
|
|
}
|
|
if (!exists $$args{"title"}) {
|
|
# A form to create a new item
|
|
if ($$args{"type"} eq "new") {
|
|
$$args{"title"} = C_("Write a New Message");
|
|
# A form to edit a current item
|
|
} elsif ($$args{"type"} eq "cur") {
|
|
$$args{"title"} = C_("Edit a Current Message");
|
|
# A form to delete a current item
|
|
} elsif ($$args{"type"} eq "del") {
|
|
$$args{"title"} = C_("Delete a Message");
|
|
}
|
|
}
|
|
$self = $class->SUPER::new($status, $args);
|
|
${$self->{"maxlens"}}{"message"} = 10240;
|
|
return $self;
|
|
}
|
|
|
|
# _html_col_ct: The country
|
|
sub _html_col_ct : method {
|
|
$_[0]->_html_coltmpl_ro_ct("ct", h_abbr(C_("Country:")));
|
|
}
|
|
|
|
# _html_col_hid: Hide?
|
|
sub _html_col_hid : method {
|
|
$_[0]->_html_coltmpl_bool("hid", h_abbr(C_("Hide?")),
|
|
h_abbr(C_("Hide this message")), h_abbr(C_("Show this message")),
|
|
h_abbr(C_("Hide this message currently.")));
|
|
}
|
|
|
|
# _html_col_name: The name
|
|
sub _html_col_name : method {
|
|
$_[0]->_html_coltmpl_text("name", h_abbr(C_("Signature:")));
|
|
}
|
|
|
|
# _html_col_oldpageno: The old page number
|
|
sub _html_col_oldpageno : method {
|
|
$_[0]->_html_coltmpl_ro("oldpageno", h_abbr(C_("Old page no.:")));
|
|
}
|
|
|
|
# _html_col_pageno: The page number
|
|
sub _html_col_pageno : method {
|
|
$_[0]->_html_coltmpl_ro("pageno", h_abbr(C_("Page no.:")));
|
|
}
|
|
|
|
return 1;
|