From b20f4b4a081114947b9dceced98891f2c95c3157 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 27 Feb 2009 22:14:30 +0000 Subject: [PATCH] Story Topic skeleton code. --- lib/WebGUI/Asset/Wobject/StoryTopic.pm | 151 ++++++++++++++++++++ lib/WebGUI/i18n/English/Asset_StoryTopic.pm | 50 +++++++ 2 files changed, 201 insertions(+) create mode 100644 lib/WebGUI/Asset/Wobject/StoryTopic.pm create mode 100644 lib/WebGUI/i18n/English/Asset_StoryTopic.pm diff --git a/lib/WebGUI/Asset/Wobject/StoryTopic.pm b/lib/WebGUI/Asset/Wobject/StoryTopic.pm new file mode 100644 index 000000000..47397e714 --- /dev/null +++ b/lib/WebGUI/Asset/Wobject/StoryTopic.pm @@ -0,0 +1,151 @@ +package WebGUI::Asset::Wobject::StoryTopic; + +$VERSION = "1.0.0"; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use Tie::IxHash; +use WebGUI::International; +use WebGUI::Utility; +use WebGUI::Asset::Story; +use base 'WebGUI::Asset::Wobject'; + +#------------------------------------------------------------------- + +=head2 definition ( ) + +defines wobject properties for New Wobject instances. You absolutely need +this method in your new Wobjects. If you choose to "autoGenerateForms", the +getEditForm method is unnecessary/redundant/useless. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, 'Asset_StoryTopic'); + my %properties; + tie %properties, 'Tie::IxHash'; + %properties = ( + storiesPer => { + tab => 'display', + fieldType => 'integer', + label => $i18n->get('stories per topic'), + hoverHelp => $i18n->get('stories per topic help'), + defaultValue => 15, + }, + storiesShort => { + tab => 'display', + fieldType => 'integer', + label => $i18n->get('stories short'), + hoverHelp => $i18n->get('stories short help'), + defaultValue => 5, + }, + storyTemplateId => { + tab => 'display', + fieldType => 'template', + label => $i18n->get('story template'), + hoverHelp => $i18n->get('story template help'), + filter => 'fixId', + namespace => 'Story', + defaultValue => '', + }, + ); + push(@{$definition}, { + assetName=>$i18n->get('assetName'), + icon=>'assets.gif', + autoGenerateForms=>1, + tableName=>'StoryTopic', + className=>'WebGUI::Asset::Wobject::StoryTopic', + properties=>\%properties, + }); + return $class->SUPER::definition($session, $definition); +} + + +#------------------------------------------------------------------- + +=head2 duplicate ( ) + +duplicates a New Wobject. This method is unnecessary, but if you have +auxiliary, ancillary, or "collateral" data or files related to your +wobject instances, you will need to duplicate them here. + +=cut + +sub duplicate { + my $self = shift; + my $newAsset = $self->SUPER::duplicate(@_); + return $newAsset; +} + +#------------------------------------------------------------------- + +=head2 prepareView ( ) + +See WebGUI::Asset::prepareView() for details. + +=cut + +sub prepareView { + my $self = shift; + $self->SUPER::prepareView(); + my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId")); + $template->prepare; + $self->{_viewTemplate} = $template; +} + + +#------------------------------------------------------------------- + +=head2 view ( ) + +method called by the www_view method. Returns a processed template +to be displayed within the page style. + +=cut + +sub view { + my $self = shift; + my $session = $self->session; + + #This automatically creates template variables for all of your wobject's properties. + my $var = $self->get; + + #This is an example of debugging code to help you diagnose problems. + #WebGUI::ErrorHandler::warn($self->get("templateId")); + + return $self->processTemplate($var, undef, $self->{_viewTemplate}); +} + +#------------------------------------------------------------------- + +=head2 www_edit ( ) + +Web facing method which is the default edit page. This method is entirely +optional. Take it out unless you specifically want to set a submenu in your +adminConsole views. + +=cut + +#sub www_edit { +# my $self = shift; +# return $self->session->privilege->insufficient() unless $self->canEdit; +# return $self->session->privilege->locked() unless $self->canEditIfLocked; +# my $i18n = WebGUI::International->new($self->session, "Asset_NewWobject"); +# return $self->getAdminConsole->render($self->getEditForm->print, $i18n->get("edit title")); +#} + + +1; +#vim:ft=perl diff --git a/lib/WebGUI/i18n/English/Asset_StoryTopic.pm b/lib/WebGUI/i18n/English/Asset_StoryTopic.pm new file mode 100644 index 000000000..d24431a8e --- /dev/null +++ b/lib/WebGUI/i18n/English/Asset_StoryTopic.pm @@ -0,0 +1,50 @@ +package WebGUI::i18n::English::Asset_StoryTopic; +use strict; + +our $I18N = { + + 'assetName' => { + message => q|Story Topic|, + context => q|An Asset that displays stories based on keywords.|, + lastUpdated => 0 + }, + + 'stories per topic' => { + message => q|Stories Per Topic|, + context => q|Label in the edit screen and template.|, + lastUpdated => 0 + }, + + 'stories per topic' => { + message => q|The number of stories displayed in RSS and Atom feeds from this Story Topic, and when viewing the Topic directly.|, + context => q|Hoverhelp in the edit screen and template.|, + lastUpdated => 0 + }, + + 'stories short' => { + message => q|Stories Per Page|, + context => q|Label in the edit screen and template.|, + lastUpdated => 0 + }, + + 'stories short help' => { + message => q|The number of stories displayed on a page.|, + context => q|Hoverhelp in the edit screen and template.|, + lastUpdated => 0 + }, + + 'story template' => { + message => q|Story Template|, + context => q|Label in the edit screen and template.|, + lastUpdated => 0 + }, + + 'story template help' => { + message => q|The Template used to display Story assets from this Story Topic.|, + context => q|Hoverhelp in the edit screen and template.|, + lastUpdated => 0 + }, + +}; + +1;