89 lines
2.5 KiB
Perl
89 lines
2.5 KiB
Perl
# ==================================================================
|
|
# Gossamer List - enhanced mailing list management system
|
|
#
|
|
# Website : http://gossamer-threads.com/
|
|
# Support : http://gossamer-threads.com/scripts/support/
|
|
# CVS Info :
|
|
# Revision : $Id: HTML.pm,v 1.10 2004/03/01 21:38:38 bao Exp $
|
|
#
|
|
# Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved.
|
|
# Redistribution in part or in whole strictly prohibited. Please
|
|
# see LICENSE file for full details.
|
|
# ==================================================================
|
|
#
|
|
|
|
package GList::HTML;
|
|
|
|
use strict;
|
|
use GList q/:objects/;
|
|
|
|
sub date_get {
|
|
#----------------------------------------------------------------------
|
|
#
|
|
my ($fld_name, $type) = @_;
|
|
|
|
my $tags = GT::Template->tags;
|
|
my $format = $tags->{usr_date_format};
|
|
$format =~ s/\#/\%/g;
|
|
$format ||= '%mm%-%dd%-%yyyy%';
|
|
$format .= ' %hh%:%MM%:%ss%' if ( $type );
|
|
|
|
require GT::Date;
|
|
( $fld_name ) or return GT::Date::date_get(time, $format);
|
|
|
|
my $record = $tags->{results}[$tags->{row_num} - 1];
|
|
return GT::Date::date_get($record->{$fld_name} || $tags->{$fld_name}, $format);
|
|
}
|
|
|
|
sub html_unescape {
|
|
#--------------------------------------------------------------------
|
|
#
|
|
my $content = shift;
|
|
$content =~ s/\n/<br>/g;
|
|
return $content;
|
|
}
|
|
|
|
sub generate_attachments {
|
|
#---------------------------------------------------------------------
|
|
#
|
|
my $col = shift || 'msg_id';
|
|
|
|
my $tags = GT::Template->tags;
|
|
my $val = $tags->{results}[$tags->{row_num} - 1]->{$col};
|
|
( $val ) or return;
|
|
|
|
my $sth;
|
|
if ( $col eq 'msg_id' ) {
|
|
$sth = $tags->{html}->{sql}->table('MessageAttachments')->select({ att_message_id_fk => $val });
|
|
}
|
|
else {
|
|
$sth = $tags->{html}->{sql}->table('MailingAttachments')->select({ mat_mailing_id_fk => $val });
|
|
}
|
|
my $attachments;
|
|
while ( my $rs = $sth->fetchrow_hashref ) {
|
|
push @$attachments, $rs;
|
|
}
|
|
|
|
return { attachments => ( !$attachments ) ? 0 : $attachments };
|
|
}
|
|
|
|
sub generate_years {
|
|
#-------------------------------------------------------------------
|
|
#
|
|
my $tags = GT::Template->tags;
|
|
my $min = $tags->{html}->{sql}->table('MailingIndex')->select(['MIN(mli_done)'])->fetchrow_array || time;
|
|
|
|
require GT::Date;
|
|
my $yy_min = GT::Date::date_get($min, '%yyyy%');
|
|
my $yy_max = GT::Date::date_get(time, '%yyyy%');
|
|
my @output;
|
|
for my $i ( $yy_min .. $yy_max ) {
|
|
push @output, { y => $i };
|
|
}
|
|
return { loop_years => \@output };
|
|
}
|
|
|
|
1;
|
|
|
|
|