several small improvements to lots of stuff

This commit is contained in:
JT Smith 2006-04-07 17:15:53 +00:00
parent d272e7de58
commit 7cf2c22a95
12 changed files with 122 additions and 64 deletions

View file

@ -1033,22 +1033,8 @@ Renders self->view based upon current style, subject to timeouts. Returns Privil
sub www_view {
my $self = shift;
return $self->session->privilege->noAccess() unless $self->canView;
unless ($self->canView) {
if ($self->get("state") eq "published") { # no privileges, make em log in
return $self->session->privilege->noAccess();
} elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^trash/) { # show em trash
$self->session->http->setRedirect($self->getUrl("func=manageTrash"));
return undef;
} elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^clipboard/) { # show em clipboard
$self->session->http->setRedirect($self->getUrl("func=manageClipboard"));
return undef;
} else { # tell em it doesn't exist anymore
$self->session->http->setStatus("410");
return WebGUI::Asset->getNotFound($self->session)->www_view;
}
}
# must find a way to do this next line better
$self->session->http->setCookie("wgSession",$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{"wgSession"};
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->getHeader;
$self->prepareView;
my $style = $self->getParent->processStyle("~~~");

View file

@ -266,7 +266,11 @@ This method sets the tags from the head block parameter of the template into the
sub prepare {
my $self = shift;
$self->{_prepared} = 1;
$self->session->style->setRawHeadTags($self->get("headBlock"));
if ($self->session->style->sent) {
$self->session->output->print($self->get("headBlock"));
} else {
$self->session->style->setRawHeadTags($self->get("headBlock"));
}
}

View file

@ -552,23 +552,8 @@ Renders self->view based upon current style, subject to timeouts. Returns Privil
sub www_view {
my $self = shift;
unless ($self->canView) {
if ($self->get("state") eq "published") { # no privileges, make em log in
return $self->session->privilege->noAccess();
} elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^trash/) { # show em trash
$self->session->http->setRedirect($self->getUrl("func=manageTrash"));
return undef;
} elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^clipboard/) { # show em clipboard
$self->session->http->setRedirect($self->getUrl("func=manageClipboard"));
return undef;
} else { # tell em it doesn't exist anymore
$self->session->http->setStatus("410");
return WebGUI::Asset->getNotFound($self->session)->www_view;
}
}
$self->logView();
# must find a way to do this next line better
$self->session->http->setCookie("wgSession",$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{"wgSession"};
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->getHeader;
$self->prepareView;
my $style = $self->processStyle("~~~");

View file

@ -265,31 +265,23 @@ sub www_setContentPositions {
#-------------------------------------------------------------------
sub www_view {
my $self = shift;
# slashdot / burst protection
# slashdot / burst protection hack
if ($self->session->var->get("userId") eq "1" && $self->session->form->param("func") eq "" && $self->session->form->param("op") eq "") {
unless ($self->canView) {
if ($self->get("state") eq "published") { # no privileges, make em log in
return $self->session->privilege->noAccess();
} elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^trash/) { # show em trash
$self->session->http->setRedirect($self->getUrl("func=manageTrash"));
return undef;
} elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^clipboard/) { # show em clipboard
$self->session->http->setRedirect($self->getUrl("func=manageClipboard"));
return undef;
} else { # tell em it doesn't exist anymore
$self->session->http->setStatus("410");
return WebGUI::Asset->getNotFound($self->session)->www_view;
}
}
$self->logView();
# must find a way to do this next line better
$self->session->http->setCookie("wgSession",$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{"wgSession"};
my $check = $self->checkView;
return $check if (defined $check);
my $cache = WebGUI::Cache->new($self->session, "view_".$self->getId);
my $out = $cache->get if defined $cache;
unless ($out) {
$self->prepareView;
$self->session->stow->set("cacheFixOverride", 1);
$out = $self->processStyle($self->view);
$cache->set($out, 60);
$self->session->stow->delete("cacheFixOverride");
}
while ($out =~ /(\[AD\:(\w+)\])/gs) {
my $ad = $1;
my $macro = "^AdSpace(".$2.");";
$out =~ s/\Q$ad/$macro/ges;
}
return $out;
}