ASP-NextLink

 view release on metacpan or  search on metacpan

NextLink.pm  view on Meta::CPAN

#####################################################################
#
# ASP::NextLink - Perl implementation of the ASP
#                 Content-Linking component
#
# Author: Tim Hammerquist
# Revision: 0.11
#
#####################################################################
#
# Copyright 2000 Tim Hammerquist.  All rights reserved.
#
# This file is distributed under the Artistic License.
# See http://www.perl.com/language/misc/Artistic.html or
# the license that comes with your perl distribution.
#
# Contact me at cafall@voffice.net with any comments,
# flames, queries, suggestions, or general curiosity.
#
#####################################################################
package ASP::NextLink;

use strict;
use CGI::Carp;
use vars qw( $VERSION );

$VERSION = '0.11';

sub new {
	my $class = shift;
	die "Cannot call class method on an object" if ref $class;
	my $linkfile = $main::Server->MapPath( shift );
	my $self = {};
	bless $self, $class;
	$self->parse_linkfile( $linkfile );
	$self;
}

sub parse_linkfile {
	my ($self, $linkfile, $idx) = (shift, shift, 0);
	die "Cannot call object method on class"  unless ref $self;
	open LNX, "<$linkfile" or die "Can't open $linkfile: $!\n";
	while ( <LNX> ) {
		chomp;
		if ( /^([^\t]+)\t([^\t]+)\t?.*$/ ) {
			$idx++;
			$self->{_url}{$main::Server->MapPath($1)} = $idx;
			$self->{_idx}{$idx} = [ $1, $2 ];
		}
	}
	close LNX;
	$self->{_file} = $linkfile;
	$self->{_count} = $idx;
	1;
}

=head1 NAME

ASP::NextLink - Perl implementation of the NextLink ASP component

=head1 SYNOPSIS

	require ASP::NextLink;
	$nl = new ASP::NextLink('linkfile.ext');

	$current = $nl->GetListIndex;
	for $idx (1..$nl->GetListCount) {
		my $url =	$nl->GetNthURL($idx);
		my $desc =	$nl->GetNthDescription($idx);
		if ($idx == $current) {
			print qq(<A href="$url">$desc</A><BR>);
		}
		else {
			print qq(<B>$desc</B>);
		}
	}

=head1 DESCRIPTION

ASP::NextLink is a Perl implementation of MSWC.NextLink, ASP's
content-linking component for use with Apache::ASP.

=head1 NOTES

ASP::NextLink is NOT functionally equivalent to MSWC.NextLink.
Whereas each method of MSWC.NextLink takes a file argument,
ASP::NextLink takes a file argument ONLY in the constructor
( ASP::NextLink->new("linkfile") ). new() parses the linkfile
given; the information derived from this linkfile is subsequently
available only through the object returned by new().

Attempts to call object methods on a class and attempts to call
class methods on an object will both trigger an exception.



( run in 2.144 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )