version 1.1075.2.35, 2013/05/10 23:18:42
|
version 1.1118, 2013/03/20 01:26:15
|
Line 72 use Apache::lonuserstate();
|
Line 72 use Apache::lonuserstate();
|
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale::Catalog; |
use DateTime::Locale::Catalog; |
|
use Text::Aspell; |
use Authen::Captcha; |
use Authen::Captcha; |
use Captcha::reCAPTCHA; |
use Captcha::reCAPTCHA; |
|
|
Line 158 sub ssi_with_retries {
|
Line 159 sub ssi_with_retries {
|
# ----------------------------------------------- Filetypes/Languages/Copyright |
# ----------------------------------------------- Filetypes/Languages/Copyright |
my %language; |
my %language; |
my %supported_language; |
my %supported_language; |
|
my %supported_codes; |
my %latex_language; # For choosing hyphenation in <transl..> |
my %latex_language; # For choosing hyphenation in <transl..> |
my %latex_language_bykey; # for choosing hyphenation from metadata |
my %latex_language_bykey; # for choosing hyphenation from metadata |
my %cprtag; |
my %cprtag; |
Line 192 BEGIN {
|
Line 194 BEGIN {
|
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line=~/^\#/); |
next if ($line=~/^\#/); |
chomp($line); |
chomp($line); |
my ($key,$two,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); |
my ($key,$code,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); |
$language{$key}=$val.' - '.$enc; |
$language{$key}=$val.' - '.$enc; |
if ($sup) { |
if ($sup) { |
$supported_language{$key}=$sup; |
$supported_language{$key}=$sup; |
|
$supported_codes{$key} = $code; |
} |
} |
if ($latex) { |
if ($latex) { |
$latex_language_bykey{$key} = $latex; |
$latex_language_bykey{$key} = $latex; |
$latex_language{$two} = $latex; |
$latex_language{$code} = $latex; |
} |
} |
} |
} |
close($fh); |
close($fh); |
Line 663 if (!Array.prototype.indexOf) {
|
Line 666 if (!Array.prototype.indexOf) {
|
var n = 0; |
var n = 0; |
if (arguments.length > 0) { |
if (arguments.length > 0) { |
n = Number(arguments[1]); |
n = Number(arguments[1]); |
if (n !== n) { // shortcut for verifying if it's NaN |
if (n !== n) { // shortcut for verifying if it is NaN |
n = 0; |
n = 0; |
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { |
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { |
n = (n > 0 || -1) * Math.floor(Math.abs(n)); |
n = (n > 0 || -1) * Math.floor(Math.abs(n)); |
Line 899 sub check_uncheck_jscript {
|
Line 902 sub check_uncheck_jscript {
|
function checkAll(field) { |
function checkAll(field) { |
if (field.length > 0) { |
if (field.length > 0) { |
for (i = 0; i < field.length; i++) { |
for (i = 0; i < field.length; i++) { |
if (!field[i].disabled) { |
if (!field[i].disabled) { |
field[i].checked = true; |
field[i].checked = true; |
} |
} |
} |
} |
} else { |
} else { |
if (!field.disabled) { |
if (!field.disabled) { |
field.checked = true; |
field.checked = true; |
} |
} |
} |
} |
Line 1014 sub select_language {
|
Line 1017 sub select_language {
|
|
|
=pod |
=pod |
|
|
|
|
|
=item * &list_languages() |
|
|
|
Returns an array reference that is suitable for use in language prompters. |
|
Each array element is itself a two element array. The first element |
|
is the language code. The second element a descsriptiuon of the |
|
language itself. This is suitable for use in e.g. |
|
&Apache::edit::select_arg (once dereferenced that is). |
|
|
|
=cut |
|
|
|
sub list_languages { |
|
my @lang_choices; |
|
|
|
foreach my $id (&languageids()) { |
|
my $code = &supportedlanguagecode($id); |
|
if ($code) { |
|
my $selector = $supported_codes{$id}; |
|
my $description = &plainlanguagedescription($id); |
|
push (@lang_choices, [$selector, $description]); |
|
} |
|
} |
|
return \@lang_choices; |
|
} |
|
|
|
=pod |
|
|
=item * &linked_select_forms(...) |
=item * &linked_select_forms(...) |
|
|
linked_select_forms returns a string containing a <script></script> block |
linked_select_forms returns a string containing a <script></script> block |
Line 2521 sub authform_nochange {
|
Line 2551 sub authform_nochange {
|
kerb_def_dom => 'MSU.EDU', |
kerb_def_dom => 'MSU.EDU', |
@_, |
@_, |
); |
); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my $result; |
my $result; |
if (!$authnum) { |
if (!$authnum) { |
$result = &mt('Under your current role you are not permitted to change login settings for this user'); |
$result = &mt('Under your current role you are not permitted to change login settings for this user'); |
Line 3017 sub get_related_words {
|
Line 3047 sub get_related_words {
|
untie %thesaurus_db; |
untie %thesaurus_db; |
return @Words; |
return @Words; |
} |
} |
|
############################################################### |
|
# |
|
# Spell checking |
|
# |
|
|
=pod |
=pod |
|
|
|
=head1 Spell checking |
|
|
|
=over 4 |
|
|
|
=item * &check_spelling($wordlist $language) |
|
|
|
Takes a string containing words and feeds it to an external |
|
spellcheck program via a pipeline. Returns a string containing |
|
them mis-spelled words. |
|
|
|
Parameters: |
|
|
|
=over 4 |
|
|
|
=item - $wordlist |
|
|
|
String that will be fed into the spellcheck program. |
|
|
|
=item - $language |
|
|
|
Language string that specifies the language for which the spell |
|
check will be performed. |
|
|
|
=back |
|
|
=back |
=back |
|
|
|
Note: This sub assumes that aspell is installed. |
|
|
|
|
=cut |
=cut |
|
|
|
|
|
=pod |
|
|
|
=back |
|
|
|
=cut |
|
|
|
sub check_spelling { |
|
my ($wordlist, $language) = @_; |
|
my @misspellings; |
|
|
|
# Generate the speller and set the langauge. |
|
# if explicitly selected: |
|
|
|
my $speller = Text::Aspell->new; |
|
if ($language) { |
|
$speller->set_option('lang', $language); |
|
} |
|
|
|
# Turn the word list into an array of words by splittingon whitespace |
|
|
|
my @words = split(/\s+/, $wordlist); |
|
|
|
foreach my $word (@words) { |
|
if(! $speller->check($word)) { |
|
push(@misspellings, $word); |
|
} |
|
} |
|
return join(' ', @misspellings); |
|
|
|
} |
|
|
# -------------------------------------------------------------- Plaintext name |
# -------------------------------------------------------------- Plaintext name |
=pod |
=pod |
|
|
Line 4985 Inputs:
|
Line 5079 Inputs:
|
|
|
=item * $bgcolor, used to override the bgcolor on a webpage to a specific value |
=item * $bgcolor, used to override the bgcolor on a webpage to a specific value |
|
|
=item * $no_inline_link, if true and in remote mode, don't show the |
|
'Switch To Inline Menu' link |
|
|
|
=item * $args, optional argument valid values are |
=item * $args, optional argument valid values are |
no_auto_mt_title -> prevents &mt()ing the title arg |
no_auto_mt_title -> prevents &mt()ing the title arg |
inherit_jsmath -> when creating popup window in a page, |
inherit_jsmath -> when creating popup window in a page, |
Line 5009 other decorations will be returned.
|
Line 5100 other decorations will be returned.
|
|
|
sub bodytag { |
sub bodytag { |
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg, |
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg, |
$no_nav_bar,$bgcolor,$no_inline_link,$args,$advtoolsref)=@_; |
$no_nav_bar,$bgcolor,$args,$advtoolsref)=@_; |
|
|
my $public; |
my $public; |
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) |
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) |
Line 5085 sub bodytag {
|
Line 5176 sub bodytag {
|
$role = '<span class="LC_nobreak">('.$role.')</span>' if $role; |
$role = '<span class="LC_nobreak">('.$role.')</span>' if $role; |
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
|
|
if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { |
if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { |
return $bodytag; |
return $bodytag; |
} |
} |
|
|
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
|
|
|
my $funclist; |
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
if (($env{'environment.remote'} eq 'on') && ($env{'request.state'} ne 'construct')) { |
|
$bodytag .= Apache::lonhtmlcommon::scripttag(Apache::lonmenu::utilityfunctions(), 'start')."\n". |
|
Apache::lonmenu::serverform(); |
|
my $forbodytag; |
|
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
|
$forcereg,$args->{'group'}, |
|
$args->{'bread_crumbs'}, |
|
$advtoolsref,'',\$forbodytag); |
|
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { |
|
$funclist = $forbodytag; |
|
} |
|
} else { |
|
|
|
# if ($env{'request.state'} eq 'construct') { |
# if ($env{'request.state'} eq 'construct') { |
# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls |
# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls |
Line 5112 sub bodytag {
|
Line 5189 sub bodytag {
|
|
|
|
|
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($dc_info) { |
if ($dc_info) { |
$dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; |
$dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; |
} |
} |
$bodytag .= qq|<div id="LC_nav_bar">$name $role<br /> |
$bodytag .= qq|<div id="LC_nav_bar">$name $role<br /> |
<em>$realm</em> $dc_info</div>|; |
<em>$realm</em> $dc_info</div>|; |
return $bodytag; |
return $bodytag; |
} |
} |
|
|
Line 5142 sub bodytag {
|
Line 5219 sub bodytag {
|
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg, |
$args->{'bread_crumbs'}); |
$args->{'bread_crumbs'}); |
} elsif ($forcereg) { |
} elsif ($forcereg) { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$args->{'group'}); |
$args->{'group'}); |
} else { |
} else { |
my $forbodytag; |
$bodytag .= |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
$forcereg,$args->{'group'}, |
$forcereg,$args->{'group'}, |
$args->{'bread_crumbs'}, |
$args->{'bread_crumbs'}, |
$advtoolsref,'',\$forbodytag); |
$advtoolsref); |
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { |
|
$bodytag .= $forbodytag; |
|
} |
|
} |
} |
}else{ |
}else{ |
# this is to seperate menu from content when there's no secondary |
# this is to seperate menu from content when there's no secondary |
Line 5163 sub bodytag {
|
Line 5237 sub bodytag {
|
} |
} |
|
|
return $bodytag; |
return $bodytag; |
} |
|
|
|
# |
|
# Top frame rendering, Remote is up |
|
# |
|
|
|
my $imgsrc = $img; |
|
if ($img =~ /^\/adm/) { |
|
$imgsrc = &lonhttpdurl($img); |
|
} |
|
my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />'; |
|
|
|
# Explicit link to get inline menu |
|
my $menu= ($no_inline_link?'' |
|
:'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>'); |
|
|
|
if ($dc_info) { |
|
$dc_info = qq|<span class="LC_cusr_subheading">($dc_info)</span>|; |
|
} |
|
|
|
unless ($env{'form.inhibitmenu'}) { |
|
$bodytag .= qq|<div id="LC_nav_bar">$name $role</div> |
|
<ol class="LC_primary_menu LC_right"> |
|
<li>$menu</li> |
|
</ol><div id="LC_realm"> $realm $dc_info</div>|; |
|
} |
|
if ($env{'request.state'} eq 'construct') { |
|
if (!$public){ |
|
if ($env{'request.state'} eq 'construct') { |
|
$funclist = &Apache::lonhtmlcommon::scripttag( |
|
&Apache::lonmenu::utilityfunctions(), 'start'). |
|
&Apache::lonhtmlcommon::scripttag('','end'). |
|
&Apache::lonmenu::innerregister($forcereg, |
|
$args->{'bread_crumbs'}); |
|
} |
|
} |
|
} |
|
return $bodytag."\n".$funclist; |
|
} |
} |
|
|
sub dc_courseid_toggle { |
sub dc_courseid_toggle { |
Line 5232 sub make_attr_string {
|
Line 5268 sub make_attr_string {
|
delete($attr_ref->{$key}); |
delete($attr_ref->{$key}); |
} |
} |
} |
} |
if ($env{'environment.remote'} eq 'on') { |
$attr_ref->{'onload'} = $on_load; |
$attr_ref->{'onload'} = |
$attr_ref->{'onunload'}= $on_unload; |
&Apache::lonmenu::loadevents(). $on_load; |
|
$attr_ref->{'onunload'}= |
|
&Apache::lonmenu::unloadevents().$on_unload; |
|
} else { |
|
$attr_ref->{'onload'} = $on_load; |
|
$attr_ref->{'onunload'}= $on_unload; |
|
} |
|
} |
} |
|
|
my $attr_string; |
my $attr_string; |
Line 6445 div.LC_edit_problem_saves {
|
Line 6474 div.LC_edit_problem_saves {
|
padding-bottom: 5px; |
padding-bottom: 5px; |
} |
} |
|
|
.LC_edit_opt { |
|
padding-left: 1em; |
|
white-space: nowrap; |
|
} |
|
|
|
img.stift { |
img.stift { |
border-width: 0; |
border-width: 0; |
vertical-align: middle; |
vertical-align: middle; |
Line 6673 ul#LC_secondary_menu li {
|
Line 6697 ul#LC_secondary_menu li {
|
font-weight: bold; |
font-weight: bold; |
line-height: 1.8em; |
line-height: 1.8em; |
border-right: 1px solid black; |
border-right: 1px solid black; |
vertical-align: middle; |
|
float: left; |
float: left; |
} |
} |
|
|
Line 6706 ul#LC_secondary_menu li ul li {
|
Line 6729 ul#LC_secondary_menu li ul li {
|
vertical-align: top; |
vertical-align: top; |
border-left: 1px solid black; |
border-left: 1px solid black; |
border-right: 1px solid black; |
border-right: 1px solid black; |
background-color: $data_table_light; |
background-color: $data_table_light |
list-style:none; |
list-style:none; |
float: none; |
float: none; |
} |
} |
Line 7233 sub headtag {
|
Line 7256 sub headtag {
|
if (!$args->{'frameset'}) { |
if (!$args->{'frameset'}) { |
$result .= &Apache::lonhtmlcommon::htmlareaheaders(); |
$result .= &Apache::lonhtmlcommon::htmlareaheaders(); |
} |
} |
if ($args->{'force_register'}) { |
if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) { |
$result .= &Apache::lonmenu::registerurl(1); |
$result .= Apache::lonxml::display_title(); |
} |
} |
if (!$args->{'no_nav_bar'} |
if (!$args->{'no_nav_bar'} |
&& !$args->{'only_body'} |
&& !$args->{'only_body'} |
Line 7443 $args - additional optional args support
|
Line 7466 $args - additional optional args support
|
skip_phases -> hash ref of |
skip_phases -> hash ref of |
head -> skip the <html><head> generation |
head -> skip the <html><head> generation |
body -> skip all <body> generation |
body -> skip all <body> generation |
no_inline_link -> if true and in remote mode, don't show the |
|
'Switch To Inline Menu' link |
|
no_auto_mt_title -> prevent &mt()ing the title arg |
no_auto_mt_title -> prevent &mt()ing the title arg |
inherit_jsmath -> when creating popup window in a page, |
inherit_jsmath -> when creating popup window in a page, |
should it have jsmath forced on by the |
should it have jsmath forced on by the |
current page |
current page |
bread_crumbs -> Array containing breadcrumbs |
bread_crumbs -> Array containing breadcrumbs |
bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs |
bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs |
group -> includes the current group, if page is for a |
group -> includes the current group, if page is for a |
specific group |
specific group |
|
|
=back |
=back |
|
|
Line 7482 sub start_page {
|
Line 7503 sub start_page {
|
$args->{'function'}, $args->{'add_entries'}, |
$args->{'function'}, $args->{'add_entries'}, |
$args->{'only_body'}, $args->{'domain'}, |
$args->{'only_body'}, $args->{'domain'}, |
$args->{'force_register'}, $args->{'no_nav_bar'}, |
$args->{'force_register'}, $args->{'no_nav_bar'}, |
$args->{'bgcolor'}, $args->{'no_inline_link'}, |
$args->{'bgcolor'}, $args, |
$args, \@advtools); |
\@advtools); |
} |
} |
} |
} |
|
|
Line 7523 sub start_page {
|
Line 7544 sub start_page {
|
}else{ |
}else{ |
$result .= &Apache::lonhtmlcommon::breadcrumbs(); |
$result .= &Apache::lonhtmlcommon::breadcrumbs(); |
} |
} |
} elsif (($env{'environment.remote'} eq 'on') && |
|
($env{'form.inhibitmenu'} ne 'yes') && |
|
($env{'request.noversionuri'} =~ m{^/res/}) && |
|
($env{'request.noversionuri'} !~ m{^/res/adm/pages/})) { |
|
$result .= '<div style="padding:0;margin:0;clear:both"><hr /></div>'; |
|
} |
} |
return $result; |
return $result; |
} |
} |
Line 7791 sub LCprogressbar {
|
Line 7807 sub LCprogressbar {
|
$LCcurrentid=$$.'_'.$LCidcnt; |
$LCcurrentid=$$.'_'.$LCidcnt; |
my $starting=&mt('Starting'); |
my $starting=&mt('Starting'); |
my $content=(<<ENDPROGBAR); |
my $content=(<<ENDPROGBAR); |
|
<p> |
<div id="progressbar$LCcurrentid"> |
<div id="progressbar$LCcurrentid"> |
<span class="pblabel">$starting</span> |
<span class="pblabel">$starting</span> |
</div> |
</div> |
|
</p> |
ENDPROGBAR |
ENDPROGBAR |
&r_print($r,$content.&LCprogressbar_script($LCcurrentid)); |
&r_print($r,$content.&LCprogressbar_script($LCcurrentid)); |
} |
} |
Line 8219 sub get_sections {
|
Line 8237 sub get_sections {
|
} |
} |
} |
} |
|
|
if ($check_students) { |
if ($check_students) { |
my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
my $sec_index = &Apache::loncoursedata::CL_SECTION(); |
my $sec_index = &Apache::loncoursedata::CL_SECTION(); |
my $status_index = &Apache::loncoursedata::CL_STATUS(); |
my $status_index = &Apache::loncoursedata::CL_STATUS(); |
Line 9532 sub ask_for_embedded_content {
|
Line 9550 sub ask_for_embedded_content {
|
my $heading = &mt('Upload embedded files'); |
my $heading = &mt('Upload embedded files'); |
my $buttontext = &mt('Upload'); |
my $buttontext = &mt('Upload'); |
|
|
my ($navmap,$cdom,$cnum); |
my $navmap; |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
if ($actionurl eq '/adm/dependencies') { |
$navmap = Apache::lonnavmaps::navmap->new(); |
$navmap = Apache::lonnavmaps::navmap->new(); |
|
} |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
} |
} |
if (($actionurl eq '/adm/portfolio') || |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
($actionurl eq '/adm/coursegrp_portfolio')) { |
|
my $current_path='/'; |
my $current_path='/'; |
if ($env{'form.currentpath'}) { |
if ($env{'form.currentpath'}) { |
$current_path = $env{'form.currentpath'}; |
$current_path = $env{'form.currentpath'}; |
} |
} |
if ($actionurl eq '/adm/coursegrp_portfolio') { |
if ($actionurl eq '/adm/coursegrp_portfolio') { |
$udom = $cdom; |
$udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$uname = $cnum; |
$uname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; |
$url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; |
} else { |
} else { |
$udom = $env{'user.domain'}; |
$udom = $env{'user.domain'}; |
Line 9572 sub ask_for_embedded_content {
|
Line 9585 sub ask_for_embedded_content {
|
$toplevel = $url; |
$toplevel = $url; |
if ($args->{'context'} eq 'paste') { |
if ($args->{'context'} eq 'paste') { |
($cdom,$cnum) = ($url =~ m{^\Q/uploaded/\E($match_domain)/($match_courseid)/}); |
($cdom,$cnum) = ($url =~ m{^\Q/uploaded/\E($match_domain)/($match_courseid)/}); |
($path) = |
($path) = |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
$fileloc =~ s{^/}{}; |
$fileloc =~ s{^/}{}; |
} |
} |
} |
} |
} elsif ($actionurl eq '/adm/dependencies') { |
} elsif ($actionurl eq '/adm/dependencies') { |
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
if (ref($args) eq 'HASH') { |
if (ref($args) eq 'HASH') { |
$url = $args->{'docs_url'}; |
$url = $args->{'docs_url'}; |
$title = $args->{'docs_title'}; |
$title = $args->{'docs_title'}; |
$toplevel = $url; |
$toplevel = "/$url"; |
unless ($toplevel =~ m{^/}) { |
|
$toplevel = "/$url"; |
|
} |
|
($rem) = ($toplevel =~ m{^(.+/)[^/]+$}); |
($rem) = ($toplevel =~ m{^(.+/)[^/]+$}); |
if ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E)}) { |
($path) = |
$path = $1; |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
} else { |
|
($path) = |
|
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
|
} |
|
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
$fileloc =~ s{^/}{}; |
$fileloc =~ s{^/}{}; |
($filename) = ($fileloc =~ m{.+/([^/]+)$}); |
($filename) = ($fileloc =~ m{.+/([^/]+)$}); |
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); |
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); |
} |
} |
} |
} |
} elsif ($actionurl eq "/public/$cdom/$cnum/syllabus") { |
|
$udom = $cdom; |
|
$uname = $cnum; |
|
$url = "/uploaded/$cdom/$cnum/portfolio/syllabus"; |
|
$toplevel = $url; |
|
$path = $url; |
|
$fileloc = &Apache::lonnet::filelocation('',$toplevel).'/'; |
|
$fileloc =~ s{^/}{}; |
|
} |
} |
} |
my $now = time(); |
foreach my $file (keys(%{$allfiles})) { |
foreach my $embed_file (keys(%{$allfiles})) { |
my $embed_file; |
|
if (($path eq "/uploaded/$cdom/$cnum/portfolio/syllabus") && ($file =~ m{^\Q$path/\E(.+)$})) { |
|
$embed_file = $1; |
|
} else { |
|
$embed_file = $file; |
|
} |
|
my $absolutepath; |
my $absolutepath; |
if ($embed_file =~ m{^\w+://}) { |
if ($embed_file =~ m{^\w+://}) { |
$newfiles{$embed_file} = 1; |
$newfiles{$embed_file} = 1; |
Line 9654 sub ask_for_embedded_content {
|
Line 9648 sub ask_for_embedded_content {
|
my $dirptr = 16384; |
my $dirptr = 16384; |
foreach my $path (keys(%subdependencies)) { |
foreach my $path (keys(%subdependencies)) { |
$currsubfile{$path} = {}; |
$currsubfile{$path} = {}; |
if (($actionurl eq '/adm/portfolio') || |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
($actionurl eq '/adm/coursegrp_portfolio')) { |
|
my ($sublistref,$listerror) = |
my ($sublistref,$listerror) = |
&Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath); |
&Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath); |
if (ref($sublistref) eq 'ARRAY') { |
if (ref($sublistref) eq 'ARRAY') { |
Line 9671 sub ask_for_embedded_content {
|
Line 9664 sub ask_for_embedded_content {
|
} |
} |
} elsif (($actionurl eq '/adm/dependencies') || |
} elsif (($actionurl eq '/adm/dependencies') || |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
($args->{'context'} eq 'paste')) || |
($args->{'context'} eq 'paste'))) { |
($actionurl eq "/public/$cdom/$cnum/syllabus")) { |
|
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
my $dir; |
my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
if ($actionurl eq "/public/$cdom/$cnum/syllabus") { |
|
$dir = $fileloc; |
|
} else { |
|
($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
|
} |
|
if ($dir ne '') { |
if ($dir ne '') { |
my ($sublistref,$listerror) = |
my ($sublistref,$listerror) = |
&Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/'); |
&Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/'); |
Line 9727 sub ask_for_embedded_content {
|
Line 9714 sub ask_for_embedded_content {
|
} |
} |
} |
} |
my %currfile; |
my %currfile; |
if (($actionurl eq '/adm/portfolio') || |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
($actionurl eq '/adm/coursegrp_portfolio')) { |
|
my ($dirlistref,$listerror) = |
my ($dirlistref,$listerror) = |
&Apache::lonnet::dirlist($url,$udom,$uname,$getpropath); |
&Apache::lonnet::dirlist($url,$udom,$uname,$getpropath); |
if (ref($dirlistref) eq 'ARRAY') { |
if (ref($dirlistref) eq 'ARRAY') { |
Line 9744 sub ask_for_embedded_content {
|
Line 9730 sub ask_for_embedded_content {
|
} |
} |
} elsif (($actionurl eq '/adm/dependencies') || |
} elsif (($actionurl eq '/adm/dependencies') || |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
($args->{'context'} eq 'paste')) || |
($args->{'context'} eq 'paste'))) { |
($actionurl eq "/public/$cdom/$cnum/syllabus")) { |
|
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
if ($dir ne '') { |
if ($dir ne '') { |
Line 9780 sub ask_for_embedded_content {
|
Line 9765 sub ask_for_embedded_content {
|
($file eq $filename.'.bak') || |
($file eq $filename.'.bak') || |
($dependencies{$file})) { |
($dependencies{$file})) { |
if ($actionurl eq '/adm/dependencies') { |
if ($actionurl eq '/adm/dependencies') { |
unless ($toplevel =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E}) { |
next if (($rem ne '') && |
next if (($rem ne '') && |
(($env{"httpref.$rem".$file} ne '') || |
(($env{"httpref.$rem".$file} ne '') || |
(ref($navmap) && |
(ref($navmap) && |
(($navmap->getResourceByUrl($rem.$file) ne '') || |
(($navmap->getResourceByUrl($rem.$file) ne '') || |
(($file =~ /^(.*\.s?html?)\.bak$/i) && |
(($file =~ /^(.*\.s?html?)\.bak$/i) && |
($navmap->getResourceByUrl($rem.$1))))))); |
($navmap->getResourceByUrl($rem.$1))))))); |
|
} |
|
} |
} |
$unused{$file} = 1; |
$unused{$file} = 1; |
} |
} |
Line 9796 sub ask_for_embedded_content {
|
Line 9779 sub ask_for_embedded_content {
|
($args->{'context'} eq 'paste')) { |
($args->{'context'} eq 'paste')) { |
$counter = scalar(keys(%existing)); |
$counter = scalar(keys(%existing)); |
$numpathchg = scalar(keys(%pathchanges)); |
$numpathchg = scalar(keys(%pathchanges)); |
return ($output,$counter,$numpathchg,\%existing); |
return ($output,$counter,$numpathchg,\%existing); |
} elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") && |
|
(ref($args) eq 'HASH') && ($args->{'context'} eq 'rewrites')) { |
|
$counter = scalar(keys(%existing)); |
|
$numpathchg = scalar(keys(%pathchanges)); |
|
return ($output,$counter,$numpathchg,\%existing,\%mapping); |
|
} |
} |
foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) { |
foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) { |
if ($actionurl eq '/adm/dependencies') { |
if ($actionurl eq '/adm/dependencies') { |
next if ($embed_file =~ m{^\w+://}); |
next if ($embed_file =~ m{^\w+://}); |
} |
} |
$upload_output .= &start_data_table_row(). |
$upload_output .= &start_data_table_row(). |
'<td valign="top"><img src="'.&icon($embed_file).'" /> '. |
'<td><img src="'.&icon($embed_file).'" /> '. |
'<span class="LC_filename">'.$embed_file.'</span>'; |
'<span class="LC_filename">'.$embed_file.'</span>'; |
unless ($mapping{$embed_file} eq $embed_file) { |
unless ($mapping{$embed_file} eq $embed_file) { |
$upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'. |
$upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'.&mt('changed from: [_1]',$mapping{$embed_file}).'</span>'; |
&mt('changed from: [_1]',$mapping{$embed_file}).'</span>'; |
|
} |
} |
$upload_output .= '</td>'; |
$upload_output .= '</td><td>'; |
if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { |
if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { |
$upload_output.='<td align="right">'. |
$upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>'; |
'<span class="LC_info LC_fontsize_medium">'. |
|
&mt("URL points to web address").'</span>'; |
|
$numremref++; |
$numremref++; |
} elsif ($args->{'error_on_invalid_names'} |
} elsif ($args->{'error_on_invalid_names'} |
&& $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { |
&& $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { |
$upload_output.='<td align="right"><span class="LC_warning">'. |
$upload_output.='<span class="LC_warning">'.&mt('Invalid characters').'</span>'; |
&mt('Invalid characters').'</span>'; |
|
$numinvalid++; |
$numinvalid++; |
} else { |
} else { |
$upload_output .= '<td>'. |
$upload_output .= &embedded_file_element('upload_embedded',$counter, |
&embedded_file_element('upload_embedded',$counter, |
|
$embed_file,\%mapping, |
$embed_file,\%mapping, |
$allfiles,$codebase,'upload'); |
$allfiles,$codebase,'upload'); |
$counter ++; |
$counter ++; |
Line 9856 sub ask_for_embedded_content {
|
Line 9829 sub ask_for_embedded_content {
|
$counter ++; |
$counter ++; |
} else { |
} else { |
$upload_output .= &start_data_table_row(). |
$upload_output .= &start_data_table_row(). |
'<td valign="top"><img src="'.&icon($embed_file).'" /> '. |
'<td><span class="LC_filename">'.$embed_file.'</span></td>'; |
'<span class="LC_filename">'.$embed_file.'</span></td>'. |
'<td><span class="LC_warning">'.&mt('Already exists').'</span></td>'. |
'<td align="right"><span class="LC_info LC_fontsize_medium">'.&mt('Already exists').'</span></td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
} |
} |
Line 9953 sub ask_for_embedded_content {
|
Line 9925 sub ask_for_embedded_content {
|
$output = '<b>'.&mt('Referenced files').'</b>:<br />'; |
$output = '<b>'.&mt('Referenced files').'</b>:<br />'; |
if ($applies > 1) { |
if ($applies > 1) { |
$output .= |
$output .= |
&mt('No dependencies need to be uploaded, as one of the following applies to each reference:').'<ul>'; |
&mt('No files need to be uploaded, as one of the following applies to each reference:').'<ul>'; |
if ($numremref) { |
if ($numremref) { |
$output .= '<li>'.&mt('reference is to a URL which points to another server').'</li>'."\n"; |
$output .= '<li>'.&mt('reference is to a URL which points to another server').'</li>'."\n"; |
} |
} |
Line 9996 sub ask_for_embedded_content {
|
Line 9968 sub ask_for_embedded_content {
|
$chgcount ++; |
$chgcount ++; |
} |
} |
} |
} |
if (($counter) || ($numunused)) { |
if ($counter) { |
if ($numpathchg) { |
if ($numpathchg) { |
$output .= '<input type ="hidden" name="number_pathchange_items" value="'. |
$output .= '<input type ="hidden" name="number_pathchange_items" value="'. |
$numpathchg.'" />'."\n"; |
$numpathchg.'" />'."\n"; |
Line 10009 sub ask_for_embedded_content {
|
Line 9981 sub ask_for_embedded_content {
|
} elsif ($actionurl eq '/adm/dependencies') { |
} elsif ($actionurl eq '/adm/dependencies') { |
$output .= '<input type="hidden" name="action" value="process_changes" />'; |
$output .= '<input type="hidden" name="action" value="process_changes" />'; |
} |
} |
$output .= '<input type ="submit" value="'.$buttontext.'" />'."\n".'</form>'."\n"; |
$output .= '<input type ="submit" value="'.$buttontext.'" />'."\n".'</form>'."\n"; |
} elsif ($numpathchg) { |
} elsif ($numpathchg) { |
my %pathchange = (); |
my %pathchange = (); |
$output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output); |
$output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output); |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
$output .= '<p>'.&mt('or').'</p>'; |
$output .= '<p>'.&mt('or').'</p>'; |
} |
} |
} |
} |
return ($output,$counter,$numpathchg); |
return ($output,$counter,$numpathchg); |
} |
} |
Line 10151 sub upload_embedded {
|
Line 10123 sub upload_embedded {
|
$output .= &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1).'<br />'; |
$output .= &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1).'<br />'; |
next; |
next; |
} elsif ($fname=~/\.(\d+)\.(\w+)$/) { |
} elsif ($fname=~/\.(\d+)\.(\w+)$/) { |
$output .= &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'<br />'; |
$output .= &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'<br />'; |
next; |
next; |
} |
} |
$env{'form.embedded_item_'.$i.'.filename'}=$fname; |
$env{'form.embedded_item_'.$i.'.filename'}=$fname; |
my $subdir = $path; |
|
$subdir =~ s{/+$}{}; |
|
if ($context eq 'portfolio') { |
if ($context eq 'portfolio') { |
my $result; |
my $result; |
if ($state eq 'existingfile') { |
if ($state eq 'existingfile') { |
$result= |
$result= |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile', |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile', |
$dirpath.$env{'form.currentpath'}.$subdir); |
$dirpath.$env{'form.currentpath'}.$path); |
} else { |
} else { |
$result= |
$result= |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'', |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'', |
$dirpath. |
$dirpath. |
$env{'form.currentpath'}.$subdir); |
$env{'form.currentpath'}.$path); |
if ($result !~ m|^/uploaded/|) { |
if ($result !~ m|^/uploaded/|) { |
$output .= '<span class="LC_error">' |
$output .= '<span class="LC_error">' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
Line 10179 sub upload_embedded {
|
Line 10149 sub upload_embedded {
|
$path.$fname.'</span>').'<br />'; |
$path.$fname.'</span>').'<br />'; |
} |
} |
} |
} |
} elsif (($context eq 'coursedoc') || ($context eq 'syllabus')) { |
} elsif ($context eq 'coursedoc') { |
my $extendedsubdir = $dirpath.'/'.$subdir; |
|
$extendedsubdir =~ s{/+$}{}; |
|
my $result = |
my $result = |
&Apache::lonnet::userfileupload('embedded_item_'.$i,$context,$extendedsubdir); |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'coursedoc', |
|
$dirpath.'/'.$path); |
if ($result !~ m|^/uploaded/|) { |
if ($result !~ m|^/uploaded/|) { |
$output .= '<span class="LC_error">' |
$output .= '<span class="LC_error">' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
Line 10193 sub upload_embedded {
|
Line 10162 sub upload_embedded {
|
} else { |
} else { |
$output .= &mt('Uploaded [_1]','<span class="LC_filename">'. |
$output .= &mt('Uploaded [_1]','<span class="LC_filename">'. |
$path.$fname.'</span>').'<br />'; |
$path.$fname.'</span>').'<br />'; |
if ($context eq 'syllabus') { |
|
&Apache::lonnet::make_public_indefinitely($result); |
|
} |
|
} |
} |
} else { |
} else { |
# Save the file |
# Save the file |
Line 10327 sub modify_html_form {
|
Line 10293 sub modify_html_form {
|
} |
} |
|
|
sub modify_html_refs { |
sub modify_html_refs { |
my ($context,$dirpath,$uname,$udom,$dir_root,$url) = @_; |
my ($context,$dirpath,$uname,$udom,$dir_root) = @_; |
my $container; |
my $container; |
if ($context eq 'portfolio') { |
if ($context eq 'portfolio') { |
$container = $env{'form.container'}; |
$container = $env{'form.container'}; |
Line 10336 sub modify_html_refs {
|
Line 10302 sub modify_html_refs {
|
} elsif ($context eq 'manage_dependencies') { |
} elsif ($context eq 'manage_dependencies') { |
(undef,undef,$container) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
(undef,undef,$container) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
$container = "/$container"; |
$container = "/$container"; |
} elsif ($context eq 'syllabus') { |
|
$container = $url; |
|
} else { |
} else { |
$container = $Apache::lonnet::perlvar{'lonDocRoot'}.$env{'form.filename'}; |
$container = $Apache::lonnet::perlvar{'lonDocRoot'}.$env{'form.filename'}; |
} |
} |
my (%allfiles,%codebase,$output,$content); |
my (%allfiles,%codebase,$output,$content); |
my @changes = &get_env_multiple('form.namechange'); |
my @changes = &get_env_multiple('form.namechange'); |
unless ((@changes > 0) || ($context eq 'syllabus')) { |
unless (@changes > 0) { |
if (wantarray) { |
if (wantarray) { |
return ('',0,0); |
return ('',0,0); |
} else { |
} else { |
Line 10351 sub modify_html_refs {
|
Line 10315 sub modify_html_refs {
|
} |
} |
} |
} |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
($context eq 'manage_dependencies') || ($context eq 'syllabus')) { |
($context eq 'manage_dependencies')) { |
unless ($container =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/}) { |
unless ($container =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/}) { |
if (wantarray) { |
if (wantarray) { |
return ('',0,0); |
return ('',0,0); |
Line 10407 sub modify_html_refs {
|
Line 10371 sub modify_html_refs {
|
if ($content =~ m{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}) { |
if ($content =~ m{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}) { |
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}; |
|
} |
} |
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 10416 sub modify_html_refs {
|
Line 10379 sub modify_html_refs {
|
} |
} |
} |
} |
} |
} |
my $skiprewrites; |
|
if ($count || $codebasecount) { |
if ($count || $codebasecount) { |
my $saveresult; |
my $saveresult; |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
($context eq 'manage_dependencies') || ($context eq 'syllabus')) { |
($context eq 'manage_dependencies')) { |
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult); |
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult); |
if ($url eq $container) { |
if ($url eq $container) { |
my ($fname) = ($container =~ m{/([^/]+)$}); |
my ($fname) = ($container =~ m{/([^/]+)$}); |
Line 10433 sub modify_html_refs {
|
Line 10395 sub modify_html_refs {
|
'<span class="LC_filename">'. |
'<span class="LC_filename">'. |
$container.'</span>').'</p>'; |
$container.'</span>').'</p>'; |
} |
} |
if ($context eq 'syllabus') { |
|
unless ($saveresult eq 'ok') { |
|
$skiprewrites = 1; |
|
} |
|
} |
|
} else { |
} else { |
if (open(my $fh,">$container")) { |
if (open(my $fh,">$container")) { |
print $fh $content; |
print $fh $content; |
Line 10453 sub modify_html_refs {
|
Line 10410 sub modify_html_refs {
|
} |
} |
} |
} |
} |
} |
if (($context eq 'syllabus') && (!$skiprewrites)) { |
|
my ($actionurl,$state); |
|
$actionurl = "/public/$udom/$uname/syllabus"; |
|
my ($ignore,$num,$numpathchanges,$existing,$mapping) = |
|
&ask_for_embedded_content($actionurl,$state,\%allfiles, |
|
\%codebase, |
|
{'context' => 'rewrites', |
|
'ignore_remote_references' => 1,}); |
|
if (ref($mapping) eq 'HASH') { |
|
my $rewrites = 0; |
|
foreach my $key (keys(%{$mapping})) { |
|
next if ($key =~ m{^https?://}); |
|
my $ref = $mapping->{$key}; |
|
my $newname = "/uploaded/$udom/$uname/portfolio/syllabus/$key"; |
|
my $attrib; |
|
if (ref($allfiles{$mapping->{$key}}) eq 'ARRAY') { |
|
$attrib = join('|',@{$allfiles{$mapping->{$key}}}); |
|
} |
|
if ($content =~ m{($attrib\s*=\s*['"]?)\Q$ref\E(['"]?)}) { |
|
my $numchg = ($content =~ s{($attrib\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi); |
|
$rewrites += $numchg; |
|
} |
|
} |
|
if ($rewrites) { |
|
my $saveresult; |
|
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult); |
|
if ($url eq $container) { |
|
my ($fname) = ($container =~ m{/([^/]+)$}); |
|
$output .= '<p>'.&mt('Rewrote [quant,_1,link] as [quant,_1,absolute link] in [_2].', |
|
$count,'<span class="LC_filename">'. |
|
$fname.'</span>').'</p>'; |
|
} else { |
|
$output .= '<p class="LC_error">'. |
|
&mt('Error: could not update links in [_1].', |
|
'<span class="LC_filename">'. |
|
$container.'</span>').'</p>'; |
|
|
|
} |
|
} |
|
} |
|
} |
|
} else { |
} else { |
&logthis('Failed to parse '.$container. |
&logthis('Failed to parse '.$container. |
' to modify references: '.$parse_result); |
' to modify references: '.$parse_result); |
Line 10909 sub process_decompression {
|
Line 10825 sub process_decompression {
|
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($dir,$error,$warning,$output); |
my ($dir,$error,$warning,$output); |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) { |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) { |
$error = &mt('Filename not a supported archive file type.'). |
$error = &mt('File name not a supported archive file type.'). |
'<br />'.&mt('Filename should end with one of: [_1].', |
'<br />'.&mt('File name should end with one of: [_1].', |
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); |
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); |
} else { |
} else { |
my $docuhome = &Apache::lonnet::homeserver($docuname,$docudom); |
my $docuhome = &Apache::lonnet::homeserver($docuname,$docudom); |
Line 11486 sub process_extracted_files {
|
Line 11402 sub process_extracted_files {
|
$folders{'0'} = $items[-2]; |
$folders{'0'} = $items[-2]; |
if ($env{'form.folderpath'} =~ /\:1$/) { |
if ($env{'form.folderpath'} =~ /\:1$/) { |
$containers{'0'}='page'; |
$containers{'0'}='page'; |
} else { |
} else { |
$containers{'0'}='sequence'; |
$containers{'0'}='sequence'; |
} |
} |
} |
} |
Line 11606 sub process_extracted_files {
|
Line 11522 sub process_extracted_files {
|
} |
} |
} |
} |
} else { |
} else { |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
} |
} |
} |
} |
for (my $i=1; $i<=$numitems; $i++) { |
for (my $i=1; $i<=$numitems; $i++) { |
Line 11628 sub process_extracted_files {
|
Line 11544 sub process_extracted_files {
|
} |
} |
if ($itemidx eq '') { |
if ($itemidx eq '') { |
$itemidx = 0; |
$itemidx = 0; |
} |
} |
if (grep(/^\Q$referrer{$i}\E$/,@archdirs)) { |
if (grep(/^\Q$referrer{$i}\E$/,@archdirs)) { |
if ($mapinner{$referrer{$i}}) { |
if ($mapinner{$referrer{$i}}) { |
$fullpath = "$prefix$dir/$docstype/$mapinner{$referrer{$i}}"; |
$fullpath = "$prefix$dir/$docstype/$mapinner{$referrer{$i}}"; |
Line 11675 sub process_extracted_files {
|
Line 11591 sub process_extracted_files {
|
$showpath = "$relpath/$title"; |
$showpath = "$relpath/$title"; |
} else { |
} else { |
$showpath = "/$title"; |
$showpath = "/$title"; |
} |
} |
$result .= '<li>'.&mt('[_1] included as a dependency',$showpath).'</li>'."\n"; |
$result .= '<li>'.&mt('[_1] included as a dependency',$showpath).'</li>'."\n"; |
} |
} |
unless ($ishome) { |
unless ($ishome) { |
my $fetch = "$fullpath/$title"; |
my $fetch = "$fullpath/$title"; |
$fetch =~ s/^\Q$prefix$dir\E//; |
$fetch =~ s/^\Q$prefix$dir\E//; |
$prompttofetch{$fetch} = 1; |
$prompttofetch{$fetch} = 1; |
} |
} |
} |
} |
Line 11690 sub process_extracted_files {
|
Line 11606 sub process_extracted_files {
|
$path,$env{'form.archive_content_'.$referrer{$i}}).'<br />'; |
$path,$env{'form.archive_content_'.$referrer{$i}}).'<br />'; |
} |
} |
} else { |
} else { |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
} |
} |
} |
} |
if (keys(%todelete)) { |
if (keys(%todelete)) { |
Line 13412 sub commit_studentrole {
|
Line 13328 sub commit_studentrole {
|
} |
} |
} |
} |
} else { |
} else { |
if ($secchange) { |
if ($secchange) { |
$$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; |
$$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; |
} else { |
} else { |
$$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed; |
$$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed; |
Line 14118 sub init_user_environment {
|
Line 14034 sub init_user_environment {
|
my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], |
my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], |
$domain,$username); |
$domain,$username); |
my $reqstatus = $reqauthor{'author_status'}; |
my $reqstatus = $reqauthor{'author_status'}; |
if ($reqstatus eq 'approval' || $reqstatus eq 'approved') { |
if ($reqstatus eq 'approval' || $reqstatus eq 'approved') { |
if (ref($reqauthor{'author'}) eq 'HASH') { |
if (ref($reqauthor{'author'}) eq 'HASH') { |
$userenv{'requestauthorqueued'} = $reqstatus.':'. |
$userenv{'requestauthorqueued'} = $reqstatus.':'. |
$reqauthor{'author'}{'timestamp'}; |
$reqauthor{'author'}{'timestamp'}; |
Line 14400 sub captcha_display {
|
Line 14316 sub captcha_display {
|
if ($captcha eq 'original') { |
if ($captcha eq 'original') { |
$output = &create_captcha(); |
$output = &create_captcha(); |
unless ($output) { |
unless ($output) { |
$error = 'captcha'; |
$error = 'captcha'; |
} |
} |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$output = &create_recaptcha($pubkey); |
$output = &create_recaptcha($pubkey); |
unless ($output) { |
unless ($output) { |
$error = 'recaptcha'; |
$error = 'recaptcha'; |
} |
} |
} |
} |
return ($output,$error); |
return ($output,$error); |