Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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.
- Loading branch information
1 parent
bcc80b8
commit 4e9405e
Showing
4 changed files
with
119 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters