Skip to content

Commit

Permalink
remove WebGUI::Utility
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Jun 16, 2010
1 parent 73319bf commit 00bd89c
Show file tree
Hide file tree
Showing 101 changed files with 253 additions and 941 deletions.
6 changes: 3 additions & 3 deletions lib/WebGUI/Account/Inbox.pm
Expand Up @@ -6,9 +6,9 @@ use WebGUI::Form;
use WebGUI::Exception;
use WebGUI::International;
use WebGUI::Pluggable;
use WebGUI::Utility;
use Tie::IxHash;
use base qw/WebGUI::Account/;
use Email::Valid;

=head1 NAME
Expand Down Expand Up @@ -901,7 +901,7 @@ sub www_inviteUserSave {
my $db = $session->db;
my @toList = split /[;,]/, $to;
for my $inviteeEmail (@toList) {
unless ( $inviteeEmail =~ WebGUI::Utility::emailRegex ) {
unless ( Email::Valid->address($inviteeEmail) ) {
return $self->www_inviteUser( sprintf $i18n->get('invalid email'), $inviteeEmail );
}

Expand Down Expand Up @@ -1169,7 +1169,7 @@ sub www_sendMessage {
$activeFriendCount++;
}

my $isChecked = WebGUI::Utility::isIn($friendId,@friendsChecked);
my $isChecked = $friendId ~~ @friendsChecked;
my $friendHash = {
'friend_id' => $friendId,
'friend_name' => $friends->{$friendId},
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/Account/Profile.pm
Expand Up @@ -7,7 +7,6 @@ use WebGUI::International;
use WebGUI::Pluggable;
use WebGUI::ProfileCategory;
use WebGUI::ProfileField;
use WebGUI::Utility;
use base qw/WebGUI::Account/;

=head1 NAME
Expand Down Expand Up @@ -242,7 +241,7 @@ sub getExtrasStyle {
my $requiredStyle = q{class="profilefield_required"};
my $errorStyle = q{class="profilefield_error"}; #Required Field Not Filled In and Error Returend

return $errorStyle if(WebGUI::Utility::isIn($field->getId,@{$fieldErrors}));
return $errorStyle if ($field->getId ~~ $fieldErrors);
return "" unless ($field->isRequired);
return $requiredStyle unless($self->session->user->profileField($field->getId) || $fieldValue);
return $requiredStyleOff;
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/Account/Shop.pm
Expand Up @@ -5,7 +5,6 @@ use strict;
use WebGUI::Exception;
use WebGUI::International;
use WebGUI::Pluggable;
use WebGUI::Utility;
use WebGUI::Shop::Vendor;
use JSON qw{ from_json };

Expand Down Expand Up @@ -52,7 +51,7 @@ sub appendCommonVars {
my $method = $session->form->get("do");

$var->{ 'manage_purchases_url' } = $self->getUrl("module=shop;do=managePurchases");
$var->{ 'managesPurchasesIsActive' } = WebGUI::Utility::isIn($method,("","managePurchases","view","viewTransaction"));
$var->{ 'managesPurchasesIsActive' } = $method ~~ [("","managePurchases","view","viewTransaction")];

$var->{ 'view_sales_url' } = $self->getUrl( 'module=shop;do=viewSales' );
$var->{ 'viewSalesIsActive' } = $method eq 'viewSales';
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset.pm
Expand Up @@ -391,7 +391,6 @@ use WebGUI::Keyword;
require WebGUI::ProgressBar;
use WebGUI::Search::Index;
use WebGUI::TabForm;
use WebGUI::Utility;

=head1 NAME
Expand Down Expand Up @@ -1063,7 +1062,7 @@ sub getEditForm {
}

# Kludge.
if (isIn($fieldHash{fieldType}, 'selectBox', 'workflow') and ref $params{value} ne 'ARRAY') {
if ($fieldHash{fieldType} ~~ ['selectBox', 'workflow'] and ref $params{value} ne 'ARRAY') {
$params{value} = [$params{value}];
}

Expand Down Expand Up @@ -2580,7 +2579,7 @@ sub www_add {
my $prototype = WebGUI::Asset->newById($self->session, $self->session->form->process("prototype"));
foreach my $property ($prototype->getProperties) { # cycle through rather than copying properties to avoid grabbing stuff we shouldn't grab
my $definition = $prototype->getProperty($property);
next if (isIn($property,qw(title menuTitle url isPrototype isPackage)));
next if ($property ~~ [qw(title menuTitle url isPrototype isPackage)]);
next if ($definition->{noFormPost});
$prototypeProperties{$property} = $prototype->get($property);
}
Expand Down
1 change: 0 additions & 1 deletion lib/WebGUI/Asset/EMSSubmission.pm
Expand Up @@ -142,7 +142,6 @@ property ticketId => (
with 'WebGUI::Role::Asset::Comments';

use Tie::IxHash;
use WebGUI::Utility;
use WebGUI::Inbox;

=head1 NAME
Expand Down
1 change: 0 additions & 1 deletion lib/WebGUI/Asset/EMSSubmissionForm.pm
Expand Up @@ -78,7 +78,6 @@ property formDescription => (

use Tie::IxHash;
use JSON;
use WebGUI::Utility;
with 'WebGUI::Role::Asset::AlwaysHidden';

=head1 NAME
Expand Down
4 changes: 2 additions & 2 deletions lib/WebGUI/Asset/File.pm
Expand Up @@ -61,7 +61,7 @@ with 'WebGUI::Role::Asset::SetStoragePermissions';

use WebGUI::Storage;
use WebGUI::SQL;
use WebGUI::Utility;
use Number::Format;


=head1 NAME
Expand Down Expand Up @@ -591,7 +591,7 @@ sub view {
$var{controls} = $self->getToolbar;
$var{fileUrl} = $self->getFileUrl;
$var{fileIcon} = $self->getFileIconUrl;
$var{fileSize} = formatBytes($self->get("assetSize"));
$var{fileSize} = Number::Format::format_bytes($self->get("assetSize"));
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
$self->session->cache->set($self->getViewCacheKey, $out, $self->get("cacheTimeout"));
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/Asset/MatrixListing.pm
Expand Up @@ -117,7 +117,6 @@ property lastUpdated => (
);

with 'WebGUI::Role::Asset::Comments';
use WebGUI::Utility;


=head1 NAME
Expand Down Expand Up @@ -534,7 +533,7 @@ sub setRatings {
my $sum = $db->quickScalar("select sum(rating) $sql", [$self->getId,$category]);
my $count = $db->quickScalar("select count(*) $sql", [$self->getId,$category]);

my $half = round($count/2);
my $half = sprintf '%d', $count / 2;
my $mean = $sum / ($count || 1);
my $median = $db->quickScalar("select rating $sql order by rating limit $half,1",[$self->getId,$category]);

Expand Down
7 changes: 3 additions & 4 deletions lib/WebGUI/Asset/RichEdit.pm
Expand Up @@ -16,7 +16,6 @@ package WebGUI::Asset::RichEdit;

use strict;
use WebGUI::Form;
use WebGUI::Utility;
use WebGUI::International;
use JSON;
use Tie::IxHash;
Expand Down Expand Up @@ -290,9 +289,9 @@ override getEditForm => sub {
my $evenOddToggle = 0;
foreach my $key (keys %buttons) {
$evenOddToggle = $evenOddToggle ? 0 : 1;
my $checked1 = isIn($key,@toolbarRow1);
my $checked2 = isIn($key,@toolbarRow2);
my $checked3 = isIn($key,@toolbarRow3);
my $checked1 = $key ~~ @toolbarRow1;
my $checked2 = $key ~~ @toolbarRow2;
my $checked3 = $key ~~ @toolbarRow3;
$buttonGrid .= '
<tr'.($evenOddToggle ? ' style="background-color: #eeeeee;"' : undef).'>
<td>'.$buttons{$key}.'</td>
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Sku/EMSBadge.pm
Expand Up @@ -85,7 +85,6 @@ use JSON;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Shop::AddressBook;
use WebGUI::Utility;

=head1 NAME
Expand Down Expand Up @@ -284,7 +283,7 @@ sub onRefund {
# get rid of any items in the cart related to this badge
foreach my $cartitem (@{$self->getCart->getItems()}) {
my $sku = $cartitem->getSku;
if (isIn((ref $sku), qw(WebGUI::Asset::Sku::EMSTicket WebGUI::Asset::Sku::EMSRibbon WebGUI::Asset::Sku::EMSToken))) {
if ((ref $sku) ~~ [qw(WebGUI::Asset::Sku::EMSTicket WebGUI::Asset::Sku::EMSRibbon WebGUI::Asset::Sku::EMSToken)]) {
if ($sku->getOptions->{badgeId} eq $badgeId) {
$cartitem->remove;
}
Expand All @@ -309,7 +308,7 @@ sub onRemoveFromCart {
my $badgeId = $self->getOptions->{badgeId};
foreach my $cartitem (@{$item->cart->getItems()}) {
my $sku = $cartitem->getSku;
if (isIn((ref $sku), qw(WebGUI::Asset::Sku::EMSTicket WebGUI::Asset::Sku::EMSRibbon WebGUI::Asset::Sku::EMSToken))) {
if ((ref $sku) ~~ [qw(WebGUI::Asset::Sku::EMSTicket WebGUI::Asset::Sku::EMSRibbon WebGUI::Asset::Sku::EMSToken)]) {
if ($sku->getOptions->{badgeId} eq $badgeId) {
$cartitem->remove;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Sku/EMSRibbon.pm
Expand Up @@ -37,7 +37,6 @@ property percentageDiscount => (
);

use WebGUI::HTMLForm;
use WebGUI::Utility;

=head1 NAME
Expand Down Expand Up @@ -232,8 +231,8 @@ sub www_delete {
my ($self) = @_;
return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked);
return $self->session->privilege->vitalComponent() if $self->isSystem;
return $self->session->privilege->vitalComponent() if (isIn($self->getId,
$self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")));
return $self->session->privilege->vitalComponent() if ($self->getId ~~
( $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage") ));
$self->trash;
return $self->getParent->www_buildBadge(undef,'ribbons');
}
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Sku/EMSTicket.pm
Expand Up @@ -92,7 +92,6 @@ property eventMetaData => (
);

use JSON ();
use WebGUI::Utility;

=head1 NAME
Expand Down Expand Up @@ -328,7 +327,7 @@ sub getPrice {
my $discount = 0;
my $badgeId = $self->getOptions->{badgeId};
my $ribbonId = $self->session->db->quickScalar("select ribbonAssetId from EMSRegistrantRibbon where badgeId=? limit 1",[$badgeId]);
if (defined $ribbonId && isIn($ribbonId, @ribbonIds)) {
if (defined $ribbonId && $ribbonId ~~ @ribbonIds) {
my $ribbon = WebGUI::Asset->newById($self->session, $ribbonId);
$discount = $ribbon->percentageDiscount;
}
Expand Down Expand Up @@ -536,7 +535,7 @@ sub www_delete {
my ($self) = @_;
return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked);
return $self->session->privilege->vitalComponent() if $self->isSystem;
return $self->session->privilege->vitalComponent() if (isIn($self->getId, $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")));
return $self->session->privilege->vitalComponent() if ($self->getId ~~ ($self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")));
$self->trash;
return $self->getParent->www_buildBadge(undef,'tickets');
}
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Sku/EMSToken.pm
Expand Up @@ -29,7 +29,6 @@ property price => (
hoverHelp => ["price help", 'Asset_EMSToken'],
);

use WebGUI::Utility;


=head1 NAME
Expand Down Expand Up @@ -226,8 +225,8 @@ sub www_delete {
my ($self) = @_;
return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked);
return $self->session->privilege->vitalComponent() if $self->isSystem;
return $self->session->privilege->vitalComponent() if (isIn($self->getId,
$self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")));
return $self->session->privilege->vitalComponent() if ($self->getId ~~
($self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")));
$self->trash;
return $self->getParent->www_buildBadge(undef,'tokens');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/Asset/Sku/Product.pm
Expand Up @@ -16,7 +16,6 @@ use Tie::IxHash;
use WebGUI::HTMLForm;
use WebGUI::Storage;
use WebGUI::SQL;
use WebGUI::Utility;
use JSON;

use Moose;
Expand Down Expand Up @@ -1108,7 +1107,7 @@ sub www_deleteFileConfirm {
my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canEdit);
my $column = $self->session->form->process("file");
return $self->www_edit unless (isIn($column, qw(image1 image2 image3 manual warranty brochure)));
return $self->www_edit unless ($column ~~ [qw(image1 image2 image3 manual warranty brochure)]);
my $store = $self->get($column);
my $file = WebGUI::Storage->get($self->session,$store);
$file->delete if defined $file;
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/Asset/Story.pm
Expand Up @@ -70,7 +70,6 @@ property photo => (

with 'WebGUI::Role::Asset::AlwaysHidden';

use WebGUI::Utility;
use WebGUI::International;
use JSON qw/from_json to_json/;
use Storable qw/dclone/;
Expand Down Expand Up @@ -234,7 +233,7 @@ sub formatDuration {
if ($hours[0]) {
$formattedDuration = join ' ', @hours;
}
my $minutes = round(($duration - $hours)/60)*60;
my $minutes = 60 * sprintf('%d', ($duration - $hours)/60);
my @minutes = $datetime->secondsToInterval($minutes);
if ($minutes[0]) {
$formattedDuration .= ', ', if $formattedDuration;
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Template.pm
Expand Up @@ -99,7 +99,6 @@ property usePacked => (

use WebGUI::International;
use WebGUI::Asset::Template::HTMLTemplate;
use WebGUI::Utility;
use WebGUI::Form;
use WebGUI::Exception;
use Tie::IxHash;
Expand Down Expand Up @@ -536,7 +535,7 @@ sub prepare {

my $id = $self->getId;
# don't send head block if we've already sent it for this template
return if isIn($id, @$sent);
return if $id ~~ $sent;

my $session = $self->session;
my ($db, $style) = $session->quick(qw(db style));
Expand Down Expand Up @@ -636,7 +635,7 @@ override processPropertiesFromFormPost => sub {
my $needsUpdate = 0;
if ($self->parser ne $self->session->form->process("parser","className") && ($self->session->form->process("parser","className") ne "")) {
$needsUpdate = 1;
if (isIn($self->session->form->process("parser","className"),@{$self->session->config->get("templateParsers")})) {
if ($self->session->form->process("parser","className") ~~ $self->session->config->get("templateParsers")) {
%data = ( parser => $self->session->form->process("parser","className") );
} else {
%data = ( parser => $self->session->config->get("defaultTemplateParser") );
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/Asset/Wobject/Calendar.pm
Expand Up @@ -275,7 +275,6 @@ sub _workflowIdCommit_builder {
return shift->session->setting->get('defaultVersionTagWorkflow'),
}

use WebGUI::Utility;
use WebGUI::International;
use WebGUI::Search;
use WebGUI::Form;
Expand Down Expand Up @@ -1020,7 +1019,7 @@ override processPropertiesFromFormPost => sub {
my @oldFeeds = map { $_->{feedId} } @{ $self->getFeeds };

for my $feedId (@oldFeeds) {
if (!isIn($feedId, @feedsFromForm)) {
if (! $feedId ~~ @feedsFromForm) {
$self->deleteFeed($feedId);
}
}
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Wobject/Collaboration.pm
Expand Up @@ -459,7 +459,6 @@ use WebGUI::Group;
use WebGUI::HTML;
use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Utility;
use WebGUI::Asset::Wobject;
use WebGUI::Workflow::Cron;

Expand Down Expand Up @@ -1162,7 +1161,7 @@ sub getThreadsPaginator {
$sortBy =~ s/^\w+\.//;
# Sort by the thread rating instead of the post rating. other places don't care about threads.
$sortBy = $sortBy eq 'rating' ? 'threadRating' : $sortBy;
if (! WebGUI::Utility::isIn($sortBy, qw/userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating/)) {
if (! $sortBy ~~ [qw(userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating)]) {
$sortBy = 'revisionDate';
}
if ($sortBy eq 'assetId' || $sortBy eq 'revisionDate') {
Expand Down Expand Up @@ -1477,7 +1476,7 @@ sub recalculateRating {
[$self->getId]
);

my $average = round($sum/$count);
my $average = sprintf '%d', $sum/$count;
$self->update({rating=>$average});
}

Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/Asset/Wobject/Collaboration/Newsletter.pm
Expand Up @@ -63,7 +63,6 @@ sub _newsletterCategories_options {

use WebGUI::Form;
use WebGUI::International;
use WebGUI::Utility;

#-------------------------------------------------------------------

Expand Down Expand Up @@ -184,7 +183,7 @@ sub www_mySubscriptions {
my @userPrefs = $self->getUserSubscriptions;
foreach my $id (keys %{$meta}) {
my @options = ();
if (isIn($id, split("\n", $self->newsletterCategories))) {
if ($id ~~ split("\n", $self->newsletterCategories)) {
foreach my $option (split("\n", $meta->{$id}{possibleValues})) {
$option =~ s/\s+$//; # remove trailing spaces
next if $option eq ""; # skip blank values
Expand All @@ -194,7 +193,7 @@ sub www_mySubscriptions {
optionForm => WebGUI::Form::checkbox($self->session, {
name => "subscriptions",
value => $preferenceName,
checked => isIn($preferenceName, @userPrefs),
checked => $preferenceName ~~ @userPrefs,
})
});
}
Expand Down

0 comments on commit 00bd89c

Please sign in to comment.