more bug fixes
This commit is contained in:
parent
6866f7dd2d
commit
acf5457f6a
12 changed files with 142 additions and 56 deletions
|
|
@ -77,6 +77,10 @@ sub definition {
|
|||
noFormPost=>1,
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>undef
|
||||
},
|
||||
templateId=>{
|
||||
fieldType=>'template',
|
||||
defaultValue=>'PBtmpl0000000000000024'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -242,7 +246,7 @@ sub view {
|
|||
$var{controls} = $self->getToolbar;
|
||||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
return $self->processTemplate(\%var,"PBtmpl0000000000000024");
|
||||
return $self->processTemplate(\%var,$self->getValue("templateId"));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -250,7 +254,12 @@ sub view {
|
|||
sub www_edit {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,"Edit File");
|
||||
my $tabform = $self->getEditForm;
|
||||
$tabform->getTab("display")->template(
|
||||
-value=>$self->getValue("templateId"),
|
||||
-namespace=>"FileAsset"
|
||||
);
|
||||
return $self->getAdminConsole->render($tabform->print,"Edit File");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -258,7 +267,7 @@ sub www_view {
|
|||
my $self = shift;
|
||||
return WebGUI::Privilege::noAccess() unless $self->canView;
|
||||
if ($session{var}{adminOn}) {
|
||||
return $self->www_edit;
|
||||
return $self->getContainer->www_view;
|
||||
}
|
||||
WebGUI::HTTP::setRedirect($self->getFileUrl);
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ sub view {
|
|||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{thumbnail} = $self->getThumbnailUrl;
|
||||
return $self->processTemplate(\%var,"PBtmpl0000000000000088");
|
||||
return $self->processTemplate(\%var,$self->get("templateId"));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -225,7 +225,13 @@ sub www_edit {
|
|||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=resize'),WebGUI::International::get("resize image","Image")) if ($self->get("filename"));
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("edit image","Image"));
|
||||
my $tabform = $self->getEditForm;
|
||||
$tabform->getTab("display")->template(
|
||||
-value=>$self->get("templateId"),
|
||||
-namespace=>"ImageAsset",
|
||||
-defaultValue=>"PBtmpl0000000000000088"
|
||||
);
|
||||
return $self->getAdminConsole->render($tabform->print,WebGUI::International::get("edit image","Image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -63,10 +63,14 @@ sub definition {
|
|||
tableName=>'snippet',
|
||||
className=>'WebGUI::Asset::Snippet',
|
||||
properties=>{
|
||||
snippet=>{
|
||||
fieldType=>'codearea',
|
||||
defaultValue=>undef
|
||||
}
|
||||
snippet=>{
|
||||
fieldType=>'codearea',
|
||||
defaultValue=>undef
|
||||
},
|
||||
processAsTemplate=>{
|
||||
fieldType=>'yesNo',
|
||||
defaultValue=>0
|
||||
}
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($definition);
|
||||
|
|
@ -88,9 +92,13 @@ sub getEditForm {
|
|||
$tabform->getTab("properties")->codearea(
|
||||
-name=>"snippet",
|
||||
-label=>WebGUI::International::get('snippet', 'Snippet'),
|
||||
-label=>"Snippet",
|
||||
-value=>$self->getValue("snippet")
|
||||
);
|
||||
$tabform->getTab("properties")->yesNo(
|
||||
-name=>"processAsTemplate",
|
||||
-label=>WebGUI::International::get('process as template', 'Snippet'),
|
||||
-value=>$self->getValue("processAsTemplate")
|
||||
);
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
|
|
@ -147,9 +155,10 @@ sub getName {
|
|||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $calledAsWebMethod = shift;
|
||||
my $output = WebGUI::Macro::process($self->get("snippet"));
|
||||
# if it's a javascript file this would break it
|
||||
# $output = '<p>'.$self->getToolbar.'</p>'.$output if ($session{var}{adminOn});
|
||||
$output = '<p>'.$self->getToolbar.'</p>'.$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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = {
|
|||
|
||||
<P>Since Snippets are Assets, so they have all the properties that Assets do.</P>
|
||||
|
||||
<P><b>Snippet</b><br/>
|
||||
<p><b>Snippet</b><br />
|
||||
This is the snippet. Either type it in or copy and paste it into the form field.
|
||||
</p>
|
||||
|
||||
<p><b>Process as template?</b><br />
|
||||
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.
|
||||
</p>
|
||||
|,
|
||||
context => 'Describing snippets and its sole field.',
|
||||
lastUpdated => 1106683569,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue