[interchange-cvs] interchange - heins modified 4 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Sun Feb 3 17:02:01 2002
User: heins
Date: 2002-02-03 22:01:57 GMT
Modified: dist/lib/UI Primitive.pm
Added: code/Widget imagedir.widget imagehelper.widget
Added: uploadhelper.widget
Log:
* Move several widgets outboard into code/Widget.
* These are widgets that have some dependency on foundation/UI
setup and are not really generic.
* Corresponding code removed from UI::Primitive.
Revision Changes Path
2.14 +2 -102 interchange/dist/lib/UI/Primitive.pm
rev 2.14, prev_rev 2.13
Index: Primitive.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/Primitive.pm,v
retrieving revision 2.13
retrieving revision 2.14
diff -u -r2.13 -r2.14
--- Primitive.pm 2 Feb 2002 17:25:47 -0000 2.13
+++ Primitive.pm 3 Feb 2002 22:01:57 -0000 2.14
@@ -1,6 +1,6 @@
# UI::Primitive - Interchange configuration manager primitives
-# $Id: Primitive.pm,v 2.13 2002/02/02 17:25:47 mheins Exp $
+# $Id: Primitive.pm,v 2.14 2002/02/03 22:01:57 mheins Exp $
# Copyright (C) 1998-2001 Red Hat, Inc. <interchange@redhat.com>
@@ -25,7 +25,7 @@
package UI::Primitive;
-$VERSION = substr(q$Revision: 2.13 $, 10);
+$VERSION = substr(q$Revision: 2.14 $, 10);
$DEBUG = 0;
@@ -622,70 +622,6 @@
return 1;
}
-sub uploadhelper_widget {
- # $column, $value, $record->{outboard}, $record->{width}
- my ($name, $val, $path, $size) = @_;
-
- $path =~ s:^/+::;
- my $view_url;
- $size = qq{ SIZE="$size"} if $size > 0;
- my $out = '';
- if ($val) {
- if($path) {
- my $base = $::Variable->{UI_BASE} || 'admin';
- my $view_url = Vend::Interpolate::tag_area("$base/do_view", "$path/$val");
- $out .= qq{<A HREF="$view_url">};
- }
- $out .= $val;
- $out .= "</A>" if $path;
- $out .= qq{ <INPUT TYPE=file NAME="$name" VALUE="$val">
-<INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
-<INPUT TYPE=hidden NAME="$name" VALUE="$val">};
- }
- else {
- $out = qq{<INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
-<INPUT TYPE=file NAME="$name"$size>};
- }
- return $out;
-}
-
-sub imagehelper_widget {
- my ($name, $val, $path, $imagebase, $size) = @_;
-
- Vend::Interpolate::vars_and_comments(\$path);
- Vend::Interpolate::vars_and_comments(\$imagebase);
- if ($imagebase ||= '') {
- $imagebase =~ s/^\s+//;
- $imagebase =~ s:[\s/]*$:/:;
- }
-
- my $of_widget;
- if($path =~ s!/\*(?:\.([^/]+))?$!!) {
- my $spec = $1;
- my @files = list_images($path, $spec);
- unshift(@files, "=(none)");
- my $passed = join ",", map { s/,/,/g; $_} @files;
- my $opt = {
- type => 'select',
- default => $val,
- attribute => 'mv_data_file_oldfile',
- passed => $passed,
- };
- $of_widget = Vend::Interpolate::tag_accessories(
- undef, undef, $opt, { 'mv_data_file_oldfile' => $val } );
- }
- else {
- $of_widget = qq{<INPUT TYPE=hidden NAME=mv_data_file_oldfile VALUE="$val">};
- }
- $size = qq{ SIZE="$size"} if $size > 0;
- if ($val) {
- qq{<A HREF="$imagebase$path/$val">$val</A> <INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name">
-<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name" VALUE="$val">};
- } else {
- qq{<INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name">
-<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name"$size>};
- }
-}
sub meta_record {
my ($item, $view, $mtable) = @_;
@@ -882,42 +818,6 @@
return $w unless $o->{template};
return ($w, $record->{label}, $record->{help}, $record->{help_url});
}
- elsif ($record->{type} eq 'imagedir') {
- my $dir = $record->{'outboard'} || $column;
- my $suf;
- if($record->{options}) {
- $suf = $record->{options};;
- if($suf !~ /[\.|]/) {
- my @types = grep /\S/, split /[,\s\0]+/, $suf;
- $suf = '\.(' . join("|", @types) . ')';
- }
- }
- my @files = list_images($dir, $suf);
- $record->{type} = 'combo';
- $record->{passed} = join ",",
- map { s/,/,/g; $_} @files;
- }
- elsif ($record->{type} eq 'imagehelper') {
- my $w = imagehelper_widget(
- $record->{name},
- $value,
- $record->{outboard},
- $record->{prepend},
- $record->{width},
- );
- return $w unless $o->{template};
- return ($w, $record->{label}, $record->{help}, $record->{help_url});
- }
- elsif ($record->{type} eq 'uploadhelper') {
- my $w = uploadhelper_widget(
- $record->{name},
- $value,
- $record->{outboard},
- $record->{width},
- );
- return $w unless $o->{template};
- return ($w, $record->{label}, $record->{help}, $record->{help_url});
- }
for(qw/append prepend/) {
next unless $record->{$_};
1.1 interchange/code/Widget/imagedir.widget
rev 1.1, prev_rev 1.0
Index: imagedir.widget
===================================================================
CodeDef imagedir Widget 1
CodeDef imagedir Routine <<EOR
use File::Find;
sub {
my ($opt) = @_;
my $dir = delete $opt->{dir} || delete $opt->{outboard};
my $suf = delete $opt->{suffix} || delete $opt->{options};
return undef unless -d $dir;
#::logDebug("passed suf=$suf");
$suf = '\.(GIF|gif|JPG|JPEG|jpg|jpeg|png|PNG)'
unless $suf;
if($suf and $suf !~ /[\.|]/) {
my @types = grep /\S/, split /[,\s\0]+/, $suf;
$suf = '\.(' . join("|", @types) . ')';
}
my @names;
my $regex;
eval {
$regex = qr{$suf$}o;
};
return undef if $@;
my $wanted = sub {
return undef unless -f $_;
return undef unless $_ =~ $regex;
my $n = $File::Find::name;
$n =~ s:^$dir/?::;
push(@names, $n);
};
find($wanted, $dir);
$opt->{passed} = [ sort @names ];
$opt->{type} = delete $opt->{variant} || 'combo';
return Vend::Form::display($opt);
}
EOR
1.1 interchange/code/Widget/imagehelper.widget
rev 1.1, prev_rev 1.0
Index: imagehelper.widget
===================================================================
CodeDef imagehelper Widget 1
CodeDef imagehelper Routine <<EOR
sub {
my ($opt) = @_;
my $name = $opt->{name};
my $size = $opt->{cols} || $opt->{width};
my $val = $opt->{value};
my $path = $opt->{image_path} || $opt->{outboard};
my $imagebase = $opt->{image_base} || $opt->{prepend};
Vend::Interpolate::vars_and_comments(\$path);
Vend::Interpolate::vars_and_comments(\$imagebase);
if ($imagebase ||= '') {
$imagebase =~ s/^\s+//;
$imagebase =~ s:[\s/]*$:/:;
}
my $of_widget;
if($path =~ s!/\*(?:\.([^/]+))?$!!) {
my $spec = $1;
my @files = list_images($path, $spec);
unshift(@files, "=(none)");
my $passed = join ",", map { s/,/,/g; $_} @files;
my $opt = {
type => 'select',
default => $val,
attribute => 'mv_data_file_oldfile',
passed => $passed,
};
$of_widget = Vend::Interpolate::tag_accessories(
undef, undef, $opt, { 'mv_data_file_oldfile' => $val } );
}
else {
$of_widget = qq{<INPUT TYPE=hidden NAME=mv_data_file_oldfile VALUE="$val">};
}
$size = qq{ SIZE="$size"} if $size > 0;
if ($val) {
qq{<A HREF="$imagebase$path/$val">$val</A> <INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name">
<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name" VALUE="$val">};
} else {
qq{<INPUT TYPE=hidden NAME=mv_data_file_field VALUE="$name">
<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="$path">$of_widget<INPUT TYPE=file NAME="$name"$size>};
}
}
EOR
1.1 interchange/code/Widget/uploadhelper.widget
rev 1.1, prev_rev 1.0
Index: uploadhelper.widget
===================================================================
CodeDef uploadhelper Widget 1
CodeDef uploadhelper Routine <<EOR
sub {
# $column, $value, $record->{outboard}, $record->{width}
my ($opt) = @_;
my $name = $opt->{name};
my $val = $opt->{value};
my $path = $opt->{path} || $opt->{outboard};
my $size = $opt->{cols} || $opt->{width};
$path =~ s:^/+::;
my $view_url;
$size = qq{ SIZE="$size"} if $size > 0;
my $out = '';
if ($val) {
if($path) {
my $base = $::Variable->{UI_BASE} || 'admin';
my $view_url = Vend::Interpolate::tag_area("$base/do_view", "$path/$val");
$out .= qq{<A HREF="$view_url">};
}
$out .= $val;
$out .= "</A>" if $path;
$out .= qq{ <INPUT TYPE=file NAME="$name" VALUE="$val">
<INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
<INPUT TYPE=hidden NAME="$name" VALUE="$val">};
}
else {
$out = qq{<INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
<INPUT TYPE=file NAME="$name"$size>};
}
return $out;
}
EOR