version 1.606, 2016/06/19 04:27:49
|
version 1.610, 2016/10/31 19:48:59
|
Line 3888 END
|
Line 3888 END
|
} |
} |
} |
} |
|
|
my ($editlink,$extresform); |
my ($editlink,$extresform,$anchor); |
my $orig_url = $url; |
my $orig_url = $url; |
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; |
$url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; |
Line 3912 END
|
Line 3912 END
|
$url='/adm/wrapper'.$url; |
$url='/adm/wrapper'.$url; |
} |
} |
if (&Apache::lonnet::symbverify($symb,$url)) { |
if (&Apache::lonnet::symbverify($symb,$url)) { |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
my $shownsymb = $symb; |
|
if ($isexternal) { |
|
if ($url =~ /^([^#]+)#([^#]+)$/) { |
|
$url = $1; |
|
$anchor = $2; |
|
if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) { |
|
$shownsymb = $1.&escape('#').$anchor; |
|
} |
|
} |
|
} |
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&'); |
} else { |
} else { |
$url=''; |
$url=''; |
} |
} |
} |
} |
|
} elsif ($supplementalflag) { |
|
if ($isexternal) { |
|
if ($url =~ /^([^#]+)#([^#]+)$/) { |
|
$url = $1; |
|
$anchor = $2; |
|
} |
|
} |
} |
} |
my ($rand_pick_text,$rand_order_text); |
my ($rand_pick_text,$rand_order_text); |
if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') { |
if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') { |
Line 3989 $form_end;
|
Line 4006 $form_end;
|
if ((($isexternal) || ($isexttool)) && $orderidx) { |
if ((($isexternal) || ($isexttool)) && $orderidx) { |
$url .= '&idx='.$orderidx; |
$url .= '&idx='.$orderidx; |
} |
} |
|
if ($anchor ne '') { |
|
$url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&'); |
|
} |
} |
} |
my ($tdalign,$tdwidth); |
my ($tdalign,$tdwidth); |
if ($allowed) { |
if ($allowed) { |
Line 4006 $form_end;
|
Line 4026 $form_end;
|
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
my ($cfile,$home,$switchserver,$forceedit,$forceview) = |
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); |
if (($cfile ne '') && ($symb ne '' || $supplementalflag)) { |
if (($cfile ne '') && ($symb ne '' || $supplementalflag)) { |
|
my $suppanchor; |
|
if ($supplementalflag) { |
|
$suppanchor = $anchor; |
|
} |
my $jscall = |
my $jscall = |
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home, |
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home, |
$switchserver, |
$switchserver, |
$forceedit, |
$forceedit, |
undef,$symb, |
undef,$symb, |
&escape($env{'form.folderpath'}), |
&escape($env{'form.folderpath'}), |
$renametitle,'','',1); |
$renametitle,'','',1,$suppanchor); |
if ($jscall) { |
if ($jscall) { |
$editlink = '<a class="LC_docs_ext_edit" href="javascript:'. |
$editlink = '<a class="LC_docs_ext_edit" href="javascript:'. |
$jscall.'" >'.&mt('Edit').'</a> '."\n"; |
$jscall.'" >'.&mt('Edit').'</a> '."\n"; |
Line 4032 $form_end;
|
Line 4056 $form_end;
|
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { |
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { |
$line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>'; |
$line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>'; |
} elsif ($url) { |
} elsif ($url) { |
$line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes', |
if ($anchor ne '') { |
|
if ($supplementalflag) { |
|
$anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&'); |
|
} else { |
|
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); |
|
} |
|
} |
|
$line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. |
|
(($anchor ne '')?$anchor:''), |
'<img src="'.$icon.'" alt="" class="LC_icon" />',600,500); |
'<img src="'.$icon.'" alt="" class="LC_icon" />',600,500); |
} else { |
} else { |
$line.='<img src="'.$icon.'" alt="" class="LC_icon" />'; |
$line.='<img src="'.$icon.'" alt="" class="LC_icon" />'; |
Line 4041 $form_end;
|
Line 4073 $form_end;
|
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { |
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { |
$line.='<a href="'.$url.'">'.$title.'</a>'; |
$line.='<a href="'.$url.'">'.$title.'</a>'; |
} elsif ($url) { |
} elsif ($url) { |
$line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes', |
$line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. |
|
(($anchor ne '')?$anchor:''), |
$title,600,500); |
$title,600,500); |
} else { |
} else { |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
Line 4908 sub handler {
|
Line 4941 sub handler {
|
my $output = &Apache::lonpublisher::batchpublish($r,$srcfile,$targetfile,$nokeyref,1); |
my $output = &Apache::lonpublisher::batchpublish($r,$srcfile,$targetfile,$nokeyref,1); |
$env{'form.folder'} = $folder; |
$env{'form.folder'} = $folder; |
&snapshotbefore(); |
&snapshotbefore(); |
my $url = $redirect; |
|
$url =~ s{^/priv/}{/res/}; |
|
my $title = &LONCAPA::map::qtunescape($env{'form.newresourcetitle'}); |
my $title = &LONCAPA::map::qtunescape($env{'form.newresourcetitle'}); |
my $ext = 'false'; |
my $ext = 'false'; |
my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url)); |
my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url)); |
Line 5394 FUFORM
|
Line 5425 FUFORM
|
</form> |
</form> |
|
|
SEDFFORM |
SEDFFORM |
my $is_home; |
|
my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if (grep(/^\Q$crshome\E$/,@ids)) { |
|
$is_home = 1; |
|
} |
|
my (%subdirs,%files,%selimport_menus); |
|
my $pickfile; |
|
my $relpath = "/res/$coursedom/$coursenum"; |
|
&recursedirs($is_home,'res',$londocroot,$relpath,'',\%subdirs,\%files); |
|
my $numdirs = scalar(keys(%files)); |
|
if ($numdirs > 1) { |
|
my @order = sort { lc($a) cmp lc($b) } (keys(%files)); |
|
foreach my $key (@order) { |
|
if (ref($files{$key}) eq 'HASH') { |
|
my $shown = $key; |
|
if ($key eq '') { |
|
$shown = '/'; |
|
} |
|
$selimport_menus{$key}->{'text'} = $shown; |
|
$selimport_menus{$key}->{'default'} = ''; |
|
my @ordered = (''); |
|
$selimport_menus{$key}->{'select2'}->{''} = ''; |
|
foreach my $file (sort { lc($a) cmp lc($b) } (keys(%{$files{$key}}))) { |
|
$selimport_menus{$key}->{'select2'}->{$file} = $file; |
|
push(@ordered,$file); |
|
} |
|
$selimport_menus{$key}->{'order'} = \@ordered; |
|
} |
|
} |
|
$pickfile = $lt{'dire'}. |
|
&Apache::loncommon::linked_select_forms('crsresimportform','<br />'. |
|
&mt('Filename: '),'', |
|
'coursepath','coursefile', |
|
\%selimport_menus,\@order, |
|
"resize_scrollbox('contentscroll','1','0');",'','res'). |
|
'<br />'; |
|
} elsif ($numdirs == 1) { |
|
my $singledir = (keys(%files))[0]; |
|
my $showdir = $singledir; |
|
if ($singledir eq '') { |
|
$showdir = '/'; |
|
} |
|
$pickfile = $lt{'dire'}. |
|
'<select name="coursepath">'. |
|
'<option value="'.$singledir.'">'.$showdir.'</option>'."\n". |
|
'</select><br />'. |
|
&mt('Filename: ').'<select name="coursefile">'."\n". |
|
'<option value="" selected="selected">'.$lt{'se'}.'</option>'."\n"; |
|
foreach my $file (sort { lc($a) cmp lc($b) } (keys(%{$files{$singledir}}))) { |
|
$pickfile .= '<option value="'.$file.'">'.$file.'</option>'."\n"; |
|
} |
|
$pickfile .= '</select><br />'."\n"; |
|
} |
|
my $importcrsresform; |
my $importcrsresform; |
|
my ($numdirs,$pickfile) = |
|
&Apache::loncommon::import_crsauthor_form('crsresimportform','coursepath','coursefile', |
|
"resize_scrollbox('contentscroll','1','0');", |
|
undef,'res'); |
if ($pickfile) { |
if ($pickfile) { |
$importcrsresform=(<<CRSFORM); |
$importcrsresform=(<<CRSFORM); |
<a class="LC_menubuttons_link" href="javascript:toggleImportCrsres('res','$numdirs');"> |
<a class="LC_menubuttons_link" href="javascript:toggleImportCrsres('res','$numdirs');"> |
Line 5675 NWEBFORM
|
Line 5656 NWEBFORM
|
if (grep(/^\Q$env{'user.home'}\E$/,@ids)) { |
if (grep(/^\Q$env{'user.home'}\E$/,@ids)) { |
my $is_home = 1; |
my $is_home = 1; |
my %subdirs; |
my %subdirs; |
&recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
$select_menus{'author'}->{'default'} = '/'; |
$select_menus{'author'}->{'default'} = '/'; |
$select_menus{'author'}->{'select2'}->{'/'} = '/'; |
$select_menus{'author'}->{'select2'}->{'/'} = '/'; |
my @ordered = ('/'); |
my @ordered = ('/'); |
Line 5706 NWEBFORM
|
Line 5687 NWEBFORM
|
my $is_home = 1; |
my $is_home = 1; |
my (%subdirs,@ordered); |
my (%subdirs,@ordered); |
my $toppath="/priv/$audom/$auname"; |
my $toppath="/priv/$audom/$auname"; |
&recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
$select_menus{$key}->{'default'} = '/'; |
$select_menus{$key}->{'default'} = '/'; |
$select_menus{$key}->{'select2'}->{'/'} = '/'; |
$select_menus{$key}->{'select2'}->{'/'} = '/'; |
my @ordered = ('/'); |
my @ordered = ('/'); |
Line 5748 NWEBFORM
|
Line 5729 NWEBFORM
|
my $is_home = 1; |
my $is_home = 1; |
my %subdirs; |
my %subdirs; |
my $toppath="/priv/$coursedom/$coursenum"; |
my $toppath="/priv/$coursedom/$coursenum"; |
&recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
$numcrsdirs = keys(%subdirs); |
$numcrsdirs = keys(%subdirs); |
$select_menus{'course'}->{'default'} = '/'; |
$select_menus{'course'}->{'default'} = '/'; |
$select_menus{'course'}->{'select2'}->{'/'} = '/'; |
$select_menus{'course'}->{'select2'}->{'/'} = '/'; |
Line 5778 NWEBFORM
|
Line 5759 NWEBFORM
|
$pickdir .= '<input type="hidden" name="authorrole" value="course" />'; |
$pickdir .= '<input type="hidden" name="authorrole" value="course" />'; |
my $toppath="/priv/$coursedom/$coursenum'}"; |
my $toppath="/priv/$coursedom/$coursenum'}"; |
my %subdirs; |
my %subdirs; |
&recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
$numcrsdirs = keys(%subdirs); |
$numcrsdirs = keys(%subdirs); |
if ($numcrsdirs) { |
if ($numcrsdirs) { |
$pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n". |
$pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n". |
'<option value="/">/</option>'."\n"; |
'<option value="/">/</option>'."\n"; |
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
$pickdir .= '<option value="'.$relpath.'</option>'."\n"; |
$pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n"; |
} |
} |
$pickdir .= '</select>'; |
$pickdir .= '</select>'; |
} else { |
} else { |
Line 6594 sub editing_js {
|
Line 6575 sub editing_js {
|
my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller); |
my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller); |
$res = &Apache::lonnet::clutter($res); |
$res = &Apache::lonnet::clutter($res); |
if (&Apache::lonnet::is_on_map($res)) { |
if (&Apache::lonnet::is_on_map($res)) { |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='. |
my ($url,$anchor); |
|
if ($res =~ /^([^#]+)#([^#]+)$/) { |
|
$url = $1; |
|
$anchor = $2; |
|
if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) { |
|
$caller = $1.&escape('#').$anchor; |
|
} |
|
} |
|
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='. |
&HTML::Entities::encode($caller,'<>&"'); |
&HTML::Entities::encode($caller,'<>&"'); |
|
if ($anchor ne '') { |
|
$backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"'); |
|
} |
$backtourl = &Apache::loncommon::escape_single($backtourl); |
$backtourl = &Apache::loncommon::escape_single($backtourl); |
} else { |
} else { |
$backtourl = '/adm/navmaps'; |
$backtourl = '/adm/navmaps'; |
Line 7838 sub makesimpleeditform {
|
Line 7830 sub makesimpleeditform {
|
SIMPFORM |
SIMPFORM |
} |
} |
|
|
sub recursedirs { |
|
my ($is_home,$context,$docroot,$toppath,$relpath,$dirhashref,$filehashref) = @_; |
|
return unless (ref($dirhashref) eq 'HASH'); |
|
my $currpath = $docroot.$toppath; |
|
if ($relpath) { |
|
$currpath .= "/$relpath"; |
|
} |
|
my $savefile; |
|
if (ref($filehashref)) { |
|
$savefile = 1; |
|
} |
|
if ($is_home) { |
|
if (opendir(my $dirh,$currpath)) { |
|
foreach my $item (sort { lc($a) cmp lc($b) } grep(!/^\.+$/,readdir($dirh))) { |
|
next if ($item eq ''); |
|
if (-d "$currpath/$item") { |
|
my $newpath; |
|
if ($relpath) { |
|
$newpath = "$relpath/$item"; |
|
} else { |
|
$newpath = $item; |
|
} |
|
$dirhashref->{&js_escape($newpath)} = 1; |
|
&recursedirs($is_home,$context,$docroot,$toppath,$newpath,$dirhashref,$filehashref); |
|
} elsif ($savefile) { |
|
if ($context eq 'priv') { |
|
unless ($item =~ /\.(meta|save|log|bak|DS_Store)$/) { |
|
$filehashref->{&js_escape($relpath)}{$item} = 1; |
|
} |
|
} else { |
|
unless (($item =~ /\.meta$/) || ($item =~ /\.\d+\.\w+$/) || ($item =~ /\.rights$/)) { |
|
$filehashref->{&js_escape($relpath)}{$item} = 1; |
|
} |
|
} |
|
} |
|
} |
|
closedir($dirh); |
|
} |
|
} else { |
|
my ($dirlistref,$listerror) = |
|
&Apache::lonnet::dirlist($toppath.$relpath); |
|
my @dir_lines; |
|
my $dirptr=16384; |
|
if (ref($dirlistref) eq 'ARRAY') { |
|
foreach my $dir_line (sort |
|
{ |
|
my ($afile)=split('&',$a,2); |
|
my ($bfile)=split('&',$b,2); |
|
return (lc($afile) cmp lc($bfile)); |
|
} (@{$dirlistref})) { |
|
my ($item,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef) = |
|
split(/\&/,$dir_line,16); |
|
$item =~ s/\s+$//; |
|
next if (($item =~ /^\.\.?$/) || ($obs)); |
|
if ($dirptr&$testdir) { |
|
my $newpath; |
|
if ($relpath) { |
|
$newpath = "$relpath/$item"; |
|
} else { |
|
$relpath = '/'; |
|
$newpath = $item; |
|
} |
|
$dirhashref->{&js_escape($newpath)} = 1; |
|
&recursedirs($is_home,$context,$docroot,$toppath,$newpath,$dirhashref,$filehashref); |
|
} elsif ($savefile) { |
|
if ($context eq 'priv') { |
|
unless ($item =~ /\.(meta|save|log|bak|DS_Store)$/) { |
|
$filehashref->{$relpath}{$item} = 1; |
|
} |
|
} else { |
|
unless (($item =~ /\.meta$/) || ($item =~ /\.\d+\.\w+$/)) { |
|
$filehashref->{$relpath}{$item} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub makenewproblem { |
sub makenewproblem { |
my ($r,$coursedom,$coursenum) = @_; |
my ($r,$coursedom,$coursenum) = @_; |
# Creating a new problem |
# Creating a new problem |
Line 8121 END
|
Line 8032 END
|
|
|
sub finishnewprob { |
sub finishnewprob { |
my ($url,$path,$subdir,$newsubdir,$filename) = @_; |
my ($url,$path,$subdir,$newsubdir,$filename) = @_; |
|
unless (-d $path) { |
|
unless (mkdir($path,02770)) { |
|
return; |
|
} |
|
} |
my $redirect; |
my $redirect; |
if ($subdir ne '/') { |
if ($subdir ne '/') { |
$subdir = &cleandir($subdir); |
$subdir = &cleandir($subdir); |