From 1d85697da1f7dad7f3a305b9cc9f5b0d33bf7250 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 2 May 2012 23:06:55 -0700 Subject: [PATCH] Start of work on UI lib conversion --- mount/edit_mount.cgi | 105 +++++++++++++++++++----------------------- mount/freebsd-lib.pl | 8 ++-- mount/hpux-lib.pl | 4 +- mount/irix-lib.pl | 4 +- mount/lang/en | 9 ++-- mount/linux-lib.pl | 70 ++++++++++++++-------------- mount/mount-lib.pl | 12 +++-- mount/netbsd-lib.pl | 4 +- mount/openbsd-lib.pl | 4 +- mount/osf1-lib.pl | 12 ++--- mount/solaris-lib.pl | 12 ++--- mount/unixware-lib.pl | 12 ++--- 12 files changed, 124 insertions(+), 132 deletions(-) diff --git a/mount/edit_mount.cgi b/mount/edit_mount.cgi index 0bd99b303..cee5fb05d 100755 --- a/mount/edit_mount.cgi +++ b/mount/edit_mount.cgi @@ -38,24 +38,22 @@ else { $msave = ($mmodes[0]==0 ? 0 : $msave); $mnow = ($mmodes[1]==0 ? $msave : $mnow); -print "
\n"; -print "\n"; +# Start of the form +print &ui_form_start("save_mount.cgi", "post"); +print &ui_hidden("return", $in{'return'}); if (!$newm) { - print "\n"; - print "\n"; - - print "\n"; - print "\n"; + print &ui_hidden("old", $in{'index'}); + print &ui_hidden("temp", $in{'temp'}); + print &ui_hidden("oldmnow", $mnow); + print &ui_hidden("oldmsave", $msave); } -print "\n"; -print "\n"; -print "\n"; -print "
",&text('edit_header', &fstype_name($type)), - "
\n"; +print &ui_hidden("type", $in{'type'}); +print &ui_table_start(&text('edit_header', &fstype_name($type)), + "width=100%", 2); -print "\n"; +# Mount point if ($type eq "swap") { - print "\n", - &nice_size($free*1024); + print &ui_table_row($text{'edit_usage'}, + "$text{'edit_size'} ", + &nice_size($size*1024)," ", + "$text{'edit_free'} ", + &nice_size($free*1024)); } -print "\n"; # Show save mount options if ($mmodes[0] != 0 && !$access{'simple'}) { - print "\n"; + print &ui_table_row($text{'edit_savemount'}, + &ui_radio("msave", $minfo[5] eq "yes" || $newm ? 2 : + $minfo[5] eq "no" ? 1 : + $minfo[5] eq "" && !$newm ? 0 : undef, + \@opts)); } # Show mount now options if ($mmodes[1] == 1 && ($mmodes[3] == 0 || !$mnow) && !$access{'simple'}) { - print "\n"; + print &ui_table_row($text{'edit_now'}, + &ui_radio("mmount", $mnow || $newm ? 1 : 0, + [ [ 1, $text{'edit_mount'} ], + [ 0, $mmodes[0] == 0 ? $text{'edit_delete'} : + $newm ? $text{'edit_dont2'} : + $text{'edit_unmount'} ] ])); } # Show fsck order options if ($mmodes[2] && !$access{'simple'}) { - print "\n"; - printf "\n"; + $second = $minfo[4] > 1 ? $minfo[4] : 2; + print &ui_table_row($text{'edit_order'}, + &ui_radio("order", $newm || $minfo[4] == 0 ? 0 : + $minfo[4] == 1 ? 1 : + $second, + [ [ 0, $text{'no'} ], + [ 1, $text{'edit_first'} ], + [ $second, $text{'edit_second'} ] ])); } # Show filesystem-specific mount source &generate_location($type, $minfo[1] || $in{'newdev'}); -print "
",&hlink("$text{'edit_dir'}", "edit_dir"), "$text{'edit_swap'}\n"; + $mfield = "$text{'edit_swap'}"; } else { local $dir = $minfo[0] || $in{'newdir'}; @@ -63,76 +61,67 @@ else { # Make relative to first allowed dir $dir =~ s/^$access_fs[0]\///; } - print "\n"; + $mfield = &ui_textbox("directory", $dir, 40); if ($access{'browse'}) { - print &file_chooser_button("directory", 1); + $mfield .= " ".&file_chooser_button("directory", 1); } } +print &ui_table_row(&hlink($text{'edit_dir'}, "edit_dir"), + $mfield); + +# Total and free space if (!$newm && (($size,$free) = &disk_space($type, $minfo[0]))) { - print " " x 8; - printf "$text{'edit_size'} %s / \n", - &nice_size($size*1024); - printf "$text{'edit_free'} %s
$text{'edit_savemount'} \n"; - printf " $text{'edit_boot'}\n", - $minfo[5] eq "yes" || $newm ? "checked" : ""; + @opts = ( [ 2, $text{'edit_boot'} ] ); if ($mmodes[0] != 1) { - printf " %s\n", - $minfo[5] eq "no" ? "checked" : "", $text{'edit_save'}; + push(@opts, [ 1, $text{'edit_save'} ]); } if (!$newm && $mmodes[1] == 0) { - printf " %s\n", - $minfo[5] eq "" && !$newm ? "checked" : "", - $text{'edit_delete'}; + push(@opts, [ 0, $text{'edit_delete'} ]); } else { - printf " %s\n", - $minfo[5] eq "" && !$newm ? "checked" : "", - $text{'edit_dont'}; + push(@opts, [ 0, $text{'edit_dont'} ]); } - print "
$text{'edit_now'} \n"; - printf " %s\n", - $mnow || $newm ? "checked" : "", $text{'edit_mount'}; - if ($mmodes[0] == 0) { - printf " %s\n", - $mnow || $newm ? "" : "checked", $text{'edit_delete'}; - } - else { - printf " %s\n", - $mnow || $newm ? "" : "checked", - $newm ? $text{'edit_dont2'} : $text{'edit_unmount'}; - } - print "
$text{'edit_order'} %s\n", - $newm || $minfo[4] == 0 ? "checked" : "", $text{'no'}; - printf " %s\n", - $minfo[4] == 1 ? "checked" : "", $text{'edit_first'}; - printf " %s 1 ? $minfo[4] : 2 , $minfo[4] > 1 ? "checked" : "", - $text{'edit_second'}; - print "

\n"; +print &ui_table_end(); if (!$access{'simple'} || !defined($access{'opts'}) || $access{'opts'} =~ /$type/) { diff --git a/mount/freebsd-lib.pl b/mount/freebsd-lib.pl index 5029038f3..b8b8a4ee2 100755 --- a/mount/freebsd-lib.pl +++ b/mount/freebsd-lib.pl @@ -379,11 +379,11 @@ if ($_[0] eq "nfs") { $_[1] =~ /^([^:]+):(.*)$/; print " NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } elsif ($_[0] eq "smbfs") { @@ -391,11 +391,11 @@ elsif ($_[0] eq "smbfs") { $_[1] =~ /^\\\\(.*)\\(.*)$/; print " $text{'linux_smbserver'}\n"; print "\n"; - &smb_server_chooser_button("smbfs_server"); + print &smb_server_chooser_button("smbfs_server"); print "\n"; print "$text{'linux_smbshare'}\n"; print "\n"; - &smb_share_chooser_button("smbfs_server", "smbfs_share"); + print &smb_share_chooser_button("smbfs_server", "smbfs_share"); print " \n"; } else { diff --git a/mount/hpux-lib.pl b/mount/hpux-lib.pl index b66c76774..f01fa017b 100755 --- a/mount/hpux-lib.pl +++ b/mount/hpux-lib.pl @@ -312,11 +312,11 @@ if ($_[0] eq "nfs") { $onenfs = !$_[1] || $_[1] =~ /^([A-z0-9\-\.]+):([^,]+)$/; print " NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } elsif ($_[0] eq "hfs") { diff --git a/mount/irix-lib.pl b/mount/irix-lib.pl index 26219d8c3..23460cb6b 100755 --- a/mount/irix-lib.pl +++ b/mount/irix-lib.pl @@ -350,11 +350,11 @@ if ($_[0] eq "nfs") { local ($nfshost, $nfspath) = $_[1] =~ /^([^:]+):(.*)/ ? ( $1, $2 ) : (); print " $text{'irix_nhost'}\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "$text{'irix_ndir'}\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } elsif ($_[0] eq "autofs") { diff --git a/mount/lang/en b/mount/lang/en index 6b0476ed3..1478f9804 100644 --- a/mount/lang/en +++ b/mount/lang/en @@ -18,11 +18,12 @@ create_title=Create Mount edit_err=Failed to edit mount edit_egone=This mount no longer exists edit_header=$1 Mount Details -edit_dir=Mounted As +edit_dir=Mounted as +edit_usage=Disk usage edit_swap=Virtual Memory edit_size=Size edit_free=Free -edit_savemount=Save Mount? +edit_savemount=Save mount? edit_boot=Save and mount at boot edit_save=Save edit_delete=Delete @@ -32,8 +33,8 @@ edit_mount=Mount edit_dont2=Don't mount edit_unmount=Unmount edit_order=Check filesystem at boot? -edit_first=Check First -edit_second=Check Second +edit_first=Check first +edit_second=Check second edit_adv=Mount Options edit_comm_opt=Common mount options edit_ext_opt=ext2/ext3 specific options diff --git a/mount/linux-lib.pl b/mount/linux-lib.pl index 4cdd51328..cd4827cb4 100755 --- a/mount/linux-lib.pl +++ b/mount/linux-lib.pl @@ -986,33 +986,32 @@ return ($_[0] eq "nfs" || $_[0] eq "nfs4" || $_[0] eq "auto" || # Output HTML for editing the mount location of some filesystem. sub generate_location { -if (($_[0] eq "nfs") || ($_[0] eq "nfs4")) { +local ($type, $loc) = @_; +if ($type eq "nfs" || $type eq "nfs4") { # NFS mount from some host and directory - local ($host, $dir) = $_[1] =~ /^([^:]+):(.*)$/ ? ( $1, $2 ) : ( ); - print " ", &hlink("$text{'linux_nfshost'}", "nfshost"), "\n"; - print "\n"; - &nfs_server_chooser_button("nfs_host"); - print " ", &hlink("$text{'linux_nfsdir'}", "nfsdir"), "\n"; - printf "\n", - ($_[0] eq "nfs4") && ($dir eq "") ? "/" : $dir; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); - print " \n"; + local ($host, $dir) = $loc =~ /^([^:]+):(.*)$/ ? ( $1, $2 ) : ( ); + print &ui_table_row(&hlink($text{'linux_nfshost'}, "nfshost"), + &ui_textbox("nfs_host", $host, 30). + &nfs_server_chooser_button("nfs_host"). + " ". + "".&hlink($text{'linux_nfsdir'}, "nfsdir")." ". + &ui_textbox("nfs_dir", + ($_[0] eq "nfs4") && ($dir eq "") ? "/" : $dir, 30). + &nfs_export_chooser_button("nfs_host", "nfs_dir")); } -elsif ($_[0] eq "auto") { +elsif ($type eq "auto") { # Using some automounter map - print " $text{'linux_map'}\n"; - print "\n"; - print &file_chooser_button("auto_map", 0); - print " \n"; + print &ui_table_row($text{'linux_map'}, + &ui_textbox("auto_map", $loc, 30)." ". + &file_chooser_button("auto_map", 0)); } -elsif ($_[0] eq "autofs") { +elsif ($type eq "autofs") { # Using some kernel automounter map - print " $text{'linux_map'}\n"; - print "\n"; - print &file_chooser_button("autofs_map", 0); - print " \n"; + print &ui_table_row($text{'linux_map'}, + &ui_textbox("autofs_map", $loc, 30)." ". + &file_chooser_button("autofs_map", 0)); } -elsif ($_[0] eq "swap") { +elsif ($type eq "swap") { # Swap file or device &foreign_require("fdisk"); printf " $text{'linux_swapfile'}\n"; @@ -1041,27 +1040,26 @@ elsif ($_[0] eq "swap") { &file_chooser_button("lnx_other"); print " \n"; } -elsif ($_[0] eq $smbfs_fs || $_[0] eq "cifs") { +elsif ($type eq $smbfs_fs || $type eq "cifs") { # Windows filesystem - local ($server, $share) = $_[1] =~ /^\\\\([^\\]*)\\(.*)$/ ? + local ($server, $share) = $loc =~ /^\\\\([^\\]*)\\(.*)$/ ? ($1, $2) : ( ); - print " $text{'linux_smbserver'}\n"; - print "\n"; - &smb_server_chooser_button("smbfs_server"); - print "\n"; - print "$text{'linux_smbshare'}\n"; - print "\n"; - &smb_share_chooser_button("smbfs_server", "smbfs_share"); - print " \n"; + print &ui_table_row($text{'linux_smbserver'}, + &ui_textbox("smbfs_server", $server, 30)." ". + &smb_server_chooser_button("smbfs_server")." ". + " ". + "$text{'linux_smbshare'} ". + &ui_textbox("smbfs_share", $share, 30)." ". + &smb_share_chooser_button("smbfs_server", "smbfs_share")); } -elsif ($_[0] eq "tmpfs") { +elsif ($type eq "tmpfs") { # RAM disk (no location needed) } -elsif ($_[0] eq "bind") { +elsif ($type eq "bind") { # Loopback filesystem, mounted from some other directory - print " $text{'linux_bind'} \n"; - printf " %s \n", - $_[1], &file_chooser_button("bind_dir", 1); + print &ui_table_row($text{'linux_bind'}, + &ui_textbox("bind_dir", $loc, 40)." ". + &file_chooser_button("bind_dir", 1)); } else { # This is some linux disk-based filesystem diff --git a/mount/mount-lib.pl b/mount/mount-lib.pl index 058043a43..be1dce5b7 100755 --- a/mount/mount-lib.pl +++ b/mount/mount-lib.pl @@ -117,8 +117,9 @@ sub nfs_server_chooser_button local($form); $form = @_ > 1 ? $_[1] : 0; if ($access{'browse'}) { - print "\n"; + return "\n"; } +return undef; } # nfs_export_chooser_button(serverinput, exportinput, [form]) @@ -127,8 +128,9 @@ sub nfs_export_chooser_button local($form); $form = @_ > 2 ? $_[2] : 0; if ($access{'browse'}) { - print "\n"; + return "\n"; } +return undef; } # smb_server_chooser_button(serverinput, [form]) @@ -137,8 +139,9 @@ sub smb_server_chooser_button local($form); $form = @_ > 1 ? $_[1] : 0; if (&has_command($config{'smbclient_path'}) && $access{'browse'}) { - print "\n"; + return "\n"; } +return undef; } # smb_share_chooser_button(serverinput, shareinput, [form]) @@ -147,8 +150,9 @@ sub smb_share_chooser_button local($form); $form = @_ > 2 ? $_[2] : 0; if (&has_command($config{'smbclient_path'}) && $access{'browse'}) { - print "\n"; + return "\n"; } +return undef; } # Include the correct OS-specific functions file diff --git a/mount/netbsd-lib.pl b/mount/netbsd-lib.pl index b7a9bef50..2c84829ef 100755 --- a/mount/netbsd-lib.pl +++ b/mount/netbsd-lib.pl @@ -284,11 +284,11 @@ if ($_[0] eq "nfs") { $_[1] =~ /^([^:]+):(.*)$/; print " NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } else { diff --git a/mount/openbsd-lib.pl b/mount/openbsd-lib.pl index d4d051043..6044306e0 100755 --- a/mount/openbsd-lib.pl +++ b/mount/openbsd-lib.pl @@ -285,11 +285,11 @@ if ($_[0] eq "nfs") { $_[1] =~ /^([^:]+):(.*)$/; print " NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } else { diff --git a/mount/osf1-lib.pl b/mount/osf1-lib.pl index 9d4f7985a..8833ad386 100755 --- a/mount/osf1-lib.pl +++ b/mount/osf1-lib.pl @@ -333,10 +333,10 @@ if ($_[0] eq "nfs") { $nfsmode == 0 ? "checked" : ""; print "NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print " NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; print " \n"; @@ -360,11 +360,11 @@ if ($_[0] eq "nfs") { else { print " NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } } @@ -516,11 +516,11 @@ elsif ($_[0] eq "rumba") { $_[1] =~ /^\\\\(.*)\\(.*)$/; print " Server Name\n"; print "\n"; - &smb_server_chooser_button("rumba_server"); + print &smb_server_chooser_button("rumba_server"); print "\n"; print "Share Name\n"; print "\n"; - &smb_share_chooser_button("rumba_server", "rumba_share"); + print &smb_share_chooser_button("rumba_server", "rumba_share"); print " \n"; } } diff --git a/mount/solaris-lib.pl b/mount/solaris-lib.pl index b0fc77a85..b5a2f2c0d 100755 --- a/mount/solaris-lib.pl +++ b/mount/solaris-lib.pl @@ -428,10 +428,10 @@ if ($_[0] eq "nfs") { $nfsmode == 0 ? "checked" : ""; print "$text{'solaris_nhost'}\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print " $text{'solaris_ndir'}\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; print " \n"; @@ -455,11 +455,11 @@ if ($_[0] eq "nfs") { else { print " $text{'solaris_nhost'}\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "$text{'solaris_ndir'}\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } } @@ -628,11 +628,11 @@ elsif ($_[0] eq "rumba") { $_[1] =~ /^\\\\(.*)\\(.*)$/; print " $text{'solaris_server'}\n"; print "\n"; - &smb_server_chooser_button("rumba_server"); + print &smb_server_chooser_button("rumba_server"); print "\n"; print "$text{'solaris_share'}\n"; print "\n"; - &smb_share_chooser_button("rumba_server", "rumba_share"); + print &smb_share_chooser_button("rumba_server", "rumba_share"); print " \n"; } } diff --git a/mount/unixware-lib.pl b/mount/unixware-lib.pl index 39f8d2f25..6c61339a7 100755 --- a/mount/unixware-lib.pl +++ b/mount/unixware-lib.pl @@ -411,10 +411,10 @@ if ($_[0] eq "nfs") { $nfsmode == 0 ? "checked" : ""; print "NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print " NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; print " \n"; @@ -438,11 +438,11 @@ if ($_[0] eq "nfs") { else { print " NFS Hostname\n"; print "\n"; - &nfs_server_chooser_button("nfs_host"); + print &nfs_server_chooser_button("nfs_host"); print "\n"; print "NFS Directory\n"; print "\n"; - &nfs_export_chooser_button("nfs_host", "nfs_dir"); + print &nfs_export_chooser_button("nfs_host", "nfs_dir"); print " \n"; } } @@ -633,11 +633,11 @@ elsif ($_[0] eq "rumba") { $_[1] =~ /^\\\\(.*)\\(.*)$/; print " Server Name\n"; print "\n"; - &smb_server_chooser_button("rumba_server"); + print &smb_server_chooser_button("rumba_server"); print "\n"; print "Share Name\n"; print "\n"; - &smb_share_chooser_button("rumba_server", "rumba_share"); + print &smb_share_chooser_button("rumba_server", "rumba_share"); print " \n"; } }