Commit 813ab059 authored by Jesse Vincent's avatar Jesse Vincent
Browse files

r65972@h4605972a:  jesse | 2007-08-15 17:18:11 -0700
checkpoint
r65973@h4605972a:  jesse | 2007-08-16 15:34:36 -0700
 * checkpoint
r65984@h4605972a:  jesse | 2007-08-16 17:06:38 -0700
 * checkpoint
r65985@h4605972a:  jesse | 2007-08-16 17:07:41 -0700
checkpoint
r65986@h4605972a:  jesse | 2007-08-16 17:08:27 -0700
checkpoint
parent 88a23041
---
abstract: RT Extension-FormTools Extension
distribution_type: module
generated_by: Module::Install version 0.67
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
name: RT-Extension-FormTools
no_index:
directory:
- etc
- html
- inc
- t
version: undef
This diff is collapsed.
use inc::Module::Install;
RTx('RT-Extension-FormTools');
WriteAll();
<%args>
$name
$label => undef
$render_as => 'normal'
$default => undef
$cols => undef
$empty_allowed => 1
</%args>
<%init>
my $NamePrefix = "Object-RT::Ticket--CustomField-";
my $queue = $m->notes('queue');
my $field_type = 'custom';
my $field_label ||= $label;
my $cf;
if ( $name =~ /^(Requestors|Cc|AdminCc|Subject)$/i ) {
$field_type = 'core';
$m->notes(
core_fields_on_page => ( $m->notes('core_fields_on_page'), $name ) );
$field_label ||= $name;
} else {
$cf = RT::CustomField->new( $session{'CurrentUser'} );
$cf->LoadByName( Name => $name, Queue => $queue->id );
unless ( $cf->id ) {
die "Could not find a custom field called $name for the queue "
. $queue->Name;
}
$m->notes( cfs_on_page => ( $m->notes('cfs_on_page'), $cf->id ) );
$field_label ||= $cf->Name;
}
</%init>
<table style="display: inline; "><tr><th valign="top"><label><%$field_label%></label></th><td style="display:block;">
% if ($field_type eq 'core') {
<input type="text" name=<%$name%> size="20" value="<%$default%>">
% } else {
% if ($render_as eq 'normal') {
<& /Elements/EditCustomField, Object => $queue, CustomField => $cf, NamePrefix => $NamePrefix,
($cf->Type =~ /text/i) ? (Rows => 6, Cols => $cols ||60) : (),
($cf->Type =~ /freeform/i) ? (Rows => 6, Cols => $cols ||30) : (),
&>
% } elsif ($render_as =~ /^radio/) {
% my $selected = 0;
% my $id = $NamePrefix . $cf->Id;
% if ($empty_allowed) {
<input type="radio" name="<%$id%>-Values" value="" <% !$default ? 'CHECKED' : '' %>><&|/l&>(no value)</&>
% if ($render_as =~ /vertical/) {
<br/>
% }
% }
% my $CFVs = $cf->Values;
% while ($CFVs and my $value = $CFVs->Next ) {
<input type="radio" name="<%$id%>-Values" value="<%$value->Name%>"
% if ($default) {
<% ($default eq $value->Name) ? 'CHECKED' : '' %>
% }
><% $value->Name%>
% if ($render_as =~ /vertical/) {
<br/>
% }
% }
% } elsif ($render_as =~ /^check/i) {
% my $id = $NamePrefix . $cf->Id;
% my $CFVs = $cf->Values;
% while ($CFVs and my $value = $CFVs->Next ) {
<input type="checkbox" name="<%$id%>-Values" value="<%$value->Name%>"
% if ($default) {
<% ($default eq $value->Name) ? 'CHECKED' : '' %>
% }
><% $value->Name%><br/>
% }
% } else {
% die "'$render_as' isn't a valid rendering option for field '$name'";
%}
% }
</td></tr></table>
<%args>
$next
</%args>
<%init>
my $content = $m->content;
my %cfs = map { $_ => 1} $m->notes('cfs_on_page') || ();
my %core_fields = map { $_ => 1} $m->notes('core_fields_on_page') || ();
my %request_args = $m->request_args;
foreach my $key (keys %request_args) {
next unless ($key =~ /CustomField-(\d+)/ );
my $cf = $1;
delete $request_args{$key} if ($cfs{$cf});
}
foreach my $key (keys %request_args) {
next unless ($key =~ /CoreField-(\d+)/ );
my $field = $1;
delete $request_args{$key} if ($core_fields{$field});
}
</%init>
<& /Elements/Header, Title => $m->notes('page_title') &>
<& /Elements/PageLayout, title => $m->notes('page_title') &>
<form method="POST" action="<%$next%>">
<%$content|n%>
% foreach my $key (keys %request_args) {
% foreach my $val ( ref ($request_args{$key}) ? @{$request_args{$key}} : ($request_args{$key})) {
<input type="hidden" name="<%$key%>" value="<%$val%>" />
% }
% }
</form>
<& /Elements/Submit &>
<%init>
my $queue = $m->notes('queue');
my %all_fields = $m->request_args;
</%init>
<table>
% foreach my $field (keys %all_fields) {
% next if $field =~ /-Magic/;
% my $cf = RT::CustomField->new($session{'CurrentUser'});
% if ($field =~ /CustomField-(\d+)/) {
% my $id = $1;
%$cf->Load($id);
<tr><td><b><%$cf->Name%></b></td><td><% ref ($all_fields{$field}) ? join(', ',@{$all_fields{$field}}) : $all_fields{$field}%></td></tr>
% } else {
<tr><td><b><%$field%></b></td><td><% $all_fields{$field} %></td></tr>
%}
% }
</table>
#line 1
package Module::Install;
# For any maintainers:
# The load order for Module::Install is a bit magic.
# It goes something like this...
#
# IF ( host has Module::Install installed, creating author mode ) {
# 1. Makefile.PL calls "use inc::Module::Install"
# 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install
# 3. The installed version of inc::Module::Install loads
# 4. inc::Module::Install calls "require Module::Install"
# 5. The ./inc/ version of Module::Install loads
# } ELSE {
# 1. Makefile.PL calls "use inc::Module::Install"
# 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
# 3. The ./inc/ version of Module::Install loads
# }
use 5.004;
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
$VERSION = '0.67';
}
# Whether or not inc::Module::Install is actually loaded, the
# $INC{inc/Module/Install.pm} is what will still get set as long as
# the caller loaded module this in the documented manner.
# If not set, the caller may NOT have loaded the bundled version, and thus
# they may not have a MI version that works with the Makefile.PL. This would
# result in false errors or unexpected behaviour. And we don't want that.
my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
unless ( $INC{$file} ) {
die <<"END_DIE";
Please invoke ${\__PACKAGE__} with:
use inc::${\__PACKAGE__};
not:
use ${\__PACKAGE__};
END_DIE
}
# If the script that is loading Module::Install is from the future,
# then make will detect this and cause it to re-run over and over
# again. This is bad. Rather than taking action to touch it (which
# is unreliable on some platforms and requires write permissions)
# for now we should catch this and refuse to run.
if ( -f $0 and (stat($0))[9] > time ) {
die << "END_DIE";
Your installer $0 has a modification time in the future.
This is known to create infinite loops in make.
Please correct this, then run $0 again.
END_DIE
}
use Cwd ();
use File::Find ();
use File::Path ();
use FindBin;
*inc::Module::Install::VERSION = *VERSION;
@inc::Module::Install::ISA = __PACKAGE__;
sub autoload {
my $self = shift;
my $who = $self->_caller;
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
unshift @_, ($self, $1);
goto &{$self->can('call')} unless uc($1) eq $1;
};
}
sub import {
my $class = shift;
my $self = $class->new(@_);
my $who = $self->_caller;
unless ( -f $self->{file} ) {
require "$self->{path}/$self->{dispatch}.pm";
File::Path::mkpath("$self->{prefix}/$self->{author}");
$self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
$self->{admin}->init;
@_ = ($class, _self => $self);
goto &{"$self->{name}::import"};
}
*{"${who}::AUTOLOAD"} = $self->autoload;
$self->preload;
# Unregister loader and worker packages so subdirs can use them again
delete $INC{"$self->{file}"};
delete $INC{"$self->{path}.pm"};
}
sub preload {
my ($self) = @_;
unless ( $self->{extensions} ) {
$self->load_extensions(
"$self->{prefix}/$self->{path}", $self
);
}
my @exts = @{$self->{extensions}};
unless ( @exts ) {
my $admin = $self->{admin};
@exts = $admin->load_all_extensions;
}
my %seen;
foreach my $obj ( @exts ) {
while (my ($method, $glob) = each %{ref($obj) . '::'}) {
next unless $obj->can($method);
next if $method =~ /^_/;
next if $method eq uc($method);
$seen{$method}++;
}
}
my $who = $self->_caller;
foreach my $name ( sort keys %seen ) {
*{"${who}::$name"} = sub {
${"${who}::AUTOLOAD"} = "${who}::$name";
goto &{"${who}::AUTOLOAD"};
};
}
}
sub new {
my ($class, %args) = @_;
# ignore the prefix on extension modules built from top level.
my $base_path = Cwd::abs_path($FindBin::Bin);
unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
delete $args{prefix};
}
return $args{_self} if $args{_self};
$args{dispatch} ||= 'Admin';
$args{prefix} ||= 'inc';
$args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
$args{bundle} ||= 'inc/BUNDLES';
$args{base} ||= $base_path;
$class =~ s/^\Q$args{prefix}\E:://;
$args{name} ||= $class;
$args{version} ||= $class->VERSION;
unless ( $args{path} ) {
$args{path} = $args{name};
$args{path} =~ s!::!/!g;
}
$args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
bless( \%args, $class );
}
sub call {
my ($self, $method) = @_;
my $obj = $self->load($method) or return;
splice(@_, 0, 2, $obj);
goto &{$obj->can($method)};
}
sub load {
my ($self, $method) = @_;
$self->load_extensions(
"$self->{prefix}/$self->{path}", $self
) unless $self->{extensions};
foreach my $obj (@{$self->{extensions}}) {
return $obj if $obj->can($method);
}
my $admin = $self->{admin} or die <<"END_DIE";
The '$method' method does not exist in the '$self->{prefix}' path!
Please remove the '$self->{prefix}' directory and run $0 again to load it.
END_DIE
my $obj = $admin->load($method, 1);
push @{$self->{extensions}}, $obj;
$obj;
}
sub load_extensions {
my ($self, $path, $top) = @_;
unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
unshift @INC, $self->{prefix};
}
foreach my $rv ( $self->find_extensions($path) ) {
my ($file, $pkg) = @{$rv};
next if $self->{pathnames}{$pkg};
local $@;
my $new = eval { require $file; $pkg->can('new') };
unless ( $new ) {
warn $@ if $@;
next;
}
$self->{pathnames}{$pkg} = delete $INC{$file};
push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
}
$self->{extensions} ||= [];
}
sub find_extensions {
my ($self, $path) = @_;
my @found;
File::Find::find( sub {
my $file = $File::Find::name;
return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
my $subpath = $1;
return if lc($subpath) eq lc($self->{dispatch});
$file = "$self->{path}/$subpath.pm";
my $pkg = "$self->{name}::$subpath";
$pkg =~ s!/!::!g;
# If we have a mixed-case package name, assume case has been preserved
# correctly. Otherwise, root through the file to locate the case-preserved
# version of the package name.
if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
open PKGFILE, "<$subpath.pm" or die "find_extensions: Can't open $subpath.pm: $!";
my $in_pod = 0;
while ( <PKGFILE> ) {
$in_pod = 1 if /^=\w/;
$in_pod = 0 if /^=cut/;
next if ($in_pod || /^=cut/); # skip pod text
next if /^\s*#/; # and comments
if ( m/^\s*package\s+($pkg)\s*;/i ) {
$pkg = $1;
last;
}
}
close PKGFILE;
}
push @found, [ $file, $pkg ];
}, $path ) if -d $path;
@found;
}
sub _caller {
my $depth = 0;
my $call = caller($depth);
while ( $call eq __PACKAGE__ ) {
$depth++;
$call = caller($depth);
}
return $call;
}
1;
#line 1
package Module::Install::Base;
$VERSION = '0.67';
# Suspend handler for "redefined" warnings
BEGIN {
my $w = $SIG{__WARN__};
$SIG{__WARN__} = sub { $w };
}
### This is the ONLY module that shouldn't have strict on
# use strict;
#line 41
sub new {
my ($class, %args) = @_;
foreach my $method ( qw(call load) ) {
*{"$class\::$method"} = sub {
shift()->_top->$method(@_);
} unless defined &{"$class\::$method"};
}
bless( \%args, $class );
}
#line 61
sub AUTOLOAD {
my $self = shift;
local $@;
my $autoload = eval { $self->_top->autoload } or return;
goto &$autoload;
}
#line 76
sub _top { $_[0]->{_top} }
#line 89
sub admin {
$_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new;
}
sub is_admin {
$_[0]->admin->VERSION;
}
sub DESTROY {}
package Module::Install::Base::FakeAdmin;
my $Fake;
sub new { $Fake ||= bless(\@_, $_[0]) }
sub AUTOLOAD {}
sub DESTROY {}
# Restore warning handler
BEGIN {
$SIG{__WARN__} = $SIG{__WARN__}->();
}
1;
#line 138
#line 1
package Module::Install::Can;
use strict;
use Module::Install::Base;
use Config ();
### This adds a 5.005 Perl version dependency.
### This is a bug and will be fixed.
use File::Spec ();
use ExtUtils::MakeMaker ();
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
$VERSION = '0.67';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
# check if we can load some module
### Upgrade this to not have to load the module if possible
sub can_use {
my ($self, $mod, $ver) = @_;
$mod =~ s{::|\\}{/}g;
$mod .= '.pm' unless $mod =~ /\.pm$/i;
my $pkg = $mod;
$pkg =~ s{/}{::}g;
$pkg =~ s{\.pm$}{}i;
local $@;
eval { require $mod; $pkg->VERSION($ver || 0); 1 };
}
# check if we can run some command
sub can_run {
my ($self, $cmd) = @_;
my $_cmd = $cmd;
return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
my $abs = File::Spec->catfile($dir, $_[1]);
return $abs if (-x $abs or $abs = MM->maybe_command($abs));
}
return;
}
# can we locate a (the) C compiler
sub can_cc {
my $self = shift;
my @chunks = split(/ /, $Config::Config{cc}) or return;
# $Config{cc} may contain args; try to find out the program part
while (@chunks) {
return $self->can_run("@chunks") || (pop(@chunks), next);
}
return;
}
# Fix Cygwin bug on maybe_command();
if ( $^O eq 'cygwin' ) {
require ExtUtils::MM_Cygwin;
require ExtUtils::MM_Win32;
if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
*ExtUtils::MM_Cygwin::maybe_command = sub {
my ($self, $file) = @_;
if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
ExtUtils::MM_Win32->maybe_command($file);
} else {
ExtUtils::MM_Unix->maybe_command($file);
}
}
}
}
1;
__END__
#line 157
#line 1
package Module::Install::Fetch;
use strict;
use Module::Install::Base;
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
$VERSION = '0.67';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}