version 1.156, 2006/07/03 11:12:24
|
version 1.159, 2006/12/12 20:41:08
|
Line 486 sub declareVar {
|
Line 486 sub declareVar {
|
$self->{VARS}->{$var} = ''; |
$self->{VARS}->{$var} = ''; |
} |
} |
|
|
my $envname = 'form.' . $var . '.forminput'; |
my $envname = 'form.' . $var . '_forminput'; |
if (defined($env{$envname})) { |
if (defined($env{$envname})) { |
if (ref($env{$envname})) { |
if (ref($env{$envname})) { |
$self->{VARS}->{$var} = join('|||', @{$env{$envname}}); |
$self->{VARS}->{$var} = join('|||', @{$env{$envname}}); |
Line 1023 sub postprocess {
|
Line 1023 sub postprocess {
|
} |
} |
1; |
1; |
|
|
|
package Apache::lonhelper::helpicon; |
|
|
|
=pod |
|
|
|
=head1 Elements |
|
|
|
=head2 Element: helpiconX<helpicon, helper element> |
|
|
|
Helpicon elements add a help icon at the current location. |
|
Example: |
|
|
|
<helpicon file="Help"> |
|
General Help |
|
</helpicon> |
|
|
|
In this example will generate a help icon to the Help.hlp url with a |
|
description of 'General Help'. The description is not required and if |
|
left out (Example: <helpicon file="Help" /> only the icon will be |
|
added.) |
|
|
|
=head3 Localization |
|
|
|
The description text will be run through the normalize_string function |
|
and that will be used as a call to &mt. |
|
|
|
=cut |
|
|
|
no strict; |
|
@ISA = ("Apache::lonhelper::element"); |
|
use strict; |
|
use Apache::lonlocal; |
|
|
|
BEGIN { |
|
&Apache::lonhelper::register('Apache::lonhelper::helpicon', |
|
('helpicon')); |
|
} |
|
|
|
sub new { |
|
my $ref = Apache::lonhelper::element->new(); |
|
bless($ref); |
|
} |
|
|
|
# CONSTRUCTION: Construct the message element from the XML |
|
sub start_helpicon { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
|
if ($target ne 'helper') { |
|
return ''; |
|
} |
|
|
|
$paramHash->{HELP_TEXT} = &mtn(&Apache::lonxml::get_all_text('/helpicon', |
|
$parser)); |
|
|
|
$paramHash->{HELP_TEXT} =~s/^\s+//; |
|
$paramHash->{HELP_TEXT} =~s/\s+$//; |
|
|
|
if (defined($token->[2]{'file'})) { |
|
$paramHash->{HELP_FILE} = $token->[2]{'file'}; |
|
} |
|
return ''; |
|
} |
|
|
|
sub end_helpicon { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
|
if ($target ne 'helper') { |
|
return ''; |
|
} |
|
Apache::lonhelper::helpicon->new(); |
|
return ''; |
|
} |
|
|
|
sub render { |
|
my $self = shift; |
|
|
|
my $text; |
|
if ( $self->{HELP_TEXT} ne '') { |
|
$text=&mtn($text); |
|
} |
|
|
|
return &Apache::loncommon::help_open_topic($self->{HELP_FILE}, |
|
$text); |
|
} |
|
1; |
|
|
package Apache::lonhelper::skip; |
package Apache::lonhelper::skip; |
|
|
=pod |
=pod |
Line 1280 sub render {
|
Line 1365 sub render {
|
function checkall(value, checkName) { |
function checkall(value, checkName) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
ele = document.forms.helpform.elements[i]; |
ele = document.forms.helpform.elements[i]; |
if (ele.name == checkName + '.forminput') { |
if (ele.name == checkName + '_forminput') { |
document.forms.helpform.elements[i].checked=value; |
document.forms.helpform.elements[i].checked=value; |
} |
} |
} |
} |
Line 1353 BUTTONS
|
Line 1438 BUTTONS
|
foreach my $choice (@{$self->{CHOICES}}) { |
foreach my $choice (@{$self->{CHOICES}}) { |
my $id = &new_id(); |
my $id = &new_id(); |
$result .= "<tr>\n<td width='20'> </td>\n"; |
$result .= "<tr>\n<td width='20'> </td>\n"; |
$result .= "<td valign='top'><input type='$type' name='$var.forminput'" |
$result .= "<td valign='top'><input type='$type' name='${var}_forminput'" |
. " value='" . |
. " value='" . |
HTML::Entities::encode($choice->[1],"<>&\"'") |
HTML::Entities::encode($choice->[1],"<>&\"'") |
. "'"; |
. "'"; |
Line 1372 BUTTONS
|
Line 1457 BUTTONS
|
$choiceLabel. "</label></td>"; |
$choiceLabel. "</label></td>"; |
if ($choice->[4]) { |
if ($choice->[4]) { |
$result .='<td><input type="text" size="5" name="' |
$result .='<td><input type="text" size="5" name="' |
.$choice->[4].'.forminput" value="' |
.$choice->[4].'_forminput" value="' |
.$choice->[5].'" /></td>'; |
.$choice->[5].'" /></td>'; |
} |
} |
$result .= "</tr>\n"; |
$result .= "</tr>\n"; |
Line 1387 BUTTONS
|
Line 1472 BUTTONS
|
# given, switch to it |
# given, switch to it |
sub postprocess { |
sub postprocess { |
my $self = shift; |
my $self = shift; |
my $chosenValue = $env{'form.' . $self->{'variable'} . '.forminput'}; |
my $chosenValue = $env{'form.' . $self->{'variable'} . '_forminput'}; |
|
|
if (!defined($chosenValue) && !$self->{'allowempty'}) { |
if (!defined($chosenValue) && !$self->{'allowempty'}) { |
$self->{ERROR_MSG} = |
$self->{ERROR_MSG} = |
Line 1411 sub postprocess {
|
Line 1496 sub postprocess {
|
} |
} |
if ($choice->[4]) { |
if ($choice->[4]) { |
my $varname = $choice->[4]; |
my $varname = $choice->[4]; |
$helper->{'VARS'}->{$varname} = $env{'form.'."$varname.forminput"}; |
$helper->{'VARS'}->{$varname} = $env{'form.'."${varname}_forminput"}; |
} |
} |
} |
} |
return 1; |
return 1; |
Line 1520 sub render {
|
Line 1605 sub render {
|
$checkedChoices{$self->{CHOICES}->[0]->[1]} = 1; |
$checkedChoices{$self->{CHOICES}->[0]->[1]} = 1; |
} |
} |
|
|
$result .= "<select name='${var}.forminput'>\n"; |
$result .= "<select name='${var}_forminput'>\n"; |
foreach my $choice (@{$self->{CHOICES}}) { |
foreach my $choice (@{$self->{CHOICES}}) { |
$result .= "<option value='" . |
$result .= "<option value='" . |
HTML::Entities::encode($choice->[1],"<>&\"'") |
HTML::Entities::encode($choice->[1],"<>&\"'") |
Line 1546 sub render {
|
Line 1631 sub render {
|
# given, switch to it |
# given, switch to it |
sub postprocess { |
sub postprocess { |
my $self = shift; |
my $self = shift; |
my $chosenValue = $env{'form.' . $self->{'variable'} . '.forminput'}; |
my $chosenValue = $env{'form.' . $self->{'variable'} . '_forminput'}; |
|
|
if (!defined($chosenValue) && !$self->{'allowempty'}) { |
if (!defined($chosenValue) && !$self->{'allowempty'}) { |
$self->{ERROR_MSG} = "You must choose one or more choices to" . |
$self->{ERROR_MSG} = "You must choose one or more choices to" . |
Line 2099 sub render {
|
Line 2184 sub render {
|
function checkall(value, checkName) { |
function checkall(value, checkName) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
ele = document.forms.helpform.elements[i]; |
ele = document.forms.helpform.elements[i]; |
if (ele.name == checkName + '.forminput') { |
if (ele.name == checkName + '_forminput') { |
document.forms.helpform.elements[i].checked=value; |
document.forms.helpform.elements[i].checked=value; |
} |
} |
} |
} |
Line 2198 BUTTONS
|
Line 2283 BUTTONS
|
} |
} |
$col .= |
$col .= |
"<td align='center'><input type='checkbox' name ='$option_var". |
"<td align='center'><input type='checkbox' name ='$option_var". |
".forminput' value='". |
"_forminput' value='". |
$resource_name . "' $checked /> </td>"; |
$resource_name . "' $checked /> </td>"; |
} |
} |
} |
} |
|
|
$col .= "<td align='center'><input type='$inputType' name='${var}.forminput' "; |
$col .= "<td align='center'><input type='$inputType' name='${var}_forminput' "; |
if (%defaultSymbs) { |
if (%defaultSymbs) { |
my $symb=$resource->symb(); |
my $symb=$resource->symb(); |
if (exists($defaultSymbs{$symb})) { |
if (exists($defaultSymbs{$symb})) { |
Line 2232 BUTTONS
|
Line 2317 BUTTONS
|
my $resource_name = |
my $resource_name = |
&HTML::Entities::encode(&$valueFunc($resource),"<>&\"'"); |
&HTML::Entities::encode(&$valueFunc($resource),"<>&\"'"); |
if ($addparts && (scalar(@{$resource->parts}) > 1)) { |
if ($addparts && (scalar(@{$resource->parts}) > 1)) { |
$col .= "<select onclick=\"javascript:updateRadio(this.form,'${var}.forminput','$resource_name');updateHidden(this.form,'$id','${var}');\" name='part_$id.forminput'>\n"; |
$col .= "<select onclick=\"javascript:updateRadio(this.form,'${var}_forminput','$resource_name');updateHidden(this.form,'$id','${var}');\" name='part_${id}_forminput'>\n"; |
$col .= "<option value=\"$part\">All Parts</option>\n"; |
$col .= "<option value=\"$part\">All Parts</option>\n"; |
foreach my $part (@{$resource->parts}) { |
foreach my $part (@{$resource->parts}) { |
$col .= "<option value=\"$part\">Part: $part</option>\n"; |
$col .= "<option value=\"$part\">Part: $part</option>\n"; |
Line 2254 BUTTONS
|
Line 2339 BUTTONS
|
} |
} |
} |
} |
function updateHidden(form,id,name) { |
function updateHidden(form,id,name) { |
var select=form['part_'+id+'.forminput']; |
var select=form['part_'+id+'_forminput']; |
var hidden=form[name+'_part.forminput']; |
var hidden=form[name+'_part_forminput']; |
var which=select.selectedIndex; |
var which=select.selectedIndex; |
hidden.value=select.options[which].value; |
hidden.value=select.options[which].value; |
} |
} |
// --> |
// --> |
</script> |
</script> |
<input type="hidden" name="${var}_part.forminput" /> |
<input type="hidden" name="${var}_part_forminput" /> |
|
|
RADIO |
RADIO |
$env{'form.condition'} = !$self->{'toponly'}; |
$env{'form.condition'} = !$self->{'toponly'}; |
Line 2430 sub render {
|
Line 2515 sub render {
|
|
|
# Current personel |
# Current personel |
|
|
$result .= '<h4>Select Currently Enrolled Students and Active Course Personnel</h4>'; |
$result .= '<h4>'.&mt('Select Currently Enrolled Students and Active Course Personnel').'</h4>'; |
$result .= &Apache::lonselstudent::render_student_list( $current_members, |
$result .= &Apache::lonselstudent::render_student_list( $current_members, |
"helpform", |
"helpform", |
"current", |
"current", |
Line 2442 sub render {
|
Line 2527 sub render {
|
|
|
# If activeonly is not set then we can also give the expired students: |
# If activeonly is not set then we can also give the expired students: |
# |
# |
if (!$self->{'activeonly'} && ((scalar @$expired_members) > 0)) { |
if (!$self->{'activeonly'} && ((scalar(@$future_members)) > 0)) { |
|
|
# And future. |
# And future. |
|
|
$result .= '<h4>Select Future Enrolled Students and Future Course Personnel</h4>'; |
$result .= '<h4>'.&mt('Select Future Enrolled Students and Future Course Personnel').'</h4>'; |
|
|
$result .= &Apache::lonselstudent::render_student_list( $future_members, |
$result .= &Apache::lonselstudent::render_student_list( $future_members, |
"helpform", |
"helpform", |
Line 2455 sub render {
|
Line 2540 sub render {
|
$self->{'multichoice'}, |
$self->{'multichoice'}, |
$self->{'variable'}, |
$self->{'variable'}, |
0); |
0); |
|
} |
|
if (!$self->{'activeonly'} && ((scalar(@$expired_members)) > 0)) { |
# Past |
# Past |
|
|
$result .= '<h4>Select Previously Enrolled Students and Inactive Course Personnel</h4>'; |
$result .= '<h4>'.&mt('Select Previously Enrolled Students and Inactive Course Personnel').'</h4>'; |
$result .= &Apache::lonselstudent::render_student_list($expired_members, |
$result .= &Apache::lonselstudent::render_student_list($expired_members, |
"helpform", |
"helpform", |
"past", |
"past", |
Line 2475 sub render {
|
Line 2562 sub render {
|
sub postprocess { |
sub postprocess { |
my $self = shift; |
my $self = shift; |
|
|
my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; |
my $result = $env{'form.' . $self->{'variable'} . '_forminput'}; |
if (!$result && !$self->{'emptyallowed'}) { |
if (!$result && !$self->{'emptyallowed'}) { |
if ($self->{'coursepersonnel'}) { |
if ($self->{'coursepersonnel'}) { |
$self->{ERROR_MSG} = |
$self->{ERROR_MSG} = |
Line 2660 sub render {
|
Line 2747 sub render {
|
function checkall(value, checkName) { |
function checkall(value, checkName) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
for (i=0; i<document.forms.helpform.elements.length; i++) { |
ele = document.forms.helpform.elements[i]; |
ele = document.forms.helpform.elements[i]; |
if (ele.name == checkName + '.forminput') { |
if (ele.name == checkName + '_forminput') { |
document.forms.helpform.elements[i].checked=value; |
document.forms.helpform.elements[i].checked=value; |
} |
} |
} |
} |
Line 2777 BUTTONS
|
Line 2864 BUTTONS
|
my $id = &new_id(); |
my $id = &new_id(); |
$result .= '<tr><td align="right"' . " bgcolor='$color'>" . |
$result .= '<tr><td align="right"' . " bgcolor='$color'>" . |
"<input $onclick type='$type' name='" . $var |
"<input $onclick type='$type' name='" . $var |
. ".forminput' ".qq{id="$id"}." value='" . HTML::Entities::encode($fileName,"<>&\"'"). |
. "_forminput' ".qq{id="$id"}." value='" . HTML::Entities::encode($fileName,"<>&\"'"). |
"'"; |
"'"; |
if (!$self->{'multichoice'} && $choices == 0) { |
if (!$self->{'multichoice'} && $choices == 0) { |
$result .= ' checked="checked"'; |
$result .= ' checked="checked"'; |
Line 2838 sub fileState {
|
Line 2925 sub fileState {
|
|
|
sub postprocess { |
sub postprocess { |
my $self = shift; |
my $self = shift; |
my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; |
my $result = $env{'form.' . $self->{'variable'} . '_forminput'}; |
if (!$result) { |
if (!$result) { |
$self->{ERROR_MSG} = 'You must choose at least one file '. |
$self->{ERROR_MSG} = 'You must choose at least one file '. |
'to continue.'; |
'to continue.'; |
Line 3074 sub render {
|
Line 3161 sub render {
|
$result .= '<p><font color="#FF0000">' . $self->{ERROR_MSG} . '</font></p>'; |
$result .= '<p><font color="#FF0000">' . $self->{ERROR_MSG} . '</font></p>'; |
} |
} |
|
|
$result .= '<input type="string" name="' . $self->{'variable'} . '.forminput"'; |
$result .= '<input type="string" name="' . $self->{'variable'} . '_forminput"'; |
|
|
if (defined($self->{'size'})) { |
if (defined($self->{'size'})) { |
$result .= ' size="' . $self->{'size'} . '"'; |
$result .= ' size="' . $self->{'size'} . '"'; |