use Module::Find instead of enumerating over the files
This commit is contained in:
parent
568fd0b608
commit
a2757494af
6 changed files with 21 additions and 27 deletions
|
|
@ -7,6 +7,11 @@ upgrading from one version to the next, or even between multiple
|
|||
versions. Be sure to heed the warnings contained herein as they will
|
||||
save you many hours of grief.
|
||||
|
||||
7.6.0
|
||||
--------------------------------------------------------------------
|
||||
* WebGUI now requires Module::Find version 0.06 or greater.
|
||||
|
||||
|
||||
7.5.21
|
||||
--------------------------------------------------------------------
|
||||
* Previous versions of WebGUI used the wrong day of the week for
|
||||
|
|
|
|||
|
|
@ -564,11 +564,8 @@ sub getLineageSql {
|
|||
my $tables = "asset left join assetData on asset.assetId=assetData.assetId ";
|
||||
if (exists $rules->{joinClass}) {
|
||||
my $className = $rules->{joinClass};
|
||||
my $file = $className;
|
||||
$file =~ s{::}{/}g;
|
||||
$file .= '.pm';
|
||||
if (!exists $INC{ $file }) { ##Alread loaded?
|
||||
eval{ require $file };
|
||||
(my $module = $className . '.pm') =~ s{::|'}{/}g;
|
||||
if ( ! eval { require $module; 1 }) {
|
||||
$self->session->errorHandler->fatal("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
|
||||
}
|
||||
foreach my $definition (@{$className->definition($self->session)}) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use Tie::IxHash;
|
|||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
use Module::Find qw(findsubmod);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -112,15 +113,15 @@ sub getTypes {
|
|||
my $self = shift;
|
||||
my @types = @{$self->get('types')};
|
||||
unless (scalar(@types)) {
|
||||
opendir(DIR,$self->session->config->getWebguiRoot."/lib/WebGUI/Form/");
|
||||
foreach my $type (readdir(DIR)) {
|
||||
if ($type =~ s/^(.*)\.pm$/$1/) {
|
||||
if (WebGUI::Pluggable::instanciate('WebGUI::Form::'.ucfirst($type),'isDynamicCompatible')) {
|
||||
my @classes = findsubmod 'WebGUI::Form';
|
||||
for my $class (@classes) {
|
||||
if ($class =~ /^WebGUI::Form::(.*)/) {
|
||||
my $type = $1;
|
||||
if (WebGUI::Pluggable::instanciate($class, 'isDynamicCompatible')) {
|
||||
push @types, $type;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
}
|
||||
my %fields = ();
|
||||
foreach my $type (@types) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package WebGUI::Help::Macros;
|
||||
use strict;
|
||||
use Module::Find qw(findsubmod);
|
||||
|
||||
our $HELP = {
|
||||
|
||||
|
|
@ -7,15 +8,8 @@ our $HELP = {
|
|||
title => 'macros list title',
|
||||
body => sub {
|
||||
my $session = shift;
|
||||
my $dir = join '/', $session->config->getWebguiRoot, "lib", "WebGUI", "Macro";
|
||||
opendir( DIR, $dir ) or $session->errorHandler->fatal("Can't open Macro directory: $dir!");
|
||||
my @macros = ();
|
||||
foreach my $dir (readdir(DIR)) {
|
||||
next unless $dir =~ /\.pm$/;
|
||||
$dir =~ s/\.pm//;
|
||||
push @macros, $dir;
|
||||
}
|
||||
closedir(DIR);
|
||||
my @macroModules = findsubmod 'WebGUI::Macro';
|
||||
my @macros = map { /^WebGUI::Macro::(.*)/; $1 } @macroModules;
|
||||
|
||||
##Build list of enabled macros, by namespace, by reversing session hash:
|
||||
my %configMacros = %{ $session->config->get("macros") };
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package WebGUI::International;
|
|||
use strict qw(vars subs);
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Pluggable;
|
||||
use Module::Find qw(findsubmod);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -185,15 +186,10 @@ Returns a hash reference to the languages installed on this WebGUI system.
|
|||
sub getLanguages {
|
||||
my ($self) = @_;
|
||||
my $hashRef;
|
||||
my $dir = $self->session->config->getWebguiRoot."/lib/WebGUI/i18n";
|
||||
opendir my $dh, $dir or $self->session->errorHandler->fatal("Can't open I18N directory! ".$dir);
|
||||
while (my $file = readdir($dh)) {
|
||||
next
|
||||
unless $file =~ s/\.pm$//;
|
||||
my $language = $file;
|
||||
$hashRef->{$language} = $self->getLanguage($language, "label");
|
||||
for my $lang ( findsubmod 'WebGUI::i18n' ) {
|
||||
$lang =~ s/^WebGUI::i18n:://;
|
||||
$hashRef->{$lang} = $self->getLanguage($lang, "label");
|
||||
}
|
||||
closedir $dh;
|
||||
return $hashRef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ checkModule("Path::Class", '0.16' );
|
|||
checkModule("Exception::Class", "1.23" );
|
||||
checkModule("List::MoreUtils", "0.22" );
|
||||
checkModule("File::Path", "2.04" );
|
||||
checkModule("Module::Find", "0.06" );
|
||||
|
||||
|
||||
###################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue