# -------------------------------------------------------------------------------------
# flo::Record::Redirect
# -------------------------------------------------------------------------------------
#
#       Author : Jean-Michel Hiver (jhiver@cisedi.com).
#    Copyright : (c) MKDoc Holdings Ltd, 2000.
# 
#      Unauthorized modification, use, reuse, distribution or redistribution
#      of this module is stricly forbidden.
#
#    Description:
#
#      Every record from the 'Redirect' table will be blessed into this class
#      so that we can add extra method to access to in the template engine.
#
# -------------------------------------------------------------------------------------
package flo::Record::Redirect;
use flo::Standard;


##
# $self->ID;
# ----------
#   Accessor for the ID attribute
##
sub ID
{
    my $self = shift;
    $self->{ID} = shift || return $self->{ID};
}


##
# $self->Old_Path;
# ----------------
#   Accessor for the Old_Path attribute
##
sub Old_Path
{
    my $self = shift;
    $self->{Old_Path} = shift || return $self->{Old_Path};
}


##
# $self->New_Path;
# ----------------
#   Accessor for the New_Path attribute
##
sub New_Path
{
    my $self = shift;
    $self->{New_Path} = shift || return $self->{New_Path};
}


##
# $self->Old_URI;
# ---------------
#   Computes the Old URI for that redirect from the Old_Path and
#   the CGI object
##
sub Old_URI
{
    my $self  = shift;
    my $cgix  = cgi->new;
    foreach ($cgix->param) { $cgix->delete ($_) }
    $cgix->path_info ($self->Old_Path);
    return $cgix->self_url;
}


##
# $self->New_URI;
# ---------------
#   Computes the Old URI for that redirect from the New_Path and
#   the CGI object
##
sub New_URI
{
    my $self  = shift;
    my $cgix  = cgi->new;
    foreach ($cgix->param) { $cgix->delete ($_) }
    $cgix->path_info ($self->New_Path);
    return $cgix->self_url;
}

1;
