migrated http proxy and ws client

This commit is contained in:
JT Smith 2005-01-03 03:24:43 +00:00
parent 15c48e14d0
commit 7416bda04f
14 changed files with 282 additions and 1306 deletions

View file

@ -1,4 +1,4 @@
package WebGUI::Wobject::HttpProxy;
package WebGUI::Asset::Wobject::HttpProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
@ -16,155 +16,182 @@ use LWP;
use HTTP::Cookies;
use HTTP::Request::Common;
use HTML::Entities;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::Wobject;
use WebGUI::Wobject::HttpProxy::Parse;
use WebGUI::Storage;
use WebGUI::Asset::Wobject;
use WebGUI::Asset::Wobject::HttpProxy::Parse;
use WebGUI::Cache;
our @ISA = qw(WebGUI::Wobject);
our @ISA = qw(WebGUI::Asset::Wobject);
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(3,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
tableName=>'HttpProxy',
className=>'WebGUI::Asset::Wobject::HttpProxy',
properties=>{
proxiedUrl=>{
fieldType=>"url",
defaultValue=>'http://'
},
timeout=>{
fieldType=>"selectList",
defaultValue=>30
},
removeStyle=>{
fieldType=>"yesNo",
defaultValue=>1
},
filterHtml=>{
fieldType=>"filterContent",
defaultValue=>"javascript"
},
followExternal=>{
fieldType=>"yesNo",
defaultValue=>1
},
rewriteUrls=>{
fieldType=>"yesNo",
defaultValue=>1
},
followRedirect=>{
fieldType=>"yesNo",
defaultValue=>0
},
searchFor=>{
defaultValue=>''
fieldType=>"text",
defaultValue=>undef
},
stopAt=>{
defaultValue=>''
fieldType=>"text",
defaultValue=>undef
},
},
-useTemplate=>1,
-useMetaData=>1
);
bless $self, $class;
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
sub uiLevel {
return 5;
sub getCookieJar {
my $self = shift;
my $storage;
unless ($self->get("cookieJarStorageId")) {
$storage = WebGUI::Storage->create;
$self->update({cookieJarStorageId=>$storage->getId});
} else {
$storage = WebGUI::Storage->get($self->get("cookieJarStorageId"));
}
return $storage;
}
#-------------------------------------------------------------------
sub www_edit {
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
my %hash;
tie %hash, 'Tie::IxHash';
%hash=(5=>5,10=>10,20=>20,30=>30,60=>60);
my $privileges = WebGUI::HTMLForm->new;
my $properties = WebGUI::HTMLForm->new;
my $layout = WebGUI::HTMLForm->new;
$properties->url(
$tabform->getTab("properties")->url(
-name=>"proxiedUrl",
-label=>WebGUI::International::get(1,$_[0]->get("namespace")),
-value=>$_[0]->getValue("proxiedUrl")
-label=>WebGUI::International::get(1,"HttpProxy"),
-value=>$self->getValue("proxiedUrl")
);
$privileges->yesNo(
$tabform->getTab("security")->yesNo(
-name=>"followExternal",
-label=>WebGUI::International::get(5,$_[0]->get("namespace")),
-value=>$_[0]->getValue("followExternal")
-label=>WebGUI::International::get(5,"HttpProxy"),
-value=>$self->getValue("followExternal")
);
$properties->yesNo(
$tabform->getTab("properties")->yesNo(
-name=>"followRedirect",
-label=>WebGUI::International::get(8,$_[0]->get("namespace")),
-value=>$_[0]->getValue("followRedirect")
-label=>WebGUI::International::get(8,"HttpProxy"),
-value=>$self->getValue("followRedirect")
);
$properties->yesNo(
$tabform->getTab("properties")->yesNo(
-name=>"rewriteUrls",
-label=>WebGUI::International::get(12,$_[0]->get("namespace")),
-value=>$_[0]->getValue("rewriteUrls")
-label=>WebGUI::International::get(12,"HttpProxy"),
-value=>$self->getValue("rewriteUrls")
);
$layout->yesNo(
$tabform->getTab("display")->yesNo(
-name=>"removeStyle",
-label=>WebGUI::International::get(6,$_[0]->get("namespace")),
-value=>$_[0]->getValue("removeStyle")
-label=>WebGUI::International::get(6,"HttpProxy"),
-value=>$self->getValue("removeStyle")
);
$layout->filterContent(
$tabform->getTab("display")->filterContent(
-name=>"filterHtml",
-value=>$_[0]->getValue("filterHtml")
-value=>$self->getValue("filterHtml")
);
$properties->select(
$tabform->getTab("properties")->selectList(
-name=>"timeout",
-options=>\%hash,
-label=>WebGUI::International::get(4,$_[0]->get("namespace")),
-value=>[$_[0]->getValue("timeout")]
-label=>WebGUI::International::get(4,"HttpProxy"),
-value=>[$self->getValue("timeout")]
);
$layout->text(
$tabform->getTab("display")->text(
-name=>"searchFor",
-label=>WebGUI::International::get(13,$_[0]->get("namespace")),
-value=>$_[0]->getValue("searchFor")
-label=>WebGUI::International::get(13,"HttpProxy"),
-value=>$self->getValue("searchFor")
);
$layout->text(
$tabform->getTab("display")->text(
-name=>"stopAt",
-label=>WebGUI::International::get(14,$_[0]->get("namespace")),
-value=>$_[0]->getValue("stopAt")
-label=>WebGUI::International::get(14,"HttpProxy"),
-value=>$self->getValue("stopAt")
);
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-layout=>$layout->printRowsOnly,
-privileges=>$privileges->printRowsOnly,
-helpId=>"http proxy add/edit",
-headingId=>2
);
return $tabform;
}
#-------------------------------------------------------------------
sub www_view {
my (%var, %formdata, @formUpload, $redirect, $response, $header, $userAgent, $proxiedUrl, $request, $ttl);
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
my $node = WebGUI::Node->new("temp",$_[0]->get("namespace")."_cookies");
$node->create;
sub getIcon {
my $self = shift;
my $small = shift;
return $session{config}{extrasURL}.'/assets/small/httpProxy.gif' if ($small);
return $session{config}{extrasURL}.'/assets/httpProxy.gif';
}
#-------------------------------------------------------------------
sub getName {
return WebGUI::International::get(3,"HttpProxy");
}
#-------------------------------------------------------------------
sub getUiLevel {
return 5;
}
#-------------------------------------------------------------------
sub purge {
my $self = shift;
$self->getCookieJar->delete;
$self->SUPER::purge;
}
#-------------------------------------------------------------------
sub view {
my $self = shift;
my $cookiebox = WebGUI::URL::escape($session{var}{sessionId});
$cookiebox =~ s/[^A-Za-z0-9\-\.\_]//g; #removes all funky characters
$cookiebox .= '.cookie';
$cookiebox = $node->getPath.$session{os}{slash}.$cookiebox;
my $jar = HTTP::Cookies->new(File => $cookiebox, AutoSave => 1, Ignore_Discard => 1);
my $jar = HTTP::Cookies->new(File => $self->getCookieJar->getPath($cookiebox), AutoSave => 1, Ignore_Discard => 1);
my (%var, %formdata, @formUpload, $redirect, $response, $header, $userAgent, $proxiedUrl, $request, $ttl);
if($session{form}{wid} eq $_[0]->get("wobjectId") && $session{form}{func}!~/editSave/i) {
$proxiedUrl = $session{form}{FormAction} || $session{form}{proxiedUrl} || $_[0]->get("proxiedUrl") ;
if($session{form}{func}!~/editSave/i) {
$proxiedUrl = $session{form}{FormAction} || $session{form}{proxiedUrl} || $self->get("proxiedUrl") ;
} else {
$proxiedUrl = $_[0]->get("proxiedUrl");
$proxiedUrl = $self->get("proxiedUrl");
$session{env}{REQUEST_METHOD}='GET';
}
$redirect=0;
return $_[0]->processTemplate($_[0]->get("templateId"),{}) unless ($proxiedUrl ne "");
return $self->processTemplate({},"HttpProxy",$self->get("templateId")) unless ($proxiedUrl ne "");
my $cachedContent = WebGUI::Cache->new($proxiedUrl,"URL");
my $cachedHeader = WebGUI::Cache->new($proxiedUrl,"HEADER");
@ -175,26 +202,26 @@ sub www_view {
until($redirect == 5) { # We follow max 5 redirects to prevent bouncing/flapping
$userAgent = new LWP::UserAgent;
$userAgent->agent($session{env}{HTTP_USER_AGENT});
$userAgent->timeout($_[0]->get("timeout"));
$userAgent->timeout($self->get("timeout"));
$userAgent->env_proxy;
$proxiedUrl = URI->new($proxiedUrl);
#my $allowed_url = URI->new($_[0]->get('proxiedUrl'))->abs;;
#my $allowed_url = URI->new($self->get('proxiedUrl'))->abs;;
#if ($_[0]->get("followExternal")==0 && $proxiedUrl !~ /\Q$allowed_url/i) {
if ($_[0]->get("followExternal")==0 &&
(URI->new($_[0]->get('proxiedUrl'))->host) ne (URI->new($proxiedUrl)->host) ) {
#if ($self->get("followExternal")==0 && $proxiedUrl !~ /\Q$allowed_url/i) {
if ($self->get("followExternal")==0 &&
(URI->new($self->get('proxiedUrl'))->host) ne (URI->new($proxiedUrl)->host) ) {
$var{header} = "text/html";
return "<h1>You are not allowed to leave ".$_[0]->get("proxiedUrl")."</h1>";
return "<h1>You are not allowed to leave ".$self->get("proxiedUrl")."</h1>";
}
$header = new HTTP::Headers;
$header->referer($_[0]->get("proxiedUrl")); # To get around referrer blocking
$header->referer($self->get("proxiedUrl")); # To get around referrer blocking
if($session{env}{REQUEST_METHOD}=~/GET/i || $redirect != 0) { # request_method is also GET after a redirection. Just to make sure we're
# not posting the same data over and over again.
if($redirect == 0 && $session{form}{wid} eq $_[0]->get("wobjectId")) {
if($redirect == 0) {
foreach my $input_name (keys %{$session{form}}) {
next if ($input_name !~ /^HttpProxy_/); # Skip non proxied form var's
$input_name =~ s/^HttpProxy_//;
@ -247,7 +274,7 @@ sub www_view {
} else {
$redirect = 5; #No redirection found. Leave loop.
}
$redirect=5 if (not $_[0]->get("followRedirect")); # No redirection. Overruled by setting
$redirect=5 if (not $self->get("followRedirect")); # No redirection. Overruled by setting
}
if($response->is_success) {
@ -256,8 +283,8 @@ sub www_view {
if($response->content_type eq "text/html" ||
($response->content_type eq "" && $var{content}=~/<html/gis)) {
$var{"search.for"} = $_[0]->getValue("searchFor");
$var{"stop.at"} = $_[0]->getValue("stopAt");
$var{"search.for"} = $self->getValue("searchFor");
$var{"stop.at"} = $self->getValue("stopAt");
if ($var{"search.for"}) {
$var{content} =~ /^(.*?)\Q$var{"search.for"}\E(.*)$/gis;
$var{"content.leading"} = $1 || $var{content};
@ -268,7 +295,7 @@ sub www_view {
$var{content} = $1 || $var{content};
$var{"content.trailing"} = $2;
}
my $p = WebGUI::Wobject::HttpProxy::Parse->new($proxiedUrl, $var{content}, $_[0]->get("wobjectId"),$_[0]->get("rewriteUrls"));
my $p = WebGUI::Asset::Wobject::HttpProxy::Parse->new($proxiedUrl, $var{content}, $self->getId,$self->get("rewriteUrls"));
$var{content} = $p->filter; # Rewrite content. (let forms/links return to us).
$p->DESTROY;
@ -277,9 +304,9 @@ sub www_view {
$var{content} = "<h1>HttpProxy: Can't display frames</h1>
Try fetching it directly <a href='$proxiedUrl'>here.</a>";
} else {
$var{content} =~ s/\<style.*?\/style\>//isg if ($_[0]->get("removeStyle"));
$var{content} =~ s/\<style.*?\/style\>//isg if ($self->get("removeStyle"));
$var{content} = WebGUI::HTML::cleanSegment($var{content});
$var{content} = WebGUI::HTML::filter($var{content}, $_[0]->get("filterHtml"));
$var{content} = WebGUI::HTML::filter($var{content}, $self->get("filterHtml"));
}
}
} else { # Fetching page failed...
@ -301,7 +328,18 @@ sub www_view {
WebGUI::HTTP::setMimeType($var{header});
return $var{content};
} else {
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
return $self->processTemplate(\%var,"HttpProxy",$self->get("templateId"));
}
}
#-------------------------------------------------------------------
sub www_edit {
my $self = shift;
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
$self->getAdminConsole->setHelp("http proxy add/edit");
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("2","HttpProxy"));
}
1;

View file

@ -1,4 +1,4 @@
package WebGUI::Wobject::HttpProxy::Parse;
package WebGUI::Asset::Wobject::HttpProxy::Parse;
# -------------------------------------------------------------------
@ -51,7 +51,7 @@ sub new {
my $self = $pack->SUPER::new();
$self->{Url} = shift;
$self->{Content} = shift;
$self->{wid} = shift;
$self->{assetId} = shift;
$self->{rewriteUrls} = shift;
$self->{Filtered} ="";
$self->{FormAction} = "";
@ -100,7 +100,7 @@ sub start {
my $self = shift;
my ($tag, $attr, $attrseq, $origtext) = @_;
# Check on the div class and div id attributes to see if we're proxying ourself.
if($tag eq "div" && $attr->{'class'} eq 'wobjectHttpProxy' && $attr->{'id'} eq ('wobjectId'.$self->{wid})) {
if($tag eq "div" && $attr->{'class'} eq 'wobjectHttpProxy' && $attr->{'id'} eq ('assetId'.$self->{assetId})) {
$self->{recurseCheck} = 1;
}
$self->output("<$tag");
@ -138,8 +138,7 @@ sub start {
$val = WebGUI::URL::page; # Form Action returns to us
} else {
$val =~ s/\n//g; # Bugfix 757068
$val = WebGUI::URL::page('proxiedUrl='.WebGUI::URL::escape($val).
'&wid='.$self->{wid}.'&func=view'); # return to us
$val = WebGUI::URL::page('proxiedUrl='.WebGUI::URL::escape($val).'&func=view'); # return to us
}
}
}
@ -149,7 +148,6 @@ sub start {
$self->output(">");
if ($self->{FormAction} ne "") {
$self->output('<input type="hidden" name="FormAction" value="'.$self->{FormAction}.'">');
$self->output('<input type="hidden" name="wid" value="'.$self->{wid}.'">');
$self->output('<input type="hidden" name="func" value="view">');
$self->{FormAction} = '';
$self->{FormActionIsDefined}=0;

View file

@ -1,4 +1,4 @@
package WebGUI::Wobject::WSClient;
package WebGUI::Asset::Wobject::WSClient;
use strict;
use Data::Dumper;
@ -7,13 +7,12 @@ use SOAP::Lite;
use Storable;
use WebGUI::Cache;
use WebGUI::ErrorHandler;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::Wobject;
use WebGUI::Asset::Wobject;
my ($hasUnblessAcme, $hasUnblessData, $hasUtf8, $utf8FieldType);
@ -39,35 +38,26 @@ BEGIN {
}
}
our @ISA = qw(WebGUI::Wobject);
our @ISA = qw(WebGUI::Asset::Wobject);
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(1, $_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my ($self, $class, $httpHeaderFieldType, $property);
$class = shift;
$property = shift;
# specify in the config file if you want to force diff http headers,
# for outputting raw pdfs, etc
sub definition {
my $class = shift;
my $definition = shift;
my $httpHeaderFieldType;
if ($session{'config'}{'soapHttpHeaderOverride'}) {
$httpHeaderFieldType = 'text';
} else {
$httpHeaderFieldType = 'hidden';
}
$self = WebGUI::Wobject->new(
-properties => $property,
-useMetaData => 1,
-extendedProperties => {
push(@{$definition}, {
tableName=>'WSClient',
className=>'WebGUI::Asset::Wobject::WSClient',
properties=>{
callMethod => {
fieldType => 'textarea',
defaultValue=>undef
},
debugMode => {
fieldType => 'integer',
@ -79,9 +69,11 @@ sub new {
},
paginateAfter => {
defaultValue => 100,
fieldType=>"integer"
},
paginateVar => {
fieldType => 'text',
defaultValue=>undef
},
params => {
fieldType => 'textarea',
@ -104,6 +96,7 @@ sub new {
},
httpHeader => {
fieldType => $httpHeaderFieldType,
defaultValue=>undef
},
cacheTTL => {
fieldType => 'integer',
@ -113,135 +106,141 @@ sub new {
fieldType => 'integer',
defaultValue => '0',
}
}
);
bless $self, $class;
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
sub uiLevel {
sub getIcon {
my $self = shift;
my $small = shift;
return $session{config}{extrasURL}.'/assets/small/web_services.gif' if ($small);
return $session{config}{extrasURL}.'/assets/web_services.gif';
}
#-------------------------------------------------------------------
sub getName {
return WebGUI::International::get(1, "WSClient");
}
#-------------------------------------------------------------------
sub getUiLevel {
return 9;
}
#-------------------------------------------------------------------
sub www_edit {
my $layout = WebGUI::HTMLForm->new;
my $privileges = WebGUI::HTMLForm->new;
my $properties = WebGUI::HTMLForm->new;
# "Layout" tab
$layout->template(
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->getTab("display")->template(
-name => 'templateId',
-value => $_[0]->getValue('templateId'),
-namespace => $_[0]->get('namespace'),
-value => $self->getValue('templateId'),
-namespace => "WSClient",
);
$layout->yesNo (
$tabform->getTab("display")->yesNo (
-name => 'preprocessMacros',
-label => WebGUI::International::get(8, $_[0]->get('namespace')),
-value => $_[0]->get('preprocessMacros'),
-label => WebGUI::International::get(8, "WSClient"),
-value => $self->get('preprocessMacros'),
);
$layout->integer(
$tabform->getTab("display")->integer(
-name => 'paginateAfter',
-label => WebGUI::International::get(13, $_[0]->get('namespace')),
-value => $_[0]->getValue("paginateAfter")
-label => WebGUI::International::get(13, "WSClient"),
-value => $self->getValue("paginateAfter")
);
$layout->text (
$tabform->getTab("display")->text (
-name => 'paginateVar',
-label => WebGUI::International::get(14, $_[0]->get('namespace')),
-value => $_[0]->get('paginateVar'),
-label => WebGUI::International::get(14, "WSClient"),
-value => $self->get('paginateVar'),
);
# "Properties" tab
$properties->text (
$tabform->getTab("properties")->text (
-name => 'uri',
-label => WebGUI::International::get(2, $_[0]->get('namespace')),
-value => $_[0]->get('uri'),
-label => WebGUI::International::get(2, "WSClient"),
-value => $self->get('uri'),
);
$properties->text (
$tabform->getTab("properties")->text (
-name => 'proxy',
-label => WebGUI::International::get(3, $_[0]->get('namespace')),
-value => $_[0]->get('proxy'),
-label => WebGUI::International::get(3, "WSClient"),
-value => $self->get('proxy'),
);
$properties->text (
$tabform->getTab("properties")->text (
-name => 'callMethod',
-label => WebGUI::International::get(4, $_[0]->get('namespace')),
-value => $_[0]->get('callMethod'),
-label => WebGUI::International::get(4, "WSClient"),
-value => $self->get('callMethod'),
);
$properties->textarea (
$tabform->getTab("properties")->textarea (
-name => 'params',
-label => WebGUI::International::get(5, $_[0]->get('namespace')),
-value => $_[0]->get('params'),
-label => WebGUI::International::get(5, "WSClient"),
-value => $self->get('params'),
);
if ($session{'config'}{'soapHttpHeaderOverride'}) {
$properties->text (
$tabform->getTab("properties")->text (
-name => 'httpHeader',
-label => WebGUI::International::get(16, $_[0]->get('namespace')),
-value => $_[0]->get('httpHeader'),
-label => WebGUI::International::get(16, "WSClient"),
-value => $self->get('httpHeader'),
);
} else {
$properties->hidden (
$tabform->getTab("properties")->hidden (
-name => 'httpHeader',
-label => WebGUI::International::get(16, $_[0]->get('namespace')),
-value => $_[0]->get('httpHeader'),
-label => WebGUI::International::get(16, "WSClient"),
-value => $self->get('httpHeader'),
);
}
$properties->yesNo (
$tabform->getTab("properties")->yesNo (
-name => 'execute_by_default',
-label => WebGUI::International::get(11, $_[0]->get('namespace')),
-value => $_[0]->get('execute_by_default'),
-label => WebGUI::International::get(11, "WSClient"),
-value => $self->get('execute_by_default'),
);
$properties->yesNo (
$tabform->getTab("properties")->yesNo (
-name => 'debugMode',
-label => WebGUI::International::get(9, $_[0]->get('namespace')),
-value => $_[0]->get('debugMode'),
-label => WebGUI::International::get(9, "WSClient"),
-value => $self->get('debugMode'),
);
if ($utf8FieldType eq 'yesNo') {
$properties->yesNo (
$tabform->getTab("properties")->yesNo (
-name => 'decodeUtf8',
-label => WebGUI::International::get(15, $_[0]->get('namespace')),
-value => $_[0]->get('decodeUtf8'),
-label => WebGUI::International::get(15, "WSClient"),
-value => $self->get('decodeUtf8'),
);
} else {
$properties->hidden (
$tabform->getTab("properties")->hidden (
-name => 'decodeUtf8',
-label => WebGUI::International::get(15, $_[0]->get('namespace')),
-value => $_[0]->get('decodeUtf8'),
-label => WebGUI::International::get(15, "WSClient"),
-value => $self->get('decodeUtf8'),
);
}
my $cacheopts = {
0 => WebGUI::International::get(29, $_[0]->get('namespace')),
1 => WebGUI::International::get(19, $_[0]->get('namespace')),
0 => WebGUI::International::get(29, "WSClient"),
1 => WebGUI::International::get(19, "WSClient"),
};
$properties->radioList (
$tabform->getTab("properties")->radioList (
-name => 'sharedCache',
-options => $cacheopts,
-label => WebGUI::International::get(28, $_[0]->get('namespace')),
-value => $_[0]->get('sharedCache'),
-label => WebGUI::International::get(28, "WSClient"),
-value => $self->get('sharedCache'),
);
$properties->text (
$tabform->getTab("properties")->text (
-name => 'cacheTTL',
-label => WebGUI::International::get(27, $_[0]->get('namespace')),
-value => $_[0]->get('cacheTTL'),
);
return $_[0]->SUPER::www_edit (
-layout => $layout->printRowsOnly,
-privileges => $privileges->printRowsOnly,
-properties => $properties->printRowsOnly,
-headingId => 20,
-helpId => "web services client add/edit",
-label => WebGUI::International::get(27, "WSClient"),
-value => $self->get('cacheTTL'),
);
return $tabform;
}
#-------------------------------------------------------------------
sub www_view {
sub www_edit {
my $self = shift;
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
$self->getAdminConsole->setHelp("web services client add/edit");
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("20","WSClient"));
}
#-------------------------------------------------------------------
sub view {
my ( $arr_ref, # temp var holding params
$cache_key, # unique cache identifier
$cache, # cache object
@ -256,9 +255,8 @@ sub www_view {
%var # HTML::Template variables
);
my $self= shift;
$self->logView() if ($session{setting}{passiveProfilingEnabled});
# this page, with important params
$url = WebGUI::URL::page("func=view&wid=" . $self->get("wobjectId"));
$url = $self->getUrl("func=view");
# snag our SOAP call and preprocess if needed
if ($self->get('preprocessMacros')) {
@ -277,7 +275,7 @@ sub www_view {
WebGUI::ErrorHandler::warn("disabling soap call $call");
$var{'disableWobject'} = 1;
return $self->processTemplate($self->get("templateId"),\%var);
return $self->processTemplate(\%var,"WSClient",$self->get("templateId"));
}
# advanced use, if you want to pass SOAP results to a single, particular
@ -296,7 +294,7 @@ sub www_view {
WebGUI::ErrorHandler::warn(($self->get('sharedCache')?'shared':'session')
. " cache_key=$cache_key md5_hex($call, $param_str)");
$cache = WebGUI::Cache->new($cache_key,
WebGUI::International::get(4, $self->get('namespace')));
WebGUI::International::get(4, "WSClient"));
# passing a form param WSClient_skipCache lets us ignore even good caches
if (!$session{'form'}{'WSClient_skipCache'}) {
@ -311,8 +309,7 @@ sub www_view {
# the solution is to normalize all params to another table
eval "\$arr_ref = [$param_str];";
eval { @params = @$arr_ref; };
WebGUI::ErrorHandler::warn(WebGUI::International::get(22,
$self->get('namespace'))) if $@ && $self->get('debugMode');
WebGUI::ErrorHandler::warn(WebGUI::International::get(22, "WSClient")) if $@ && $self->get('debugMode');
if ($self->get('execute_by_default') || grep /^$call$/,
@targetWobjects) {
@ -326,8 +323,7 @@ sub www_view {
$soap = $self->_instantiate_soap;
} else {
WebGUI::ErrorHandler::warn(WebGUI::International::get(23,
$self->get('namespace'))) if $self->get('debugMode');
WebGUI::ErrorHandler::warn(WebGUI::International::get(23, "WSClient")) if $self->get('debugMode');
}
}
}
@ -349,10 +345,7 @@ sub www_view {
# a hash reference, a blessed object or a simple scalar. Each type
# requires different handling (woohoo!) before being passed to the
# template system
WebGUI::ErrorHandler::warn(WebGUI::International::get(24,
$self->get('namespace')) .
(ref $return ? ref $return : 'scalar'))
if $self->get('debugMode');
WebGUI::ErrorHandler::warn(WebGUI::International::get(24, "WSClient") . (ref $return ? ref $return : 'scalar')) if $self->get('debugMode');
# SOAP object
if ((ref $return) =~ /SOAP/i) {
@ -387,8 +380,7 @@ sub www_view {
if ($@) {
WebGUI::ErrorHandler::warn($@) if $self->get('debugMode');
$var{'soapError'} = $@;
WebGUI::ErrorHandler::warn(WebGUI::International::get(25,
$self->get('namespace')) . $var{'soapError'})
WebGUI::ErrorHandler::warn(WebGUI::International::get(25, "WSClient") . $var{'soapError'})
if $self->get('debugMode');
}
@ -471,8 +463,7 @@ sub www_view {
} else {
WebGUI::ErrorHandler::warn(WebGUI::International::get(26,
$self->get('namespace')) . $@) if $self->get('debugMode');
WebGUI::ErrorHandler::warn(WebGUI::International::get(26, "WSClient") . $@) if $self->get('debugMode');
}
# did they request a funky http header?
@ -493,7 +484,7 @@ sub www_view {
}
$var{'results'} = \@result;
return $self->processTemplate($self->get("templateId"),\%var);
return $self->processTemplate(\%var, "WSClient",$self->get("templateId"));
}

View file

@ -231,7 +231,7 @@ sub fieldType {
#-------------------------------------------------------------------
=head2 filter ( name )
=head2 filterContent ( name )
Returns a scalar filter type. Defaults to "most".
@ -241,7 +241,7 @@ The name of the form variable to retrieve.
=cut
sub filter {
sub filterContent {
return ($session{form}{$_[0]} || "most");
}

View file

@ -1,52 +0,0 @@
package WebGUI::Help::FileManager;
our $HELP = {
'file manager add/edit' => {
title => '61',
body => '71',
related => [
{
tag => 'file manager template',
namespace => 'FileManager'
},
{
tag => 'file add/edit',
namespace => 'FileManager'
},
{
tag => 'wobjects using',
namespace => 'WebGUI'
}
]
},
'file add/edit' => {
title => '72',
body => '73',
related => [
{
tag => 'file manager add/edit',
namespace => 'FileManager'
}
]
},
'file manager template' => {
title => '75',
body => '76',
related => [
{
tag => 'file manager add/edit',
namespace => 'FileManager'
},
{
tag => 'pagination template variables',
namespace => 'WebGUI'
},
{
tag => 'wobject template',
namespace => 'WebGUI'
}
]
},
};
1;

View file

@ -1,34 +0,0 @@
package WebGUI::Help::SiteMap;
our $HELP = {
'site map add/edit' => {
title => '61',
body => '71',
related => [
{
tag => 'site map template',
namespace => 'SiteMap'
},
{
tag => 'wobjects using',
namespace => 'WebGUI'
}
]
},
'site map template' => {
title => '72',
body => '73',
related => [
{
tag => 'site map add/edit',
namespace => 'SiteMap'
},
{
tag => 'wobject template',
namespace => 'WebGUI'
}
]
},
};
1;

View file

@ -96,6 +96,29 @@ sub _addError {
}
#-------------------------------------------------------------------
=head2 _makePath ( )
Creates the filesystem folders for a storage location.
NOTE: This is a private method and should never be called except internally to this package.
=cut
sub _makePath {
my $self = shift;
my $node = $session{config}{uploadsPath};
foreach my $folder ($self->{_part1}, $self->{_part2}, $self->{_id}) {
$node .= $session{os}{slash}.$folder;
unless (-e $node) { # check to see if it already exists
unless (mkdir($node)) { # check to see if there was an error during creation
$self->_addError("Couldn't create storage location: $node : $!");
}
}
}
}
#-------------------------------------------------------------------
=head2 addFileFromFilesystem( pathToFile )
@ -292,15 +315,7 @@ sub create {
my $class = shift;
my $id = WebGUI::Id::generate();
my $self = $class->get($id);
my $node = $session{config}{uploadsPath};
foreach my $folder ($self->{_part1}, $self->{_part2}, $id) {
$node .= $session{os}{slash}.$folder;
unless (-e $node) { # check to see if it already exists
unless (mkdir($node)) { # check to see if there was an error during creation
$self->_addError("Couldn't create storage location: $node : $!");
}
}
}
$self->_makePath;
return $self;
}
@ -353,7 +368,10 @@ sub get {
my $class = shift;
my $id = shift;
$id =~ m/^(.{2})(.{2})/;
bless {_id => $id, _part1 => $1, _part2 => $2}, ref($class)||$class;
my $self = {_id => $id, _part1 => $1, _part2 => $2};
bless $self, ref($class)||$class;
$self->_makePath unless (-e $self->getPath); # create the folder in case it got deleted somehow
return $self;
}
#-------------------------------------------------------------------

View file

@ -1,410 +0,0 @@
package WebGUI::Wobject::FileManager;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::DateTime;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::Id;
use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Search;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Utility;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub _sortByColumn {
if ($session{scratch}{$_[0]->get("namespace").".".$_[0]->get("wobjectId").".sortDirection"} eq "asc") {
return WebGUI::URL::append($_[2],'sort='.$_[1]."&sortDirection=desc");
} else {
return WebGUI::URL::append($_[2],'sort='.$_[1]."&sortDirection=asc");
}
}
#-------------------------------------------------------------------
sub duplicate {
my ($file, $w, %row, $sth, $newDownloadId);
tie %row, 'Tie::CPHash';
$w = $_[0]->SUPER::duplicate($_[1]);
$sth = WebGUI::SQL->read("select * from FileManager_file where wobjectId=".quote($_[0]->get("wobjectId")));
while (%row = $sth->hash) {
$newDownloadId = WebGUI::Id::generate();
$file = WebGUI::Attachment->new($row{downloadFile},$_[0]->get("wobjectId"),$row{FileManager_fileId});
$file->copy($w,$newDownloadId);
$file = WebGUI::Attachment->new($row{alternateVersion1},$_[0]->get("wobjectId"),$row{FileManager_fileId});
$file->copy($w,$newDownloadId);
$file = WebGUI::Attachment->new($row{alternateVersion2},$_[0]->get("wobjectId"),$row{FileManager_fileId});
$file->copy($w,$newDownloadId);
WebGUI::SQL->write("insert into FileManager_file values (".quote($newDownloadId).", ".quote($w).", ".
quote($row{fileTitle}).", ".quote($row{downloadFile}).", ".quote($row{groupToView}).", ".
quote($row{briefSynopsis}).", $row{dateUploaded}, $row{sequenceNumber}, ".
quote($row{alternateVersion1}).", ".quote($row{alternateVersion2}).")");
}
$sth->finish;
}
#-------------------------------------------------------------------
sub getIndexerParams {
my $self = shift;
my $now = shift;
return {
FileManager_file => {
sql => "select FileManager_file.wobjectId as wid,
FileManager_file.fileTitle as fileTitle,
FileManager_file.downloadFile as downloadFile,
FileManager_file.briefSynopsis as briefSynopsis,
FileManager_file.alternateVersion1 as alternateVersion1,
FileManager_file.alternateVersion2 as alternateVersion2,
FileManager_file.FileManager_fileId as fid,
wobject.addedBy as ownerId,
wobject.namespace as namespace,
page.urlizedTitle as urlizedTitle,
page.languageId as languageId,
page.pageId as pageId,
page.groupIdView as page_groupIdView,
wobject.groupIdView as wobject_groupIdView,
FileManager_file.groupToView as wobject_special_groupIdView
from FileManager_file, wobject, page
where FileManager_file.wobjectId = wobject.wobjectId
and wobject.pageId = page.pageId
and wobject.startDate < $now
and wobject.endDate > $now
and page.startDate < $now
and page.endDate > $now",
fieldsToIndex => ["fileTitle", "downloadFile", "briefSynopsis", "alternateVersion1", "alternateVersion2"],
contentType => 'wobjectDetail',
url => '$data{urlizedTitle}."#".$data{wid}',
headerShortcut => 'select fileTitle from FileManager_file where FileManager_fileId = \'$data{fid}\'',
bodyShortcut => 'select briefSynopsis from FileManager_file where FileManager_fileId = \'$data{fid}\'',
}
};
}
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(1,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{
paginateAfter=>{
defaultValue=>50,
}
},
-useTemplate=>1,
-useMetaData=>1
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from FileManager_file where wobjectId=".quote($_[0]->get("wobjectId")));
$_[0]->SUPER::purge();
}
#-------------------------------------------------------------------
sub uiLevel {
return 4;
}
#-------------------------------------------------------------------
sub www_deleteFile {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
$_[0]->setCollateral("FileManager_file","FileManager_fileId",
{$session{form}{file}=>'',FileManager_fileId=>$session{form}{did}},0,0);
return $_[0]->www_editDownload();
}
#-------------------------------------------------------------------
sub www_deleteDownloadConfirm {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
my ($output, $file);
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
$file->deleteNode;
$_[0]->deleteCollateral("FileManager_file","FileManager_fileId",$session{form}{did});
$_[0]->reorderCollateral("FileManager_file","FileManager_fileId");
return "";
}
#-------------------------------------------------------------------
sub www_download {
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
my (%download, $file);
tie %download,'Tie::CPHash';
%download = WebGUI::SQL->quickHash("select * from FileManager_file where FileManager_fileId=".quote($session{form}{did}));
if (WebGUI::Grouping::isInGroup($download{groupToView})) {
if ($session{form}{alternateVersion} == 1) {
$file = WebGUI::Attachment->new($download{alternateVersion1},
$session{form}{wid},
$session{form}{did});
} elsif ($session{form}{alternateVersion} == 2) {
$file = WebGUI::Attachment->new($download{alternateVersion2},
$session{form}{wid},
$session{form}{did});
} else {
$file = WebGUI::Attachment->new($download{downloadFile},
$session{form}{wid},
$session{form}{did});
}
WebGUI::HTTP::setRedirect($file->getURL);
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my $properties = WebGUI::HTMLForm->new;
my $layout = WebGUI::HTMLForm->new;
$layout->integer(
-name=>"paginateAfter",
-label=>WebGUI::International::get(20,$_[0]->get("namespace")),
-value=>$_[0]->getValue("paginateAfter")
);
if ($_[0]->get("wobjectId") eq "new") {
$properties->whatNext(
-options=>{
addFile=>WebGUI::International::get(74,$_[0]->get("namespace")),
backToPage=>WebGUI::International::get(745)
},
-value=>"addFile"
);
}
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-layout=>$layout->printRowsOnly,
-headingId=>9,
-helpId=>"file manager add/edit"
);
}
#-------------------------------------------------------------------
sub www_editSave {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
$_[0]->SUPER::www_editSave();
if ($session{form}{proceed} eq "addFile") {
$session{form}{did} = "new";
return $_[0]->www_editDownload();
} else {
return "";
}
}
#-------------------------------------------------------------------
sub www_editDownload {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
$session{page}{useAdminStyle} = 1;
my ($output, $file, $f);
$file = $_[0]->getCollateral("FileManager_file","FileManager_fileId",$session{form}{did});
$output .= helpIcon("file add/edit",$_[0]->get("namespace"));
$output .= '<h1>'.WebGUI::International::get(10,$_[0]->get("namespace")).'</h1>';
$f = WebGUI::HTMLForm->new;
$f->hidden("wid",$_[0]->get("wobjectId"));
$f->hidden("did",$file->{FileManager_fileId});
$f->hidden("func","editDownloadSave");
$f->text("fileTitle",WebGUI::International::get(5,$_[0]->get("namespace")),$file->{fileTitle});
if ($file->{downloadFile} ne "") {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteFile&file=downloadFile&wid='.
$_[0]->get("wobjectId").'&did='.$file->{FileManager_fileId}).'">'.WebGUI::International::get(391).
'</a>',WebGUI::International::get(6,$_[0]->get("namespace")));
} else {
$f->file("downloadFile",WebGUI::International::get(6,$_[0]->get("namespace")));
}
if ($file->{alternateVersion1} ne "") {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteFile&file=alternateVersion1&wid='.
$_[0]->get("wobjectId").'&did='.$file->{FileManager_fileId}).'">'.
WebGUI::International::get(391).'</a>',WebGUI::International::get(17,$_[0]->get("namespace")));
} else {
$f->file("alternateVersion1",WebGUI::International::get(17,$_[0]->get("namespace")));
}
if ($file->{alternateVersion2} ne "") {
$f->readOnly('<a href="'.WebGUI::URL::page('func=deleteFile&file=alternateVersion2&wid='.
$_[0]->get("wobjectId").'&did='.$file->{FileManager_fileId}).'">'.
WebGUI::International::get(391).'</a>',WebGUI::International::get(18,$_[0]->get("namespace")));
} else {
$f->file("alternateVersion2",WebGUI::International::get(18,$_[0]->get("namespace")));
}
$f->text("briefSynopsis",WebGUI::International::get(8,$_[0]->get("namespace")),$file->{briefSynopsis});
$f->group("groupToView",WebGUI::International::get(7,$_[0]->get("namespace")),[$file->{groupToView}]);
if ($file->{FileManager_fileId} eq "new") {
$f->whatNext(
-options=>{
addFile=>WebGUI::International::get(74,$_[0]->get("namespace")),
backToPage=>WebGUI::International::get(745)
},
-value=>"backToPage"
);
}
$f->submit;
$output .= $f->print;
return $output;
}
#-------------------------------------------------------------------
sub www_editDownloadSave {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
my ($file, %files);
$files{FileManager_fileId} = $_[0]->setCollateral("FileManager_file", "FileManager_fileId", {
FileManager_fileId => $session{form}{did},
fileTitle => $session{form}{fileTitle},
briefSynopsis => $session{form}{briefSynopsis},
dateUploaded => time(),
groupToView => $session{form}{groupToView}
});
$_[0]->reorderCollateral("FileManager_file","FileManager_fileId");
$file = WebGUI::Attachment->new("",$_[0]->get("wobjectId"),$files{FileManager_fileId});
$file->save("downloadFile");
if ($file->getFilename ne "") {
$files{downloadFile} = $file->getFilename;
$files{fileTitle} = $files{downloadFile} if ($session{form}{fileTitle} eq "");
}
$file = WebGUI::Attachment->new("",$_[0]->get("wobjectId"),$files{FileManager_fileId});
$file->save("alternateVersion1");
if ($file->getFilename ne "") {
$files{alternateVersion1} = $file->getFilename;
}
$file = WebGUI::Attachment->new("",$_[0]->get("wobjectId"),$files{FileManager_fileId});
$file->save("alternateVersion2");
if ($file->getFilename ne "") {
$files{alternateVersion2} = $file->getFilename;
}
$_[0]->setCollateral("FileManager_file", "FileManager_fileId", \%files);
if ($session{form}{proceed} eq "addFile") {
$session{form}{did} = "new";
return $_[0]->www_editDownload();
} else {
return "";
}
}
#-------------------------------------------------------------------
sub www_moveDownloadDown {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
WebGUI::Session::setScratch($_[0]->get("namespace").".".$_[0]->get("wobjectId").".sortDirection","-delete-");
WebGUI::Session::setScratch($_[0]->get("namespace").".".$_[0]->get("wobjectId").".sort","-delete-");
$_[0]->moveCollateralUp("FileManager_file","FileManager_fileId",$session{form}{did});
return "";
}
#-------------------------------------------------------------------
sub www_moveDownloadUp {
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
WebGUI::Session::setScratch($_[0]->get("namespace").".".$_[0]->get("wobjectId").".sortDirection","-delete-");
WebGUI::Session::setScratch($_[0]->get("namespace").".".$_[0]->get("wobjectId").".sort","-delete-");
$_[0]->moveCollateralDown("FileManager_file","FileManager_fileId",$session{form}{did});
return "";
}
#-------------------------------------------------------------------
sub www_view {
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
my ($sortDirection, %var, @fileloop, $files, $sort, $file, $p, $file1, $file2, $file3, $constraints,
$url, $numResults, $sql, $flag);
$url = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId"));
WebGUI::Session::setScratch($_[0]->get("namespace").".".$_[0]->get("wobjectId").".sortDirection",$session{form}{sortDirection});
WebGUI::Session::setScratch($_[0]->get("namespace").".".$_[0]->get("wobjectId").".sort",$session{form}{sort});
$numResults = $_[0]->get("paginateAfter") || 25;
$var{"titleColumn.label"} = WebGUI::International::get(14,$_[0]->get("namespace"));
$var{"titleColumn.url"} = $_[0]->_sortByColumn("fileTitle",$url);
$var{"descriptionColumn.label"} = WebGUI::International::get(15,$_[0]->get("namespace"));
$var{"descriptionColumn.url"} = $_[0]->_sortByColumn("briefSynopsis",$url);
$var{"dateColumn.label"} = WebGUI::International::get(16,$_[0]->get("namespace"));
$var{"dateColumn.url"} = $_[0]->_sortByColumn("dateUploaded",$url);
$session{form}{sort} = "sequenceNumber" if ($session{form}{sort} eq "");
$var{"search.form"} = WebGUI::Search::form({wid=>$_[0]->get("wobjectId"),func=>"view"});
$var{"search.url"} = WebGUI::Search::toggleURL("wid=".$_[0]->get("wobjectId")."&func=view");
$var{"search.label"} = WebGUI::International::get(364);
$var{"addfile.url"} = WebGUI::URL::page('func=editDownload&did=new&wid='.$_[0]->get("wobjectId"));
$var{"addfile.label"} = WebGUI::International::get(11,$_[0]->get("namespace"));
$sql = "select * from FileManager_file where wobjectId=".quote($_[0]->get("wobjectId"))." ";
if ($session{scratch}{search}) {
$numResults = $session{scratch}{numResults};
$constraints = WebGUI::Search::buildConstraints(
[qw(fileTitle downloadFile alternateVersion1 alternateVersion2 briefSynopsis)]);
$sql .= " and ".$constraints if ($constraints ne "");
}
$sort = $session{scratch}{$_[0]->get("namespace").".".$_[0]->get("wobjectId").".sort"} || "sequenceNumber";
$sortDirection = $session{scratch}{$_[0]->get("namespace").".".$_[0]->get("wobjectId").".sortDirection"} || "desc";
$sql .= " order by $sort $sortDirection";
$p = WebGUI::Paginator->new($url,$numResults);
$p->setDataByQuery($sql);
$files = $p->getPageData;
my $canEditWobject = ($_[0]->canEdit);
foreach $file (@$files) {
$file1 = WebGUI::Attachment->new($file->{downloadFile},$_[0]->get("wobjectId"),$file->{FileManager_fileId});
$file2 = WebGUI::Attachment->new($file->{alternateVersion1},$_[0]->get("wobjectId"),$file->{FileManager_fileId});
$file3 = WebGUI::Attachment->new($file->{alternateVersion2},$_[0]->get("wobjectId"),$file->{FileManager_fileId});
push (@fileloop,{
"file.canView"=>(WebGUI::Grouping::isInGroup($file->{groupToView}) || $canEditWobject),
"file.controls"=>deleteIcon('func=deleteDownloadConfirm&wid='.$_[0]->get("wobjectId")
.'&did='.$file->{FileManager_fileId},'',WebGUI::International::get(12,$_[0]->get("namespace"))).editIcon('func=editDownload&wid='.$_[0]->get("wobjectId")
.'&did='.$file->{FileManager_fileId}).moveUpIcon('func=moveDownloadUp&wid='
.$_[0]->get("wobjectId")
.'&did='.$file->{FileManager_fileId}).moveDownIcon('func=moveDownloadDown&wid='
.$_[0]->get("wobjectId").'&did='.$file->{FileManager_fileId}),
"file.title"=>$file->{fileTitle},
"file.version1.name"=>$file1->getFilename,
"file.version1.url"=>$file1->getURL,
"file.version1.icon"=>$file1->getIcon,
"file.version1.size"=>$file1->getSize,
"file.version1.type"=>$file1->getType,
"file.version1.thumbnail"=>$file1->getThumbnail,
"file.version1.isImage"=>$file1->isImage,
"file.version2.name"=>$file2->getFilename,
"file.version2.url"=>$file2->getURL,
"file.version2.icon"=>$file2->getIcon,
"file.version2.size"=>$file2->getSize,
"file.version2.type"=>$file2->getType,
"file.version2.thumbnail"=>$file2->getThumbnail,
"file.version2.isImage"=>$file2->isImage,
"file.version3.name"=>$file3->getFilename,
"file.version3.url"=>$file3->getURL,
"file.version3.icon"=>$file3->getIcon,
"file.version3.size"=>$file3->getSize,
"file.version3.type"=>$file3->getType,
"file.version3.thumbnail"=>$file3->getThumbnail,
"file.version3.isImage"=>$file3->isImage,
"file.description"=>$file->{briefSynopsis},
"file.date"=>epochToHuman($file->{dateUploaded},"%z"),
"file.time"=>epochToHuman($file->{dateUploaded},"%Z")
});
$flag = 1;
}
$var{"noresults.message"} = WebGUI::International::get(19,$_[0]->get("namespace"));
$var{noresults} = !$flag;
$var{file_loop} = \@fileloop;
$p->appendTemplateVars(\%var);
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
1;

View file

@ -1,145 +0,0 @@
package WebGUI::Wobject::SiteMap;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Page;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub _traversePageTree {
my ($parent, $sth, $data, $indent, @pages, $i, $currentDepth, $depth, $indentString, $alphabetic, $orderBy);
$parent = $_[0];
$currentDepth = $_[1];
$depth = $_[2] || 99;
$indent = $_[3];
$alphabetic = $_[4];
$indentString = "&nbsp;" x ($indent*$currentDepth);
if ($currentDepth < $depth) {
if ($alphabetic) {
$orderBy = 'title';
} else {
$orderBy = 'nestedSetLeft';
}
$sth = WebGUI::SQL->read("select urlizedTitle, menuTitle, title, pageId, synopsis, isSystem from page where parentId=".quote($parent)." and hideFromNavigation = 0 order by $orderBy");
while ($data = $sth->hashRef) {
if (!$data->{isSystem} && WebGUI::Page::canView($data->{pageId})) {
push(@pages,{
"page.indent" => $indentString,
"page.url" => WebGUI::URL::gateway($data->{urlizedTitle}),
"page.id" => $data->{pageId},
"page.title" => $data->{title},
"page.menuTitle" => $data->{menuTitle},
"page.synopsis" => $data->{synopsis},
"page.isRoot" => ($parent eq "0"),
"page.isTop" => ($currentDepth == 0 || ($currentDepth == 1 && $parent eq "0"))
});
push(@pages,@{_traversePageTree($data->{pageId},($currentDepth+1),$depth,$indent,$alphabetic)});
}
}
$sth->finish;
}
return \@pages;
}
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(2,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{
startAtThisLevel=>{
defaultValue=>1
},
indent=>{
defaultValue=>5
},
depth=>{
defaultValue=>0
},
alphabetic=>{
defaultValue=>0
}
},
-useTemplate=>1,
-useMetaData=>1
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub www_edit {
my $options = WebGUI::SQL->buildHashRef("select pageId,title from page where parentId='0'
and (pageId='1' or pageId>'999') order by title");
my $layout = WebGUI::HTMLForm->new;
my $properties = WebGUI::HTMLForm->new;
$properties->select(
-name=>"startAtThisLevel",
-label=>WebGUI::International::get(3,$_[0]->get("namespace")),
-value=>[$_[0]->getValue("startAtThisLevel")],
-options=>{
0=>WebGUI::International::get(75,$_[0]->get("namespace")),
$session{page}{pageId}=>WebGUI::International::get(74,$_[0]->get("namespace")),
%{$options}
}
);
$layout->integer(
-name=>"depth",
-label=>WebGUI::International::get(4,$_[0]->get("namespace")),
-value=>$_[0]->getValue("depth")
);
$layout->integer(
-name=>"indent",
-label=>WebGUI::International::get(6,$_[0]->get("namespace")),
-value=>$_[0]->getValue("indent")
);
$layout->yesNo(
-name=>"alphabetic",
-label=>WebGUI::International::get(7,$_[0]->get("namespace")),
-value=>$_[0]->getValue("alphabetic")
);
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-layout=>$layout->printRowsOnly,
-headingId=>5,
-helpId=>"site map add/edit"
);
}
#-------------------------------------------------------------------
sub www_view {
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
my (%var);
$var{page_loop} = _traversePageTree($_[0]->get("startAtThisLevel"),0,$_[0]->get("depth"),$_[0]->get("indent"),$_[0]->get("alphabetic"));
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
1;

View file

@ -1,312 +0,0 @@
package WebGUI::i18n::English::FileManager;
our $I18N = {
'11' => {
message => q|Add a new file.|,
lastUpdated => 1038882956
},
'71' => {
message => q|The File Manager is designed to help you manage file distribution on your site. It allows you to specify who may view/download files from your site. Viewing
access is set by privileges on the page. Download privileges are set on
a per file basis.
<p>
<b>What next?</b><br>
This field is available only when you create a File Manager. After hitting the
Save button, you may either start loading files into the manager or go back to
the page with the File Manager on it.
<p>
<b>Template</b><br/>
Choose a layout for the file manager.
<p/>
<b>Paginate After</b><br>
How many files should be displayed before splitting the results into separate pages? In other words, how many files should be displayed per page?
<p>
|,
lastUpdated => 1099611680
},
'7' => {
message => q|Group to Download|,
lastUpdated => 1031514049
},
'17' => {
message => q|Alternate Version #1|,
lastUpdated => 1031514049
},
'1' => {
message => q|File Manager|,
lastUpdated => 1038028463
},
'18' => {
message => q|Alternate Version #2|,
lastUpdated => 1031514049
},
'72' => {
message => q|File, Add/Edit|,
lastUpdated => 1038883174
},
'16' => {
message => q|Date Uploaded|,
lastUpdated => 1031514049
},
'74' => {
message => q|Add a new file.|,
lastUpdated => 1038262375
},
'6' => {
message => q|File|,
lastUpdated => 1038882929
},
'75' => {
message => q|File Manager Template|,
lastUpdated => 1038853712
},
'3' => {
message => q|Proceed to add file?|,
lastUpdated => 1031514049
},
'61' => {
message => q|File Manager, Add/Edit|,
lastUpdated => 1038887335
},
'9' => {
message => q|Edit File Manager|,
lastUpdated => 1038028499
},
'12' => {
message => q|Are you certain that you wish to delete this file?|,
lastUpdated => 1038882975
},
'20' => {
message => q|Paginate After|,
lastUpdated => 1031514049
},
'14' => {
message => q|File|,
lastUpdated => 1031514049
},
'15' => {
message => q|Description|,
lastUpdated => 1031514049
},
'8' => {
message => q|Brief Synopsis|,
lastUpdated => 1031514049
},
'73' => {
message => q|<b>File Title</b><br>
The title that will be displayed for this file. If left blank the filename will be used.
<p>
<b>File</b><br>
Choose the file from your hard drive that you wish to upload.
<p>
<b>Alternate Version #1</b><br>
An alternate version of the file. For instance, if the file was a JPEG, perhaps the alternate version would be a TIFF or a BMP.
<p>
<b>Alternate Version #2</b><br>
An alternate version of the file. For instance, if the file was a JPEG, perhaps the alternate version would be a TIFF or a BMP.
<p>
<b>Brief Synopsis</b><br>
A short description of this file. Be sure to include keywords that users may try to search for.
<p>
<b>Group To Download</b><br>
Choose the group that may download this file.
<p>
<b>What next?</b><br>
If you'd like to add another file after this one, then select "Add a new file" otherwise select "Go back to the page".
<p>
|,
lastUpdated => 1099611855
},
'76' => {
message => q|This is the list of template variables available in File Manager templates.
<p/>
<b>titleColumn.label</b><br/>
The translated label for the title.
<p/>
<b>titleColumn.url</b><br/>
The URL to sort the displayed files by their titles.
<p/>
<b>descriptionColumn.label</b><br/>
The translated label for the description.
<p/>
<b>descriptionColumn.url</b><br/>
The URL to sort the displayed files by their descriptions.
<p/>
<b>dateColumn.label</b><br/>
The translated label for the upload date.
<p/>
<b>dateColumn.url</b><br/>
The URL to sort the displayed files by their date uploaded.
<p/>
<b>search.url</b><br/>
The URL to toggle search mode on and off.
<p/>
<b>search.label</b><br/>
The translated label for the search link.
<p/>
<b>addfile.url</b><br/>
The URL to add a file to the file manager.
<p/>
<b>addfile.label</b><br/>
The translated label for the add file link.
<p/>
<b>search.form</b><br/>
WebGUI's power search form.
<p/>
<b>file_loop</b><br/>
A loop containing the information about each file uploaded to this file manager.
<blockquote>
<b>file.canView</b><br/>
A condition as to whether the current user has the privileges to view this file.
<p/>
<b>file.controls</b><br/>
The WebGUI management controls for this file.
<p/>
<b>file.title</b><br/>
The title for this file.
<p/>
<b>file.description</b><br/>
The description of this file.
<p/>
<b>file.date</b><br/>
The last date that any version of this file was uploaded.
<p/>
<b>file.time</b><br/>
The time that this file was uploaded.
<p/>
<p/>
<b>file.version1.name</b><br/>
The filename for the first version of this file.
<p/>
<b>file.version1.url</b><br/>
The download URL for the first version of this file.
<p/>
<b>file.version1.icon</b><br/>
The URL to the icon for the file type of the first version of this file.
<p/>
<b>file.version1.size</b><br/>
The storage size of the first version of this file.
<p/>
<b>file.version1.type</b><br/>
The type (or file extension) of the first version of this file.
<p/>
<b>file.version1.thumbnail</b><br/>
The URL to the thumbnail for the first version of this file.
<p/>
<b>file.version1.isImage</b><br/>
A conditional indicating whether the first version of this file is an image or not.
<p/>
<b>file.version2.name</b><br/>
The filename for the second version of this file.
<p/>
<b>file.version2.url</b><br/>
The download URL for the second version of this file.
<p/>
<b>file.version2.icon</b><br/>
The URL to the icon for the file type of the second version of this file.
<p/>
<b>file.version2.size</b><br/>
The storage size of the second version of this file.
<p/>
<b>file.version2.type</b><br/>
The type (or file extension) of the second version of this file.
<p/>
<b>file.version2.thumbnail</b><br/>
The URL to the thumbnail for the second version of this file.
<p/>
<b>file.version2.isImage</b><br/>
A conditional indicating whether the second version of this file is an image or not.
<p/>
<b>file.version3.name</b><br/>
The filename for the third version of this file.
<p/>
<b>file.version3.url</b><br/>
The download URL for the third version of this file.
<p/>
<b>file.version3.icon</b><br/>
The URL to the icon for the file type of the third version of this file.
<p/>
<b>file.version3.size</b><br/>
The storage size of the third version of this file.
<p/>
<b>file.version3.type</b><br/>
The type (or file extension) of the third version of this file.
<p/>
<b>file.version3.thumbnail</b><br/>
The URL to the thumbnail for the third version of this file.
<p/>
<b>file.version3.isImage</b><br/>
A conditional indicating whether the third version of this file is an image or not.
</blockquote>
<p/>
<b>noresults.message</b><br/>
A translated message stating that this file manager has no files for this user to view.
<p/>
<b>noresults</b><br/>
A conditional indicating whether there are any files for this user to view.
<p/>
|,
lastUpdated => 1099611278
},
'10' => {
message => q|Edit File|,
lastUpdated => 1038882889
},
'19' => {
message => q|You have no files available.|,
lastUpdated => 1038882995
},
'5' => {
message => q|File Title|,
lastUpdated => 1031514049
},
};
1;

View file

@ -1,131 +0,0 @@
package WebGUI::i18n::English::SiteMap;
our $I18N = {
'74' => {
message => q|This Page|,
lastUpdated => 1039908565
},
'6' => {
message => q|Indent|,
lastUpdated => 1031514049
},
'75' => {
message => q|All Roots|,
lastUpdated => 1039908572
},
'71' => {
message => q|Site maps are used to provide additional navigation in WebGUI. You could set up a traditional site map that would display a hierarchical view of all the pages in the site. On the other hand, you could use site maps to provide extra navigation at certain levels in your site.
<br><br>
<b>Template</b><br/>
Choose a layout for this site map.
<p/>
<b>Start With</b><br>
Select the page that this site map should start from.
<br><br>
<b>Depth To Traverse</b><br>
How many levels deep of navigation should the Site Map show? If 0 (zero) is specified, it will show as many levels as there are.
<p>
<b>Indent</b><br>
How many &amp;nbsp;'s should indent each level?
<p>
<b>Alphabetic?</b><br>
If this setting is true, site map entries are sorted alphabetically. If this setting is false, site map entries are sorted by the page sequence order (editable via the up and down arrows in the page toolbar).
<p>
|,
lastUpdated => 1096092248
},
'3' => {
message => q|Start With|,
lastUpdated => 1039908390
},
'7' => {
message => q|Alphabetic?|,
lastUpdated => 1057208065
},
'61' => {
message => q|Site Map, Add/Edit|,
lastUpdated => 1038890147
},
'2' => {
message => q|Site Map|,
lastUpdated => 1031514049
},
'4' => {
message => q|Depth To Traverse|,
lastUpdated => 1031514049
},
'72' => {
message => q|Site Map Template|,
lastUpdated => 1047855100
},
'73' => {
message => q|This is the list of template variables available for site map templates.
<p />
<b>page_loop</b><br />
This loop contains all of the pages in the site map.
<blockquote>
<b>page.indent</b><br />
The indent spacer for this page indicating the depth of the page in the tree,
which by default is 5 &amp;nbsp;'s for each level of depth in the tree.
<p />
<b>page.url</b><br />
The URL to the page.
<p />
<b>page.id</b><br />
The unique identifier for this page that WebGUI uses internally.
<p />
<b>page.title</b><br />
The title of this page.
<p />
<b>page.menutitle</b><br />
The title of this page that appears in navigation.
<p />
<b>page.synopsis</b><br />
The description of the contents of this page (if any).
<p />
<b>page.isRoot</b><br />
A condition indicating whether or not this page is a root.
<p />
<b>page.isTop</b><br />
A condition indicating whether or not this page is at the top of the navigation tree.
<p />
</blockquote>
<p />|,
lastUpdated => 1096092207
},
'5' => {
message => q|Edit Site Map|,
lastUpdated => 1031514049
},
};
1;