KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/compasssysweb/calendar/CalciumDir39/Calendar/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/compasssysweb/calendar/CalciumDir39/Calendar/GetHTML.pm
# Copyright 1999-2003, Fred Steinberg, Brown Bear Software

# GetHTML

package GetHTML;
use strict;

use CGI (':standard');
use Calendar::Date;
use Calendar::I18N;
use Calendar::Preferences;
use Calendar::MasterDB;

# Centered, bold, something like:   February 16, 1999
#                                        Tuesday
sub dateHeader {
    my $className = shift;
    my ($i18n, $title, $date) = @_;

    $title ||= '';
    $title =~ s/\n/<br>/g unless ($title =~ /<[^>]*>/);

    my $monthName = $i18n->get ($date->monthName);
    my $dateString;
    if ($i18n->getLanguage ne 'English') {
        $dateString = $date->day . " $monthName " . $date->year;
    } else {
        $dateString = "$monthName " . $date->day . ', ' . $date->year;
    }

    "<center><h1>" .
    ($title ? "$title<br>" : '')  .
    "$dateString<br><small><small>" .
    $i18n->get ($date->dayName()) .
    "</small></small></h1></center>";
}


# Produce a popup to select a date.
# Pass hash pairs with 'name', 'default', 'start' keys.
# The name of each popup_menu will be the 'name' passed in prepended to
#  'YearPopup', 'MonthPopup', & 'DayPopup'.
# 'default' is a date ref; defaults to today
# 'start' is to specify the earliest year in the popup; defaults to this year
# 'numYears' is how many years to include in the year popup
# 'excludeDay' is whether or not to supress the date popup
# 'onChange' is JavaScript code to call on selecting anything
sub datePopup {
    my $className = shift;
    my ($i18n, $params) = @_;
    my $today = Date->new();
    my %args = (name       => '',
                default    => $today,
                start      => $today,
                numYears   => 5,
                excludeDay => undef,
                onChange   => '',
                %$params);

    my $html;
    my ($monthPopup, $dayPopup, $yearPopup);
    $monthPopup =
            popup_menu ('-name'    => $args{name} . 'MonthPopup',
                        '-default' => $args{default}->month(),
                        '-values'  => [1..12],
                        '-labels'  => {map {$_,
                                            $i18n->get (Date->monthName ($_))}
                                           (1..12)},
                        '-onChange' => $args{onChange});

    $dayPopup = '';
    $dayPopup =
            popup_menu ('-name'     => $args{name} . 'DayPopup',
                        '-default'  => $args{default}->day(),
                        '-values'   => [1..31],
                        '-onChange' => $args{onChange})
            unless $args{excludeDay};

    $yearPopup =
            popup_menu ('-name'    => $args{name} . 'YearPopup',
                        '-default' => $args{default}->year(),
                        '-values'  => [$args{start}->year() ..
                                       $args{start}->year() + $args{numYears}],
                        '-onChange' => $args{onChange});

    if ($i18n->getLanguage ne 'English') {
        $html = "$dayPopup$monthPopup,$yearPopup";
    } else {
        $html = "$monthPopup$dayPopup,$yearPopup";
    }
    return $html;
}



sub AdminHeader {
    my ($className, %args) = @_;
    my $calName = $args{cal};
    my $group   = $args{group};
    my $section = $args{section};
    my $i18n    = $args{i18n}  || I18N->new (Preferences->new
                                              (MasterDB->new)->Language);
    my $html;
    my @rows;

    my $targetLabel = 'for Calendar: ';
    my $target      = $calName;

    if ($args{goob}) {
        $targetLabel = $args{goob}; # e.g. "Calendars not in any group"
        $target = '&nbsp;';
    }
    elsif ($group) {
        $targetLabel = 'for Calendar Group: ';
        $target      = $group;
    }

    push @rows, Tr (td ({align => 'center'},
                        font ({-size => 6},
                              b ($i18n->get ('Calendar Administration')))));
    push @rows, Tr (td ({align => 'center'},
                        font ({-size => 4}, $i18n->get ($targetLabel)) .
                        font ({-size  => 6,
                               -color => 'blue'}, $target)))
        if $target;
    push @rows, Tr (td ({-align   => 'center',
                         -bgcolor => 'thistle'},
                        font ({-size => 3}, b ($i18n->get ($section)))))
        if $section;


    $html = table ({-align   => 'center',
                    -width   => '100%',
                    -bgcolor => '#cccccc'},
                   \@rows);
    $html;
}

sub OptionsHeader {
    my $className = shift;
    my ($i18n, $calName, $sectionName) = (@_);
    my $html;
    my @rows;

    push @rows, Tr (td ({align => 'center'},
                        font ({-size => 6},
                              b ($i18n->get ('Options for Calendar:'))),
                        font ({-size  => 6,
                               -color => 'blue'}, $calName)))
        if $calName;
    push @rows, Tr (td ({-align   => 'center',
                         -bgcolor => 'thistle'},
                        font ({-size => 5}, b ($i18n->get ($sectionName)))))
        if $sectionName;

    $html = table ({-align   => 'center',
                    -width   => '100%',
                    -bgcolor => '#cccccc'},
                   \@rows);
    $html;
}

sub PageHeader {
    my $className = shift;
    my ($text) = (@_);
    my $html;
    return unless $text;
    $html = table ({-width   => '100%',
                    -bgcolor => '#cccccc'},
                   Tr (td ({align => 'center'},
                           font ({-size => 6}, b ($text)))));
    $html;
}

sub SectionHeader {
    my $className = shift;
    my ($sectionName) = (@_);
    my $html;
    return unless $sectionName;
    $html = table ({-width   => '100%',
                    -bgcolor => 'thistle'},
                   Tr (td ({align => 'center'},
                           font ({-size => 3}, b ($sectionName)))));
    $html;
}

sub SysAdminHeader {
    my ($class, $i18n, $pageTitle, $notDefaults) = @_;
    my $html;
    my $header = 'Calcium ' . $i18n->get ('System Administration');
    $header .= '<br>' . $i18n->get ('Defaults for New Calendars')
        unless $notDefaults;

    $html = $class->PageHeader ($header);
    $html .= $class->SectionHeader ($i18n->get ($pageTitle));
    $html .= h3 ($i18n->get ('Note: these are defaults you can use when '  .
                             'creating <em>new</em> calendars. They will ' .
                             'not affect any calendars which already exist.'))
        unless $notDefaults;
    $html;
}

sub errorPage {
    my $className = shift;
    my $i18n = shift;
    my %args = (header    => '',
                message   => '',
                isWarning => 0,
                backCount => -1,
                moreStuff => undef,
                @_);

    $i18n = I18N->new (Preferences->new (MasterDB->new)->Language)
        unless $i18n;

    my $title = ($args{isWarning} ? 'Calendar Warning' : 'Calendar Error');
    my $cgi = CGI->new;
    print $cgi->header;
    print $cgi->start_html ('-title'   => $i18n->get ($title),
                            '-bgcolor' => 'white');
    print $className->PageHeader ('Compass Calendar ' .
                                  ($args{isWarning} ? $i18n->get ('Warning')
                                                    : '<font color=red>'   .
                                                      $i18n->get ('Error') .
                                                      '</font>'));
    print $className->SectionHeader ($args{header});
    print "<blockquote><p>$args{message}</blockquote></p>";

    print "<blockquote><p>$args{moreStuff}</p><blockquote>"
        if ($args{moreStuff});

    print '<table width="95%", align="center"><tr><td>';
    print $cgi->startform (-onSubmit => 'return false;');
    print submit (-name    => 'Back',
                  -value   => $i18n->get ('Go Back'),
                  -onClick => "history.go($args{backCount})")
        if $args{backCount};

    print $cgi->endform;
    print '</td></tr></table>';
    print $cgi->end_html;
}

1;

Anon7 - 2021