package Gestinanna::ContentProvider::Portal; use base qw(Gestinanna::ContentProvider); use Data::UUID; sub config { my($class, $config) = @_; } sub init { my($class, %info) = @_; my $self = $class -> SUPER::init(%info); my $R = Gestinanna::Request -> instance; #warn "initialized " . __PACKAGE__ . " object: $self\n"; # use Data::Dumper; # warn "Info: " . Data::Dumper -> Dump([\%info]); # we want to use the default page or the user's preference my $actor_id = $R -> session -> {actor_id}; # we want to put portal pages under revision control so customers can undo changes :) # but this is limited to undo|redo - no branching my $page; my $site = $R -> config -> {site}; my @possibilities; # we might want to become more sophisticated, but this should do okay for now # example: add bits and pieces depending on the state of the user: student, staff, OC, etc. if($info{filename}) { @possibilities = ( $info{filename} ); } elsif(defined $actor_id) { @possibilities = ( "/user/$actor_id/$site$info{filename}", "/user/_default/$site$info{filename}", "/user/_default/0$info{filename}", ); } else { my @possibilities = ( "/default/$site$info{filename}", "/default/0$info{filename}", ); } while(@possibilities) { my $p = shift @possibilities; #warn "Getting $p\n"; $page = $R -> factory -> new( $info{type} => object_id => $p, #(defined($actor_id) # ? (tag_path => [ $actor_id, @{$info{factory}->{tag_path}||[]} ]) # : ( ) #), ); #warn "\$page -> is_live: " . $page -> is_live . "\n"; last if $page -> is_live; } #return $sm -> view; # we need to return a content provider for the view return $R -> error( error => 'not-found.view.portal', args => { uri => $info{filename}, actor_id => $actor_id, site => $site, }, ) unless $page -> is_live; my $parser = XML::LibXML -> new; my $xml = $page -> data; $self -> {dom} = $parser -> parse_string($xml); #Carp::cluck "Returning $self"; $self -> dom; # make sure things are initialized and Ops can be thrown at the right time return $self; } sub content { my $self = shift; my $content = $self -> dom -> toString(0); return \$content; } sub dom { my $self = shift; my $dom = $self -> {dom}; return $dom if $self -> {_processed_dom}; my $parser = XML::LibXML -> new; # find top-level
and insert