Apache-Keywords
view release on metacpan or search on metacpan
CONTENTS
The package Apache::Keywords contains:
Makefile.PL
lib/Apache/Keywords.pm
README
MANIFEST
PREREQUISITES
You need Apache::Constants and Apache::Cookie to use
Apache::Keywords.
INSTALLATION
tar zxf Apache-Keywords-0.1.tar.gz
perl Makefile.PL
make
make install
SYNOPSIS
In a dynamic mod_perl source-file:
lib/Apache/Keywords.pm view on Meta::CPAN
package Apache::Keywords;
# Copyright 2000 Magnus Cedergren, mace@lysator.liu.se
#
# This library is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
use Apache::Constants qw(:common);
use Apache::Cookie;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
require Exporter;
require AutoLoader;
#Items to export to callers namespace
@EXPORT = qw();
$VERSION = '0.1';
lib/Apache/Keywords.pm view on Meta::CPAN
The package Apache::Keywords contains:
Makefile.PL
lib/Apache/Keywords.pm
README
MANIFEST
=head1 PREREQUISITES
You need Apache::Constants and Apache::Cookie to use Apache::Keywords.
=head1 INSTALLATION
tar zxf Apache-Keywords-0.1.tar.gz
perl Makefile.PL
make
make install
=head1 SYNOPSIS
lib/Apache/Keywords.pm view on Meta::CPAN
# "Touch" the file, so that the ContentHandler really sends the file
# (including the updated cookie)
my $now = time;
utime $now,$now,$r->filename;
# If there are any new keywords from this document, update the user's
# profile and re-store it in the cookie
# Get old "keywords" cookie
if (!defined($name) || $name eq "") {
$name = "Keywords";
}
my $cookie = Apache::Cookie->new($r);
$keywords = $cookie->get($name);
# Make profile
$keywords = make_profile($keywords,$new_keywords);
if (defined($expires)) {
$cookie->set(-expires => $expires);
}
if (defined($domain)) {
$cookie->set(-domain => $domain);
}
if (defined($path)) {
lib/Apache/Keywords.pm view on Meta::CPAN
$domain = $self->{DOMAIN};
} elsif ($r) {
$domain = $r->dir_config('KeywordsDomain');
}
if (defined($self->{PATH})) {
$path = $self->{PATH};
} elsif ($r) {
$path = $r->dir_config('KeywordsPath');
}
# Get old "keywords" cookie
my $cookie = Apache::Cookie->new($r);
$keywords = $cookie->get($name);
# Make profile
$keywords = make_profile($keywords,$new_keywords);
# Replace the old cookie with a new one
if (!defined($expires) || length($expires) <= 0) {
$expires = undef;
}
if (!defined($domain) || length($domain) <= 0) {
$domain = undef;
}
lib/Apache/Keywords.pm view on Meta::CPAN
Return the profile in a hash reference, e.g. profile->{'horse'} == 3,
profile->{'dog'} == 2.
=cut
# Return the profile in a hash
sub profile {
my ($self,$r) = @_;
my ($keywords,$cookie,@k,@item,$i);
my %ret = ();
my $cookie = Apache::Cookie->new($r);
my $name = $self->name;
if (!defined($name) || $name eq "") {
$name = "Keywords";
}
$cookie = Apache::Cookie->new($r);
$keywords = $cookie->get($name);
@k = split(/\,\s*/,$keywords);
for ($i=0;$i<=$#k;$i++) {
@item = split(/\:\s*/,$k[$i]);
$ret{$item[0]} = $item[1];
}
return \%ret;
}
=item $k->profile_asp
( run in 0.278 second using v1.01-cache-2.11-cpan-4e96b696675 )