version 1.1138, 2013/07/11 18:24:31
|
version 1.1159, 2013/11/25 20:18:55
|
Line 1388 sub top_nav_help {
|
Line 1388 sub top_nav_help {
|
|
|
return <<"END"; |
return <<"END"; |
$banner_link |
$banner_link |
<a href="$link" title="$title">$text</a> |
<a href="$link" title="$title">$text</a> |
END |
END |
} |
} |
|
|
sub help_menu_js { |
sub help_menu_js { |
my ($text) = @_; |
my ($httphost) = @_; |
my $stayOnPage = 1; |
my $stayOnPage = 1; |
my $width = 620; |
my $width = 620; |
my $height = 600; |
my $height = 600; |
my $helptopic=&general_help(); |
my $helptopic=&general_help(); |
my $details_link = '/adm/help/'.$helptopic.'.hlp'; |
my $details_link = $httphost.'/adm/help/'.$helptopic.'.hlp'; |
my $nothing=&Apache::lonhtmlcommon::javascript_nothing(); |
my $nothing=&Apache::lonhtmlcommon::javascript_nothing(); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Help Menu', undef, |
&Apache::loncommon::start_page('Help Menu', undef, |
{'frameset' => 1, |
{'frameset' => 1, |
'js_ready' => 1, |
'js_ready' => 1, |
|
'use_absolute' => $httphost, |
'add_entries' => { |
'add_entries' => { |
'border' => '0', |
'border' => '0', |
'rows' => "110,*",},}); |
'rows' => "110,*",},}); |
Line 2351 Outputs:
|
Line 2352 Outputs:
|
|
|
=item * $clientmobile |
=item * $clientmobile |
|
|
|
=item * $clientinfo |
|
|
=back |
=back |
|
|
=back |
=back |
Line 2381 sub decode_user_agent {
|
Line 2384 sub decode_user_agent {
|
} |
} |
} |
} |
my $clientos='unknown'; |
my $clientos='unknown'; |
|
my $clientinfo; |
if (($httpbrowser=~/linux/i) || |
if (($httpbrowser=~/linux/i) || |
($httpbrowser=~/unix/i) || |
($httpbrowser=~/unix/i) || |
($httpbrowser=~/ux/i) || |
($httpbrowser=~/ux/i) || |
Line 2395 sub decode_user_agent {
|
Line 2399 sub decode_user_agent {
|
if ($httpbrowser=~/(Android|iPod|iPad|iPhone|webOS|Blackberry|Windows Phone|Opera m(?:ob|in)|Fennec)/i) { |
if ($httpbrowser=~/(Android|iPod|iPad|iPhone|webOS|Blackberry|Windows Phone|Opera m(?:ob|in)|Fennec)/i) { |
$clientmobile=lc($1); |
$clientmobile=lc($1); |
} |
} |
|
if ($httpbrowser=~ m{Firefox/(\d+\.\d+)}) { |
|
$clientinfo = 'firefox-'.$1; |
|
} elsif ($httpbrowser=~ m{chromeframe/(\d+\.\d+)\.}) { |
|
$clientinfo = 'chromeframe-'.$1; |
|
} |
return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
$clientunicode,$clientos,$clientmobile); |
$clientunicode,$clientos,$clientmobile,$clientinfo); |
} |
} |
|
|
############################################################### |
############################################################### |
Line 3066 sub get_related_words {
|
Line 3075 sub get_related_words {
|
|
|
=pod |
=pod |
|
|
|
=back |
|
|
=head1 Spell checking |
=head1 Spell checking |
|
|
=over 4 |
=over 4 |
Line 3099 Note: This sub assumes that aspell is in
|
Line 3110 Note: This sub assumes that aspell is in
|
=cut |
=cut |
|
|
|
|
=pod |
|
|
|
=back |
|
|
|
=cut |
|
|
|
sub check_spelling { |
sub check_spelling { |
my ($wordlist, $language) = @_; |
my ($wordlist, $language) = @_; |
my @misspellings; |
my @misspellings; |
Line 3320 sub screenname {
|
Line 3325 sub screenname {
|
# ------------------------------------------------------------- Confirm Wrapper |
# ------------------------------------------------------------- Confirm Wrapper |
=pod |
=pod |
|
|
=item confirmwrapper |
=item * &confirmwrapper($message) |
|
|
Wrap messages about completion of operation in box |
Wrap messages about completion of operation in box |
|
|
Line 5120 sub bodytag {
|
Line 5125 sub bodytag {
|
$public = 1; |
$public = 1; |
} |
} |
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } |
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } |
|
my $httphost = $args->{'use_absolute'}; |
|
|
$function = &get_users_function() if (!$function); |
$function = &get_users_function() if (!$function); |
my $img = &designparm($function.'.img',$domain); |
my $img = &designparm($function.'.img',$domain); |
Line 5192 sub bodytag {
|
Line 5198 sub bodytag {
|
# } |
# } |
|
|
$bodytag .= Apache::lonhtmlcommon::scripttag( |
$bodytag .= Apache::lonhtmlcommon::scripttag( |
Apache::lonmenu::utilityfunctions(), 'start'); |
Apache::lonmenu::utilityfunctions($httphost), 'start'); |
|
|
my ($left,$right) = Apache::lonmenu::primary_menu(); |
my ($left,$right) = Apache::lonmenu::primary_menu(); |
|
|
Line 5218 sub bodytag {
|
Line 5224 sub bodytag {
|
|
|
#don't show menus for public users |
#don't show menus for public users |
if (!$public){ |
if (!$public){ |
$bodytag .= Apache::lonmenu::secondary_menu(); |
$bodytag .= Apache::lonmenu::secondary_menu($httphost); |
$bodytag .= Apache::lonmenu::serverform(); |
$bodytag .= Apache::lonmenu::serverform(); |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
Line 5278 sub make_attr_string {
|
Line 5284 sub make_attr_string {
|
} |
} |
|
|
my $attr_string; |
my $attr_string; |
foreach my $attr (keys(%$attr_ref)) { |
foreach my $attr (sort(keys(%$attr_ref))) { |
$attr_string .= " $attr=\"".$attr_ref->{$attr}.'" '; |
$attr_string .= " $attr=\"".$attr_ref->{$attr}.'" '; |
} |
} |
return $attr_string; |
return $attr_string; |
Line 6492 div.LC_edit_problem_saves {
|
Line 6498 div.LC_edit_problem_saves {
|
white-space: nowrap; |
white-space: nowrap; |
} |
} |
|
|
|
.LC_edit_problem_latexhelper{ |
|
text-align: right; |
|
} |
|
|
|
#LC_edit_problem_colorful div{ |
|
margin-left: 40px; |
|
} |
|
|
img.stift { |
img.stift { |
border-width: 0; |
border-width: 0; |
vertical-align: middle; |
vertical-align: middle; |
Line 7257 sub headtag {
|
Line 7271 sub headtag {
|
my $function = $args->{'function'} || &get_users_function(); |
my $function = $args->{'function'} || &get_users_function(); |
my $domain = $args->{'domain'} || &determinedomain(); |
my $domain = $args->{'domain'} || &determinedomain(); |
my $bgcolor = $args->{'bgcolor'} || &designparm($function.'.pgbg',$domain); |
my $bgcolor = $args->{'bgcolor'} || &designparm($function.'.pgbg',$domain); |
|
my $httphost = $args->{'use_absolute'}; |
my $url = join(':',$env{'user.name'},$env{'user.domain'}, |
my $url = join(':',$env{'user.name'},$env{'user.domain'}, |
$Apache::lonnet::perlvar{'lonVersion'}, |
$Apache::lonnet::perlvar{'lonVersion'}, |
#time(), |
#time(), |
Line 7280 sub headtag {
|
Line 7295 sub headtag {
|
if (!$args->{'no_nav_bar'} |
if (!$args->{'no_nav_bar'} |
&& !$args->{'only_body'} |
&& !$args->{'only_body'} |
&& !$args->{'frameset'}) { |
&& !$args->{'frameset'}) { |
$result .= &help_menu_js(); |
$result .= &help_menu_js($httphost); |
$result.=&modal_window(); |
$result.=&modal_window(); |
$result.=&togglebox_script(); |
$result.=&togglebox_script(); |
$result.=&wishlist_window(); |
$result.=&wishlist_window(); |
Line 7340 sub font_settings {
|
Line 7355 sub font_settings {
|
my $headerstring=''; |
my $headerstring=''; |
if (!$env{'browser.mathml'} && $env{'browser.unicode'}) { |
if (!$env{'browser.mathml'} && $env{'browser.unicode'}) { |
$headerstring.= |
$headerstring.= |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n"; |
} |
} |
return $headerstring; |
return $headerstring; |
} |
} |
Line 7444 sub xml_begin {
|
Line 7459 sub xml_begin {
|
.'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' |
.'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' |
.'xmlns="http://www.w3.org/1999/xhtml">'; |
.'xmlns="http://www.w3.org/1999/xhtml">'; |
} else { |
} else { |
$output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' |
$output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n" |
.'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'; |
.'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'."\n"; |
} |
} |
return $output; |
return $output; |
} |
} |
Line 7656 var modalWindow = {
|
Line 7671 var modalWindow = {
|
$(".LCmodal-overlay").click(function(){modalWindow.close();}); |
$(".LCmodal-overlay").click(function(){modalWindow.close();}); |
} |
} |
}; |
}; |
var openMyModal = function(source,width,height,scrolling) |
var openMyModal = function(source,width,height,scrolling,transparency,style) |
{ |
{ |
modalWindow.windowId = "myModal"; |
modalWindow.windowId = "myModal"; |
modalWindow.width = width; |
modalWindow.width = width; |
modalWindow.height = height; |
modalWindow.height = height; |
modalWindow.content = "<iframe width='"+width+"' height='"+height+"' frameborder='0' scrolling='"+scrolling+"' allowtransparency='true' src='" + source + "'></iframe>"; |
modalWindow.content = "<iframe width='"+width+"' height='"+height+"' frameborder='0' scrolling='"+scrolling+"' allowtransparency='"+transparency+"' src='" + source + "' style='"+style+"'></iframe>"; |
modalWindow.open(); |
modalWindow.open(); |
}; |
}; |
// END LON-CAPA Internal --> |
// END LON-CAPA Internal --> |
Line 7671 ENDMODAL
|
Line 7686 ENDMODAL
|
} |
} |
|
|
sub modal_link { |
sub modal_link { |
my ($link,$linktext,$width,$height,$target,$scrolling,$title)=@_; |
my ($link,$linktext,$width,$height,$target,$scrolling,$title,$transparency,$style)=@_; |
unless ($width) { $width=480; } |
unless ($width) { $width=480; } |
unless ($height) { $height=400; } |
unless ($height) { $height=400; } |
unless ($scrolling) { $scrolling='yes'; } |
unless ($scrolling) { $scrolling='yes'; } |
|
unless ($transparency) { $transparency='true'; } |
|
|
my $target_attr; |
my $target_attr; |
if (defined($target)) { |
if (defined($target)) { |
$target_attr = 'target="'.$target.'"'; |
$target_attr = 'target="'.$target.'"'; |
} |
} |
return <<"ENDLINK"; |
return <<"ENDLINK"; |
<a href="$link" $target_attr title="$title" onclick="javascript:openMyModal('$link',$width,$height,'$scrolling'); return false;"> |
<a href="$link" $target_attr title="$title" onclick="javascript:openMyModal('$link',$width,$height,'$scrolling','$transparency','$style'); return false;"> |
$linktext</a> |
$linktext</a> |
ENDLINK |
ENDLINK |
} |
} |
Line 7707 sub modal_adhoc_inner {
|
Line 7724 sub modal_adhoc_inner {
|
my ($funcname,$width,$height,$content)=@_; |
my ($funcname,$width,$height,$content)=@_; |
my $innerwidth=$width-20; |
my $innerwidth=$width-20; |
$content=&js_ready( |
$content=&js_ready( |
&start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). |
&start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). |
&start_scrollbox($width.'px',$innerwidth.'px',$height.'px','modal'). |
&start_scrollbox($width.'px',$innerwidth.'px',$height.'px','myModal','#FFFFFF',undef,1). |
$content. |
$content. |
&end_scrollbox(). |
&end_scrollbox(). |
&end_page() |
&end_page() |
); |
); |
return &modal_adhoc_script($funcname,$width,$height,$content); |
return &modal_adhoc_script($funcname,$width,$height,$content); |
} |
} |
Line 7928 sub validate_page {
|
Line 7945 sub validate_page {
|
|
|
|
|
sub start_scrollbox { |
sub start_scrollbox { |
my ($outerwidth,$width,$height,$id,$bgcolor,$cursor) = @_; |
my ($outerwidth,$width,$height,$id,$bgcolor,$cursor,$needjsready) = @_; |
unless ($outerwidth) { $outerwidth='520px'; } |
unless ($outerwidth) { $outerwidth='520px'; } |
unless ($width) { $width='500px'; } |
unless ($width) { $width='500px'; } |
unless ($height) { $height='200px'; } |
unless ($height) { $height='200px'; } |
my ($table_id,$div_id,$tdcol); |
my ($table_id,$div_id,$tdcol); |
if ($id ne '') { |
if ($id ne '') { |
$table_id = " id='table_$id'"; |
$table_id = ' id="table_'.$id.'"'; |
$div_id = ' id="div_'.$id.'"'; |
$div_id = ' id="div_'.$id.'"'; |
} |
} |
if ($bgcolor ne '') { |
if ($bgcolor ne '') { |
Line 7942 sub start_scrollbox {
|
Line 7959 sub start_scrollbox {
|
} |
} |
my $nicescroll_js; |
my $nicescroll_js; |
if ($env{'browser.mobile'}) { |
if ($env{'browser.mobile'}) { |
my %options; |
$nicescroll_js = &nicescroll_javascript('div_'.$id,$cursor,$needjsready); |
if (ref($cursor) eq 'HASH') { |
|
%options = %{$cursor}; |
|
} |
|
unless ($options{'railalign'} =~ /^left|right$/) { |
|
$options{'railalign'} = 'left'; |
|
} |
|
unless ($options{'cursorcolor'} =~ /^\#\w+$/) { |
|
my $function = &get_users_function(); |
|
$options{'cursorcolor'} = &designparm($function.'.sidebg',$env{'request.role.domain'}); |
|
unless ($options{'cursorcolor'} =~ /^\#\w+$/) { |
|
$options{'cursorcolor'} = '#00F'; |
|
} |
|
} |
|
if ($options{'cursoropacity'} =~ /^[\d.]+$/) { |
|
unless ($options{'cursoropacity'} >= 0.0 && $options{'cursoropacity'} <=1.0) { |
|
$options{'cursoropacity'}='1.0'; |
|
} |
|
} else { |
|
$options{'cursoropacity'}='1.0'; |
|
} |
|
if ($options{'cursorfixedheight'} eq 'none') { |
|
delete($options{'cursorfixedheight'}); |
|
} else { |
|
unless ($options{'cursorfixedheight'} =~ /^\d+$/) { $options{'cursorfixedheight'}='50'; } |
|
} |
|
unless ($options{'railoffset'} =~ /^{[\w\:\d]+}$/) { |
|
delete($options{'railoffset'}); |
|
} |
|
my @niceoptions; |
|
while (my($key,$value) = each(%options)) { |
|
if ($value =~ /^\{.+\}$/) { |
|
push(@niceoptions,$key.':'.$value); |
|
} else { |
|
push(@niceoptions,$key.':"'.$value.'"'); |
|
} |
|
} |
|
$nicescroll_js = ' |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
$(document).ready( |
|
function() { |
|
$("#div_'.$id.'").niceScroll({'.join(',',@niceoptions).'}); |
|
} |
|
); |
|
|
|
// ]]> |
|
</script> |
|
'; |
|
} |
} |
|
|
return <<"END"; |
return <<"END"; |
$nicescroll_js |
$nicescroll_js |
|
|
Line 8005 sub end_scrollbox {
|
Line 7973 sub end_scrollbox {
|
return '</div></td></tr></table>'; |
return '</div></td></tr></table>'; |
} |
} |
|
|
|
sub nicescroll_javascript { |
|
my ($id,$cursor,$needjsready,$framecheck,$location) = @_; |
|
my %options; |
|
if (ref($cursor) eq 'HASH') { |
|
%options = %{$cursor}; |
|
} |
|
unless ($options{'railalign'} =~ /^left|right$/) { |
|
$options{'railalign'} = 'left'; |
|
} |
|
unless ($options{'cursorcolor'} =~ /^\#\w+$/) { |
|
my $function = &get_users_function(); |
|
$options{'cursorcolor'} = &designparm($function.'.sidebg',$env{'request.role.domain'}); |
|
unless ($options{'cursorcolor'} =~ /^\#\w+$/) { |
|
$options{'cursorcolor'} = '#00F'; |
|
} |
|
} |
|
if ($options{'cursoropacity'} =~ /^[\d.]+$/) { |
|
unless ($options{'cursoropacity'} >= 0.0 && $options{'cursoropacity'} <=1.0) { |
|
$options{'cursoropacity'}='1.0'; |
|
} |
|
} else { |
|
$options{'cursoropacity'}='1.0'; |
|
} |
|
if ($options{'cursorfixedheight'} eq 'none') { |
|
delete($options{'cursorfixedheight'}); |
|
} else { |
|
unless ($options{'cursorfixedheight'} =~ /^\d+$/) { $options{'cursorfixedheight'}='50'; } |
|
} |
|
unless ($options{'railoffset'} =~ /^{[\w\:\d\-,]+}$/) { |
|
delete($options{'railoffset'}); |
|
} |
|
my @niceoptions; |
|
while (my($key,$value) = each(%options)) { |
|
if ($value =~ /^\{.+\}$/) { |
|
push(@niceoptions,$key.':'.$value); |
|
} else { |
|
push(@niceoptions,$key.':"'.$value.'"'); |
|
} |
|
} |
|
my $nicescroll_js = ' |
|
$(document).ready( |
|
function() { |
|
$("#'.$id.'").niceScroll({'.join(',',@niceoptions).'}); |
|
} |
|
); |
|
'; |
|
if ($framecheck) { |
|
$nicescroll_js .= ' |
|
function expand_div(caller) { |
|
if (top === self) { |
|
document.getElementById("'.$id.'").style.width = "auto"; |
|
document.getElementById("'.$id.'").style.height = "auto"; |
|
} else { |
|
try { |
|
if (parent.frames) { |
|
if (parent.frames.length > 1) { |
|
var framesrc = parent.frames[1].location.href; |
|
var currsrc = framesrc.replace(/\#.*$/,""); |
|
if ((caller == "search") || (currsrc == "'.$location.'")) { |
|
document.getElementById("'.$id.'").style.width = "auto"; |
|
document.getElementById("'.$id.'").style.height = "auto"; |
|
} |
|
} |
|
} |
|
} catch (e) { |
|
return; |
|
} |
|
} |
|
return; |
|
} |
|
'; |
|
} |
|
if ($needjsready) { |
|
$nicescroll_js = ' |
|
<script type="text/javascript">'."\n".$nicescroll_js."\n</script>\n"; |
|
} else { |
|
$nicescroll_js = &Apache::lonhtmlcommon::scripttag($nicescroll_js); |
|
} |
|
return $nicescroll_js; |
|
} |
|
|
sub simple_error_page { |
sub simple_error_page { |
my ($r,$title,$msg) = @_; |
my ($r,$title,$msg,$args) = @_; |
|
if (ref($args) eq 'HASH') { |
|
if (!$args->{'no_auto_mt_msg'}) { $msg = &mt($msg); } |
|
} else { |
|
$msg = &mt($msg); |
|
} |
|
|
my $page = |
my $page = |
&Apache::loncommon::start_page($title). |
&Apache::loncommon::start_page($title). |
'<p class="LC_error">'.&mt($msg).'</p>'. |
'<p class="LC_error">'.$msg.'</p>'. |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
if (ref($r)) { |
if (ref($r)) { |
$r->print($page); |
$r->print($page); |
Line 8744 Retrieves default quota assigned for sto
|
Line 8799 Retrieves default quota assigned for sto
|
given an (optional) user's institutional status. |
given an (optional) user's institutional status. |
|
|
Incoming parameters: |
Incoming parameters: |
|
|
1. domain |
1. domain |
2. (Optional) institutional status(es). This is a : separated list of |
2. (Optional) institutional status(es). This is a : separated list of |
status types (e.g., faculty, staff, student etc.) |
status types (e.g., faculty, staff, student etc.) |
Line 8754 Incoming parameters:
|
Line 8810 Incoming parameters:
|
(if no quota name provided, defaults to portfolio). |
(if no quota name provided, defaults to portfolio). |
|
|
Returns: |
Returns: |
|
|
1. Default disk quota (in Mb) for user portfolios in the domain. |
1. Default disk quota (in Mb) for user portfolios in the domain. |
2. (Optional) institutional type which determined the value of the |
2. (Optional) institutional type which determined the value of the |
default quota. |
default quota. |
Line 8767 If the user's status includes multiple t
|
Line 8824 If the user's status includes multiple t
|
the largest default quota which applies to the user determines the |
the largest default quota which applies to the user determines the |
default quota returned. |
default quota returned. |
|
|
=back |
|
|
|
=cut |
=cut |
|
|
############################################### |
############################################### |
Line 8817 sub default_quota {
|
Line 8872 sub default_quota {
|
$defquota = $quotahash{'quotas'}{'default'}; |
$defquota = $quotahash{'quotas'}{'default'}; |
} |
} |
$settingstatus = 'default'; |
$settingstatus = 'default'; |
|
if ($defquota eq '') { |
|
if ($quotaname eq 'author') { |
|
$defquota = 500; |
|
} |
|
} |
} |
} |
} else { |
} else { |
$settingstatus = 'default'; |
$settingstatus = 'default'; |
Line 8841 sub default_quota {
|
Line 8901 sub default_quota {
|
|
|
Returns warning message if upload of file to authoring space, or copying |
Returns warning message if upload of file to authoring space, or copying |
of existing file within authoring space will cause quota for the authoring |
of existing file within authoring space will cause quota for the authoring |
space to be exceeded, |
space to be exceeded. |
|
|
Same, if upload of a file directly to a course/community via Course Editor |
Same, if upload of a file directly to a course/community via Course Editor |
will cause quota for uploaded content for the course to be exceeded. |
will cause quota for uploaded content for the course to be exceeded. |
Line 8855 Inputs: 6
|
Line 8915 Inputs: 6
|
6. action being taken: copy or upload. |
6. action being taken: copy or upload. |
|
|
Returns: 1 scalar: HTML to display containing warning if quota would be exceeded, |
Returns: 1 scalar: HTML to display containing warning if quota would be exceeded, |
otherwise return null. |
otherwise return null. |
|
|
|
=back |
|
|
=cut |
=cut |
|
|
Line 9727 sub ask_for_embedded_content {
|
Line 9789 sub ask_for_embedded_content {
|
my $numexisting = 0; |
my $numexisting = 0; |
my $numunused = 0; |
my $numunused = 0; |
my ($output,$upload_output,$toplevel,$url,$udom,$uname,$getpropath,$cdom,$cnum, |
my ($output,$upload_output,$toplevel,$url,$udom,$uname,$getpropath,$cdom,$cnum, |
$fileloc,$filename,$delete_output,$modify_output,$title,$symb,$path); |
$fileloc,$filename,$delete_output,$modify_output,$title,$symb,$path,$navmap); |
my $heading = &mt('Upload embedded files'); |
my $heading = &mt('Upload embedded files'); |
my $buttontext = &mt('Upload'); |
my $buttontext = &mt('Upload'); |
|
|
my ($navmap,$cdom,$cnum); |
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
if ($actionurl eq '/adm/dependencies') { |
if ($actionurl eq '/adm/dependencies') { |
$navmap = Apache::lonnavmaps::navmap->new(); |
$navmap = Apache::lonnavmaps::navmap->new(); |
Line 9815 sub ask_for_embedded_content {
|
Line 9876 sub ask_for_embedded_content {
|
} else { |
} else { |
$embed_file = $file; |
$embed_file = $file; |
} |
} |
my $absolutepath; |
my ($absolutepath,$cleaned_file); |
if ($embed_file =~ m{^\w+://}) { |
if ($embed_file =~ m{^\w+://}) { |
$newfiles{$embed_file} = 1; |
$cleaned_file = $embed_file; |
$mapping{$embed_file} = $embed_file; |
$newfiles{$cleaned_file} = 1; |
|
$mapping{$cleaned_file} = $embed_file; |
} else { |
} else { |
|
$cleaned_file = &clean_path($embed_file); |
if ($embed_file =~ m{^/}) { |
if ($embed_file =~ m{^/}) { |
$absolutepath = $embed_file; |
$absolutepath = $embed_file; |
$embed_file =~ s{^(/+)}{}; |
|
} |
} |
if ($embed_file =~ m{/}) { |
if ($cleaned_file =~ m{/}) { |
my ($path,$fname) = ($embed_file =~ m{^(.+)/([^/]*)$}); |
my ($path,$fname) = ($cleaned_file =~ m{^(.+)/([^/]*)$}); |
$path = &check_for_traversal($path,$url,$toplevel); |
$path = &check_for_traversal($path,$url,$toplevel); |
my $item = $fname; |
my $item = $fname; |
if ($path ne '') { |
if ($path ne '') { |
Line 9842 sub ask_for_embedded_content {
|
Line 9904 sub ask_for_embedded_content {
|
} else { |
} else { |
$dependencies{$embed_file} = 1; |
$dependencies{$embed_file} = 1; |
if ($absolutepath) { |
if ($absolutepath) { |
$mapping{$embed_file} = $absolutepath; |
$mapping{$cleaned_file} = $absolutepath; |
} else { |
} else { |
$mapping{$embed_file} = $embed_file; |
$mapping{$cleaned_file} = $embed_file; |
} |
} |
} |
} |
} |
} |
Line 10218 sub ask_for_embedded_content {
|
Line 10280 sub ask_for_embedded_content {
|
return ($output,$counter,$numpathchg); |
return ($output,$counter,$numpathchg); |
} |
} |
|
|
|
=pod |
|
|
|
=item * clean_path($name) |
|
|
|
Performs clean-up of directories, subdirectories and filename in an |
|
embedded object, referenced in an HTML file which is being uploaded |
|
to a course or portfolio, where |
|
"Upload embedded images/multimedia files if HTML file" checkbox was |
|
checked. |
|
|
|
Clean-up is similar to replacements in lonnet::clean_filename() |
|
except each / between sub-directory and next level is preserved. |
|
|
|
=cut |
|
|
|
sub clean_path { |
|
my ($embed_file) = @_; |
|
$embed_file =~s{^/+}{}; |
|
my @contents; |
|
if ($embed_file =~ m{/}) { |
|
@contents = split(/\//,$embed_file); |
|
} else { |
|
@contents = ($embed_file); |
|
} |
|
my $lastidx = scalar(@contents)-1; |
|
for (my $i=0; $i<=$lastidx; $i++) { |
|
$contents[$i]=~s{\\}{/}g; |
|
$contents[$i]=~s/\s+/\_/g; |
|
$contents[$i]=~s{[^/\w\.\-]}{}g; |
|
if ($i == $lastidx) { |
|
$contents[$i]=~s/\.(\d+)(?=\.)/_$1/g; |
|
} |
|
} |
|
if ($lastidx > 0) { |
|
return join('/',@contents); |
|
} else { |
|
return $contents[0]; |
|
} |
|
} |
|
|
sub embedded_file_element { |
sub embedded_file_element { |
my ($context,$num,$embed_file,$mapping,$allfiles,$codebase,$type) = @_; |
my ($context,$num,$embed_file,$mapping,$allfiles,$codebase,$type) = @_; |
return unless ((ref($mapping) eq 'HASH') && (ref($allfiles) eq 'HASH') && |
return unless ((ref($mapping) eq 'HASH') && (ref($allfiles) eq 'HASH') && |
Line 10342 sub upload_embedded {
|
Line 10444 sub upload_embedded {
|
# Check if extension is valid |
# Check if extension is valid |
if (($fname =~ /\.(\w+)$/) && |
if (($fname =~ /\.(\w+)$/) && |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
$output .= &mt('Invalid file extension ([_1]) - reserved for LONCAPA use - rename the file with a different extension and re-upload. ',$1).'<br />'; |
$output .= &mt('Invalid file extension ([_1]) - reserved for internal use.',$1) |
|
.' '.&mt('Rename the file with a different extension and re-upload.').'<br />'; |
next; |
next; |
} elsif (($fname =~ /\.(\w+)$/) && |
} elsif (($fname =~ /\.(\w+)$/) && |
(!defined(&Apache::loncommon::fileembstyle($1)))) { |
(!defined(&Apache::loncommon::fileembstyle($1)))) { |
Line 10606 sub modify_html_refs {
|
Line 10709 sub modify_html_refs {
|
my $numchg = ($content =~ s{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi); |
my $numchg = ($content =~ s{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi); |
$count += $numchg; |
$count += $numchg; |
$allfiles{$newname} = $allfiles{$ref}; |
$allfiles{$newname} = $allfiles{$ref}; |
|
delete($allfiles{$ref}); |
} |
} |
if ($env{'form.embedded_codebase_'.$i} ne '') { |
if ($env{'form.embedded_codebase_'.$i} ne '') { |
$codebase = &unescape($env{'form.embedded_codebase_'.$i}); |
$codebase = &unescape($env{'form.embedded_codebase_'.$i}); |
Line 12076 sub get_turnedin_filepath {
|
Line 12180 sub get_turnedin_filepath {
|
my $title = $res->compTitle(); |
my $title = $res->compTitle(); |
$title =~ s/\W+/_/g; |
$title =~ s/\W+/_/g; |
if ($title ne '') { |
if ($title ne '') { |
|
if (($pc > 1) && (length($title) > 12)) { |
|
$title = substr($title,0,12); |
|
} |
push(@pathitems,$title); |
push(@pathitems,$title); |
} |
} |
} |
} |
Line 12084 sub get_turnedin_filepath {
|
Line 12191 sub get_turnedin_filepath {
|
my $maptitle = $mapres->compTitle(); |
my $maptitle = $mapres->compTitle(); |
$maptitle =~ s/\W+/_/g; |
$maptitle =~ s/\W+/_/g; |
if ($maptitle ne '') { |
if ($maptitle ne '') { |
|
if (length($maptitle) > 12) { |
|
$maptitle = substr($maptitle,0,12); |
|
} |
push(@pathitems,$maptitle); |
push(@pathitems,$maptitle); |
} |
} |
unless ($env{'request.state'} eq 'construct') { |
unless ($env{'request.state'} eq 'construct') { |
Line 12124 sub get_turnedin_filepath {
|
Line 12234 sub get_turnedin_filepath {
|
$restitle = time; |
$restitle = time; |
} |
} |
} |
} |
|
if (length($restitle) > 12) { |
|
$restitle = substr($restitle,0,12); |
|
} |
push(@pathitems,$restitle); |
push(@pathitems,$restitle); |
$path .= join('/',@pathitems); |
$path .= join('/',@pathitems); |
} |
} |
Line 13061 sub restore_settings {
|
Line 13174 sub restore_settings {
|
|
|
=item * &build_recipient_list() |
=item * &build_recipient_list() |
|
|
Build recipient lists for five types of e-mail: |
Build recipient lists for following types of e-mail: |
(a) Error Reports, (b) Package Updates, (c) lonstatus warnings/errors |
(a) Error Reports, (b) Package Updates, (c) lonstatus warnings/errors |
(d) Help requests, (e) Course requests needing approval, generated by |
(d) Help requests, (e) Course requests needing approval, (f) loncapa |
lonerrorhandler.pm, CHECKRPMS, loncron, lonsupportreq.pm and |
module change checking, student/employee ID conflict checks, as |
loncoursequeueadmin.pm respectively. |
generated by lonerrorhandler.pm, CHECKRPMS, loncron, |
|
lonsupportreq.pm, loncoursequeueadmin.pm, searchcat.pl respectively. |
|
|
Inputs: |
Inputs: |
defmail (scalar - email address of default recipient), |
defmail (scalar - email address of default recipient), |
mailing type (scalar - errormail, packagesmail, or helpdeskmail), |
mailing type (scalar: errormail, packagesmail, helpdeskmail, |
|
requestsmail, updatesmail, or idconflictsmail). |
|
|
defdom (domain for which to retrieve configuration settings), |
defdom (domain for which to retrieve configuration settings), |
|
|
origmail (scalar - email address of recipient from loncapa.conf, |
origmail (scalar - email address of recipient from loncapa.conf, |
i.e., predates configuration by DC via domainprefs.pm |
i.e., predates configuration by DC via domainprefs.pm |
|
|
Line 13448 sub assign_category_rows {
|
Line 13565 sub assign_category_rows {
|
if (ref($cats->[$depth]{$parent}) eq 'ARRAY') { |
if (ref($cats->[$depth]{$parent}) eq 'ARRAY') { |
my $numchildren = @{$cats->[$depth]{$parent}}; |
my $numchildren = @{$cats->[$depth]{$parent}}; |
my $css_class = $itemcount%2?' class="LC_odd_row"':''; |
my $css_class = $itemcount%2?' class="LC_odd_row"':''; |
$text .= '<td><table class="LC_datatable">'; |
$text .= '<td><table class="LC_data_table">'; |
for (my $j=0; $j<$numchildren; $j++) { |
for (my $j=0; $j<$numchildren; $j++) { |
$name = $cats->[$depth]{$parent}[$j]; |
$name = $cats->[$depth]{$parent}[$j]; |
$item = &escape($name).':'.&escape($parent).':'.$depth; |
$item = &escape($name).':'.&escape($parent).':'.$depth; |
Line 14246 sub init_user_environment {
|
Line 14363 sub init_user_environment {
|
# ------------------------------------ Check browser type and MathML capability |
# ------------------------------------ Check browser type and MathML capability |
|
|
my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, |
$clientunicode,$clientos,$clientmobile) = &decode_user_agent($r); |
$clientunicode,$clientos,$clientmobile,$clientinfo) = &decode_user_agent($r); |
|
|
# ------------------------------------------------------------- Get environment |
# ------------------------------------------------------------- Get environment |
|
|
Line 14278 sub init_user_environment {
|
Line 14395 sub init_user_environment {
|
"browser.unicode" => $clientunicode, |
"browser.unicode" => $clientunicode, |
"browser.os" => $clientos, |
"browser.os" => $clientos, |
"browser.mobile" => $clientmobile, |
"browser.mobile" => $clientmobile, |
|
"browser.info" => $clientinfo, |
"server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'}, |
"server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'}, |
"request.course.fn" => '', |
"request.course.fn" => '', |
"request.course.uri" => '', |
"request.course.uri" => '', |
Line 14297 sub init_user_environment {
|
Line 14415 sub init_user_environment {
|
$env{'browser.interface'}=$form->{'interface'}; |
$env{'browser.interface'}=$form->{'interface'}; |
} |
} |
|
|
|
if ($form->{'iptoken'}) { |
|
my $lonhost = $r->dir_config('lonHostID'); |
|
$initial_env{"user.noloadbalance"} = $lonhost; |
|
$env{'user.noloadbalance'} = $lonhost; |
|
} |
|
|
my %is_adv = ( is_adv => $env{'user.adv'} ); |
my %is_adv = ( is_adv => $env{'user.adv'} ); |
my %domdef; |
my %domdef; |
unless ($domain eq 'public') { |
unless ($domain eq 'public') { |
Line 14530 sub parse_supplemental_title {
|
Line 14654 sub parse_supplemental_title {
|
return $title; |
return $title; |
} |
} |
|
|
|
sub recurse_supplemental { |
|
my ($cnum,$cdom,$suppmap,$numfiles,$errors) = @_; |
|
if ($suppmap) { |
|
my ($errtext,$fatal) = &LONCAPA::map::mapread('/uploaded/'.$cdom.'/'.$cnum.'/'.$suppmap); |
|
if ($fatal) { |
|
$errors ++; |
|
} else { |
|
if ($#LONCAPA::map::resources > 0) { |
|
foreach my $res (@LONCAPA::map::resources) { |
|
my ($title,$src,$ext,$type,$status)=split(/\:/,$res); |
|
if (($src ne '') && ($status eq 'res')) { |
|
if ($src =~ m{^\Q/uploaded/$cdom/$cnum/\E(supplemental_\d+\.sequence)$}) { |
|
($numfiles,$errors) = &recurse_supplemental($cnum,$cdom,$1,$numfiles,$errors); |
|
} else { |
|
$numfiles ++; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return ($numfiles,$errors); |
|
} |
|
|
sub symb_to_docspath { |
sub symb_to_docspath { |
my ($symb) = @_; |
my ($symb) = @_; |
return unless ($symb); |
return unless ($symb); |
Line 14559 sub symb_to_docspath {
|
Line 14707 sub symb_to_docspath {
|
my $thistitle = $res->title(); |
my $thistitle = $res->title(); |
$path .= '&'. |
$path .= '&'. |
&Apache::lonhtmlcommon::entity_encode($thisurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($thisurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($thistitle). |
&escape($thistitle). |
':'.$res->randompick(). |
':'.$res->randompick(). |
':'.$res->randomout(). |
':'.$res->randomout(). |
':'.$res->encrypted(). |
':'.$res->encrypted(). |
Line 14575 sub symb_to_docspath {
|
Line 14723 sub symb_to_docspath {
|
} |
} |
$path .= (($path ne '')? '&' : ''). |
$path .= (($path ne '')? '&' : ''). |
&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($maptitle). |
&escape($maptitle). |
':'.$mapresobj->randompick(). |
':'.$mapresobj->randompick(). |
':'.$mapresobj->randomout(). |
':'.$mapresobj->randomout(). |
':'.$mapresobj->encrypted(). |
':'.$mapresobj->encrypted(). |
Line 14588 sub symb_to_docspath {
|
Line 14736 sub symb_to_docspath {
|
$maptitle = 'Main Content'; |
$maptitle = 'Main Content'; |
} |
} |
$path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
$path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage; |
&escape($maptitle).':::::'.$ispage; |
} |
} |
unless ($mapurl eq 'default') { |
unless ($mapurl eq 'default') { |
$path = 'default&'. |
$path = 'default&'. |
&Apache::lonhtmlcommon::entity_encode('Main Content'). |
&escape('Main Content'). |
':::::&'.$path; |
':::::&'.$path; |
} |
} |
return $path; |
return $path; |
Line 14731 sub check_captcha {
|
Line 14879 sub check_captcha {
|
|
|
sub create_recaptcha { |
sub create_recaptcha { |
my ($pubkey) = @_; |
my ($pubkey) = @_; |
|
my $use_ssl; |
|
if ($ENV{'SERVER_PORT'} == 443) { |
|
$use_ssl = 1; |
|
} |
my $captcha = Captcha::reCAPTCHA->new; |
my $captcha = Captcha::reCAPTCHA->new; |
return $captcha->get_options_setter({theme => 'white'})."\n". |
return $captcha->get_options_setter({theme => 'white'})."\n". |
$captcha->get_html($pubkey). |
$captcha->get_html($pubkey,undef,$use_ssl). |
&mt('If either word is hard to read, [_1] will replace them.', |
&mt('If either word is hard to read, [_1] will replace them.', |
'<img src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
'<img src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
'<br /><br />'; |
'<br /><br />'; |