Viewing stories is now possible.

This commit is contained in:
Colin Kuskie 2009-03-05 22:47:43 +00:00
parent 06790fa72b
commit 882b8a5c89

View file

@ -128,7 +128,7 @@ sub definition {
defaultValue => '',
},
highlights => {
fieldType => 'text',
fieldType => 'textarea',
#label => $i18n->get('highlights'),
#hoverHelp => $i18n->get('highlights help'),
defaultValue => '',
@ -216,7 +216,9 @@ sub getEditForm {
. WebGUI::Form::hidden($session, { name => 'func', value => 'editSave' })
. WebGUI::Form::hidden($session, { name => 'proceed', value => 'showConfirmation' }),
formFooter => WebGUI::Form::formFooter($session),
formTitle => $i18n->get('editing','Asset_WikiPage').' '.$title,
formTitle => $isNew
? $i18n->get('add a story','Asset_StoryArchive')
: $i18n->get('editing','Asset_WikiPage').' '.$title,
titleForm => WebGUI::Form::text($session, {
name => 'title',
value => $form->get('title') || $self->get('title'),
@ -237,10 +239,6 @@ sub getEditForm {
name => 'keywords',
value => $form->get('keywords') || WebGUI::Keyword->new($session)->getKeywordsForAsset({ asset => $self })
} ),
summaryForm => WebGUI::Form::textarea($session, {
name => 'summary',
value => $form->get('summary') || $self->get('summary')
} ),
highlightsForm => WebGUI::Form::textarea($session, {
name => 'highlights',
value => $form->get('highlights') || $self->get('highlights')
@ -318,16 +316,23 @@ sub getStorageLocation {
#-------------------------------------------------------------------
=head2 prepareView ( )
=head2 prepareView ( $templateId )
See WebGUI::Asset::prepareView() for details.
=head3 $templateId
By default, the Story looks in its parent Story Archive to get a template. If $templateId
is passed, it will use that template instead.
=cut
sub prepareView {
my $self = shift;
my $self = shift;
my $templateId = shift || $self->getArchive->get('storyTemplateId');
$self->SUPER::prepareView();
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
$self->session->log->warn("storyTemplateId: $templateId");
my $template = WebGUI::Asset::Template->new($self->session, $templateId);
$template->prepare;
$self->{_viewTemplate} = $template;
}
@ -520,12 +525,38 @@ method called by the container www_view method.
##Keyword cloud generated by WebGUI::Keyword
sub view {
my $self = shift;
my $var = $self->get; # $var is a hash reference.
$var->{controls} = $self->getToolbar;
my $self = shift;
my $session = $self->session;
my $var = $self->viewTemplateVariables();
return $self->processTemplate($var,undef, $self->{_viewTemplate});
}
#-------------------------------------------------------------------
=head2 viewTemplateVars ( $var )
Add template variables to the existing template variables. This includes asset level variables.
=head3 $var
Template variables will be added onto this hash ref.
=cut
sub viewTemplateVariables {
my ($self) = @_;
my $session = $self->session;
my $var = $self->get;
if ($var->{highlights}) {
my @highlights = split "\n", $var->{highlights};
foreach my $highlight (@highlights) {
push @{ $var->{highlightsLoop} }, { highlight => $highlight };
}
}
##TODO: publish time, calculated from revisionDate
return $var;
}
#-------------------------------------------------------------------
@ -559,6 +590,22 @@ sub www_showConfirmation {
return $self->getArchive->processStyle('<p>'.$i18n->get('story received').'</p><p><a href="'.$self->getArchive->getUrl.'">'.$i18n->get('493','WebGUI').'</a></p>');
}
#-------------------------------------------------------------------
=head2 www_view
Override www_view from asset because assets (vs wobjects) do not have style templates.
=cut
sub www_view {
my $self = shift;
return $self->session->privilege->noAccess unless $self->canView;
$self->session->http->sendHeader;
$self->prepareView;
return $self->getArchive->processStyle($self->view);
}
1;