- Added a wiki-like feature that will automatically bring a user to the

create a page form if they are in admin mode, and click on a link to
   a page that doesn't exist yet.
This commit is contained in:
JT Smith 2006-03-25 21:39:15 +00:00
parent 9ddea59a79
commit 29bd26a975
4 changed files with 47 additions and 11 deletions

View file

@ -10,6 +10,9 @@
- Addded a lock menu item to explicitly lock an asset from editing.
- Run on registration and alert on new user have been converted to a single
workflow.
- Added a wiki-like feature that will automatically bring a user to the
create a page form if they are in admin mode, and click on a link to
a page that doesn't exist yet.
- Many changes for better XHTML compliance.
- Refactored admin bar to be more dynamic.
- Removed start/end dates from assets in favor of the workflow system.

View file

@ -136,7 +136,7 @@ sub fixupHandler {
#-------------------------------------------------------------------
=head2 page ( session )
=head2 page ( session , [ assetUrl ] )
Processes operations (if any), then tries the requested method on the asset corresponding to the requested URL. If that asset fails to be created, it tries the default page.
@ -144,16 +144,20 @@ Processes operations (if any), then tries the requested method on the asset corr
The current WebGUI::Session object.
=head3 assetUrl
Optionally pass in a URL to be loaded.
=cut
sub page {
my $session = shift;
my $assetUrl = shift;
my $assetUrl = shift || $session->url->getRequestedUrl;
my $output = processOperations($session);
if ($output eq "") {
my $asset = eval{WebGUI::Asset->newByUrl($session,$assetUrl,$session->form->process("revision"))};
if ($@) {
$session->errorHandler->warn("Couldn't instantiate asset for url: ".$session->url->getRequestedUrl." Root cause: ".$@);
$session->errorHandler->warn("Couldn't instantiate asset for url: ".$assetUrl." Root cause: ".$@);
}
if (defined $asset) {
my $method = "view";
@ -169,15 +173,20 @@ sub page {
}
}
if (defined($output) and $output eq "") {
$session->http->setStatus("404","Page Not Found");
my $notFound = WebGUI::Asset->getNotFound($session);
if (defined $notFound) {
$output = tryAssetMethod($session,$notFound,'view');
} else {
$session->errorHandler->error("The notFound page failed to be created!");
$output = "An error was encountered while processing your request.";
if ($session->var->isAdminOn) { # they're expecting it to be there, so let's help them add it
my $asset = WebGUI::Asset->newByUrl($session, $session->url->getRefererUrl) || WebGUI::Asset->getDefault($session);
$session->http->setRedirect($asset->getUrl("func=add;assetId=new;class=WebGUI::Asset::Wobject::Layout;url=".$assetUrl));
} else { # not in admin mode, so can't create it, so display not found
$session->http->setStatus("404","Page Not Found");
my $notFound = WebGUI::Asset->getNotFound($session);
if (defined $notFound) {
$output = tryAssetMethod($session,$notFound,'view');
} else {
$session->errorHandler->error("The notFound page could not be instanciated!");
$output = "An error was encountered while processing your request.";
}
$output = "An error was encountered while processing your request." if $output eq '';
}
$output = "An error was encountered while processing your request." if $output eq '';
}
if ($output eq "chunked") {
$output = undef;

View file

@ -1696,6 +1696,7 @@ sub www_add {
printableStyleTemplateId => $self->get("printableStyleTemplateId"),
isHidden => $self->get("isHidden"),
className=>$class,
url=>$self->session->form->param("url"),
assetId=>"new"
);
$properties{isHidden} = 1 unless (WebGUI::Utility::isIn($class, @{$self->session->config->get("assetContainers")}));

View file

@ -155,6 +155,29 @@ sub gateway {
return $url;
}
#-------------------------------------------------------------------
=head2 getRefererUrl ( )
Returns the URL of the page this request was refered from (no gateway, no query params, just the page url). Returns undef if there was no referer.
=cut
sub getRefererUrl {
my $self = shift;
my $referer = $self->session->env->get("HTTP_REFERER");
return undef unless ($referer);
my $url = $referer;
my $gateway = $self->session->config->get("gateway");
$url =~ s/htt\w+\:\/\/[A-Za-z0-9\.\-]+$gateway\/*(\S*)/$1/;;
if ($url eq $referer) {
return undef;
} else {
return $url;
}
}
#-------------------------------------------------------------------
=head2 getRequestedUrl ( )