Gossamer Forum
Home : Products : Gossamer Links : Discussions :

print.cgi modification

Quote Reply
print.cgi modification
I found a great mod listed under the resources section on the GT web site. Unfortunately, it looks like the mod was writting for versions 1.x of Links SQL. The mod, print.cgi, looks fairly easy to setup... however I think several of the perl modules bundled with Links SQL have changed.

Can someone take a look at this code for me and see what needs to be modified? It should be fairly easy.

Code:
#!/usr/bin/perl
# ==============================================================
# -------------
# Links SQL
# -------------
# Links Manager
#
# Author: Alex404
# Email: silberling@t-online.de
#
# for Version: 1.x of Links SQL (c)Gossamer Threads Inc
# ============================================================== # Load required modules.
# ---------------------------------------------------
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'admin';
use Links;
use Links::DBSQL;
use Links::DB_Utils;
use Links::HTML_Templates;
use strict;
use vars qw!$LINKDB $CATDB $GRAND_TOTAL $USE_HTML!;
&main;
# ==============================================================



sub main {
# --------------------------------------------------------------
# Wrap in a subroutine to prevent possible mod_perl probs.
#
my $in = new CGI;
my $id = $in->param('ID') || undef;

# Check the parameter

$id =~ s/[^0-9]//g;

if ($id > 0 ) { &print_page($in,$id) }
else {
print $in->header();
&site_html_error ( { error => "Sorry, I'm not sure what page you are asking for: '$id'" }, $in);
return;
}
}



sub print_page {
# --------------------------------------------------------
# This routine build a single page for printout
#
my ($in,$id) = @_;
my ($link_db, $cat_db, $link, $category, $category_name, $total);




# Create our database objects.



$link_db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Links.def";
$cat_db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Category.def";
$link = $link_db->get_record ($id, 'HASH');



# Check if the link exists

if (!$link) {
print $in->header();
&site_html_error ( { error => "Sorry, we don't seem to have link '$id'" }, $in);
return;
}



# We seem to have a valid link

$category = $cat_db->get_record ($link->{'CategoryID'}, 'HASH');
$category_name = $category->{'Name'};
$total = $link_db->total();



print $in->header();
print &print_html ($link,{Total =>$total, CategoryName => $category_name});
}
1;
Code:
sub print_html {
# --------------------------------------------------------
# This routine will build a single page per link for printing
#
# be shure to add it to @EXPORT array in the beginning of HTML_Templates.pm
#
my ($rec, $tags) = @_;
my $template =undef;
my $dynamic = undef;
(ref $rec eq 'HASH') or croak "HTML_TEMPLATES: Argument '$rec' must be hash reference";
(ref $tags eq 'HASH') or croak "HTML_TEMPLATES: Argument '$tags' must be hash reference";
# Set new and pop to either 1 or undef for templates.
($rec->{'isNew'} eq 'Yes') ? ($rec->{'isNew'} = 1) : (delete $rec->{'isNew'});
($rec->{'isChanged'} eq 'Yes') ? ($rec->{'isChanged'} = 1) : (delete $rec->{'isChanged'});
($rec->{'isPopular'} eq 'Yes') ? ($rec->{'isPopular'} = 1) : (delete $rec->{'isPopular'});
#
defined $dynamic and &load_user ($dynamic, $tags);
my $output = &load_template ('print.html', {%$tags, %$rec, %GLOBALS }, undef, undef );
defined $dynamic and &clean_output($dynamic, \$output);
return $output;
}


Thanks,



Jaron

Last edited by:

pugdog: Mar 17, 2002, 11:11 AM
Subject Author Views Date
Thread print.cgi modification jlbrass 2096 Mar 10, 2002, 5:20 PM
Thread Re: [jlbrass] print.cgi modification
fmp 1990 Mar 17, 2002, 10:35 AM
Thread Re: [fmp] print.cgi modification
pugdog 1956 Mar 17, 2002, 11:19 AM
Thread Re: [pugdog] print.cgi modification
fmp 1933 Apr 2, 2002, 1:22 AM
Post Re: [fmp] print.cgi modification
Alex 1909 Apr 3, 2002, 2:51 PM