'.$self->getToolbar.'
'.$output if ($session{var}{adminOn}); + $output = ''.$self->getToolbar.'
'.$output if ($session{var}{adminOn} && !$calledAsWebMethod); + return $output unless ($self->getValue("processAsTemplate")); return WebGUI::Asset::Template->processRaw($output); } @@ -170,7 +179,7 @@ A web accessible version of the view method. sub www_view { my $self = shift; - return $self->view; + return $self->view(1); } diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index ef04c0925..7c4220769 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -62,18 +62,20 @@ sub appendPostListTemplateVars { for (my $i=0;$i<=$post->get("rating");$i++) { push(@rating_loop,{'rating_loop.count'=>$i}); } - my $lastPost = $post->getLastPost(); my %lastReply; - if ($self->get("displayLastReply")) { - %lastReply = ( - "lastReply.url"=>$lastPost->getUrl(), - "lastReply.title"=>$lastPost->get("title"), - "lastReply.user.isVisitor"=>$lastPost->get("ownerUserId") eq "1", - "lastReply.username"=>$lastPost->get("username"), - "lastReply.userProfile.url"=>$lastPost->WebGUI::Asset::Post::getPosterProfileUrl(), - "lastReply.dateSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%z"), - "lastReply.timeSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%Z") - ); + if ($post->get("className") =~ /Thread/) { + my $lastPost = $post->getLastPost(); + if ($self->get("displayLastReply")) { + %lastReply = ( + "lastReply.url"=>$lastPost->getUrl(), + "lastReply.title"=>$lastPost->get("title"), + "lastReply.user.isVisitor"=>$lastPost->get("ownerUserId") eq "1", + "lastReply.username"=>$lastPost->get("username"), + "lastReply.userProfile.url"=>$lastPost->WebGUI::Asset::Post::getPosterProfileUrl(), + "lastReply.dateSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%z"), + "lastReply.timeSubmitted.human"=>epochToHuman($lastPost->get("dateSubmitted"),"%Z") + ); + } } push(@{$var->{post_loop}}, { %{$post->get}, diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index 556cbff27..e6817f673 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -883,27 +883,52 @@ sub www_editTabSave { #------------------------------------------------------------------- sub www_exportTab { - my $self = shift; - return WebGUI::Privilege::insufficient() unless $self->canEdit; - WebGUI::HTTP::setFilename($self->get("url").".tab","text/plain"); - my %fields = WebGUI::SQL->buildHash("select DataForm_fieldId,name from DataForm_field where assetId=".quote($self->getId)." order by sequenceNumber"); - my $select = "select a.DataForm_entryId as entryId, a.ipAddress, a.username, a.userId, a.submissionDate"; - my $from = " from DataForm_entry a"; - my $join; - my $where = " where a.assetId=".quote($self->getId); - my $orderBy = " order by a.DataForm_entryId"; - my $columnCounter = "b"; - my $mailData = ($self->get("mailData") == 0); - foreach my $fieldId (keys %fields) { - next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $mailData); - my $extension = ""; - $extension = "mail_" if (isIn($fields{$fieldId}, qw(to from cc bcc subject))); - $select .= ", ".$columnCounter.".value as ".$extension.$fields{$fieldId}; - $join .= " left join DataForm_entryData ".$columnCounter." on a.DataForm_entryId=".$columnCounter.".DataForm_entryId and " - .$columnCounter.".DataForm_fieldId=".quote($fieldId); - $columnCounter++; - } - return WebGUI::SQL->quickTab($select.$from.$join.$where.$orderBy); + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + WebGUI::HTTP::setFilename($self->get("url").".tab","text/plain"); + my %fields = WebGUI::SQL->buildHash("select DataForm_fieldId,name from DataForm_field where + assetId=".quote($self->getId)." order by sequenceNumber"); + my @data; + my $entries = WebGUI::SQL->read("select * from DataForm_entry where assetId=".quote($self->getId)); + my $i; + my $noMailData = ($self->get("mailData") == 0); + while (my $entryData = $entries->hashRef) { + $data[$i] = { + entryId => $entryData->{DataForm_entryId}, + ipAddress => $entryData->{ipAddress}, + username => $entryData->{username}, + userId => $entryData->{userId}, + submissionDate => WebGUI::DateTime::epochToHuman($entryData->{submissionDate}), + }; + my $values = WebGUI::SQL->read("select value,DataForm_fieldId from DataForm_entryData where + DataForm_entryId=".quote($entryData->{DataForm_entryId})); + while (my ($value, $fieldId) = $values->array) { + next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $noMailData); + $data[$i]{$fields{$fieldId}} = $value; + } + $values->finish; + $i++; + } + $entries->finish; + my @row; + foreach my $fieldId (keys %fields) { + next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $noMailData); + push(@row, $fields{$fieldId}); + } + my $tab = join("\t",@row)."\n"; + foreach my $record (@data) { + @row = (); + foreach my $fieldId (keys %fields) { + next if (isIn($fields{$fieldId}, qw(to from cc bcc subject)) && $noMailData); + my $value = $record->{$fields{$fieldId}}; + $value =~ s/\t/\\t/g; + $value =~ s/\r//g; + $value =~ s/\n/;/g; + push(@row, $value); + } + $tab .= join("\t", @row)."\n"; + } + return $tab; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/IndexedSearch.pm b/lib/WebGUI/Asset/Wobject/IndexedSearch.pm index b3da396f9..ccb2a320d 100644 --- a/lib/WebGUI/Asset/Wobject/IndexedSearch.pm +++ b/lib/WebGUI/Asset/Wobject/IndexedSearch.pm @@ -422,10 +422,10 @@ sub _buildFilter { my $self = shift; my %filter = (); - # pages - if($self->get('searchRoot') !~ /any/i) { - $filter{pageId} = $self->_buildPageList; - } +# # pages +# if($self->get('searchRoot') !~ /any/i) { +# $filter{assetId} = $self->_buildPageList; +# } # content-types if($session{form}{contentTypes} && ! isIn('any', $session{cgi}->param('contentTypes'))) { @@ -528,10 +528,10 @@ sub _getContentTypes { sub _getSearchablePages { my $searchRoot = shift; my %pages; - my $sth = WebGUI::SQL->read("select pageId from page where parentId = ".quote($searchRoot)); + my $sth = WebGUI::SQL->read("select assetId from asset where parentId = ".quote($searchRoot)); while (my %data = $sth->hash) { - $pages{$data{pageId}} = 1; - %pages = (%pages, _getSearchablePages($data{pageId}) ); + $pages{$data{assetId}} = 1; + %pages = (%pages, _getSearchablePages($data{assetId}) ); } return %pages; } diff --git a/lib/WebGUI/i18n/English/Snippet.pm b/lib/WebGUI/i18n/English/Snippet.pm index 01912cc2b..b5e1bb191 100644 --- a/lib/WebGUI/i18n/English/Snippet.pm +++ b/lib/WebGUI/i18n/English/Snippet.pm @@ -8,6 +8,11 @@ our $I18N = { context => 'Default name of all snippets' }, + 'process as template' => { + message => q|Process as template?|, + lastUpdated => 1104630516, + }, + 'snippet add/edit title' => { message => q|Snippet, Add/Edit|, lastUpdated => 1104630516, @@ -18,8 +23,13 @@ our $I18N = {Since Snippets are Assets, so they have all the properties that Assets do.
-Snippet
+
Snippet
This is the snippet. Either type it in or copy and paste it into the form field.
+
Process as template?
+This will run the snippet through the template engine. It will enable you to use session variables in the snippet, but it is a little slower.
+