merging back with HEAD

This commit is contained in:
Colin Kuskie 2009-02-27 06:06:05 +00:00
parent cd30eb437c
commit f8b11b5423
42 changed files with 1201 additions and 182 deletions

View file

@ -1,10 +1,28 @@
7.6.14
- fixed: IE6 shows Admin Bar over Asset Manager
- fixed #9808: Search i18n
- fixed #9818: deleteAttachedFiles bug (THE REVENGE)
- fixed #9809: Pagination list up to 10/20: not working correctly on last pages.
- fixed #9820: Survey: political party spelled wrong
- fixed #9819: Survey: hoverhelp showing instead of field name
- fixed #9822: Matrix: Wrong field label
- fixed #9823: Matrix: no cancel button in add/edit listing
7.6.13
- fixed AdSpace bug: impressions and clicks for most non-human web clients will not be counted.
- fixed #9760: DataForm not working in demo.plainblack.com
- fixed #9759: Delete Entry Button missing in Data Form
- fixed #9767: FileAsset breaks 'null' rule for FileAsset table
- fixed defaultValues of undef cause mysql5.1 to complain about columns that are set to be NOT NULL. 5.0 doesn't care.
- International text retrieval has been optimized
- fixed #9766: Thingy Pagination Broken
- fixed #9779: Gallery: js for search (datepicker?) included in album view
- fixed #9783: payment methods are not added
- fixed #9785: Delete All button not working in Account/Inbox [TEMPLATE]
- fixed #9803: Survey 2.0- Gradebook spelled wrong
- fixed #9801: Survey 2.0- Template spelled wrong
- fixed #9802: Survey Template field names to be consistent
- fixed: HTMLForm generated forms have an extra double quote in the table tag.
7.6.12
- fixed: During postback on a recurring transaction, the routine could error out instead of catching an error.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -295,7 +295,8 @@ sub upgradeMatrix {
$db->write("alter table Matrix_rating rename MatrixListing_rating");
$db->write("alter table Matrix_ratingSummary rename MatrixListing_ratingSummary");
$db->write("alter table Matrix_field rename Matrix_attribute");
$db->write("alter table Matrix_attribute drop column label");
$db->write("alter table Matrix_attribute drop column name");
$db->write("alter table Matrix_attribute change label name char(255)");
$db->write("alter table Matrix_attribute add column options text");
$db->write("alter table Matrix_attribute change fieldType fieldType char(255) not null default 'MatrixCompare'");
$db->write("alter table Matrix_attribute change fieldId attributeId char(22) not null");

View file

@ -0,0 +1,125 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.6.14';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore
$package->update({ isPackage => 0 });
# Set the default flag for templates added
my $assetIds
= $package->getLineage( ['self','descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
for my $assetId ( @{ $assetIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( !$asset ) {
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
next;
}
$asset->update( { isDefault => 1 } );
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -102,7 +102,8 @@ sub upgradeMatrix {
$db->write("alter table Matrix_rating rename MatrixListing_rating");
$db->write("alter table Matrix_ratingSummary rename MatrixListing_ratingSummary");
$db->write("alter table Matrix_field rename Matrix_attribute");
$db->write("alter table Matrix_attribute drop column label");
$db->write("alter table Matrix_attribute drop column name");
$db->write("alter table Matrix_attribute change label name char(255)");
$db->write("alter table Matrix_attribute add column options text");
$db->write("alter table Matrix_attribute change fieldType fieldType char(255) not null default 'MatrixCompare'");
$db->write("alter table Matrix_attribute change fieldId attributeId char(22) not null");

View file

@ -1,7 +1,7 @@
package WebGUI;
our $VERSION = '7.6.13';
our $VERSION = '7.6.14';
our $STATUS = 'stable';

View file

@ -52,6 +52,7 @@ sub countClick {
my $session = shift;
my $id = shift;
my ($url) = $session->db->quickArray("select url from advertisement where adId=?",[$id]);
return $url if $session->env->requestNotViewed();
$session->db->write("update advertisement set clicks=clicks+1 where adId=?",[$id]);
return $url;
}
@ -131,6 +132,7 @@ A boolean that tells the ad system not to count this impression if true.
sub displayImpression {
my $self = shift;
my $dontCount = shift;
return '' if $self->session->env->requestNotViewed();
my ($id, $ad, $priority, $clicks, $clicksBought, $impressions, $impressionsBought) = $self->session->db->quickArray("select adId, renderedAd, priority, clicks, clicksBought, impressions, impressionsBought from advertisement where adSpaceId=? and isActive=1 order by nextInPriority asc limit 1",[$self->getId]);
unless ($dontCount) {
my $isActive = 1;

View file

@ -262,10 +262,25 @@ sub set {
# prerender the ad for faster display
my $adSpace = WebGUI::AdSpace->new($self->session, $self->get("adSpaceId"));
if ($self->get("type") eq "text") {
$self->{_properties}{renderedAd} = '<div style="position:relative; width:'.($adSpace->get("width")-2).'px; height:'.($adSpace->get("height")-2).'px; margin:0px; overflow:hidden; border:solid '.$self->get("borderColor").' 1px;"><a href="'.$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId).'" style="position:absolute; padding: 3px; top:0px; left:0px; width:100%; height:100%; z-index:10; display:block; text-decoration:none; vertical-align:top; background-color:'.$self->get("backgroundColor").'; font-size: 13px; font-weight: normal;"><b><span style="color:'.$self->get("textColor").';">'.$self->get("title").'</span></b><br /><span style="color:'.$self->get("textColor").';">'.$self->get("adText").'</span></a></div>';
$self->{_properties}{renderedAd} = '<div style="position:relative; width:' . ($adSpace->get("width")-2) . 'px; height:' .
($adSpace->get("height")-2) . 'px; margin:0px; overflow:hidden; border:solid ' . $self->get("borderColor") .
q{ 1px;"><a href='#' OnClick="window.location.assign('} .
$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId) .
q{')" style="position:absolute; padding: 3px; top:0px; left:0px; width:100%; height:100%; z-index:10;} .
' display:block; text-decoration:none; vertical-align:top; background-color:' . $self->get("backgroundColor") .
'; font-size: 13px; font-weight: normal;"><b><span style="color:' . $self->get("textColor") . ';">' .
$self->get("title") . '</span></b><br /><span style="color:' . $self->get("textColor") . ';">' .
$self->get("adText") . '</span></a></div>';
} elsif ($self->get("type") eq "image") {
my $storage = WebGUI::Storage->get($self->session, $self->get("storageId"));
$self->{_properties}{renderedAd} = '<div style="position:relative; width:'.$adSpace->get("width").'px; height:'.$adSpace->get("height").'px; margin:0px; overflow:hidden; border:0px;"><a href="'.$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId).'" style="position:absolute; padding: 3px; top:0px; left:0px; width:100%; height:100%; z-index:10; display:block; text-decoration:none; vertical-align:top;"><img src="'.$storage->getUrl($storage->getFiles->[0]).'" alt="'.$self->get("title").'" style="z-index:0;position:relative;border-style:none;border: 0px;" /></a></div>';
$self->{_properties}{renderedAd} = '<div style="position:relative; width:' . $adSpace->get("width") . 'px; height:' .
$adSpace->get("height") . 'px; margin:0px; overflow:hidden; border:0px;"><a href="#" ' .
q{onClick="window.location.assign('} .
$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId) . q{')" style="position:absolute; padding: } .
'3px; top:0px; left:0px; width:100%; height:100%; z-index:10; display:block; text-decoration:none; ' .
'vertical-align:top;"><img ' .
'src="' . $storage->getUrl($storage->getFiles->[0]) . '" alt="' . $self->get("title") .
'" style="z-index:0;position:relative;border-style:none;border: 0px;" /></a></div>';
} elsif ($self->get("type") eq "rich") {
my $ad = $self->get("richMedia");
WebGUI::Macro::process($self->session, \$ad);

View file

@ -215,17 +215,27 @@ A reference to the current session.
If supplied, provides a list of defaults such as title and icons for the admin console.
=head3 options
A hash reference of options with the following keys
=head4 showAdminBar
If true, will show the admin bar on this admin console page
=cut
sub new {
my $class = shift;
my $session = shift;
my $id = shift;
my $options = shift;
my $self;
$self->{_session} = $session;
bless $self, $class;
$self->{_function} = {};
$self->{_functionId} = $id;
$self->{_options} = $options;
return $self;
}
@ -289,7 +299,17 @@ sub render {
}
$var{"backtosite.url"} = $self->session->url->getBackToSiteURL();
return $self->session->style->process(WebGUI::Asset::Template->new($self->session,$self->session->setting->get("AdminConsoleTemplate"))->process(\%var),"PBtmpl0000000000000137");
my $template
= WebGUI::Asset::Template->new(
$self->session,
$self->session->setting->get("AdminConsoleTemplate")
);
if ( $self->{_options}->{showAdminBar} ) {
$var{adminBar}
= WebGUI::Macro::AdminBar::process($self->session);
}
my $output = $template->process(\%var);
return $self->session->style->process($output,"PBtmpl0000000000000137");
}
#-------------------------------------------------------------------

View file

@ -317,7 +317,15 @@ sub getEditForm {
}
}
$form->submit();
$form->raw(
'<tr><td COLSPAN=2>'.
WebGUI::Form::Button($session, {}).
WebGUI::Form::Button($session, {
-value => $i18n->get('cancel', 'WebGUI'),
-extras => q|onclick="history.go(-1);" class="backwardButton"|
}).
'</td></tr>'
);
return $form;
}
@ -631,53 +639,28 @@ sub view {
@files = @{ $storage->getFiles } if (defined $storage);
$var->{screenshots} = qq|
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="/extras/ukplayer/AC_RunActiveContent.js" language="javascript"></script>
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '400',
'height', '300',
'src', 'swc/assets',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'slideShow',
'bgcolor', '#ffffff',
'name', 'coverflow',
'menu', 'true',
// note: the width & height in the flashVars below MUST match the width & height set above
'flashVars',
'config=?func=getScreenshotsConfig&width=400&height=300&backgroundColor=0xCCCCCC&fontColor=&textBorderColor=&textBackgroundColor=&controlsColor=&controlsBorderColor=&controlsBackgroundColor=',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', '/extras/ukplayer/slideShow',
'salign', ''
); //end AC code
}
<script type="text/javascript" src="/extras/ukplayer/swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myFlashContent","9.0.0","/extras/ukplayer/expressInstall.swf");
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400"
height="300" id="swc/assets" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="flashVars" value="config=?func=getScreenshotsConfig" />
<param name="movie" value="/extras/ukplayer/slideShow.swf" /><param name="quality" value="high" /><param
name="bgcolor" value="#ffffff" /> <embed src="/extras/ukplayer/slideShow.swf" quality="high" bgcolor="#ffffff"
width="400" height="300" name="swc/assets" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false"
flashvars="config=?func=getScreenshotsConfig" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="myFlashContent">
<param name="movie" value="/extras/ukplayer/slideShow.swf" />
<param name="flashvars" value="config=?func=getScreenshotsConfig" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/extras/ukplayer/slideShow.swf" width="400"
height="300">
<param name="flashvars" value="config=?func=getScreenshotsConfig" />
<!--<![endif]-->
<a href="http:/www.adobe.com/go/getflashplayer">
<img src="http:/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe
Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</noscript>
</div>
|;
}

View file

@ -484,9 +484,7 @@ sub deleteAttachedFiles {
my $form = $self->_createForm($fieldConfig->{$field}, $entryData->{$field});
if ($form->can('getStorageLocation')) {
my $storage = $form->getStorageLocation;
if ($storage) {
$storage->delete;
}
$storage->delete if $storage;
}
}
}
@ -498,7 +496,7 @@ sub deleteAttachedFiles {
my $form = $self->_createForm($fieldConfig->{$field}, $entryData->{$field});
if ($form->can('getStorageLocation')) {
my $storage = $form->getStorageLocation;
$storage->delete;
$storage->delete if $storage;
}
}
}

View file

@ -647,7 +647,8 @@ sub prepareView {
= WebGUI::Asset::Template->new($self->session, $templateId);
$template->prepare($self->getMetaDataAsTemplateVariables);
$self->{_viewTemplate} = $template;
$self->{_viewTemplate} = $template;
$self->{_viewVariables} = $self->getTemplateVars;
}
#----------------------------------------------------------------------------
@ -776,7 +777,7 @@ to be displayed within the page style.
sub view {
my $self = shift;
my $session = $self->session;
my $var = $self->getTemplateVars;
my $var = delete $self->{_viewVariables};
my $p = $self->getFilePaginator;
$p->appendTemplateVars( $var );

View file

@ -98,70 +98,80 @@ sub definition {
maxResponsesPerUser => {
fieldType => 'integer',
defaultValue => 1,
label => 'Max user reponses',
label => $i18n->get('Max user responses'),
hoverHelp => $i18n->get('Max user responses help'),
},
overviewTemplateId => {
tab => 'display',
fieldType => 'template',
defaultValue => 'PBtmpl0000000000000063',
label => 'Overview template id',
namespace => 'Survey/Overview',
label => $i18n->get('Survey Overview Template'),
hoverHelp => $i18n->get('Survey Overview Template help'),
},
gradebookTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Grabebook template id',
defaultValue => 'PBtmpl0000000000000062',
namespace => 'Survey/Gradebook',
label => $i18n->get('Gradebook Template'),
hoverHelp => $i18n->get('Gradebook Template help'),
},
responseTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Response template id',
defaultValue => 'PBtmpl0000000000000064',
namespace => 'Survey/Response',
label => $i18n->get('Response Template'),
hoverHelp => $i18n->get('Response Template help'),
},
surveyEditTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Survey edit template id',
defaultValue => 'GRUNFctldUgop-qRLuo_DA',
namespace => 'Survey/Edit',
label => $i18n->get('Edit Survey Template'),
hoverHelp => $i18n->get('Edit Survey Template help'),
},
surveyTakeTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Take survey template id',
defaultValue => 'd8jMMMRddSQ7twP4l1ZSIw',
namespace => 'Survey/Take',
label => $i18n->get('Take Survey Template'),
hoverHelp => $i18n->get('Take Survey Template help'),
},
surveyQuestionsId => {
tab => 'display',
fieldType => 'template',
label => 'Questions template id',
defaultValue => 'CxMpE_UPauZA3p8jdrOABw',
namespace => 'Survey/Take',
label => $i18n->get('Questions Template'),
hoverHelp => $i18n->get('Questions Template help'),
},
sectionEditTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Section Edit Tempalte',
defaultValue => '1oBRscNIcFOI-pETrCOspA',
namespace => 'Survey/Edit',
label => $i18n->get('Section Edit Template'),
hoverHelp => $i18n->get('Section Edit Template help'),
},
questionEditTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Question Edit Tempalte',
defaultValue => 'wAc4azJViVTpo-2NYOXWvg',
namespace => 'Survey/Edit',
label => $i18n->get('Question Edit Template'),
hoverHelp => $i18n->get('Question Edit Template help'),
},
answerEditTemplateId => {
tab => 'display',
fieldType => 'template',
label => 'Answer Edit Tempalte',
defaultValue => 'AjhlNO3wZvN5k4i4qioWcg',
namespace => 'Survey/Edit',
label => $i18n->get('Answer Edit Template'),
hoverHelp => $i18n->get('Answer Edit Template help'),
},
);

View file

@ -785,7 +785,7 @@ sub updateQuestionAnswers {
}
elsif ( $type eq 'Party' ) {
my @ans
= ( 'Democratic party', 'Republican party (or GOP)', 'Independant party', 'Other party (verbatim)' );
= ( 'Democratic party', 'Republican party (or GOP)', 'Independent party', 'Other party (verbatim)' );
$self->addAnswersToQuestion( \@addy, \@ans, { 3, 1 } );
}
elsif ( $type eq 'Race' ) {

View file

@ -323,7 +323,9 @@ JavaScript that will take over if the browser has the cojones.
sub www_manage {
my ( $session ) = @_;
my $ac = WebGUI::AdminConsole->new( $session, "assets" );
my $ac = WebGUI::AdminConsole->new( $session, "assets", {
showAdminBar => 1
} );
my $currentAsset = getCurrentAsset( $session );
my $i18n = WebGUI::International->new( $session, "Asset" );
@ -413,7 +415,7 @@ sub www_manage {
YAHOO.util.Event.onDOMReady( WebGUI.AssetManager.initManager );
</script>
ENDHTML
my $output = WebGUI::Macro::AdminBar::process($session).'<div class="yui-skin-sam" id="assetManager">' . getHeader( $session );
my $output = '<div class="yui-skin-sam" id="assetManager">' . getHeader( $session );
### Crumbtrail
my $crumb_markup = '<li><a href="%s">%s</a> &gt;</li>';

View file

@ -186,7 +186,7 @@ sub fieldSetEnd {
my $legend = shift;
$self->{_data} .= "</tbody></table>\n"
."</fieldset>\n"
."<table ".$self->{_tableExtras}.'" style="width: 100%;"><tbody>'
."<table ".$self->{_tableExtras}.' style="width: 100%;"><tbody>'
."\n";
}
@ -208,7 +208,7 @@ sub fieldSetStart {
my $legend = shift;
$self->{_data} .= "</tbody></table>\n"
."<fieldset>\n<legend>".$legend."</legend>\n"
."<table ".$self->{_tableExtras}.'" style="width: 100%;"><tbody>'
."<table ".$self->{_tableExtras}.' style="width: 100%;"><tbody>'
."\n";
}

View file

@ -27,6 +27,58 @@ our $HELP = {
related => [ ],
},
'view inbox' => {
title => 'view inbox template',
body => '',
isa => [
{
tag => 'common vars',
namespace => 'Account_Inbox',
},
{
tag => 'pagination template variables',
namespace => 'WebGUI',
},
],
fields => [ ],
variables => [
{ name => 'subject_url', },
{ name => 'status_url', },
{ name => 'from_url', },
{ name => 'dateStamp_url', },
{ name => 'rpp_url', },
{ name => 'has_messages', },
{ name => 'message_total', },
{ name => 'new_message_url', },
{ name => 'canSendMessages', },
{ name => 'message_rpp', },
{ name => 'form_header',
required => 1, },
{ name => 'form_footer',
required => 1, },
{
name => 'message_loop',
variables => [
{ name => 'message_id', },
{ name => 'message_url', },
{ name => 'subject', },
{ name => 'status', },
{ name => 'status_class', },
{ name => 'isRead', },
{ name => 'isReplied', },
{ name => 'isPending', },
{ name => 'isCompleted', },
{ name => 'from_id', },
{ name => 'from_url', },
{ name => 'from', },
{ name => 'dateStamp', },
{ name => 'dateStamp_formatted', },
{ name => 'inbox_form_delete', },
],
},
],
related => [ ],
},
};
1;

View file

@ -161,26 +161,38 @@ sub _processMacro {
$parameters =~ s/^\(//;
$parameters =~ s/\)$//;
# there are two possible matches and only one will ever match at a time, so we filter out the undef ones
my @params = grep { defined $_ } ($parameters =~ /
my @params;
while ($parameters =~ /
(?<!\z) # don't try to match if we are at the end of the string
(?: # either
\s* " # white space followed by quotes
\s* " # white space followed by a double quote
( (?: # capture inside
[^"\\] # something other than a quote or backslash
[^"\\] # something other than backslash or double quote
| # or
\\. # a backslash followed by any character
) * ) # as many times as needed
" \s* # end quote and any white space
" \s* # end quote and any white space
| # or
([^,]*) # anything but a comma
\s* ' # same as above, but with single quotes
( (?:
[^'\\]
|
\\.
) * )
' \s*
| # or
([^,]*) # anything but a comma
)
(?: # followed by
\z # end of the string
| # or
, # a comma
)
/xg);
/xg) {
# three matches, only one will exist per run
push @params, defined $1 ? $1 : defined $2 ? $2 : $3;
}
for my $param (@params) {
$param =~ s/\\(.)/$1/xmsg; # deal with backslash escapes
process($session, \$param)

View file

@ -504,6 +504,10 @@ sub getPageLinks {
my $start = ($minPage > 0) ? $minPage : 1;
my $maxPage = $start + $limit - 1;
my $end = ($maxPage < $self->getPageNumber) ? $self->getPageNumber : $maxPage;
if ($maxPage > $self->getNumberOfPages) {
$end = $self->getNumberOfPages;
$start = $self->getNumberOfPages - $limit + 1;
}
my @temp;
foreach my $page (@pages) {
if ($i <= $end && $i >= $start) {
@ -754,5 +758,24 @@ sub setAlphabeticalKey {
return 1;
}
#-------------------------------------------------------------------
=head2 setPageNumber ( pageNumber )
Sets the page number. This is really a convenience method for testing.
Returns the page number that was set.
=head3 pageNumber
Sets the pageNumber. Setting the pageNumber outside of the set of
pages would cause the Paginator to behave poorly.
=cut
sub setPageNumber {
my $self = shift;
$self->{_pn} = shift;
}
1;

View file

@ -30,6 +30,8 @@ $env = WebGUI::Session::Env->new;
$value = $env->get('REMOTE_ADDR');
return 'not gonna see it' if $env->requestNotViewed() ;
=head1 METHODS
These methods are available from this package:
@ -37,6 +39,66 @@ These methods are available from this package:
=cut
#-------------------------------------------------------------------
=head2 callerIsSearchSite ( )
returns true if the remote address matches a site which is a known indexer or spider.
=cut
sub callerIsSearchSite {
my $self = shift;
my $remoteAddress = $self->getIp;
return 1 if $remoteAddress =~ /203\.87\.123\.1../ # Blaiz Enterprise Rawgrunt search
|| $remoteAddress =~ /123\.113\.184\.2../ # Unknown Yahoo Robot
|| $remoteAddress == '';
return 0;
}
#-------------------------------------------------------------------
=head2 clientIsSpider ( )
returns true is the client/agent is a spider/indexer or some other non-human interface
=cut
sub clientIsSpider {
my $self = shift;
my $userAgent = $self->get('HTTP_USER_AGENT');
return 1 if $userAgent eq ''
|| $userAgent =~ m<(^wre\/| # the WRE wget's http://localhost/ every 2-3 minutes 24 hours a day...
^morpheus|
libwww|
s[pb]ider|
bot|
robo|
sco[ou]t|
crawl|
miner|
reaper|
finder|
search|
engine|
download|
fetch|
scan|
slurp)>ix;
return 0;
}
#-------------------------------------------------------------------
=head2 DESTROY ( )
@ -100,5 +162,22 @@ sub new {
bless {_env=>\%ENV}, $class;
}
#-------------------------------------------------------------------
=head2 requestNotViewed ( )
returns true is the client/agent is a spider/indexer or some other non-human interface
=cut
sub requestNotViewed {
my $self = shift;
return $self->clientIsSpider()
|| $self->callerIsSearchSite();
}
1;

View file

@ -233,7 +233,7 @@ sub www_addPaymentGateway {
my $className = $session->form->process('className')
|| WebGUI::Error::InvalidParam->throw(error => 'No class name passed');
my $payDriver = $self->addPaymentGateway( $className, $className->getName( $session ), { enabled => 0 } );
my $payDriver = $self->addPaymentGateway( $className, { enabled => 0, label => $className->getName($session), } );
return $payDriver->www_edit;
}

View file

@ -23,7 +23,7 @@ our $I18N = {
message => q|Edit Layout Template|,
lastUpdated => 1119068809
},
'inbox layout template hoverHelp' => {
message => q{Choose a layout from the list to display the various account pluggins that are editable by the current user as well as the contents of the one currently chosen},
lastUpdated => 1119068809
@ -194,7 +194,7 @@ our $I18N = {
message => q|Subject|,
lastUpdated => 1119068809
},
'status label' => {
message => q{Status},
lastUpdated => 1119068809
@ -214,7 +214,7 @@ our $I18N = {
message => q{Add Recipients},
lastUpdated => 1119068809
},
'from label' => {
message => q{From},
lastUpdated => 1119068809
@ -224,7 +224,7 @@ our $I18N = {
message => q{To},
lastUpdated => 1119068809
},
'member since' => {
message => q{Member Since },
lastUpdated => 1119068809
@ -234,7 +234,7 @@ our $I18N = {
message => q{Delete},
lastUpdated => 1119068809
},
'view my profile' => {
message => q{view my profile as others see it},
lastUpdated => 1119068809
@ -546,6 +546,181 @@ our $I18N = {
lastUpdated => 0,
context => "Description of Inbox setting",
},
'subject_url' => {
message => q{The URL to sort the inbox by subject.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'status_url' => {
message => q{The URL to sort the inbox by status.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'from_url' => {
message => q{The URL to sort the inbox by who sent the messages.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'dateStamp_url' => {
message => q{The URL to sort the inbox by when the message was sent.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'rpp_url' => {
message => q{The current URL with sort, sort direction and user filtering params added.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'has_messages' => {
message => q{A boolean which is true if the user has messages.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'message_total' => {
message => q{The total number of messages the user has in their inbox.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'new_message_url' => {
message => q{The URL to take the user to the screen where they can send new messages to other users.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'canSendMessages' => {
message => q{A boolean which is true if the user has friends that he can send messages to.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'message_loop' => {
message => q{A loop containing all messages, as determined by the sorting and number of messages per page options.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'view inbox template' => {
message => q{View Inbox Template},
lastUpdated => 1235421123,
context => "The template that allows you to view the contents of the Inbox",
},
'message_rpp' => {
message => q{A select box that allows the user to change the number of messages displayed per page},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'form_header' => {
message => q{HTML elements to begin the form on this page},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'form_footer' => {
message => q{HTML elements to end the form on this page},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'message_id' => {
message => q{The unique identifier for this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'message_url' => {
message => q{The URL to view the contents of this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'subject' => {
message => q{The subject of this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'status' => {
message => q{The status of this message, internationalized.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'status_class' => {
message => q{The status of this message, raw.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'isRead' => {
message => q{A boolean which will be true if this message has been read.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'isReplied' => {
message => q{A boolean which will be true if this message has been replied to.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'isPending' => {
message => q{A boolean which will be true if this message represents an action by the user that is pending.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'isCompleted' => {
message => q{A boolean which will be true if this message represents an action by the user that has been completed.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'from_id' => {
message => q{The userId of the person who sent this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'from_url' => {
message => q{The URL to view the profile of the user who sent this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'from' => {
message => q{The name of the person who sent this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'dateStamp' => {
message => q{The date the message was sent, as an epoch.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'dateStamp_formatted' => {
message => q{The date the message was sent, using the user's preferred date and time format.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
'inbox_form_delete' => {
message => q{A little checkbox for the user to check if they want to delete this message.},
lastUpdated => 1235421123,
context => "template variable for view inbox template",
},
};
1;

View file

@ -418,8 +418,8 @@ listing,|,
},
'max comparisons privileged description' => {
message => q|Specifies how many comparisons are allowed in searches and comparisons for users in the privileged group.|,
lastUpdated => 0,
message => q|Specifies how many comparisons are allowed in searches and comparisons for users who have accounts on the site.|,
lastUpdated => 1235681965,
},
'rating timeout description' => {
@ -548,8 +548,8 @@ listing,|,
},
'max comparisons privileged label' => {
message => q|Maximum Comparisons (For Privileged Users)|,
lastUpdated => 0,
message => q|Maximum Comparisons (For Registered Users)|,
lastUpdated => 1235681967,
},
'rating timeout' => {

View file

@ -161,14 +161,10 @@ our $I18N = { ##hashref of hashes
'no results' => {
message => q|No results were found.|,
content => q|An internationalized label for telling the user that no results were found.|,
lastUpdated => 1170549113,
},
'no_results' => {
message => q|An internationalized label for telling the user that no results were found.|,
lastUpdated => 1170549119,
},
};
1;

View file

@ -490,6 +490,116 @@ our $I18N = {
lastUpdated => 1233714385,
},
'Max user responses' => {
message => q|Max user responses|,
context => q|The maximum number of times a user may take this survey.|,
lastUpdated => 0
},
'Max user responses help' => {
message => q|The maximum number of times a user may take this survey.|,
lastUpdated => 0
},
'Survey Overview Template' => {
message => q|Survey Overview Template|,
context => q|The template that provides an overview of the survey.|,
lastUpdated => 0
},
'Survey Overview Template help' => {
message => q|The template that provides an overview of the survey.|,
lastUpdated => 0
},
'Gradebook Template' => {
message => q|Gradebook Template|,
context => q|The template for displaying the gradebook.|,
lastUpdated => 0
},
'Gradebook Template help' => {
message => q|The template for displaying the gradebook.|,
lastUpdated => 0
},
'Response Template' => {
message => q|Response Template|,
context => q|The template for displaying responses to the survey.|,
lastUpdated => 0
},
'Response Template help' => {
message => q|The template for displaying responses to the survey.|,
lastUpdated => 0
},
'Edit Survey Template' => {
message => q|Edit Survey Template|,
context => q|The template for displaying the screen for editing the survey.|,
lastUpdated => 0
},
'Edit Survey Template help' => {
message => q|The template for displaying the screen for editing the survey.|,
lastUpdated => 0
},
'Take Survey Template' => {
message => q|Take Survey Template|,
context => q|The template for displaying the screen where a user takes the survey.|,
lastUpdated => 0
},
'Take Survey Template help' => {
message => q|The template for displaying the screen where a user takes the survey.|,
lastUpdated => 0
},
'Questions Template' => {
message => q|Questions Template|,
context => q|The template for rendering questions in the survey.|,
lastUpdated => 0
},
'Questions Template help' => {
message => q|The template for rendering questions in the survey.|,
lastUpdated => 0
},
'Section Edit Template' => {
message => q|Section Edit Template|,
context => q|The template for adding or editing sections.|,
lastUpdated => 0
},
'Section Edit Template help' => {
message => q|The template for adding or editing sections.|,
lastUpdated => 0
},
'Question Edit Template' => {
message => q|Question Edit Template|,
context => q|The template for adding or editing questions.|,
lastUpdated => 0
},
'Question Edit Template help' => {
message => q|The template for adding or editing questions.|,
lastUpdated => 0
},
'Answer Edit Template' => {
message => q|Answer Edit Template|,
context => q|The template for adding or editing answers.|,
lastUpdated => 0
},
'Answer Edit Template help' => {
message => q|The template for adding or editing answers.|,
lastUpdated => 0
},
'percentage label' => {
message => q|Percentage|,
context => q|Label for the Percentage column on the gradebook screen.|,

View file

@ -21,7 +21,7 @@ my $session = WebGUI::Test->session;
my $numTests = 1; ##For conditional load check
my $langTests = 4; ##For language look-up tests
$numTests += 11 + $langTests;
$numTests += 12 + $langTests;
plan tests => $numTests;
@ -76,6 +76,11 @@ SKIP: {
undef,
'Language check: key from non-existant file returns an empty string'
);
is(
$i18n->get('key with spaces in it','WebGUI','PigLatin'),
'Key Contained Spaces',
'keys with spaces work'
);
}

View file

@ -43,7 +43,7 @@ foreach my $macro (qw/
}
$session->config->addToHash('macros', "Ex'tras", "Extras");
plan tests => 33;
plan tests => 35;
my $macroText = "CompanyName: ^c;";
my $companyName = $session->setting->get('companyName');
@ -200,6 +200,23 @@ is(
"Carriage returns pass through as needed."
);
my $macroText = qq|^ReverseParams(1,'Single quoted parameters work properly',2);|;
WebGUI::Macro::process($session, \$macroText),
is(
$macroText,
"2Single quoted parameters work properly1",
"Single quoted parameters work properly."
);
my $macroText = qq|^ReverseParams(1,'Escaped single\\' quotes work',2);|;
WebGUI::Macro::process($session, \$macroText),
is(
$macroText,
"2Escaped single' quotes work1",
"Escaped single quotes work."
);
tie my %quotingEdges, 'Tie::IxHash';
%quotingEdges = (
'^VisualMacro(text);' => '@MacroCall[`text`]:',
@ -217,7 +234,7 @@ while (my ($inText, $outText) = each %quotingEdges) {
is(
$procText,
$outText,
"Nesting edge case: $inText",
"Quoting/Nesting edge case: $inText",
);
}

View file

@ -20,15 +20,17 @@ use WebGUI::Paginator;
use Test::More; # increment this value for each test you create
use Test::Deep;
use POSIX qw(ceil);
use Storable qw/dclone/;
use Data::Dumper;
my $session = WebGUI::Test->session;
plan tests => 26; # increment this value for each test you create
my $startingRowNum = 0;
my $endingRowNum = 99;
my @paginatingData = ($startingRowNum..$endingRowNum);
plan tests => 15; # increment this value for each test you create
my $rowCount = $endingRowNum - $startingRowNum + 1;
my $NumberOfPages = ceil($rowCount/25); ##Default page size=25
my $url = "/home";
@ -47,7 +49,26 @@ cmp_bag([0..24], $p->getPageData(1), 'page 1 data correct');
cmp_bag([25..49], $p->getPageData(2), 'page 2 data correct');
cmp_bag([ ], $p->getPageData(5), 'page 5 data correct');
# Test getPageLinks
########################################################################
#
# getPageNumber, setPageNumber
#
########################################################################
my $p2 = WebGUI::Paginator->new($session, '/work');
is($p2->getPageNumber, 1, 'pageNumber set to 1 at object creation by default');
is($p2->setPageNumber(0), 0, 'setPageNumber returns the page number set');
is($p2->getPageNumber, 0, 'pageNumber set by setPageNumber');
is($p2->setPageNumber(3), 3, 'setPageNumber returns the page number set');
is($p2->getPageNumber, 3, 'pageNumber set by setPageNumber');
########################################################################
#
# getPageLinks
#
########################################################################
my $expectedPages;
$expectedPages = [ map { +{
'pagination.text' => ( $_ + 1 ),
@ -63,7 +84,6 @@ cmp_deeply(
'page links correct',
);
$startingRowNum = 0;
$endingRowNum = 100;
@paginatingData = ($startingRowNum..$endingRowNum);
@ -78,7 +98,7 @@ $p->setDataByArrayRef(\@paginatingData);
is($p->getRowCount, $rowCount, '(101) paginator returns correct number of rows');
is($p->getNumberOfPages, $NumberOfPages, '(101) paginator returns right number of pages (default setting)');
my $page1Data = $p->getPageData(1);
$page1Data = $p->getPageData(1);
cmp_bag([0..24], $p->getPageData(1), '(101) page 1 data correct');
cmp_bag([25..49], $p->getPageData(2), '(101) page 2 data correct');
cmp_bag([100 ], $p->getPageData(5), '(101) page 5 data correct');
@ -95,11 +115,105 @@ $expectedPages = [ map { +{
$expectedPages->[0]->{'pagination.activePage'} = 'true';
########################################################################
#
# getPageLinks with limits
#
########################################################################
# Test getPageLinks
cmp_deeply(
($p->getPageLinks)[0],
$expectedPages,
'page links correct',
'set of 5 pages looks right',
);
$startingRowNum = 0;
$endingRowNum = 199;
@paginatingData = ($startingRowNum..$endingRowNum);
$p = WebGUI::Paginator->new($session, '/home', 10);
$rowCount = $endingRowNum - $startingRowNum + 1;
$NumberOfPages = ceil($rowCount/10); ##Default page size=25
$p->setDataByArrayRef(\@paginatingData);
$expectedPages = [ map { +{
'pagination.text' => ( $_ + 1 ),
'pagination.range' => ( 10 * $_ + 1 ) . "-" . ( $_ * 10 + 10 <= $endingRowNum + 1 ? $_ * 10 + 10 : $endingRowNum + 1 ), # First row number - Last row number
'pagination.url' => ( '/home?pn=' . ( $_ + 1 ) ), # Current page has no URL
} } (0..$NumberOfPages-1) ];
my $copy;
$copy = dclone($expectedPages);
$copy->[0]->{'pagination.activePage'} = 'true';
$copy->[0]->{'pagination.url'} = '';
cmp_deeply(
($p->getPageLinks)[0],
$copy,
'set of 20 pages looks right',
);
my @pageWindow;
$copy = dclone($expectedPages);
$copy->[0]->{'pagination.activePage'} = 'true';
$copy->[0]->{'pagination.url'} = '';
@pageWindow = @{ $copy }[0..9];
cmp_deeply(
($p->getPageLinks(10))[0],
\@pageWindow,
'set of first 10 pages selected correctly',
);
$p->setPageNumber(10);
my $copy = dclone($expectedPages);
$copy->[9]->{'pagination.activePage'} = 'true';
$copy->[9]->{'pagination.url'} = '';
@pageWindow = @{ $copy }[4..13];
cmp_deeply(
($p->getPageLinks(10))[0],
\@pageWindow,
'set of middle 10 pages @10 selected correctly',
);
$p->setPageNumber(3);
my $copy = dclone($expectedPages);
$copy->[2]->{'pagination.activePage'} = 'true';
$copy->[2]->{'pagination.url'} = '';
delete $copy->[0]->{'pagination.activePage'};
@pageWindow = @{ $copy }[0..9];
cmp_deeply(
($p->getPageLinks(10))[0],
\@pageWindow,
'set of 10 pages selected correctly, with off edge page number (3/20)',
);
$p->setPageNumber(17);
my $copy = dclone($expectedPages);
$copy->[16]->{'pagination.activePage'} = 'true';
$copy->[16]->{'pagination.url'} = '';
@pageWindow = @{ $copy }[10..19];
cmp_deeply(
($p->getPageLinks(10))[0],
\@pageWindow,
'set of last 10 pages selected correctly, (17/20)',
);
$p->setPageNumber(20);
my $copy = dclone($expectedPages);
$copy->[19]->{'pagination.activePage'} = 'true';
$copy->[19]->{'pagination.url'} = '';
@pageWindow = @{ $copy }[10..19];
cmp_deeply(
($p->getPageLinks(10))[0],
\@pageWindow,
'set of last 10 pages selected correctly, (20/20)',
);

42
t/ProfileCategory.t Normal file
View file

@ -0,0 +1,42 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2008 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 FindBin;
use strict;
use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::ProfileCategory;
use Test::More tests => 1; # increment this value for each test you create
use Test::Deep;
my $session = WebGUI::Test->session;
###################################################################
#
# getCategories
#
###################################################################
my $categories = WebGUI::ProfileCategory->getCategories($session);
my @labels = map { $_->getLabel } @{ $categories };
$categories->[0]->set({ visible => 0});
my $newCategories = WebGUI::ProfileCategory->getCategories($session);
my @newLabels = map { $_->getLabel } @{ $newCategories };
cmp_bag(\@newLabels, \@labels, 'Setting a category to not be visible does not change its availability through getCategories, with no options');
END {
}

206
t/Session/CheckClient.t Normal file
View file

@ -0,0 +1,206 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
# this test can take two parameters
# first is an xml file, second indicates
# the percentage of items to test.
# the xml file can be downloaded from
# http://www.user-agents.org/
# the percent will default to 25 and
# should be passed as a whole number
# so 100 will test all items, 75 will
# test 75% or 3 out of four items
use FindBin;
use strict;
use lib "$FindBin::Bin/lib";
use lib '/data/WebGUI/t/lib';
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
my $session = WebGUI::Test->session;
# this test is for code in the WebGUI::Session::Env Module
my @testArray = (
{
agent => "",
output => 1,
comment => "blank user agent"
},
{
agent => "&lt;a href='http://www.unchaos.com/'> UnChaos &lt;/a> From Chaos To Order Hybrid Web Search Engine.(vadim_goncharunchaos.com)",
output => 1,
comment => "UnChaos hybrid search engine"
},
{
agent => "(DreamPassport/3.0; isao/MyDiGiRabi)",
output => 0,
comment => "DreamCast DreamPassport browser"
},
{
agent => "Privoxy web proxy", # I think proxy's whould be considered browsers?
output => 0,
comment => "s.also Privoxy/3.0 (Anonymous)"
},
{
agent => "*/Nutch-0.9-dev",
address => "123.113.184.232",
output => 1,
comment => "Unknown Yahoo robot"
},
{
agent => "123spider-Bot (Version: 1.02&#44; powered by www.123spider.de",
output => 1,
comment => "123spider.de (Germany) web directory link checking"
},
{
agent => "1st ZipCommander (Net) - http://www.zipcommander.com/",
output => 0,
comment => "1st ZipCommander Net - IE based browser"
},
{
agent => "2Bone_LinkChecker/1.0 libwww-perl/5.64",
output => 1,
comment => "2Bone online link checker"
},
{
agent => "A-Online Search",
output => 1,
comment => "A-Online.at robot - now Jet2Web Search"
},
{
agent => "Advanced Browser (http://www.avantbrowser.com)",
output => 0,
comment => "Avant Browser - IE based browser"
},
{
agent => "AESOP_com_SpiderMan",
output => 1,
comment => "Aesop robot"
},
{
agent => "Mozilla/5.0 (compatible; SpurlBot/0.2)",
output => 1,
comment => "Spurl.net bookmark service & search engine (84.40.30.xxx)"
},
{
agent => "Mozilla/5.0 (compatible;MAINSEEK_BOT)",
output => 1,
comment => "Mozilla/5.0 (compatible;MAINSEEK_BOT)"
},
{
agent => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20021219 Chimera/0.6",
output => 0,
comment => "Chimera browser (Mozilla/Gecko engine) - now Camino Mac PowerPC"
},
{
agent => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/xx (KHTML like Gecko) OmniWeb/v5xx.xx",
output => 0,
comment => "OmniWeb 5.x.x Mac OS X browser"
},
{
agent => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:x.x.x) Gecko/20041107 Firefox/x.x",
output => 0,
comment => "Firefox browser (Mozilla/Gecko engine) - ex Firebird WinXP"
},
{
agent => "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) VoilaBot BETA 1.2 (support.voilabotorange-ftgroup.com)",
output => 1,
comment => "Voila.fr robot"
},
{
agent => "Mozilla/5.0 (Windows;) NimbleCrawler 1.12 obeys UserAgent NimbleCrawler For problems contact: crawlerhealth",
output => 1,
comment => "Healthline health related search robot (72.5.115.xx)"
},
{
agent => "Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8.0.2) Gecko/20060309 SeaMonkey/1.0",
output => 0,
comment => "SeaMonkey browser suite (ex Mozilla) on Linux"
},
{
agent => "Mozilla/5.0 [en] (compatible; Gulper Web Bot 0.2.4 www.ecsl.cs.sunysb.edu/~maxim/cgi-bin/Link/GulperBot)",
output => 1,
comment => "Yuntis : Collaborative Web Resource Categorization and Ranking Project robot"
},
);
sub transType {
return 0 if $_[0] =~ /(B|P)/; # browser or proxy
return 1;
}
sub getAddress { # There are precious few that have an IP that can be gotten out of the XML so I decided to skip this.
my $x = '69.42.78.32';
#if( $_[0]{Comment} =~ /\d\.\d\.\d/ ) {
# print $_[0]{Comment},"\t|\t",$_[0]{Description},"\n";
# $x = $_[0]{Comment};
# $x =~ s/x/2/;
#}
return $x;
}
sub testCount {
if( @ARGV ) {
if( $ARGV[0] =~ /\.xml$/ && -r $ARGV[0] ) {
my $infile = shift @ARGV ;
my $percent = shift @ARGV || 25;
use XML::Simple;
my $xml = new XML::Simple;
my $data = $xml->XMLin($infile);
# use Data::Dumper;
# print Dumper $data;
@testArray = ();
my $c = 1;
my $div = 20;
my $n = $div * $percent / 100;
foreach my $set (@{$data->{'user-agent'}}) {
$c = 1 if $c > $div;
if( $c <= $n ) {
push @testArray, {
agent => $set->{String},
output => transType($set->{Type}),
type => $set->{Type},
comment => $set->{Description},
# comment => $set->{String}, # this is handy for fine tuning the code: it shows the string that failed...
address => getAddress($set),
};
}
$c ++;
}
# use Data::Dumper;
# print Dumper \@testArray;
}
}
return scalar(@testArray);
}
plan tests => testCount() ;
my $output;
foreach my $testSet (@testArray) {
$output = FAKE_ENV->new( $testSet->{agent},
$testSet->{address} || '69.42.78.32')
->requestNotViewed();
is($output, $testSet->{output}, $testSet->{comment});
}
{ # this is a local fake of the session, used for testing only
package FAKE_ENV;
use base 'WebGUI::Session::Env';
sub new { shift; return bless { _env => { HTTP_USER_AGENT => $_[0], REMOTE_ADDR => $_[1] } }, __PACKAGE__; }
}

View file

@ -95,3 +95,8 @@ foreach my $label ( @questionableTemplates ) {
sprintf "Empty template: %s, id: %s, url: %s", @{ $label }{qw/title id url/}
);
}
END {
defined $session &&
$session->config->set('macros', $originalMacros);
}

View file

@ -6,6 +6,11 @@ our $I18N = {
lastUpdated => 1141963573,
context => q|Test key for International macro test. DO NOT TRANSLATE|,
},
'key with spaces in it' => {
message => q|Key Contained Spaces|,
lastUpdated => 0,
}
};
1;

View file

@ -1,37 +1,36 @@
dl.accordion-menu dd.a-m-d div.ncmct {
width: 140px;
border-bottom: 1px solid #bbbbbb;
color: black;
font-weight: bold;
font-size: 12px;
margin-bottom: 5px;
width: 140px;
border-bottom: 1px solid #bbbbbb;
color: black;
font-weight: bold;
font-size: 12px;
margin-bottom: 5px;
font-family: sans-serif;
}
dl.accordion-menu {
margin: 0;
padding: 0;
width: 160px;
background: #eeeeee;
margin: 0;
padding: 0;
width: 160px;
background: #eeeeee;
position:fixed;
_position:absolute;
top:0;
_top:expression(eval((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop));
/*
_top:expression(eval((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop)); */
left:0;
_left: -175px;
z-index: 100;
}
dl.accordion-menu dt.a-m-t {
margin: 0;
padding: 0;
margin: 0;
padding: 0;
background-color:#dddddd;
background-image: url(btn_bg.jpg);
font-weight: bold;
height: 20px;
color: #444444;
color: #444444;
border: 1px solid #ACACAC;
line-height: 20px;
font-size: 12px;
@ -40,31 +39,31 @@ dl.accordion-menu dt.a-m-t {
}
dl.accordion-menu dt.a-m-t-hover{
margin: 0;
padding: 0;
background:#cdcdcd;
margin: 0;
padding: 0;
background:#cdcdcd;
}
dl.accordion-menu dt.a-m-t-down{
margin: 0;
padding: 0;
border: solid 1px #222222;
border-right-color: #dfdfdf;
border-bottom-color: #dfdfdf;
margin: 0;
padding: 0;
border: solid 1px #222222;
border-right-color: #dfdfdf;
border-bottom-color: #dfdfdf;
}
html.accordion-menu-js dt.a-m-t{
margin: 0;
padding: 0;
cursor:pointer;
zoom:1;
margin: 0;
padding: 0;
cursor:pointer;
zoom:1;
}
dl.accordion-menu dd.a-m-d {
margin: 0;
padding: 0;
margin: 0;
padding: 0;
overflow: auto;
background-color: #eeeeee;
background-image: url(panel_bg.jpg);
@ -73,24 +72,24 @@ dl.accordion-menu dd.a-m-d {
}
dl.accordion-menu dd.a-m-d .link {
margin: 0;
padding: 0;
margin: 0;
padding: 0;
display: block;
width: 118px;
text-align:left;
padding-left:20px;
text-align:left;
padding-left:20px;
text-decoration: none;
color: black;
font-family: sans-serif;
cursor: pointer;
font-weight: normal;
font-size: 12px;
margin-bottom:5px;
margin-left:2px;
letter-spacing:0px;
text-transform:none;
font-variant:normal;
line-height:12px;
margin-bottom:5px;
margin-left:2px;
letter-spacing:0px;
text-transform:none;
font-variant:normal;
line-height:12px;
}
dl.accordion-menu dd.a-m-d .link img {
@ -104,45 +103,48 @@ dl.accordion-menu dd.a-m-d .link:hover {
}
html.accordion-menu-js dd.a-m-d{
margin: 0;
padding: 0;
display:none;
margin: 0;
padding: 0;
display:none;
}
html.accordion-menu-js dd.a-m-d-expand {
margin: 0;
padding: 0;
display:block;
margin: 0;
padding: 0;
display:block;
}
html.accordion-menu-js dd.a-m-d-before-expand {
margin: 0;
padding: 0;
display:block;
position:relative;
z-index:-1;
opacity:0;
height:auto !important;
visibility:hidden;
overflow:visible;
margin: 0;
padding: 0;
display:block;
position:relative;
z-index:-1;
opacity:0;
height:auto !important;
visibility:hidden;
overflow:visible;
}
html.accordion-menu-js dt.a-m-t-expand {
margin: 0;
padding: 0;
border-left-color:#222222;
color:black;
background:#c0c0c0;
margin: 0;
padding: 0;
border-left-color:#222222;
color:black;
background:#c0c0c0;
}
html.accordion-menu-js dd.a-m-d-anim {
margin: 0;
padding: 0;
overflow:hidden;
display:block;
margin: 0;
padding: 0;
overflow:hidden;
display:block;
}