Liz::URLSet - URLSet module
use Liz::URLSet;
$url = new Liz::URLSet;
#!/usr/local/bin/perl
use Liz::URLSet;
The Liz::URLSet package allows for very simple storage of sets of urls. As such it can function as a database for links associated with a client or a project.
The Liz::URLSet module itself works best when incorporated into a client module because it moves the responsibility of aquiring a connection to a database to the client module and it allows any customisation to take place transparently to the developer.
Take for example the URLSet method of HN.pm module:
sub URLSet {
# Obtain the parameters # Start the url using the $hn handle as the database handle # Return the finished object
my( $hn,$token ) = @_; my( $urlset ) = Liz::URLSet->new( $token,$hn ); $urlset; }
Because of the above code in HN.pm, it is now possible to write the following code:
$hn = new HN; $urlset = $hn->URLSet( 'technology' );
Note that the database connection of the url is hidden in the creation of
the $hn object.
The following methods can be called without an object specification, but as a class method such as Liz::URLSet->method().
Return list of url identification names of all urlsets in the database specified. Usually not called by itself, but rather incorporated inside a Client Module.
1 wildcard specification to match (default: all) 2 Liz::SQL compatible handle or reference to routine that performs connect (default: &Connect from caller's namespace)
1 reference to list of identification names in the current database 2 reference to hash with full names
$hn = new HN;
($id,$name) = $hn->URLSets;
$urlsets = @{$id};
print "All $urlsets urlsets in Hospitality Net:\n";
foreach( @{$id} ) {
print " URLSet '$$name{$_}' ($_)\n";
}
In HN.pm:
sub URLSets { Liz::URLSet->urlsets( $_[1],$_[0] ) }
Create a new Liz::URLSet object. Creates connection or re-establishes connection with the MySQL database. Usually not called by itself, but rather incorporated inside a Client Module.
1 identification name of url set (default: default url set for database) 2 Liz::SQL compatible handle or reference to routine that performs connect (default: &Connect from caller's namespace)
1 instantiated object 2 flag whether URLSet was just created
$hn = new HN; $url = $hn->URLSet( 'technology' );
In HN.pm:
sub URLSet { Liz::URLSet->new( $_[1],$_[0] ) }
Delete one or more urls from the Liz::URLSet database without first having to create an object for each url to be deleted.
1..N url ID's to be deleted
$hn = new HN; $url = $hn->URLSet( 'technology' ); $url->delete( 3000320,3000321 );
Remove all urls from this URLSet.
$urlset->reset; print "All urls have been removed\n";
The following methods allow changes to information that is associated with an entire urlset.
Specify or return the current name of the urlset object. The name can be anything to further identify the goal of the urlset.
1 new name of urlset (default: no change)
1 current/old name of urlset
$xxlink = new xxLINK; $urlset = $xxlink->URLSet( 'libris' ); $urlset->Name( 'Links op de Libris Website' );
The following methods create HTML of Liz::Perl's pseudo HTML from information in a urlset.
Return the almost complete HTML for the display of a link to the url. Use method LINK to obtain the complete HTML for a link.
1 ID of the url of which to return the HTML 2 ALT-text to be used (default: alt-text specified with the url)
1 almost complete HTML for a link 2 title of the link in the database
<A <PRINT "$urlset->HREF( $linkID )">>link</A>
Return the complete HTML for the display of a link to the url.
1 ID of the url of which to return the HTML 2 ALT-text to be used (default: alt-text specified with the url) 3 Title to be used (default: title specified with the URL
1 complete HTML for a link
<PRINT "$urlset->LINK( $linkID )">
The following methods allow changes to a single url in a URLSet.
Create a new Liz::URLSet::URL object, either from existing information or for a new entry. For more documentation, see the Liz::URLSet::URL object itself.
1 ID to create URL object with (default: none = new url)
1 instantiated URL object
$hn = new HN; $urlset = $hn->URLSet( 'technology' );
$url = $urlset->URL; $url = $urlset->URL( $urlID );
Return an SQL statement handle for a list of urls. This list can be either from the top or of all urls immediately belonging to another url.
The following fields may be specified with the 2nd parameter:
ID The ID of the url
title The title of the url
serverID The ID of the server on which the URL is located
uri The part of the URL after the servername
anchor Any internal anchor specification (always begins with "#")
parameters Any extra CGI-like parameters (always begin with "?")
alt The default ALT-texts to be used with this url
published Timestamp value when this url was published
lastchecked Timestamp value when this url was last checked
created Timestamp value when this url was created
updated Timestamp when the url was last updated
options Options associated with the url
status The status of this url
1 fields to return (comma delimited) (default: 'ID,title,serverID,uri,anchor,parameters,alt,published,lastchecked,created,updated,options,status' ); 2 fieldname on which to order the result (default: 'created') 3 extra condition to be applied (default: none)
1 SQL statement handle (on which method "fetchrow" can be applied)
Elizabeth Mattijsen ( lizperl@INC.nl )
(C) 1998-1999 International Network Consultants
Put module name between quotes to fix obscure bug in Perl 5.005x under ModPerl in method new.
Put module name between quotes to fix obscure bug in Perl 5.005x under ModPerl in method URL.
Now no longer puts Exporter in ISA: it was not needed.
Fixed problem introduced on August 20th.
Added support for extra fields to method new.
Method urlsets reduced to a call to Liz::SQL's ``sets''.
Method new now calls Liz::SQL's ``new'' to create object.
Changed to new source typography.
Removed dependency on local GetSetMeta internal subroutine and replaced this with a call to the new method TableMeta of the Liz::SQL module.
Changed CREATE TABLE to new Liz::SQL 'create' method format.
Changed from using method ``Exists'' to ``Count'' in method new to allow for a much faster check on the existence of a table.
First version of this true Perl module.