Audio-DB

 view release on metacpan or  search on metacpan

DB/Web.pm  view on Meta::CPAN

package Audio::DB::Web;

# $Id: Web.pm,v 1.2 2005/02/27 16:56:25 todd Exp $

# ALL THE SQL queries need to be moved in dbi::mysql module

use strict 'vars';
use vars qw(@ISA $VERSION);
#use Apache::Constants qw(:common REDIRECT HTTP_NO_CONTENT);

use CGI qw/:standard *table *div *TR/;
use CGI::Cookie;

use DBI;
use Audio::DB;
use Audio::DB::Query;
use Audio::DB::Util::Rearrange;
use Audio::DB::Util::SystemConfig;
use Audio::DB::Util::Playlists;

use Audio::DB::DataTypes::Artist;
use Audio::DB::DataTypes::ArtistList;
use Audio::DB::DataTypes::Album;
use Audio::DB::DataTypes::AlbumList;
use Audio::DB::DataTypes::Genre;
use Audio::DB::DataTypes::GenreList;
use Audio::DB::DataTypes::Song;
use Audio::DB::DataTypes::SongList;

@ISA = qw/Audio::DB Audio::DB::Query/;

###################################################
# The new constructor is inherited from Audio::DB #
###################################################

# Farms out requests to various subs,
# creating the appropriate objects
sub process_requests {
  my $self = shift;
   return ($self->authenticate()) if (param('submit') eq 'Log In');
  
  # Nothing to process if the action is a 'tryin'
  # to retrieve the search form...passed as the 'search' value to the action key
  return if (url_param('action') eq 'search');
  
  # System Configuration, including user management
  return Audio::DB::Util::SystemConfig->new($self->dbh) if (url_param('admin'));
  
  # PLAYLISTS - Either trying to manipulate a playlist
  # by a form, grab it by a url...
  if (param('todo') eq 'add to playlist' || url_param('playlist')) {
    return Audio::DB::Util::Playlists->new($self->{dbh},$self->{user_id});
  } elsif (url_param('song_id')) {
    return ($self->_fetch_song);
  } else {
    # Searches from the form
    # Generating a coderef on the fly??
    my $coderef = 'search' if param('search_term');
    $coderef ||= url_param('action') . '_' . url_param('class') 
      if (url_param('action') && url_param('class'));
    if ($coderef) {
      my $results = $self->$coderef;
      return $results;
    }
  }
}



################################
# Generic database manipulation
################################



( run in 1.264 second using v1.01-cache-2.11-cpan-39bf76dae61 )