Merge branch 'WebGUI8' of github.com:plainblack/webgui into 8
Conflicts: lib/WebGUI.pm lib/WebGUI/Auth/WebGUI.pm sbin/findBrokenAssets.pl sbin/testEnvironment.pl
This commit is contained in:
commit
677ac978b6
89 changed files with 1064 additions and 448 deletions
|
|
@ -287,7 +287,7 @@ sub displayContent {
|
|||
|
||||
return $output if($noStyle);
|
||||
#Wrap the layout in the user style
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
return $session->style->process($output,$self->getStyleTemplateId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ A string that defaults to _function's title.
|
|||
sub render {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my %var;
|
||||
$var{"application_loop"} = $self->getAdminFunction;
|
||||
$var{"application.workarea"} = shift;
|
||||
|
|
|
|||
|
|
@ -653,11 +653,11 @@ sub checkView {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
my $session = $self->session;
|
||||
my ($conf, $http) = $self->session->quick(qw(config http));
|
||||
my ($conf, $response) = $self->session->quick(qw(config response));
|
||||
if ($conf->get("sslEnabled") && $self->get("encryptPage") && ! $self->session->request->secure) {
|
||||
# getUrl already changes url to https if 'encryptPage'
|
||||
$http->setRedirect($self->getUrl);
|
||||
$http->sendHeader;
|
||||
$response->setRedirect($self->getUrl);
|
||||
$response->sendHeader;
|
||||
return "chunked";
|
||||
}
|
||||
elsif ($session->isAdminOn && $self->get("state") =~ /^trash/) { # show em trash
|
||||
|
|
@ -665,8 +665,8 @@ sub checkView {
|
|||
if ($self->session->form->process('revision')) {
|
||||
$queryFrag .= ";revision=".$self->session->form->process('revision');
|
||||
}
|
||||
$http->setRedirect($self->getUrl($queryFrag));
|
||||
$http->sendHeader;
|
||||
$response->setRedirect($self->getUrl($queryFrag));
|
||||
$response->sendHeader;
|
||||
return "chunked";
|
||||
}
|
||||
elsif ($session->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard
|
||||
|
|
@ -674,8 +674,8 @@ sub checkView {
|
|||
if ($self->session->form->process('revision')) {
|
||||
$queryFrag .= ";revision=".$self->session->form->process('revision');
|
||||
}
|
||||
$http->setRedirect($self->getUrl($queryFrag));
|
||||
$http->sendHeader;
|
||||
$response->setRedirect($self->getUrl($queryFrag));
|
||||
$response->sendHeader;
|
||||
return "chunked";
|
||||
}
|
||||
elsif ($self->get("state") ne "published") { # tell em it doesn't exist anymore
|
||||
|
|
@ -949,7 +949,7 @@ sub forkWithStatusPage {
|
|||
proceed => $args->{redirect} || '',
|
||||
}
|
||||
);
|
||||
$session->http->setRedirect( $self->getUrl($pairs) );
|
||||
$session->response->setRedirect( $self->getUrl($pairs) );
|
||||
return 'redirect';
|
||||
} ## end sub forkWithStatusPage
|
||||
|
||||
|
|
@ -2212,23 +2212,23 @@ sub proceed {
|
|||
return $session->asset->www_manageAssets;
|
||||
}
|
||||
elsif ($proceed eq "viewParent") {
|
||||
$session->http->setRedirect( $self->getParent->getUrl );
|
||||
$session->response->setRedirect( $self->getParent->getUrl );
|
||||
return "redirect";
|
||||
}
|
||||
elsif ($proceed eq "editParent") {
|
||||
$session->http->setRedirect( $self->getParent->getUrl('func=edit') );
|
||||
$session->response->setRedirect( $self->getParent->getUrl('func=edit') );
|
||||
return "redirect";
|
||||
}
|
||||
elsif ($proceed eq "goBackToPage" && $session->form->process('returnUrl')) {
|
||||
$session->http->setRedirect($session->form->process("returnUrl"));
|
||||
$session->response->setRedirect($session->form->process("returnUrl"));
|
||||
return "redirect";
|
||||
}
|
||||
elsif ($proceed ne "") {
|
||||
$session->http->setRedirect( $self->getUrl( 'func=' . $proceed ) );
|
||||
$session->response->setRedirect( $self->getUrl( 'func=' . $proceed ) );
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
$session->http->setRedirect( $self->getUrl );
|
||||
$session->response->setRedirect( $self->getUrl );
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
|
|
@ -2964,7 +2964,7 @@ sub www_view {
|
|||
|
||||
# don't allow viewing of the root asset
|
||||
if ($self->getId eq "PBasset000000000000001") {
|
||||
$self->session->http->setRedirect($self->getDefault($self->session)->getUrl);
|
||||
$self->session->response->setRedirect($self->getDefault($self->session)->getUrl);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2425,7 +2425,7 @@ ENDJS
|
|||
|
||||
|
||||
### Show the processed template
|
||||
$session->http->sendHeader;
|
||||
$session->response->sendHeader;
|
||||
my $style = $self->getParent->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
$self->session->output->print($head, 1);
|
||||
|
|
@ -2461,8 +2461,8 @@ sub www_view {
|
|||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
$self->session->http->setCacheControl($self->getParent->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->setCacheControl($self->getParent->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView;
|
||||
my $style = $self->getParent->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
|
|
|
|||
|
|
@ -667,9 +667,10 @@ sub www_view {
|
|||
return sprintf($i18n->get("file not found"), $self->getUrl());
|
||||
}
|
||||
|
||||
$session->http->setRedirect($self->getFileUrl) unless $session->config->get('enableStreamingUploads');
|
||||
$session->http->setStreamedFile($self->getStorageLocation->getPath($self->filename));
|
||||
$session->http->sendHeader;
|
||||
# sendFile does either a redirect or starts a stream depending on how we're configured
|
||||
|
||||
$session->response->sendFile($self->getStorageLocation, $self->filename);
|
||||
|
||||
return 'chunked';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1154,8 +1154,8 @@ sub www_view {
|
|||
# Add to views
|
||||
$self->update({ views => $self->views + 1 });
|
||||
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->setLastModified($self->getContentLastModified);
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView;
|
||||
my $style = $self->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ sub www_download {
|
|||
my $storage = $self->getStorageLocation;
|
||||
|
||||
$self->session->response->content_type( "image/jpeg" );
|
||||
$self->session->http->setLastModified( $self->getContentLastModified );
|
||||
$self->session->response->setLastModified( $self->getContentLastModified );
|
||||
|
||||
my $resolution = $self->session->form->get("resolution");
|
||||
if ($resolution) {
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ sub www_view {
|
|||
if ($self->session->isAdminOn) {
|
||||
return $self->session->asset($self->getContainer)->www_view;
|
||||
}
|
||||
$self->session->http->setRedirect($self->getFileUrl($self->showPage));
|
||||
$self->session->response->setRedirect($self->getFileUrl($self->showPage));
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ so that this point is automatically shown.
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->http->setRedirect(
|
||||
$self->session->response->setRedirect(
|
||||
$self->getParent->getUrl('focusOn=' . $self->getId )
|
||||
);
|
||||
return "redirect";
|
||||
|
|
|
|||
|
|
@ -785,10 +785,10 @@ sub www_click {
|
|||
|
||||
$self->incrementCounter('clicks');
|
||||
if ($session->form->process("manufacturer")) {
|
||||
$session->http->setRedirect( $self->get('manufacturerURL') );
|
||||
$session->response->setRedirect( $self->get('manufacturerURL') );
|
||||
}
|
||||
else {
|
||||
$session->http->setRedirect( $self->get('productURL') );
|
||||
$session->response->setRedirect( $self->get('productURL') );
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1445,20 +1445,20 @@ Renders self->view based upon current style, subject to timeouts. Returns Privil
|
|||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
my $currentPost = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
$self->session->http->sendHeader;
|
||||
$self->prepareView;
|
||||
my $style = $self->getParent->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
$self->session->output->print($head,1);
|
||||
$self->session->output->print($self->view($currentPost));
|
||||
$self->session->output->print($foot,1);
|
||||
return "chunked";
|
||||
my $self = shift;
|
||||
my $currentPost = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView;
|
||||
my $style = $self->getParent->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
$self->session->output->print($head,1);
|
||||
$self->session->output->print($self->view($currentPost));
|
||||
$self->session->output->print($foot,1);
|
||||
return "chunked";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ sub exportHtml_view {
|
|||
my $url = $self->redirectUrl;
|
||||
WebGUI::Macro::process($self->session, \$url);
|
||||
return '' if ($url eq $self->url);
|
||||
$self->session->http->setRedirect($url);
|
||||
$self->session->response->setRedirect($url);
|
||||
return $self->session->style->process('', 'PBtmpl0000000000000060');
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ sub www_view {
|
|||
</ul>',$i18n->get("assetName"));
|
||||
}
|
||||
unless ($url eq $self->url) {
|
||||
$self->session->http->setRedirect($url,$self->redirectType);
|
||||
$self->session->response->setRedirect($url,$self->redirectType);
|
||||
return undef;
|
||||
}
|
||||
return $i18n->get('self_referential');
|
||||
|
|
|
|||
|
|
@ -326,46 +326,31 @@ override getEditForm => sub {
|
|||
return $f;
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getAllButtons ( )
|
||||
|
||||
Get a list of all the buttons in this MCE
|
||||
|
||||
=cut
|
||||
|
||||
# Get a list of all the buttons in this MCE
|
||||
sub getAllButtons {
|
||||
my ( $self ) = @_;
|
||||
my @toolbarRows = map{[split "\n", $self->get("toolbarRow$_")]} (1..3);
|
||||
my @toolbarRows = map{[split "\n", $self->getValue("toolbarRow$_")]} (1..3);
|
||||
my @toolbarButtons = map{ @{$_} } @toolbarRows;
|
||||
return @toolbarButtons;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getConfig ( )
|
||||
|
||||
Get a hashref of configuration to create this MCE. You must run the code
|
||||
from getLoadPlugins before you can successfully initialize an MCE. You
|
||||
must also specify the "elements" key so TinyMCE knows what textarea to
|
||||
replace.
|
||||
|
||||
=cut
|
||||
|
||||
# Get a hashref of configuration to create this MCE. You must run the code
|
||||
# from getLoadPlugins before you can successfully initialize an MCE. You
|
||||
# must also specify the "elements" key so TinyMCE knows what textarea to
|
||||
# replace.
|
||||
sub getConfig {
|
||||
my ($self) = @_;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_RichEdit');
|
||||
my @plugins;
|
||||
push @plugins, "safari";
|
||||
push @plugins, "paste";
|
||||
push @plugins, "contextmenu"
|
||||
if $self->enableContextMenu;
|
||||
if $self->getValue("enableContextMenu");
|
||||
push @plugins, "inlinepopups"
|
||||
if $self->inlinePopups;
|
||||
if $self->getValue("inlinePopups");
|
||||
push @plugins, "media"
|
||||
if $self->allowMedia;
|
||||
if $self->getValue( 'allowMedia' );
|
||||
|
||||
my @toolbarRows = map{[split "\n", $self->get("toolbarRow$_")]} (1..3);
|
||||
my @toolbarRows = map{[split "\n", $self->getValue("toolbarRow$_")]} (1..3);
|
||||
my @toolbarButtons = map{ @{$_} } @toolbarRows;
|
||||
my %config = (
|
||||
mode => 'exact',
|
||||
|
|
@ -379,18 +364,17 @@ sub getConfig {
|
|||
( map { "theme_advanced_buttons" . ( $_ + 1 ) => ( join ',', @{ $toolbarRows[$_] } ) } ( 0 .. $#toolbarRows ) ),
|
||||
|
||||
ask => JSON::false(),
|
||||
preformatted => $self->preformatted ? JSON::true() : JSON::false(),
|
||||
force_br_newlines => $self->useBr ? JSON::true() : JSON::false(),
|
||||
force_p_newlines => $self->useBr ? JSON::false() : JSON::true(),
|
||||
$self->useBr ? ( forced_root_block => JSON::false() ) : (),
|
||||
remove_linebreaks => $self->removeLineBreaks ? JSON::true() : JSON::false(),
|
||||
nowrap => $self->nowrap ? JSON::true() : JSON::false(),
|
||||
directionality => $self->directionality,
|
||||
theme_advanced_toolbar_location => $self->toolbarLocation,
|
||||
preformatted => $self->getValue("preformatted") ? JSON::true() : JSON::false(),
|
||||
force_br_newlines => $self->getValue("useBr") ? JSON::true() : JSON::false(),
|
||||
force_p_newlines => $self->getValue("useBr") ? JSON::false() : JSON::true(),
|
||||
$self->getValue("useBr") ? ( forced_root_block => JSON::false() ) : (),
|
||||
remove_linebreaks => $self->getValue("removeLineBreaks") ? JSON::true() : JSON::false(),
|
||||
nowrap => $self->getValue("nowrap") ? JSON::true() : JSON::false(),
|
||||
directionality => $self->getValue("directionality"),
|
||||
theme_advanced_toolbar_location => $self->getValue("toolbarLocation"),
|
||||
theme_advanced_statusbar_location => "bottom",
|
||||
valid_elements => $self->validElements,
|
||||
valid_elements => $self->getValue("validElements"),
|
||||
wg_userIsVisitor => $self->session->user->isVisitor ? JSON::true() : JSON::false(),
|
||||
paste_postprocess => 'tinyMCE_WebGUI_paste_postprocess',
|
||||
);
|
||||
foreach my $button (@toolbarButtons) {
|
||||
if ( $button eq "spellchecker" && $self->session->config->get('availableDictionaries') ) {
|
||||
|
|
@ -441,10 +425,10 @@ sub getConfig {
|
|||
push @plugins, "-wgmacro";
|
||||
}
|
||||
if ( $button eq "code" ) {
|
||||
$config{theme_advanced_source_editor_width} = $self->sourceEditorWidth
|
||||
if ( $self->sourceEditorWidth > 0 );
|
||||
$config{theme_advanced_source_editor_height} = $self->sourceEditorHeight
|
||||
if ( $self->sourceEditorHeight > 0 );
|
||||
$config{theme_advanced_source_editor_width} = $self->getValue("sourceEditorWidth")
|
||||
if ( $self->getValue("sourceEditorWidth") > 0 );
|
||||
$config{theme_advanced_source_editor_height} = $self->getValue("sourceEditorHeight")
|
||||
if ( $self->getValue("sourceEditorHeight") > 0 );
|
||||
}
|
||||
} ## end foreach my $button (@toolbarButtons)
|
||||
my $language = $i18n->getLanguage( '', "languageAbbreviation" );
|
||||
|
|
@ -452,10 +436,10 @@ sub getConfig {
|
|||
$language = $i18n->getLanguage( "English", "languageAbbreviation" );
|
||||
}
|
||||
$config{language} = $language;
|
||||
$config{content_css} = $self->cssFile
|
||||
$config{content_css} = $self->getValue("cssFile")
|
||||
|| $self->session->url->extras('tinymce-webgui/defaultcontent.css');
|
||||
$config{width} = $self->editorWidth if ( $self->editorWidth > 0 );
|
||||
$config{height} = $self->editorHeight if ( $self->editorHeight > 0 );
|
||||
$config{width} = $self->getValue("editorWidth") if ( $self->getValue("editorWidth") > 0 );
|
||||
$config{height} = $self->getValue("editorHeight") if ( $self->getValue("editorHeight") > 0 );
|
||||
$config{plugins} = join( ",", @plugins );
|
||||
|
||||
return \%config;
|
||||
|
|
@ -485,15 +469,8 @@ my $sql = "select asset.assetId, assetData.revisionDate from RichEdit left join
|
|||
return \%richEditors;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLoadPlugins ( )
|
||||
|
||||
Get the JS code to load the plugins for this MCE. Needs to be called once
|
||||
on the page this MCE will be on
|
||||
|
||||
=cut
|
||||
|
||||
# Get the JS code to load the plugins for this MCE. Needs to be called once
|
||||
# on the page this MCE will be on
|
||||
sub getLoadPlugins {
|
||||
my ( $self ) = @_;
|
||||
my %loadPlugins;
|
||||
|
|
@ -536,16 +513,131 @@ sub getRichEditor {
|
|||
my $self = shift;
|
||||
return '' if ($self->disableRichEditor);
|
||||
my $nameId = shift;
|
||||
<<<<<<< HEAD
|
||||
my @plugins;
|
||||
my %loadPlugins;
|
||||
push @plugins, "safari";
|
||||
push @plugins, "contextmenu"
|
||||
if $self->enableContextMenu;
|
||||
push @plugins, "inlinepopups"
|
||||
if $self->inlinePopups;
|
||||
push @plugins, "media"
|
||||
if $self->allowMedia;
|
||||
|
||||
my @toolbarRows = map{[split "\n", $self->get("toolbarRow$_")]} (1..3);
|
||||
my @toolbarButtons = map{ @{$_} } @toolbarRows;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_RichEdit');
|
||||
my $ask = $self->askAboutRichEdit;
|
||||
my %config = (
|
||||
mode => $ask ? "none" : "exact",
|
||||
elements => $nameId,
|
||||
theme => "advanced",
|
||||
relative_urls => JSON::false(),
|
||||
remove_script_host => JSON::true(),
|
||||
auto_reset_designmode => JSON::true(),
|
||||
cleanup_callback => "tinyMCE_WebGUI_Cleanup",
|
||||
urlconverter_callback => "tinyMCE_WebGUI_URLConvertor",
|
||||
theme_advanced_resizing => JSON::true(),
|
||||
(map { "theme_advanced_buttons".($_+1) => (join ',', @{$toolbarRows[$_]}) }
|
||||
(0..$#toolbarRows)),
|
||||
#ask => $self->getValue("askAboutRichEdit") ? JSON::true() : JSON::false(),
|
||||
ask => JSON::false(),
|
||||
preformatted => $self->preformatted ? JSON::true() : JSON::false(),
|
||||
force_br_newlines => $self->useBr ? JSON::true() : JSON::false(),
|
||||
force_p_newlines => $self->useBr ? JSON::false() : JSON::true(),
|
||||
$self->useBr ? ( forced_root_block => JSON::false() ) : (),
|
||||
remove_linebreaks => $self->removeLineBreaks ? JSON::true() : JSON::false(),
|
||||
nowrap => $self->nowrap ? JSON::true() : JSON::false(),
|
||||
directionality => $self->directionality,
|
||||
theme_advanced_toolbar_location => $self->toolbarLocation,
|
||||
theme_advanced_statusbar_location => "bottom",
|
||||
valid_elements => $self->validElements,
|
||||
wg_userIsVisitor => $self->session->user->isVisitor ? JSON::true() : JSON::false(),
|
||||
);
|
||||
# if ($ask) {
|
||||
# $config{oninit} = 'turnOffTinyMCE_'.$nameId;
|
||||
# }
|
||||
$self->richedit_headTags;
|
||||
foreach my $button (@toolbarButtons) {
|
||||
if ($button eq "spellchecker" && $self->session->config->get('availableDictionaries')) {
|
||||
push(@plugins,"-wgspellchecker");
|
||||
$loadPlugins{wgspellchecker} = $self->session->url->extras("tinymce-webgui/plugins/wgspellchecker/editor_plugin.js");
|
||||
$config{spellchecker_rpc_url} = $self->session->url->gateway('', "op=spellCheck");
|
||||
$config{spellchecker_languages} =
|
||||
join(',', map { ($_->{default} ? '+' : '').$_->{name}.'='.$_->{id} } @{$self->session->config->get('availableDictionaries')});
|
||||
}
|
||||
push(@plugins,"table") if ($button eq "tablecontrols");
|
||||
push(@plugins,"save") if ($button eq "save");
|
||||
push(@plugins,"advhr") if ($button eq "advhr");
|
||||
push(@plugins,"fullscreen") if ($button eq "fullscreen");
|
||||
if ($button eq "advimage") {
|
||||
push(@plugins,"advimage");
|
||||
$config{external_link_list_url} = "";
|
||||
}
|
||||
if ($button eq "advlink") {
|
||||
$config{external_image_list_url} = "";
|
||||
$config{file_browser_callback} = "mcFileManager.filebrowserCallBack";
|
||||
push(@plugins,"advlink");
|
||||
}
|
||||
push(@plugins,"emotions") if ($button eq "emotions");
|
||||
push(@plugins,"iespell") if ($button eq "iespell");
|
||||
$config{gecko_spellcheck} = 'true' if ($button eq "iespell");
|
||||
if ($button eq "paste" || $button eq "pastetext" || $button eq "pasteword") {
|
||||
push(@plugins,"paste");
|
||||
}
|
||||
if ($button eq "insertdate" || $button eq "inserttime" || $button eq "insertdatetime") {
|
||||
$config{plugin_insertdate_dateFormat} = "%Y-%m-%d";
|
||||
$config{plugin_insertdate_timeFormat} = "%H:%M:%S";
|
||||
push(@plugins,"insertdatetime");
|
||||
}
|
||||
push(@plugins,"preview") if ($button eq "preview");
|
||||
if ($button eq "media") {
|
||||
push(@plugins,"media");
|
||||
}
|
||||
push(@plugins,"searchreplace") if ($button eq "search" || $button eq "replace" || $button eq "searchreplace");
|
||||
push(@plugins,"print") if ($button eq "print");
|
||||
if ($button eq "wginsertimage") {
|
||||
push @plugins, "-wginsertimage";
|
||||
$loadPlugins{wginsertimage} = $self->session->url->extras("tinymce-webgui/plugins/wginsertimage/editor_plugin.js");
|
||||
}
|
||||
if ($button eq "wgpagetree") {
|
||||
push @plugins, "-wgpagetree";
|
||||
$loadPlugins{wgpagetree} = $self->session->url->extras("tinymce-webgui/plugins/wgpagetree/editor_plugin.js");
|
||||
}
|
||||
if ($button eq "wgmacro") {
|
||||
push @plugins, "-wgmacro";
|
||||
$loadPlugins{wgmacro} = $self->session->url->extras("tinymce-webgui/plugins/wgmacro/editor_plugin.js");
|
||||
}
|
||||
if ($button eq "code") {
|
||||
$config{theme_advanced_source_editor_width} = $self->sourceEditorWidth if ($self->sourceEditorWidth > 0);
|
||||
$config{theme_advanced_source_editor_height} = $self->sourceEditorHeight if ($self->sourceEditorHeight > 0);
|
||||
}
|
||||
}
|
||||
my $language = $i18n->getLanguage('' ,"languageAbbreviation");
|
||||
unless ($language) {
|
||||
$language = $i18n->getLanguage("English","languageAbbreviation");
|
||||
}
|
||||
$config{language} = $language;
|
||||
$config{content_css} = $self->cssFile || $self->session->url->extras('tinymce-webgui/defaultcontent.css');
|
||||
$config{width} = $self->editorWidth || "100%";
|
||||
$config{height} = $self->editorHeight || "100%";
|
||||
$config{plugins} = join(",",@plugins);
|
||||
|
||||
=======
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_RichEdit');
|
||||
my $ask = $self->getValue("askAboutRichEdit");
|
||||
# if ($ask) {
|
||||
# $config{oninit} = 'turnOffTinyMCE_'.$nameId;
|
||||
# }
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/yahoo/yahoo-min.js'),{type=>"text/javascript"});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/event/event-min.js'),{type=>"text/javascript"});
|
||||
$self->session->style->setScript($self->session->url->extras('tinymce/jscripts/tiny_mce/tiny_mce_src.js'),{type=>"text/javascript"});
|
||||
$self->session->style->setScript($self->session->url->extras("tinymce-webgui/callbacks.js"),{type=>"text/javascript"});
|
||||
>>>>>>> fix carousel editor panel
|
||||
my $out = '';
|
||||
if ($ask) {
|
||||
$out = q|<a style="display: block;" href="javascript:toggleEditor('|.$nameId.q|')">|.$i18n->get('Toggle editor').q|</a>|;
|
||||
}
|
||||
$self->richedit_headTags;
|
||||
$out .= qq|<script type="text/javascript">\n|;
|
||||
if ($ask) {
|
||||
$out .= <<"EOHTML1";
|
||||
|
|
|
|||
|
|
@ -1261,8 +1261,8 @@ sub www_view {
|
|||
$shortcut->purgeCache();
|
||||
|
||||
if ($shortcut->isa('WebGUI::Asset::Wobject')) {
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->setLastModified($self->getContentLastModified);
|
||||
$self->session->response->sendHeader;
|
||||
##Tell processStyle not to set the h
|
||||
my $style = $shortcut->processStyle($shortcut->getSeparator, { noHeadTags => 1 });
|
||||
my ($head, $foot) = split($shortcut->getSeparator,$style);
|
||||
|
|
|
|||
|
|
@ -649,8 +649,8 @@ sub www_view {
|
|||
my $self = shift;
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->setLastModified($self->getContentLastModified);
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView;
|
||||
my $style = $self->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
|
|
|
|||
|
|
@ -584,8 +584,8 @@ sub www_manage {
|
|||
my $self = shift;
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->setLastModified($self->getContentLastModified);
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView($self->manageTemplate);
|
||||
my $style = $self->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
|
|
|
|||
|
|
@ -1904,7 +1904,7 @@ Extend the base method to handle caching.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->session->response->setCacheControl($self->cacheTimeout);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ sub www_view {
|
|||
return $self->session->privilege->insufficient() unless $self->canView;
|
||||
my $mimeType=$self->mimeType;
|
||||
$self->session->response->content_type($mimeType || 'text/html');
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->session->response->setCacheControl($self->cacheTimeout);
|
||||
my $output = $self->view(1);
|
||||
if (!defined $output) {
|
||||
$output = 'empty';
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ the Story Archive that contains them.
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->noAccess unless $self->canView;
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView;
|
||||
return $self->getArchive->processStyle($self->view);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -985,7 +985,7 @@ the user back to the site.
|
|||
|
||||
sub www_goBackToPage {
|
||||
my $self = shift;
|
||||
$self->session->http->setRedirect($self->session->form->get("returnUrl")) if ($self->session->form->get("returnUrl"));
|
||||
$self->session->response->setRedirect($self->session->form->get("returnUrl")) if ($self->session->form->get("returnUrl"));
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ sub www_purgeRevision {
|
|||
$asset->purgeRevision;
|
||||
if ($session->form->process("proceed") eq "manageRevisionsInTag") {
|
||||
my $working = (defined $self) ? $self : $parent;
|
||||
$session->http->setRedirect($working->getUrl("op=manageRevisionsInTag"));
|
||||
$session->response->setRedirect($working->getUrl("op=manageRevisionsInTag"));
|
||||
return undef;
|
||||
}
|
||||
unless (defined $self) {
|
||||
|
|
@ -601,9 +601,9 @@ sub www_view {
|
|||
return $self->session->privilege->noAccess unless $self->canView;
|
||||
$self->update({ views => $self->views+1 });
|
||||
# TODO: This should probably exist, as the CS has one.
|
||||
# $self->session->http->setCacheControl($self->getWiki->get('visitorCacheTimeout'))
|
||||
# $self->session->response->setCacheControl($self->getWiki->get('visitorCacheTimeout'))
|
||||
# if ($self->session->user->isVisitor);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
$self->prepareView;
|
||||
return $self->getWiki->processStyle($self->view);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -505,8 +505,8 @@ sub www_view {
|
|||
my $self = shift;
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->setLastModified($self->getContentLastModified);
|
||||
$self->session->response->sendHeader;
|
||||
##Have to dupe this code here because Wobject does not call SUPER.
|
||||
$self->prepareView;
|
||||
my $style = $self->processStyle($self->getSeparator, { noHeadTags => 1 });
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->session->response->setCacheControl($self->cacheTimeout);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1885,7 +1885,7 @@ Extend the base method to handle the visitor cache timeout.
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
my $disableCache = ($self->session->form->process("sortBy") ne "");
|
||||
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor && !$disableCache);
|
||||
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor && !$disableCache);
|
||||
return $self->next::method(@_);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -611,10 +611,10 @@ sub www_view {
|
|||
if ($self->state eq "published") { # no privileges, make em log in
|
||||
return $self->session->privilege->noAccess();
|
||||
} elsif ($self->session->isAdminOn && $self->state =~ /^trash/) { # show em trash
|
||||
$self->session->http->setRedirect($self->getUrl("func=manageTrash"));
|
||||
$self->session->response->setRedirect($self->getUrl("func=manageTrash"));
|
||||
return undef;
|
||||
} elsif ($self->session->isAdminOn && $self->state =~ /^clipboard/) { # show em clipboard
|
||||
$self->session->http->setRedirect($self->getUrl("func=manageClipboard"));
|
||||
$self->session->response->setRedirect($self->getUrl("func=manageClipboard"));
|
||||
return undef;
|
||||
} else { # tell em it doesn't exist anymore
|
||||
$self->session->response->status(410);
|
||||
|
|
|
|||
|
|
@ -1341,7 +1341,7 @@ sub viewForm {
|
|||
}
|
||||
$var = $passedVars || $self->getRecordTemplateVars($var, $entry);
|
||||
if ($self->hasCaptcha) {
|
||||
$self->session->http->setCacheControl('none');
|
||||
$self->session->response->setCacheControl('none');
|
||||
}
|
||||
return $self->processTemplate($var, undef, $self->{_viewFormTemplate});
|
||||
}
|
||||
|
|
@ -1891,7 +1891,7 @@ sub www_exportTab {
|
|||
|
||||
$session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->url.'.tab"');
|
||||
$session->response->content_type('text/plain');
|
||||
$session->http->sendHeader;
|
||||
$session->response->sendHeader;
|
||||
$session->output->print($tsv->string, 1);
|
||||
|
||||
my $entryIter = $self->entryClass->iterateAll($self);
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -837,8 +837,8 @@ sub sendChunkedContent {
|
|||
|
||||
my $session = $self->session;
|
||||
|
||||
$session->http->setLastModified($self->getContentLastModified);
|
||||
$session->http->sendHeader;
|
||||
$session->response->setLastModified($self->getContentLastModified);
|
||||
$session->response->sendHeader;
|
||||
my $style = $self->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
$session->output->print($head, 1);
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ sub www_view {
|
|||
if ($self->session->response->content_type ne "text/html") {
|
||||
return $output;
|
||||
} else {
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
my $style = $self->processStyle($self->getSeparator, { noHeadTags => 1 });
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
$self->session->output->print($head);
|
||||
|
|
|
|||
|
|
@ -426,8 +426,8 @@ override www_view => sub {
|
|||
my $ad = $adSpace->displayImpression if (defined $adSpace);
|
||||
$out =~ s/\Q$code/$ad/ges;
|
||||
}
|
||||
$session->http->setLastModified($self->getContentLastModified);
|
||||
$session->http->sendHeader;
|
||||
$session->response->setLastModified($self->getContentLastModified);
|
||||
$session->response->sendHeader;
|
||||
$session->output->print($out, 1);
|
||||
return "chunked";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1080,7 +1080,7 @@ sub www_exportAttributes {
|
|||
|
||||
$session->response->header( 'Content-Disposition' => qq{attachment; filename="export_matrix_attributes.csv"});
|
||||
$session->response->content_type('application/octet-stream');
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->session->response->setCacheControl($self->cacheTimeout);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ Do a redirect to the form parameter returnUrl if it exists.
|
|||
|
||||
sub www_goBackToPage {
|
||||
my $self = shift;
|
||||
$self->session->http->setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl"));
|
||||
$self->session->response->setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl"));
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ sub www_download {
|
|||
$self->downloadType eq 'csv' ? "application/octet-stream" : $self->downloadMimeType
|
||||
);
|
||||
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
|
||||
|
||||
return $self->download;
|
||||
|
|
@ -722,7 +722,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->session->response->setCacheControl($self->cacheTimeout);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->session->response->setCacheControl($self->cacheTimeout);
|
||||
super();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -356,9 +356,9 @@ sub www_deployPackage {
|
|||
return undef;
|
||||
};
|
||||
if ($session->form->param("proceed") eq "manageAssets") {
|
||||
$session->http->setRedirect($self->getManagerUrl);
|
||||
$session->response->setRedirect($self->getManagerUrl);
|
||||
} else {
|
||||
$session->http->setRedirect($self->getUrl());
|
||||
$session->response->setRedirect($self->getUrl());
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ sub www_exportPackage {
|
|||
return $self->session->privilege->insufficient() unless ($self->canEdit);
|
||||
my $storage = $self->exportPackage;
|
||||
my $filename = $storage->getFiles->[0];
|
||||
$self->session->http->setRedirect($storage->getUrl($storage->getFiles->[0]));
|
||||
$self->session->response->setRedirect($storage->getUrl($storage->getFiles->[0]));
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ sub www_purgeRevision {
|
|||
$asset->purgeRevision;
|
||||
if ($session->form->process("proceed") eq "manageRevisionsInTag") {
|
||||
my $working = (defined $self) ? $self : $parent;
|
||||
$session->http->setRedirect($working->getUrl("op=manageRevisionsInTag"));
|
||||
$session->response->setRedirect($working->getUrl("op=manageRevisionsInTag"));
|
||||
return undef;
|
||||
}
|
||||
unless (defined $self) {
|
||||
|
|
|
|||
|
|
@ -973,12 +973,12 @@ sub www_createAccountSave {
|
|||
return $self->showMessageOnLogin;
|
||||
}
|
||||
elsif ($self->session->form->get('returnUrl')) {
|
||||
$self->session->http->setRedirect( $self->session->form->get('returnUrl') );
|
||||
$self->session->response->setRedirect( $self->session->form->get('returnUrl') );
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
elsif ($self->session->scratch->get("redirectAfterLogin")) {
|
||||
my $url = $self->session->scratch->delete("redirectAfterLogin");
|
||||
$self->session->http->setRedirect($url);
|
||||
$self->session->response->setRedirect($url);
|
||||
return undef;
|
||||
}
|
||||
else {
|
||||
|
|
@ -1185,7 +1185,7 @@ sub www_login {
|
|||
if ($self->session->setting->get('encryptLogin')) {
|
||||
my $currentUrl = $self->session->url->page(undef,1);
|
||||
$currentUrl =~ s/^https:/http:/;
|
||||
$self->session->http->setRedirect($currentUrl);
|
||||
$self->session->response->setRedirect($currentUrl);
|
||||
}
|
||||
|
||||
# Run on login
|
||||
|
|
@ -1205,14 +1205,14 @@ sub www_login {
|
|||
return $self->showMessageOnLogin;
|
||||
}
|
||||
elsif ( $self->session->form->get('returnUrl') ) {
|
||||
$self->session->http->setRedirect( $self->session->form->get('returnUrl') );
|
||||
$self->session->response->setRedirect( $self->session->form->get('returnUrl') );
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
elsif ( my $url = $self->session->scratch->delete("redirectAfterLogin") ) {
|
||||
$self->session->http->setRedirect($url);
|
||||
$self->session->response->setRedirect($url);
|
||||
}
|
||||
elsif ( $self->session->setting->get("redirectAfterLoginUrl") ) {
|
||||
$self->session->http->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
|
||||
$self->session->response->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
|
||||
|
|
@ -1249,7 +1249,7 @@ sub www_logout {
|
|||
}
|
||||
|
||||
# Do not allow caching of the logout page (to ensure the page gets requested)
|
||||
$self->session->http->setCacheControl( "none" );
|
||||
$self->session->response->setCacheControl( "none" );
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ sub www_login {
|
|||
->extend_permissions(qw(email))
|
||||
->uri_as_string;
|
||||
|
||||
$session->http->setRedirect($auth_url);
|
||||
$session->response->setRedirect($auth_url);
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ sub www_login {
|
|||
$scratch->set( 'AuthTwitterToken', $nt->request_token );
|
||||
$scratch->set( 'AuthTwitterTokenSecret', $nt->request_token_secret );
|
||||
|
||||
$session->http->setRedirect($auth_url);
|
||||
$session->response->setRedirect($auth_url);
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ sub dispatch {
|
|||
if ($session->user->isVisitor
|
||||
&& !$session->request->ifModifiedSince($asset->getContentLastModified, $session->setting->get('maxCacheTimeout'))) {
|
||||
$session->response->status("304");
|
||||
$session->http->sendHeader;
|
||||
$session->response->sendHeader;
|
||||
return "chunked";
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ The content handler for this package.
|
|||
|
||||
sub handler {
|
||||
my ($session) = @_;
|
||||
my ($log, $http, $asset, $request, $config) = $session->quick(qw(errorHandler http asset request config));
|
||||
my ($log, $asset, $request, $config) = $session->quick(qw(errorHandler asset request config));
|
||||
my $output = "";
|
||||
if (my $perfLog = $log->performanceLogger) { #show performance indicators if required
|
||||
my $t = [Time::HiRes::gettimeofday()];
|
||||
|
|
@ -176,19 +176,6 @@ sub handler {
|
|||
else {
|
||||
$output = dispatch($session, getRequestedAssetUrl($session));
|
||||
}
|
||||
|
||||
my $filename = $http->getStreamedFile();
|
||||
if ((defined $filename) && ($config->get("enableStreamingUploads") eq "1")) {
|
||||
my $ct = guess_media_type($filename);
|
||||
my $oldContentType = $request->content_type($ct);
|
||||
if ($request->sendfile($filename) ) {
|
||||
return; # TODO - what should we return to indicate streaming?
|
||||
}
|
||||
else {
|
||||
$request->content_type($oldContentType);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ The content handler for this package.
|
|||
sub handler {
|
||||
my $session = shift;
|
||||
if ($session->setting->get("specialState") eq "upgrading") {
|
||||
$session->http->sendHeader;
|
||||
$session->response->sendHeader;
|
||||
open my $fh, '<', $session->config->get('maintenancePage');
|
||||
my $output = do { local $/; <$fh> };
|
||||
close $fh;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ status of.
|
|||
);
|
||||
# See WebGUI::Operation::Fork
|
||||
my $pairs = $process->contentPairs('DoWork');
|
||||
$session->http->setRedirect($self->getUrl($pairs));
|
||||
$session->response->setRedirect($self->getUrl($pairs));
|
||||
return 'redirect';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ form variable C<classLimiter>. A crumb trail is provided for navigation.
|
|||
|
||||
sub www_assetTree {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
|
||||
my @crumb;
|
||||
my $ancestorIter = $base->getLineageIterator(["self","ancestors"]);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ sub www_show {
|
|||
else {
|
||||
@assetIds = $session->form->param("attachments");
|
||||
}
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
$style->setScript($url->extras("/AttachmentsControl/AttachmentsControl.js"));
|
||||
$style->setCss($url->extras("/AttachmentsControl/AttachmentsControl.css"));
|
||||
my $uploadControl = '';
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ Asset picker for the rich editor.
|
|||
|
||||
sub www_pageTree {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
$session->style->setCss($session->url->extras('/tinymce-webgui/plugins/wgpagetree/css/pagetree.css'));
|
||||
$session->style->setRawHeadTags(<<"JS");
|
||||
<style type="text/css">body { margin: 0 }</style>
|
||||
|
|
@ -270,7 +270,7 @@ Each link display a thumbnail of the image via www_viewThumbnail.
|
|||
|
||||
sub www_imageTree {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
$session->style->setCss($session->url->extras('/tinymce-webgui/plugins/wginsertimage/css/insertimage.css'));
|
||||
$session->style->setRawHeadTags(<<"JS");
|
||||
<style type="text/css">body { margin: 0 }</style>
|
||||
|
|
@ -349,7 +349,7 @@ URL in the session object is used to determine which Image is used.
|
|||
|
||||
sub www_viewThumbnail {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
$session->style->setCss($session->url->extras('/tinymce-webgui/plugins/wginsertimage/css/insertimage.css'));
|
||||
my $image = WebGUI::Asset->newByUrl($session);
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
|
|
@ -375,7 +375,7 @@ Returns a form to add a folder using the rich editor. The purpose of this featur
|
|||
|
||||
sub www_addFolder {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers');
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
|
|
@ -416,7 +416,7 @@ Creates a directory under the current asset. The filename should be specified in
|
|||
|
||||
sub www_addFolderSave {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
# get base url
|
||||
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
|
||||
# check if user can edit the current asset
|
||||
|
|
@ -453,7 +453,7 @@ sub www_addFolderSave {
|
|||
#filename => $filename,
|
||||
});
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
$session->response->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ Returns a form to add an image using the rich editor. The purpose of this featur
|
|||
|
||||
sub www_addImage {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers');
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
|
|
@ -508,7 +508,7 @@ Creates an Image asset under the current asset. The filename should be specified
|
|||
|
||||
sub www_addImageSave {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
# get base asset
|
||||
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ sub www_addImageSave {
|
|||
$child->applyConstraints;
|
||||
}
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
$session->response->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ sub www_clickAd {
|
|||
my $id = $session->form->param("id");
|
||||
return undef unless $id;
|
||||
my $url = WebGUI::AdSpace->countClick($session, $id);
|
||||
$session->http->setRedirect($url);
|
||||
$session->response->setRedirect($url);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ via WebGUI::Session::switchAdminOff()
|
|||
sub www_switchOffAdmin {
|
||||
my $session = shift;
|
||||
return "" unless ($session->user->canUseAdminMode);
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
$session->switchAdminOff();
|
||||
return "";
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ If the current user is in the Turn On Admin Group, then allow them to turn on Ad
|
|||
sub www_switchOnAdmin {
|
||||
my $session = shift;
|
||||
return "" unless ($session->user->canUseAdminMode);
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
$session->switchAdminOn();
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ is returned.
|
|||
|
||||
sub www_auth {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $auth;
|
||||
($auth) = $session->db->quickArray("select authMethod from users where username=".$session->db->quote($session->form->process("username"))) if($session->form->process("username"));
|
||||
my $authMethod = getInstance($session,$auth);
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ Checks to ensure the requestor is who we think it is, and then executes a cron j
|
|||
sub www_runCronJob {
|
||||
my $session = shift;
|
||||
$session->response->content_type("text/plain");
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
unless (Net::CIDR::Lite->new(@{ $session->config->get('spectreSubnets') })->find($session->request->address) || canView($session)) {
|
||||
$session->log->security("make a Spectre cron job runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
|
||||
return "error";
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ sub www_editLDAPLinkSave {
|
|||
$properties->{ldapLoginTemplate} = $session->form->template("ldapLoginTemplate");
|
||||
$session->db->setRow("ldapLink","ldapLinkId",$properties);
|
||||
if($session->form->process("returnUrl")) {
|
||||
$session->http->setRedirect($session->form->process("returnUrl"));
|
||||
$session->response->setRedirect($session->form->process("returnUrl"));
|
||||
return undef;
|
||||
}
|
||||
return www_listLDAPLinks($session);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Checks to ensure the requestor is who we think it is, and then returns a JSON st
|
|||
sub www_spectreGetSiteData {
|
||||
my $session = shift;
|
||||
$session->response->content_type("application/json");
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my %siteData = ();
|
||||
my $subnets = $session->config->get("spectreSubnets");
|
||||
if (!defined $subnets) {
|
||||
|
|
@ -117,7 +117,7 @@ sub www_spectreStatus {
|
|||
my $ac = WebGUI::AdminConsole->new($session, 'spectre');
|
||||
my $i18n = WebGUI::International->new($session, 'Spectre');
|
||||
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
|
||||
my $remote = create_ikc_client(
|
||||
port=>$session->config->get("spectrePort"),
|
||||
|
|
@ -174,7 +174,7 @@ spectreSubnet, instead of checking the IP address of the spectre process.
|
|||
sub www_spectreTest {
|
||||
my $session = shift;
|
||||
$session->response->content_type("text/plain");
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
|
||||
my $subnets = $session->config->get("spectreSubnets");
|
||||
if (!defined $subnets) {
|
||||
|
|
|
|||
|
|
@ -943,7 +943,7 @@ A reference to the current session.
|
|||
|
||||
sub www_formUsers {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
return $session->privilege->insufficient() unless $session->user->isInGroup(12);
|
||||
$session->style->useEmptyStyle("1");
|
||||
my $output = getUserSearchForm($session,"formUsers",{formId=>$session->form->process("formId")},1);
|
||||
|
|
|
|||
|
|
@ -912,7 +912,7 @@ sub www_rollbackVersionTag {
|
|||
my $method = $session->form->process("proceed");
|
||||
$method = $method eq "manageCommittedVersions" ? $method : 'manageVersions';
|
||||
my $redir = WebGUI::Asset->getDefault($session)->getUrl("op=$method");
|
||||
$session->http->setRedirect(
|
||||
$session->response->setRedirect(
|
||||
$session->url->page(
|
||||
$process->contentPairs(
|
||||
'ProgressBar', {
|
||||
|
|
|
|||
|
|
@ -482,7 +482,7 @@ Checks to ensure the requestor is who we think it is, and then executes a workfl
|
|||
sub www_runWorkflow {
|
||||
my $session = shift;
|
||||
$session->response->content_type("text/plain");
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
unless (Net::CIDR::Lite->new(@{ $session->config->get('spectreSubnets')} )->find($session->request->address) || canRunWorkflow($session)) {
|
||||
$session->log->security("make a Spectre workflow runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
|
||||
return "error";
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ sub exportSomething {
|
|||
$csvData .= WebGUI::Text::joinCSV(@row) . "\n";
|
||||
}
|
||||
$storage->addFileFromScalar($filename, $csvData);
|
||||
$session->http->setRedirect($storage->getUrl($filename));
|
||||
$session->response->setRedirect($storage->getUrl($filename));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ The url to the icon you want to display.
|
|||
|
||||
sub start {
|
||||
my ($self, $title, $icon) = @_;
|
||||
$self->session->http->setCacheControl("none");
|
||||
$self->session->response->setCacheControl("none");
|
||||
my %var = (
|
||||
title => $title,
|
||||
icon => $icon
|
||||
|
|
@ -159,7 +159,7 @@ sub start {
|
|||
my $output = $self->session->style->process($template->process(\%var).'~~~', "PBtmpl0000000000000137");
|
||||
my ($head, $foot) = split '~~~', $output;
|
||||
local $| = 1; # Tell modperl not to buffer the output
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
$self->session->output->print($head, 1); #skipMacros
|
||||
$self->{_foot} = $foot;
|
||||
return '';
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ sub _httpBasicLogin {
|
|||
'WWW-Authenticate' => 'Basic realm="'.$self->session->setting->get('companyName').'"'
|
||||
);
|
||||
$self->session->response->status(401);
|
||||
$self->session->http->sendHeader;
|
||||
$self->session->response->sendHeader;
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -571,6 +571,7 @@ sub open {
|
|||
##Set defaults
|
||||
$self->{_response} = $request->new_response( 200 );
|
||||
$self->{_response}->content_type('text/html; charset=UTF-8');
|
||||
$self->{_response}->session( $self );
|
||||
|
||||
# Use the WebGUI::Session::Request object to look up the sessionId from cookies, if it
|
||||
# wasn't given explicitly
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ Package WebGUI::Session::Http
|
|||
|
||||
This package allows the manipulation of HTTP protocol information.
|
||||
|
||||
*** This module is deprecated in favor of L<WebGUI::Session::Request> and
|
||||
L<WebGUI::Session::Response>.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Session::Http;
|
||||
|
|
@ -53,89 +56,6 @@ These methods are available from this package:
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCacheControl ( )
|
||||
|
||||
Returns the cache control setting from this object.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCacheControl {
|
||||
my $self = shift;
|
||||
return $self->{_http}{cacheControl} || 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCookies ( )
|
||||
|
||||
Retrieves the cookies from the HTTP header and returns a hash reference containing them.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCookies {
|
||||
my $self = shift;
|
||||
_deprecated('Request::cookies');
|
||||
return $self->session->request->cookies;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLastModified ( )
|
||||
|
||||
Returns the stored epoch date when the page as last modified.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLastModified {
|
||||
my $self = shift;
|
||||
return $self->{_http}{lastModified};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNoHeader ( )
|
||||
|
||||
Returns whether or not a HTTP header will be printed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNoHeader {
|
||||
my $self = shift;
|
||||
return $self->{_http}{noHeader};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStreamedFile ( ) {
|
||||
|
||||
Returns the location of a file to be streamed thru mod_perl, if one has been set.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStreamedFile {
|
||||
my $self = shift;
|
||||
return $self->{_http}{streamlocation} || undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isRedirect ( )
|
||||
|
||||
Returns a boolean value indicating whether the current page will redirect to some other location.
|
||||
|
||||
=cut
|
||||
|
||||
sub isRedirect {
|
||||
my $self = shift;
|
||||
my $status = $self->session->response->status;
|
||||
return $status == 302 || $status == 301;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( session )
|
||||
|
|
@ -156,76 +76,6 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 sendHeader ( )
|
||||
|
||||
Generates and sends HTTP headers for a response.
|
||||
|
||||
=cut
|
||||
|
||||
sub sendHeader {
|
||||
my $self = shift;
|
||||
return undef if ($self->{_http}{noHeader});
|
||||
return $self->_sendMinimalHeader unless defined $self->session->db(1);
|
||||
|
||||
my $session = $self->session;
|
||||
my ($request, $response, $config) = $session->quick(qw(request response config ));
|
||||
return undef unless $request;
|
||||
my $userId = $session->get("userId");
|
||||
|
||||
# send webgui session cookie
|
||||
my $cookieName = $config->getCookieName;
|
||||
$self->setCookie($cookieName, $session->getId, $config->getCookieTTL, $config->get("cookieDomain")) unless $session->getId eq $request->cookies->{$cookieName};
|
||||
|
||||
$self->setNoHeader(1);
|
||||
my %params;
|
||||
if (!$self->isRedirect()) {
|
||||
my $cacheControl = $self->getCacheControl;
|
||||
my $date = ($userId eq "1") ? HTTP::Date::time2str($self->getLastModified) : HTTP::Date::time2str();
|
||||
# under these circumstances, don't allow caching
|
||||
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
|
||||
$response->header(
|
||||
"Cache-Control" => "private, max-age=1",
|
||||
"Pragma" => "no-cache",
|
||||
"Cache-Control" => "no-cache",
|
||||
);
|
||||
}
|
||||
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
|
||||
else {
|
||||
if ( $cacheControl eq "none" ) {
|
||||
$response->header("Cache-Control" => "private, max-age=1");
|
||||
}
|
||||
else {
|
||||
$response->header(
|
||||
'Last-Modified' => $date,
|
||||
'Cache-Control' => "must-revalidate, max-age=" . $cacheControl,
|
||||
);
|
||||
}
|
||||
# do an extra incantation if the HTTP protocol is really old
|
||||
if ($request->protocol =~ /(\d\.\d)/ && $1 < 1.1) {
|
||||
my $date = HTTP::Date::time2str(time() + $cacheControl);
|
||||
$response->header( 'Expires' => $date );
|
||||
}
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub _sendMinimalHeader {
|
||||
my $self = shift;
|
||||
my $response = $self->session->response;
|
||||
$response->content_type('text/html; charset=UTF-8');
|
||||
$response->header(
|
||||
'Cache-Control' => 'private',
|
||||
"Pragma" => "no-cache",
|
||||
"Cache-Control" => "no-cache",
|
||||
);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ( )
|
||||
|
|
@ -239,6 +89,106 @@ sub session {
|
|||
return $self->{_session};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCacheControl ( )
|
||||
|
||||
Returns the cache control setting from this object.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCacheControl {
|
||||
my $self = shift;
|
||||
return $self->session->response->getCacheControl;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCookies ( )
|
||||
|
||||
Retrieves the cookies from the HTTP header and returns a hash reference containing them.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCookies {
|
||||
my $self = shift;
|
||||
_deprecated('Session::Request::cookies');
|
||||
return $self->session->request->cookies;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLastModified ( )
|
||||
|
||||
Returns the stored epoch date when the page as last modified.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLastModified {
|
||||
my $self = shift;
|
||||
return $self->session->response->getLastModified;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNoHeader ( )
|
||||
|
||||
Returns whether or not a HTTP header will be printed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNoHeader {
|
||||
my $self = shift;
|
||||
return $self->session->response->getNoHeader;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStreamedFile ( ) {
|
||||
|
||||
Returns the location of a file to be streamed thru mod_perl, if one has been set.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStreamedFile {
|
||||
my $self = shift;
|
||||
_deprecated('Session::Response::getStreamedFile');
|
||||
return $self->session->response->getStreamedFile;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isRedirect ( )
|
||||
|
||||
Returns a boolean value indicating whether the current page will redirect to some other location.
|
||||
|
||||
=cut
|
||||
|
||||
sub isRedirect {
|
||||
my $self = shift;
|
||||
_deprecated('Session::Response::isRedirect');
|
||||
return $self->session->response->isRedirect;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head3 sendHeader
|
||||
|
||||
Moved to L<WebGUI::Session::Response>.
|
||||
|
||||
=cut
|
||||
|
||||
sub sendHeader {
|
||||
my $self = shift;
|
||||
_deprecated('Session::Response::sendHeader');
|
||||
$self->session->response->sendHeader(@_);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setCacheControl ( timeout )
|
||||
|
|
@ -253,49 +203,20 @@ Either the number of seconds until the cache expires, or the word "none" to disa
|
|||
|
||||
sub setCacheControl {
|
||||
my $self = shift;
|
||||
my $timeout = shift;
|
||||
$self->{_http}{cacheControl} = $timeout;
|
||||
_deprecated('Session::Response::setCacheControl');
|
||||
$self->session->response->setCacheControl(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setCookie ( name, value [ , timeToLive, domain ] )
|
||||
|
||||
Sends a cookie to the browser.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the cookie to set. Must be unique from all other cookies from this domain or it will overwrite that cookie.
|
||||
|
||||
=head3 value
|
||||
|
||||
The value to set.
|
||||
|
||||
=head3 timeToLive
|
||||
|
||||
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
|
||||
This may be "session" to indicate that the cookie is for the current browser session only.
|
||||
|
||||
=head3 domain
|
||||
|
||||
Explicitly set the domain for this cookie.
|
||||
|
||||
=cut
|
||||
Moved to L<WebGUI::Session::Response>.
|
||||
|
||||
sub setCookie {
|
||||
my $self = shift;
|
||||
my $name = shift;
|
||||
my $value = shift;
|
||||
my $ttl = shift;
|
||||
my $domain = shift;
|
||||
$ttl = (defined $ttl ? $ttl : '+10y');
|
||||
|
||||
$self->session->response->cookies->{$name} = {
|
||||
value => $value,
|
||||
path => '/',
|
||||
expires => $ttl ne 'session' ? $ttl : undef,
|
||||
domain => $domain,
|
||||
};
|
||||
_deprecated('Session::Request');
|
||||
$self->session->response->setCookie(@_);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -311,8 +232,8 @@ The epoch date when the page was last modified.
|
|||
|
||||
sub setLastModified {
|
||||
my $self = shift;
|
||||
my $epoch = shift;
|
||||
$self->{_http}{lastModified} = $epoch;
|
||||
_deprecated('Session::Response::setLastModified');
|
||||
$self->session->response->setLastModified(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -330,36 +251,22 @@ Any value other than 0 will disable header printing.
|
|||
|
||||
sub setNoHeader {
|
||||
my $self = shift;
|
||||
$self->{_http}{noHeader} = shift;
|
||||
_deprecated('Session::Response::setNoHeader');
|
||||
$self->session->response->setNoHeader(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setRedirect ( url, [ type ] )
|
||||
|
||||
Sets the necessary information in the HTTP header to redirect to another URL.
|
||||
|
||||
=head3 url
|
||||
|
||||
The URL to redirect to. To prevent infinite loops, no redirect will be set if
|
||||
url is the same as the current page, as found through $session->url->page.
|
||||
|
||||
=head3 type
|
||||
|
||||
Defaults to 302 (temporary redirect), but you can optionally set 301 (permanent redirect).
|
||||
Moved to L<WebGUI::Session::Response>.
|
||||
|
||||
=cut
|
||||
|
||||
sub setRedirect {
|
||||
my $self = shift;
|
||||
my $url = shift;
|
||||
my $type = shift || 302;
|
||||
my @params = $self->session->form->param;
|
||||
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
|
||||
$self->session->log->info("Redirecting to $url");
|
||||
$self->session->response->location($url);
|
||||
$self->session->response->status($type);
|
||||
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
|
||||
_deprecated('Session::Response');
|
||||
$self->session->response->setRedirect(@_);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -373,7 +280,8 @@ Set a file to be streamed thru mod_perl.
|
|||
|
||||
sub setStreamedFile {
|
||||
my $self = shift;
|
||||
$self->{_http}{streamlocation} = shift;
|
||||
_deprecated('Session::Response');
|
||||
$self->session->response->setStreamedFile(@_);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
package WebGUI::Session::Response;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use parent qw(Plack::Response);
|
||||
|
||||
use IO::File::WithPath;
|
||||
use Class::C3;
|
||||
use LWP::MediaTypes;
|
||||
|
||||
use Plack::Util::Accessor qw(session streaming writer streamer);
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
|
@ -18,6 +25,10 @@ is created.
|
|||
|
||||
=cut
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 stream
|
||||
|
||||
=cut
|
||||
|
|
@ -28,6 +39,10 @@ sub stream {
|
|||
$self->streaming(1);
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 stream_write
|
||||
|
||||
=cut
|
||||
|
|
@ -41,4 +56,385 @@ sub stream_write {
|
|||
$self->writer->write(@_);
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 sendHeader ( )
|
||||
|
||||
Generates and sends HTTP headers for a response.
|
||||
|
||||
=cut
|
||||
|
||||
sub sendHeader {
|
||||
my $self = shift;
|
||||
return undef if $self->{_http}{noHeader};
|
||||
return $self->_sendMinimalHeader unless defined $self->session->db(1);
|
||||
|
||||
no warnings 'uninitialized';
|
||||
|
||||
my $session = $self->session;
|
||||
my ($request, $config) = $session->quick(qw(request config ));
|
||||
return undef unless $request;
|
||||
my $userId = $session->get("userId");
|
||||
|
||||
# send webgui session cookie
|
||||
my $cookieName = $config->getCookieName;
|
||||
$self->setCookie($cookieName, $session->getId, $config->getCookieTTL, $config->get("cookieDomain")) unless $session->getId eq $request->cookies->{$cookieName};
|
||||
|
||||
$self->setNoHeader(1);
|
||||
my %params;
|
||||
if (!$self->isRedirect()) {
|
||||
my $cacheControl = $self->getCacheControl;
|
||||
my $date = ($userId eq "1") ? HTTP::Date::time2str($self->getLastModified) : HTTP::Date::time2str();
|
||||
# under these circumstances, don't allow caching
|
||||
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
|
||||
$self->header(
|
||||
"Cache-Control" => "private, max-age=1",
|
||||
"Pragma" => "no-cache",
|
||||
"Cache-Control" => "no-cache",
|
||||
);
|
||||
}
|
||||
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
|
||||
else {
|
||||
if ( $cacheControl eq "none" ) {
|
||||
$self->header("Cache-Control" => "private, max-age=1");
|
||||
}
|
||||
else {
|
||||
$self->header(
|
||||
'Last-Modified' => $date,
|
||||
'Cache-Control' => "must-revalidate, max-age=" . $cacheControl,
|
||||
);
|
||||
}
|
||||
# do an extra incantation if the HTTP protocol is really old
|
||||
if ($request->protocol =~ /(\d\.\d)/ && $1 < 1.1) {
|
||||
my $date = HTTP::Date::time2str(time() + $cacheControl);
|
||||
$self->header( 'Expires' => $date );
|
||||
}
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub _sendMinimalHeader {
|
||||
my $self = shift;
|
||||
$self->content_type('text/html; charset=UTF-8');
|
||||
$self->header(
|
||||
'Cache-Control' => 'private',
|
||||
"Pragma" => "no-cache",
|
||||
"Cache-Control" => "no-cache",
|
||||
);
|
||||
return undef;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 setCookie ( name, value [ , timeToLive, domain ] )
|
||||
|
||||
Sends a cookie to the browser.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the cookie to set. Must be unique from all other cookies from this domain or it will overwrite that cookie.
|
||||
|
||||
=head3 value
|
||||
|
||||
The value to set.
|
||||
|
||||
=head3 timeToLive
|
||||
|
||||
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
|
||||
This may be "session" to indicate that the cookie is for the current browser session only.
|
||||
|
||||
=head3 domain
|
||||
|
||||
Explicitly set the domain for this cookie.
|
||||
|
||||
=cut
|
||||
|
||||
sub setCookie {
|
||||
my $self = shift;
|
||||
my $name = shift;
|
||||
my $value = shift;
|
||||
my $ttl = shift;
|
||||
my $domain = shift;
|
||||
$ttl = (defined $ttl ? $ttl : '+10y');
|
||||
|
||||
$self->cookies->{$name} = {
|
||||
value => $value,
|
||||
path => '/',
|
||||
expires => $ttl ne 'session' ? $ttl : undef,
|
||||
domain => $domain,
|
||||
};
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 setRedirect ( url, [ type ] )
|
||||
|
||||
Sets the necessary information in the HTTP header to redirect to another URL.
|
||||
|
||||
=head3 url
|
||||
|
||||
The URL to redirect to. To prevent infinite loops, no redirect will be set if
|
||||
url is the same as the current page, as found through $session->url->page.
|
||||
|
||||
=head3 type
|
||||
|
||||
Defaults to 302 (temporary redirect), but you can optionally set 301 (permanent redirect).
|
||||
|
||||
=cut
|
||||
|
||||
sub setRedirect {
|
||||
my $self = shift;
|
||||
my $url = shift || '';
|
||||
my $type = shift || 302;
|
||||
my @params = $self->session->form->param;
|
||||
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
|
||||
$self->session->log->info("Redirecting to $url");
|
||||
$self->location($url);
|
||||
$self->status($type);
|
||||
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 getLastModified ( )
|
||||
|
||||
Returns the stored epoch date when the page as last modified.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLastModified {
|
||||
my $self = shift;
|
||||
return $self->{_http}{lastModified};
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 setLastModified ( epoch )
|
||||
|
||||
=head3 epoch
|
||||
|
||||
The epoch date when the page was last modified.
|
||||
|
||||
=cut
|
||||
|
||||
sub setLastModified {
|
||||
my $self = shift;
|
||||
my $epoch = shift;
|
||||
$self->{_http}{lastModified} = $epoch;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 getNoHeader ( )
|
||||
|
||||
Returns whether or not a HTTP header will be printed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNoHeader {
|
||||
my $self = shift;
|
||||
return $self->{_http}{noHeader};
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 setNoHeader ( boolean )
|
||||
|
||||
Disables the printing of a HTTP header. Useful in situations when content is not
|
||||
returned to a browser (export to disk for example).
|
||||
|
||||
=head3 boolean
|
||||
|
||||
Any value other than 0 will disable header printing.
|
||||
|
||||
=cut
|
||||
|
||||
sub setNoHeader {
|
||||
my $self = shift;
|
||||
$self->{_http}{noHeader} = shift;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 isRedirect ( )
|
||||
|
||||
Returns a boolean value indicating whether the current page will redirect to some other location.
|
||||
|
||||
=cut
|
||||
|
||||
sub isRedirect {
|
||||
my $self = shift;
|
||||
my $status = $self->status;
|
||||
return $status == 302 || $status == 301;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 getStreamedFile ( ) {
|
||||
|
||||
Returns the location of a file to be streamed thru mod_perl, if one has been set.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStreamedFile {
|
||||
my $self = shift;
|
||||
return $self->{_http}{streamlocation} || undef;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 setStreamedFile ( ) {
|
||||
|
||||
Set a file to be streamed through mod_perl.
|
||||
Rrequires that C<enableStreamingUploads> be set in the config file and then
|
||||
some middleware or reverse-proxy in front of L<WebGUI> to catch the X-Sendfile
|
||||
headers and replace that with the file to be sent.
|
||||
|
||||
=cut
|
||||
|
||||
sub setStreamedFile {
|
||||
my $self = shift;
|
||||
my $fn = shift;
|
||||
|
||||
if( ! defined $fn or ! length $fn ) {
|
||||
# t/Session/Http.t tests that it can call this with '' as an arg
|
||||
# really, it looks like it is testing implementation rather than behavior but I don't know what behavior it's getting at so, voodoo
|
||||
$self->body(undef);
|
||||
$self->{_http}{streamlocation} = undef;
|
||||
return;
|
||||
}
|
||||
|
||||
$self->{_http}{streamlocation} = $fn;
|
||||
|
||||
# return undef unless $self->session->config->get('enableStreamingUploads'); # throw an error? handle gracefully? XX
|
||||
|
||||
my $fh = eval { IO::File::WithPath->new( $fn ) } or WebGUI::Error::InvalidFile->throw(
|
||||
error => "Couldn't create an IO::File::WithPath object: $@ $!",
|
||||
brokenFile => $fn,
|
||||
);
|
||||
|
||||
$self->body( $fh );
|
||||
|
||||
1;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 sendFile ( ) {
|
||||
|
||||
Either redirect (C<setRedirect()>) or trigger a stream (C<setStreamedFile()>) depending on how L<WebGUI> is configured.
|
||||
If C<enableStreamingUploads> is set in the config file, C<setStreamedFile()> is used.
|
||||
|
||||
=cut
|
||||
|
||||
# $session->response->sendFile($self->getStorageLocation, $self->filename);
|
||||
|
||||
|
||||
sub sendFile {
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
my $filename = shift;
|
||||
if( $self->session->config->get('enableStreamingUploads') ) {
|
||||
$self->setStreamedFile( $storage->getPath($filename) );
|
||||
}
|
||||
else {
|
||||
$self->setRedirect( $storage->getUrl($filename) );
|
||||
}
|
||||
1;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 setCacheControl ( timeout )
|
||||
|
||||
Sets the cache control headers.
|
||||
|
||||
=head3 timeout
|
||||
|
||||
Either the number of seconds until the cache expires, or the word "none" to disable cache completely for this request.
|
||||
|
||||
=cut
|
||||
|
||||
sub setCacheControl {
|
||||
my $self = shift;
|
||||
my $timeout = shift;
|
||||
$self->{_http}{cacheControl} = $timeout;
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head2 getCacheControl ( )
|
||||
|
||||
Returns the cache control setting from this object.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCacheControl {
|
||||
my $self = shift;
|
||||
return $self->{_http}{cacheControl} || 1;
|
||||
}
|
||||
|
||||
=head2 finalize ( )
|
||||
|
||||
Subclasses Plack::Response C<finalize()>, doing L<WebGUI> specific finalization chores.
|
||||
|
||||
=cut
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
sub finalize {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $filename = $self->getStreamedFile();
|
||||
if (defined $filename and $self->session->config->get("enableStreamingUploads") ) {
|
||||
# at this point, $request->body contains an IO::File::WithPath object, and that's all Plack needs
|
||||
my $ct = LWP::MediaTypes::guess_media_type($filename);
|
||||
$self->content_type($ct);
|
||||
}
|
||||
|
||||
# in the future, sendHeader's logic should be moved into here and sendHeader should vanish.
|
||||
# the rest of WebGUI should essentially never need to call sendHeader explicitly but should
|
||||
# just call methods in here to configure the response and then return back up to the top where
|
||||
# WebGUI.pm calls finalize and returns the response object back to Plack.
|
||||
# for now, I've added this extra (harmless) call to sendHeader to get started on removing the
|
||||
# others.
|
||||
|
||||
$self->sendHeader(); # doesn't send the header, only fixes the response up based on options set
|
||||
|
||||
$self->next::method(@_);
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ if ($self->session->user->isRegistered || $self->session->setting->get("preventP
|
|||
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate, max-age=0, private" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
';
|
||||
$self->session->http->setCacheControl("none");
|
||||
$self->session->response->setCacheControl("none");
|
||||
} else {
|
||||
$var{'head.tags'} .= '<meta http-equiv="Cache-Control" content="must-revalidate" />'
|
||||
}
|
||||
|
|
@ -559,7 +559,7 @@ The content to be wrappered.
|
|||
sub userStyle {
|
||||
my $self = shift;
|
||||
my $output = shift;
|
||||
$self->session->http->setCacheControl("none");
|
||||
$self->session->response->setCacheControl("none");
|
||||
if (defined $output) {
|
||||
return $self->process($output,$self->session->setting->get("userFunctionStyleId"));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ is not passed in, it will attempt to get one from the L<page> method, or finally
|
|||
sub forceSecureConnection {
|
||||
my $self = shift;
|
||||
my $url = shift;
|
||||
my ($conf, $http) = $self->session->quick(qw(config http));
|
||||
my ($conf, $response) = $self->session->quick(qw(config response));
|
||||
|
||||
if ($conf->get("sslEnabled") && ! $self->session->request->secure){
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ sub forceSecureConnection {
|
|||
}
|
||||
if($url =~ /^http/i) {
|
||||
$url =~ s/^https?/https/i;
|
||||
$http->setRedirect($url);
|
||||
$response->setRedirect($url);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@ sub www_editSave {
|
|||
return $session->privilege->insufficient() unless $session->user->isAdmin;
|
||||
|
||||
$self->processPropertiesFromFormPost;
|
||||
$session->http->setRedirect($session->url->page('shop=pay;method=manage'));
|
||||
$session->response->setRedirect($session->url->page('shop=pay;method=manage'));
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ sub www_cancelTransaction {
|
|||
$self->_setPaymentStatus( 0, $form->process('PAYID'), $form->process('STATUS'), 'Cancelled' );
|
||||
$self->processTransaction( $transaction );
|
||||
|
||||
$session->http->setRedirect($self->session->url->getSiteURL.'?shop=cart');
|
||||
$session->response->setRedirect($self->session->url->getSiteURL.'?shop=cart');
|
||||
return $session->style->userStyle('Transaction cancelled');
|
||||
}
|
||||
|
||||
|
|
@ -373,7 +373,7 @@ sub www_declineTransaction {
|
|||
$self->_setPaymentStatus( 0, $form->process('PAYID'), $form->process('STATUS'), 'Declined' );
|
||||
$self->processTransaction( $transaction );
|
||||
|
||||
$session->http->setRedirect($self->session->url->getSiteURL.'?shop=cart');
|
||||
$session->response->setRedirect($self->session->url->getSiteURL.'?shop=cart');
|
||||
return $session->style->userStyle('Transaction declined');
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ sub www_exceptionTransaction {
|
|||
$self->_setPaymentStatus( 0, $form->process('PAYID'), $form->process('STATUS'), 'Transaction exception occurred' );
|
||||
$self->processTransaction( $transaction );
|
||||
|
||||
$session->http->setRedirect($self->session->url->getSiteURL.'?shop=cart');
|
||||
$session->response->setRedirect($self->session->url->getSiteURL.'?shop=cart');
|
||||
return $session->style->userStyle('A transaction exception occurred.');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ sub www_sendToPayPal {
|
|||
}
|
||||
);
|
||||
|
||||
return $session->http->setRedirect($dest);
|
||||
return $session->response->setRedirect($dest);
|
||||
} ## end sub www_sendToPayPal
|
||||
|
||||
=head1 LIMITATIONS
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ sub www_editSave {
|
|||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $session->user->isAdmin;
|
||||
$self->processPropertiesFromFormPost;
|
||||
$session->http->setRedirect($session->url->page('shop=ship;method=manage'));
|
||||
$session->response->setRedirect($session->url->page('shop=ship;method=manage'));
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ sub www_exportTax {
|
|||
return $session->privilege->insufficient unless $self->canManage;
|
||||
|
||||
my $storage = $self->exportTaxData();
|
||||
$self->session->http->setRedirect($storage->getUrl($storage->getFiles->[0]));
|
||||
$self->session->response->setRedirect($storage->getUrl($storage->getFiles->[0]));
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ use Scope::Guard;
|
|||
use WebGUI::Paths -inc;
|
||||
use namespace::clean;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Test::Mechanize;
|
||||
use HTTP::Request::Common;
|
||||
|
||||
our @EXPORT = qw(cleanupGuard addToCleanup);
|
||||
our @EXPORT_OK = qw(session config collateral);
|
||||
|
|
@ -378,6 +380,7 @@ below.
|
|||
|
||||
# I think that getPage should be entirely replaced with calles to Plack::Test::test_psgi
|
||||
# - testing with the callback is better and it means we can run on any backend
|
||||
# I agree.
|
||||
sub getPage {
|
||||
my $class = shift;
|
||||
my $actor = shift; # The actor to work on
|
||||
|
|
@ -432,6 +435,82 @@ sub getPage {
|
|||
return join '', @{$session->response->body};
|
||||
}
|
||||
|
||||
=head2 getPage2 ( request|url [, opts] )
|
||||
|
||||
Get the entire response from a page request using L<WebGUI::Test::Mechanize>.
|
||||
This is a wrapper around L<WebGUI::Test::Mechanize> for the purpose of easing conversion of tests that use C<getPage>.
|
||||
|
||||
Accepts an L<HTTP::Request> object as an argument, which cooked up auth info will be added to.
|
||||
An L<HTTP::Request> will be constructed from a simple relative URL such as C<home> if a string is passed instead.
|
||||
|
||||
Returns a string containing the body of the requested page.
|
||||
|
||||
C<options> is a hash reference of options with keys outlined below.
|
||||
|
||||
user => A user object to set for this request
|
||||
userId => A userId to set for this request
|
||||
formParams => A hash reference of form parameters
|
||||
|
||||
Compared to C<getPage> above, these are not yet supported:
|
||||
|
||||
uploads
|
||||
args
|
||||
|
||||
=cut
|
||||
|
||||
sub getPage2 {
|
||||
my $class = shift;
|
||||
my $request = shift;
|
||||
my $optionsRef = shift; # A hashref of options
|
||||
# args => Array ref of args to the page sub
|
||||
# user => A user object to set
|
||||
# userId => A user ID to set, "user" takes
|
||||
# precedence
|
||||
|
||||
die "not supported" if exists $optionsRef->{args};
|
||||
die "not supported" if exists $optionsRef->{uploads};
|
||||
|
||||
my $session = $CLASS->session;
|
||||
|
||||
# Save state
|
||||
my $oldUser = $session->user;
|
||||
my $oldRequest = $session->request;
|
||||
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
|
||||
# Set the appropriate user
|
||||
if ($optionsRef->{user}) {
|
||||
$mech->session->user({ user => $optionsRef->{user} });
|
||||
}
|
||||
elsif ($optionsRef->{userId}) {
|
||||
$mech->session->user({ userId => $optionsRef->{userId} });
|
||||
}
|
||||
$session->user->uncache;
|
||||
|
||||
$mech->session or die; # force a session to be created for the request
|
||||
my $session_id = $mech->sessionId or die;
|
||||
|
||||
# Build or fix up a request object
|
||||
if( ! eval { $request->isa('HTTP::Request') } ) {
|
||||
if( $optionsRef->{formParams} ) {
|
||||
$request = HTTP::Request::Common::POST( "http://127.0.0.1/$request", [ %{ $optionsRef->{formParams} } ] ) or die;
|
||||
}
|
||||
else {
|
||||
$request = HTTP::Request->new( GET => "http://127.0.0.1/$request" ) or die;
|
||||
}
|
||||
}
|
||||
$request->header( 'Set-Cookie3' => qq{wgSession=$session_id; path="/"; domain=127.0.0.1; path_spec; discard; version=0} );
|
||||
|
||||
$mech->request( $request );
|
||||
|
||||
# Restore the former user and request
|
||||
$session->user({ user => $oldUser });
|
||||
$session->{_request} = $oldRequest; # dubious about this; if we're going to try to support requests inside of other requests, it should be tested and actually supported rather than just some optimistic arm waving done
|
||||
|
||||
return $mech->response->decoded_content;
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTestCollateralPath ( [filename] )
|
||||
|
|
|
|||
|
|
@ -58,10 +58,15 @@ sub new {
|
|||
|
||||
sub session {
|
||||
my $self = shift;
|
||||
if( @_ ) {
|
||||
$self->{_webgui_session} = shift; # take session as an arg
|
||||
$self->{_webgui_sessionId} ||= $self->{_webgui_session}->getId;
|
||||
}
|
||||
return $self->{_webgui_session}
|
||||
if $self->{_webgui_session};
|
||||
my $session = WebGUI::Session->open($self->{_webgui_config}, undef, $self->sessionId);
|
||||
my $session = WebGUI::Session->open($self->{_webgui_config}, undef, $self->sessionId) or die;
|
||||
$self->{_webgui_session} = $session;
|
||||
$self->{_webgui_sessionId} ||= $session->getId; # sessionId() sets it from
|
||||
return $session;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +83,9 @@ sub sessionId {
|
|||
}
|
||||
});
|
||||
if (! $sessionId) {
|
||||
die "Unable to find session cookie!";
|
||||
# die "Unable to find session cookie!";
|
||||
# when called from session() above, there is no session yet and no sessionId; that's okay
|
||||
return; # empty list; make WebGUI::Session generate one for us
|
||||
}
|
||||
$self->{_webgui_sessionId} = $sessionId;
|
||||
return $sessionId;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ sub autoCommitWorkingIfEnabled {
|
|||
}
|
||||
else {
|
||||
my $url = $versionTag->autoCommitUrl($options->{returnUrl});
|
||||
$session->http->setRedirect($url);
|
||||
$session->response->setRedirect($url);
|
||||
return 'redirect';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ sub www_cleanup {
|
|||
my ( $self ) = @_;
|
||||
|
||||
$self->cleanup;
|
||||
$self->session->http->setRedirect( $self->session->url->page );
|
||||
$self->session->response->setRedirect( $self->session->url->page );
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ sub www_chooseContent {
|
|||
my ($self) = @_;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
||||
|
||||
my $output = '<h1>' . $i18n->get('Initial Pages') . '</h1>';
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ sub wrapStyle {
|
|||
my ( $self, $output ) = @_;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
||||
my $page = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
|
@ -142,7 +142,7 @@ sub www_adminAccount {
|
|||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
||||
|
||||
my $legend = $i18n->get('admin account');
|
||||
|
|
@ -246,7 +246,7 @@ sub www_companyInformation {
|
|||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
||||
|
||||
my $output = '<h1>' . $i18n->get('company information') . '</h1>';
|
||||
|
|
@ -306,7 +306,7 @@ sub www_siteStats {
|
|||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
||||
|
||||
my $enableForm = $self->getForm;
|
||||
|
|
@ -390,7 +390,7 @@ sub www_cleanup {
|
|||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->response->setCacheControl("none");
|
||||
my $i18n = WebGUI::International->new( $session, "WebGUI" );
|
||||
|
||||
$self->cleanup;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue