version 1.177, 2010/01/12 10:40:01
|
version 1.194, 2015/08/14 15:34:01
|
Line 261 sub real_handler {
|
Line 261 sub real_handler {
|
my $uri = shift; |
my $uri = shift; |
if (!defined($uri)) { $uri = $r->uri(); } |
if (!defined($uri)) { $uri = $r->uri(); } |
$env{'request.uri'} = $uri; |
$env{'request.uri'} = $uri; |
my $filename = '/home/httpd/html' . $uri; |
my $filename = $r->dir_config('lonDocRoot').$uri; |
my $fh = Apache::File->new($filename); |
my $fh = Apache::File->new($filename); |
my $file; |
my $file; |
read $fh, $file, 100000000; |
read $fh, $file, 100000000; |
Line 571 sub process {
|
Line 571 sub process {
|
# 4: Render the current state to the screen as an HTML page. |
# 4: Render the current state to the screen as an HTML page. |
sub display { |
sub display { |
my $self = shift; |
my $self = shift; |
|
my $footer = shift; |
my $state = $self->{STATES}{$self->{STATE}}; |
my $state = $self->{STATES}{$self->{STATE}}; |
|
|
my $result = ""; |
my $result = ""; |
Line 606 sub display {
|
Line 606 sub display {
|
# FIXME: This should be parameterized, not concatenated - Jeremy |
# FIXME: This should be parameterized, not concatenated - Jeremy |
|
|
|
|
if (!$state->overrideForm()) { $result.='<form name="helpform" method="post">'; } |
if (!$state->overrideForm()) { $result.='<form name="helpform" method="post" action="">'; } |
if ($stateHelp) { |
if ($stateHelp) { |
$stateHelp = &Apache::loncommon::help_open_topic($stateHelp); |
$stateHelp = &Apache::loncommon::help_open_topic($stateHelp); |
} |
} |
Line 651 sub display {
|
Line 651 sub display {
|
$result .= $buttons; |
$result .= $buttons; |
|
|
|
|
#foreach my $key (keys %{$self->{VARS}}) { |
#foreach my $key (keys(%{$self->{VARS}})) { |
# $result .= "|$key| -> " . $self->{VARS}->{$key} . "<br />"; |
# $result .= "|$key| -> " . $self->{VARS}->{$key} . "<br />"; |
#} |
#} |
|
|
Line 661 sub display {
|
Line 661 sub display {
|
</form> |
</form> |
FOOTER |
FOOTER |
|
|
$result .= &Apache::loncommon::end_page(); |
$result .= $footer.&Apache::loncommon::end_page(); |
# Handle writing out the vars to the file |
# Handle writing out the vars to the file |
my $file = Apache::File->new('>'.$self->{FILENAME}); |
my $file = Apache::File->new('>'.$self->{FILENAME}); |
print $file $self->_varsInFile(); |
print $file $self->_varsInFile(); |
Line 1476 BUTTONS
|
Line 1476 BUTTONS
|
HTML::Entities::encode($choice->[1],"<>&\"'") |
HTML::Entities::encode($choice->[1],"<>&\"'") |
. "'"; |
. "'"; |
if ($checkedChoices{$choice->[1]}) { |
if ($checkedChoices{$choice->[1]}) { |
$result .= " checked='checked' "; |
$result .= " checked='checked'"; |
} |
} |
$result .= qq{id="id$id"}; |
$result .= qq{ id="id$id"}; |
my $choiceLabel = $choice->[0]; |
my $choiceLabel = $choice->[0]; |
if ($choice->[3]) { # if we need to evaluate this choice |
if ($choice->[3]) { # if we need to evaluate this choice |
$choiceLabel = "sub { my $helper = shift; my $state = shift;" . |
$choiceLabel = "sub { my $helper = shift; my $state = shift;" . |
Line 1486 BUTTONS
|
Line 1486 BUTTONS
|
$choiceLabel = eval($choiceLabel); |
$choiceLabel = eval($choiceLabel); |
$choiceLabel = &$choiceLabel($helper, $self); |
$choiceLabel = &$choiceLabel($helper, $self); |
} |
} |
$result .= "/></td><td> ".qq{<label for="id$id">}. |
$result .= " /></td><td> ".qq{<label for="id$id">}. |
$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="' |
Line 1913 CHECK
|
Line 1913 CHECK
|
if ($anytime) { |
if ($anytime) { |
$result.=' checked="checked" ' |
$result.=' checked="checked" ' |
} |
} |
$result.="name='${var}anytime'/>".&mt('Any time').'</label>' |
my $anytimetext = &mt('Any time'); |
|
if (($var eq 'startreserve') || ($var eq 'endreserve')) { |
|
$anytimetext = &mt('Any time before slot starts'); |
|
} elsif (($var eq 'startunique') || ($var eq 'endunique')) { |
|
$anytimetext = &mt('No restriction on uniqueness'); |
|
} |
|
$result.="name='${var}anytime'/>".$anytimetext.'</label>' |
} |
} |
return $result; |
return $result; |
|
|
Line 2066 the toplevel default.sequence in the res
|
Line 2072 the toplevel default.sequence in the res
|
evaluated with "sub { my $helper = shift; my $state = shift;" and |
evaluated with "sub { my $helper = shift; my $state = shift;" and |
"}", with the return value used as the mapurl. |
"}", with the return value used as the mapurl. |
|
|
|
=item * <option />: Allows you to add optional elements to the |
|
resource chooser currently these can be a checkbox, or a text entry |
|
or hidden (see the 'type' attribute below). |
|
the following attributes are supported by this tag: |
|
|
|
=over 4 |
|
|
|
=item * type=control-type : determines the type of control displayed. |
|
This can be one of the following types: 'checkbox' provides a true/false |
|
checkbox. 'text' provides a text entry control. 'hidden' provides a |
|
hidden form element that returns the name of the resource for each |
|
element of the text box. |
|
|
|
=item * text=header-text : provides column header text for the option. |
|
|
|
=item * variable=helpervar : provides a helper variable to contain the |
|
value of the input control for each resource. In general, the result |
|
will be a set of values separated by ||| for the checkbox the value between |
|
the |||'s will either be empty, if the box is not checked, or the resource |
|
name if checked. For the text entry, the values will be the text in the |
|
text box. This could be empty. Hidden elements unconditionally provide |
|
the resource name for each row of the chooser and allow you to therefore |
|
correlate text entries to their resources. |
|
The helper variable can be initialized by the user code to pre-load values |
|
into the controls: |
|
|
|
=over 4 |
|
|
|
|
|
=item * Preloading checkboxes : Set the helper variable to the value you |
|
would have gotten from the control if it had been manually set as desired. |
|
|
|
=item * Preloading text entries : Set the helper variable to triple pipe |
|
separated values where each value is of the form resource-name=value |
|
|
|
=item * Preloading hidden fields : These cannot be pre-loaded and will always |
|
be pipe separated resource names. |
|
|
|
=back |
|
|
|
|
|
=back |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 2347 BUTTONS
|
Line 2396 BUTTONS
|
$result .= "<th>$text</th>"; |
$result .= "<th>$text</th>"; |
} |
} |
} |
} |
$result .= "<th>Select</th>"; |
$result .= '<th>'.&Apache::lonlocal::mt('Select').'</th>'; |
$result .= "</tr><tr>"; # Close off the extra row and start a new one. |
$result .= "</tr><tr>"; # Close off the extra row and start a new one. |
$headings_done = 1; |
$headings_done = 1; |
} |
} |
Line 2395 BUTTONS
|
Line 2444 BUTTONS
|
last; |
last; |
} |
} |
} |
} |
|
# TODO: add an attribute to <option> that allows the |
|
# programmer to set the width of the tex entry box. |
|
|
$col .= |
$col .= |
"<td align='center'><input type='text' name ='$option_var". |
"<td align='center'><input type='text' name ='$option_var". |
Line 2442 BUTTONS
|
Line 2493 BUTTONS
|
&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\">".&Apache::lonlocal::mt('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\">".&Apache::lonlocal::mt('Part: [_1]',$part)."</option>\n"; |
} |
} |
$col .= "</select>"; |
$col .= "</select>"; |
} |
} |
Line 2489 RADIO
|
Line 2540 RADIO
|
'closeAllPages' => $self->{'closeallpages'}, |
'closeAllPages' => $self->{'closeallpages'}, |
'suppressEmptySequences' => $self->{'suppressEmptySequences'}, |
'suppressEmptySequences' => $self->{'suppressEmptySequences'}, |
'include_top_level_map' => $self->{'include_top_level_map'}, |
'include_top_level_map' => $self->{'include_top_level_map'}, |
'iterator_map' => $mapUrl } |
'iterator_map' => $mapUrl, |
|
'map_no_edit_link' => 1, } |
); |
); |
|
|
$result .= $buttons; |
$result .= $buttons; |
Line 2926 BUTTONS
|
Line 2978 BUTTONS
|
} |
} |
|
|
# Get the list of files in this directory. |
# Get the list of files in this directory. |
my @fileList; |
my (@fileList,$listref,$listerror); |
|
|
# If the subdirectory is in local CSTR space |
# If the subdirectory is in local CSTR space |
my $metadir; |
my $metadir; |
if ($subdir =~ m|/home/([^/]+)/public_html/(.*)|) { |
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my ($user,$domain)= |
if ($subdir =~ m{^(?:\Q$londocroot\E)*/priv/[^/]+/[^/]+/(.*)$}) { |
&Apache::loncacc::constructaccess($subdir, |
my $innerpath=$1; |
$Apache::lonnet::perlvar{'lonDefDomain'}); |
unless ($subdir=~m{^\Q$londocroot\E}) { |
$metadir='/res/'.$domain.'/'.$user.'/'.$2; |
$subdir=$londocroot.$subdir; |
@fileList = &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/'); |
} |
} elsif ($subdir =~ m|^~([^/]+)/(.*)$|) { |
|
$subdir='/home/'.$1.'/public_html/'.$2; |
|
my ($user,$domain)= |
my ($user,$domain)= |
&Apache::loncacc::constructaccess($subdir, |
&Apache::lonnet::constructaccess($subdir); |
$Apache::lonnet::perlvar{'lonDefDomain'}); |
$metadir='/res/'.$domain.'/'.$user.'/'.$innerpath; |
$metadir='/res/'.$domain.'/'.$user.'/'.$2; |
($listref,$listerror) = |
@fileList = &Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/'); |
&Apache::lonnet::dirlist($subdir,$domain,$user,undef,undef,'/'); |
} else { |
} else { |
# local library server resource space |
# local library server resource space |
@fileList = &Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/'); |
($listref,$listerror) = |
|
&Apache::lonnet::dirlist($subdir,$env{'user.domain'},$env{'user.name'},undef,undef,'/'); |
} |
} |
|
|
# Sort the fileList into order |
# Sort the fileList into order |
@fileList = sort {lc($a) cmp lc($b)} @fileList; |
if (ref($listref) eq 'ARRAY') { |
|
@fileList = sort {lc($a) cmp lc($b)} @{$listref}; |
|
} |
|
|
$result .= $buttons; |
$result .= $buttons; |
|
|
Line 3044 sub fileState {
|
Line 3097 sub fileState {
|
} |
} |
my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $subdirpart = $constructionSpaceDir; |
my $subdirpart = $constructionSpaceDir; |
$subdirpart =~ s/^\/home\/$uname\/public_html//; |
$subdirpart =~ s{^\Q$docroot/priv/$udom/$uname\E}{}; |
my $resdir = $docroot . '/res/' . $udom . '/' . $uname . |
my $resdir = $docroot . '/res/' . $udom . '/' . $uname . |
$subdirpart; |
$subdirpart; |
|
|
Line 3244 package Apache::lonhelper::string;
|
Line 3297 package Apache::lonhelper::string;
|
string elements provide a string entry field for the user. string elements |
string elements provide a string entry field for the user. string elements |
take the usual 'variable' and 'nextstate' parameters. string elements |
take the usual 'variable' and 'nextstate' parameters. string elements |
also pass through 'maxlength' and 'size' attributes to the input tag. |
also pass through 'maxlength' and 'size' attributes to the input tag. |
|
Since you could have multiple strings in a helper state, each with its own |
|
validator, all but the last string should have |
|
noproceed='1' so that _all_ validators are evaluated before the next |
|
state can be reached. |
|
|
string honors the defaultvalue tag, if given. |
string honors the defaultvalue tag, if given. |
|
|
Line 3263 BEGIN {
|
Line 3320 BEGIN {
|
|
|
sub new { |
sub new { |
my $ref = Apache::lonhelper::element->new(); |
my $ref = Apache::lonhelper::element->new(); |
|
$ref->{'PROCEED'} = 1; # By default postprocess goes to next state. |
bless($ref); |
bless($ref); |
} |
} |
|
|
Line 3279 sub start_string {
|
Line 3337 sub start_string {
|
$paramHash->{'nextstate'} = $token->[2]{'nextstate'}; |
$paramHash->{'nextstate'} = $token->[2]{'nextstate'}; |
$paramHash->{'maxlength'} = $token->[2]{'maxlength'}; |
$paramHash->{'maxlength'} = $token->[2]{'maxlength'}; |
$paramHash->{'size'} = $token->[2]{'size'}; |
$paramHash->{'size'} = $token->[2]{'size'}; |
|
|
return ''; |
return ''; |
} |
} |
|
|
sub end_string { |
sub end_string { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
|
|
if ($target ne 'helper') { |
if ($target ne 'helper') { |
return ''; |
return ''; |
} |
} |
Apache::lonhelper::string->new(); |
my $state = Apache::lonhelper::string->new(); |
|
|
|
|
|
if(&Apache::lonxml::get_param('noproceed', $parstack, $safeeval, undef, 1)) { |
|
$state->noproceed(); |
|
} |
|
|
|
|
|
|
return ''; |
return ''; |
} |
} |
|
|
|
sub noproceed() { |
|
my $self = shift; |
|
$self->{PROCEED} = 0; |
|
} |
|
|
sub render { |
sub render { |
my $self = shift; |
my $self = shift; |
my $result = ''; |
my $result = ''; |
Line 3301 sub render {
|
Line 3372 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="text" name="' . $self->{'variable'} . '_forminput"'; |
|
|
if (defined($self->{'size'})) { |
if (defined($self->{'size'})) { |
$result .= ' size="' . $self->{'size'} . '"'; |
$result .= ' size="' . $self->{'size'} . '"'; |
Line 3336 sub postprocess {
|
Line 3407 sub postprocess {
|
} |
} |
} |
} |
|
|
if (defined($self->{'nextstate'})) { |
if (defined($self->{'nextstate'}) && $self->{PROCEED}) { |
$helper->changeState($self->{'nextstate'}); |
$helper->changeState($self->{'nextstate'}); |
} |
} |
|
|
Line 3563 sub render {
|
Line 3634 sub render {
|
my @results; |
my @results; |
|
|
# Collect all the results |
# Collect all the results |
for my $stateName (keys %{$helper->{STATES}}) { |
for my $stateName (keys(%{$helper->{STATES}})) { |
my $state = $helper->{STATES}->{$stateName}; |
my $state = $helper->{STATES}->{$stateName}; |
|
|
for my $element (@{$state->{ELEMENTS}}) { |
for my $element (@{$state->{ELEMENTS}}) { |
Line 3616 sub render {
|
Line 3687 sub render {
|
} |
} |
my $previous = HTML::Entities::encode(&mt("Back"), '<>&"'); |
my $previous = HTML::Entities::encode(&mt("Back"), '<>&"'); |
my $next = HTML::Entities::encode(&mt("Next"), '<>&"'); |
my $next = HTML::Entities::encode(&mt("Next"), '<>&"'); |
my $target = " target='loncapaclient'"; |
|
if ($env{'environment.remote'} eq 'off') { $target=''; } |
|
$result .= "<p>\n" . |
$result .= "<p>\n" . |
"<form action='".$actionURL."' method='post' $target>\n" . |
"<form action='".$actionURL."' method='post' >\n" . |
"<input type='button' onclick='history.go(-1)' value='$previous' />" . |
"<input type='button' onclick='history.go(-1)' value='$previous' />" . |
"<input type='hidden' name='orgurl' value='$targetURL' />" . |
"<input type='hidden' name='orgurl' value='$targetURL' />" . |
"<input type='hidden' name='selectrole' value='1' />\n" . |
"<input type='hidden' name='selectrole' value='1' />\n" . |