--- loncom/interface/londocs.pm 2012/10/01 12:34:18 1.497 +++ loncom/interface/londocs.pm 2012/12/02 18:44:04 1.516 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.497 2012/10/01 12:34:18 raeburn Exp $ +# $Id: londocs.pm,v 1.516 2012/12/02 18:44:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonclonecourse; use Apache::lonnavmaps; use Apache::lonnavdisplay(); use Apache::lonuserstate(); +use Apache::lonextresedit(); use HTML::Entities; use HTML::TokeParser; use GDBM_File; @@ -312,62 +313,6 @@ sub group_import { return &storemap($coursenum, $coursedom, $folder.'.'.$container,1); } -sub breadcrumbs { - my ($allowed,$crstype)=@_; - &Apache::lonhtmlcommon::clear_breadcrumbs(); - my (@folders); - if ($env{'form.pagepath'}) { - @folders = split('&',$env{'form.pagepath'}); - } else { - @folders=split('&',$env{'form.folderpath'}); - } - my $folderpath; - my $cpinfo=''; - my $plain=''; - my $randompick=-1; - my $isencrypted=0; - my $ishidden=0; - my $is_random_order=0; - while (@folders) { - my $folder=shift(@folders); - my $foldername=shift(@folders); - if ($folderpath) {$folderpath.='&';} - $folderpath.=$folder.'&'.$foldername; - my $url; - if ($allowed) { - $url = '/adm/coursedocs?folderpath='; - } else { - $url = '/adm/supplemental?folderpath='; - } - $url .= &escape($folderpath); - my $name=&unescape($foldername); -# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername - $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; - if ($1 ne '') { - $randompick=$1; - } else { - $randompick=-1; - } - if ($2) { $ishidden=1; } - if ($3) { $isencrypted=1; } - if ($4 ne '') { $is_random_order = 1; } - if ($folder eq 'supplemental') { - $name = &mt('Supplemental '.$crstype.' Content'); - } - &Apache::lonhtmlcommon::add_breadcrumb( - {'href'=>$url.$cpinfo, - 'title'=>$name, - 'text'=>$name, - 'no_mt'=>1, - }); - $plain.=$name.' > '; - } - $plain=~s/\>\;\s*$//; - return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - undef, undef, 1 ),$randompick,$ishidden, - $isencrypted,$plain,$is_random_order); -} - sub log_docs { return &Apache::lonnet::write_log('course','docslog',@_); } @@ -455,7 +400,8 @@ sub docs_change_log { if ($folderpath eq '') { $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents')); } - $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; + $pathitem = '<input type="hidden" name="folderpath" value="'. + &HTML::Entities::encode($folderpath,'<>&"').'" />'; } my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container"; my $jumpto = $readfile; @@ -464,7 +410,8 @@ sub docs_change_log { if ($supplementalflag) { $tid = 2; } - my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype); + my ($breadcrumbtrail) = + &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); $r->print($breadcrumbtrail. &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto, $readfile)); @@ -1744,13 +1691,15 @@ sub handle_edit_cmd { sub editor { my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, - $supplementalflag,$orderhash,$iconpath)=@_; + $supplementalflag,$orderhash,$iconpath,$pathitem)=@_; my $container= ($env{'form.pagepath'}) ? 'page' : 'sequence'; - - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = - &breadcrumbs($allowed,$crstype); - $r->print($breadcrumbtrail); + my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order); + if ($allowed) { + (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); + $r->print($breadcrumbtrail); + } my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container"; @@ -1829,6 +1778,18 @@ sub editor { if (defined($item)) { my ($name,$url,$residx)= map {&unescape($_)} split(/\=/,$item); + if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) { + my ($suffix,$errortxt,$locknotfreed) = + &newmap_suffix($1,$2,$coursedom,$coursenum); + if ($locknotfreed) { + $r->print($locknotfreed); + } + if ($suffix) { + $url =~ s/_new\./_$suffix./; + } else { + return $errortxt; + } + } push(@imports, [$name, $url, $residx]); } } @@ -1900,35 +1861,62 @@ sub editor { unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $idx++; next; } $output .= &entryline($idx,$name,$url,$folder,$allowed,$res, - $coursenum,$crstype); + $coursenum,$coursedom,$crstype, + $pathitem,$supplementalflag); $idx++; $shown++; } &Apache::loncommon::end_data_table_count(); - - if ($shown) { - $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll') - .&Apache::loncommon::start_data_table(undef,'contentlist'); - if ($allowed) { - $to_show .= &Apache::loncommon::start_data_table_header_row() - .'<th colspan="2">'.&mt('Move').'</th>' - .'<th>'.&mt('Actions').'</th>' - .'<th colspan="2">'.&mt('Document').'</th>'; - if ($folder !~ /^supplemental/) { - $to_show .= '<th colspan="4">'.&mt('Settings').'</th>'; + + if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { + if ($shown) { + if ($allowed) { + $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll') + .&Apache::loncommon::start_data_table(undef,'contentlist') + .&Apache::loncommon::start_data_table_header_row() + .'<th colspan="2">'.&mt('Move').'</th>' + .'<th>'.&mt('Actions').'</th>' + .'<th colspan="2">'.&mt('Document').'</th>'; + if ($folder !~ /^supplemental/) { + $to_show .= '<th colspan="4">'.&mt('Settings').'</th>'; + } + $to_show .= &Apache::loncommon::end_data_table_header_row() + .$output.' ' + .&Apache::loncommon::end_data_table() + .'<br style="line-height:2px;" />' + .&Apache::loncommon::end_scrollbox(); + } else { + $to_show = '<table><tr><td>'.&Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT') + .'</td><td class="LC_middle">'.&mt('Tools:').'</td>' + .'<td align="left"><ul id="LC_toolbar">' + .'<li><a href="/adm/coursedocs?forcesupplement=1" ' + .'id="LC_content_toolbar_edittoplevel" ' + .'class="LC_toolbarItem" ' + .'title="'.&mt('Supplemental Content Editor').'">' + .'</a></li></ul></td></tr></table><br />' + .&Apache::loncommon::start_data_table('LC_tableOfContent') + .$output.' ' + .&Apache::loncommon::end_data_table(); } - $to_show .= &Apache::loncommon::end_data_table_header_row(); + } else { + $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') + .'<div class="LC_info" id="contentlist">' + .&mt('Currently no documents.') + .'</div>' + .&Apache::loncommon::end_scrollbox(); } - $to_show .= $output.' ' - .&Apache::loncommon::end_data_table() - .'<br style="line-height:2px;" />' - .&Apache::loncommon::end_scrollbox(); } else { - $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') - .'<div class="LC_info" id="contentlist">' - .&mt('Currently no documents.') - .'</div>' - .&Apache::loncommon::end_scrollbox(); + if ($shown) { + $to_show = '<div>' + .&Apache::loncommon::start_data_table('LC_tableOfContent') + .$output + .&Apache::loncommon::end_data_table() + .'</div>'; + } else { + $to_show = '<div class="LC_info" id="contentlist">' + .&mt('Currently no documents.') + .'</div>' + } } my $tid = 1; if ($supplementalflag) { @@ -1940,19 +1928,6 @@ sub editor { $readfile)); &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum); } else { - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - #Function Box for Supplemental Content for users with mdc priv. - my $funcname = &mt('Folder Editor'); - $r->print( - &Apache::loncommon::head_subbox( - &Apache::lonhtmlcommon::start_funclist(). - &Apache::lonhtmlcommon::add_item_funclist( - '<a href="/adm/coursedocs?command=direct&forcesupplement=1&'. - 'supppath='.&HTML::Entities::encode($env{'form.folderpath'}).'">'. - '<img src="/res/adm/pages/docs.png" alt="'.$funcname.'" class="LC_icon" />'. - '<span class="LC_menubuttons_inline_text">'.$funcname.'</span></a>'). - &Apache::lonhtmlcommon::end_funclist())); - } $r->print($to_show); } return; @@ -2117,7 +2092,8 @@ sub is_supplemental_title { # --------------------------------------------------------------- An entry line sub entryline { - my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_; + my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, + $crstype,$pathitem,$supplementalflag)=@_; my ($foldertitle,$pagetitle,$renametitle); if (&is_supplemental_title($title)) { ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); @@ -2131,7 +2107,6 @@ sub entryline { my $orderidx=$LONCAPA::map::order[$index]; - $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; $renametitle=~s/ /%20/g; @@ -2150,9 +2125,24 @@ sub entryline { $type = $container = 'page'; $esc_path=&escape($env{'form.pagepath'}); $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); - $symb=&escape($env{'form.pagesymb'}); } - my $cpinfo=''; + my $isexternal; + if ($residx) { + my $currurl = $url; + $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; + if ($currurl =~ m{^/adm/wrapper/ext/}) { + $isexternal = 1; + } + if (!$supplementalflag) { + my $path = 'uploaded/'. + $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. + $env{'course.'.$env{'request.course.id'}.'.num'}.'/'; + $symb = &Apache::lonnet::encode_symb($path.$folder.".$container", + $residx, + &Apache::lonnet::declutter($currurl)); + } + } + my %lt; if ($allowed) { my $incindex=$index+1; my $selectbox=''; @@ -2175,13 +2165,20 @@ sub entryline { } $selectbox.='</select>'; } - my %lt=&Apache::lonlocal::texthash( + %lt=&Apache::lonlocal::texthash( 'up' => 'Move Up', 'dw' => 'Move Down', 'rm' => 'Remove', 'ct' => 'Cut', 'rn' => 'Rename', - 'cp' => 'Copy'); + 'cp' => 'Copy', + 'ex' => 'External Resource', + 'ed' => 'Edit', + 'pr' => 'Preview', + 'sv' => 'Save', + 'ul' => 'URL', + 'ti' => 'Title', + ); my $nocopy=0; my $nocut=0; my $noremove=0; @@ -2242,10 +2239,7 @@ sub entryline { $nocopy=1; } } - my $copylink=' '; - my $cutlink=' '; - my $removelink=' '; - + my ($copylink,$cutlink,$removelink,$renamelink); my $skip_confirm = 0; if ( $folder =~ /^supplemental/ || ($url =~ m{( /smppg$ @@ -2253,26 +2247,41 @@ sub entryline { |/aboutme$ |/navmaps$ |/bulletinboard$ - |\.html$ - |^/adm/wrapper/ext)}x)) { + |\.html$)}x) + || $isexternal) { $skip_confirm = 1; } - if (!$nocopy) { + if ($nocopy) { + $copylink=(<<ENDCOPY); +<span style="visibility: hidden;">$lt{'cp'}</span> +ENDCOPY + } else { $copylink=(<<ENDCOPY); <a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$symb','$folder');" class="LC_docs_copy">$lt{'cp'}</a> ENDCOPY } - if (!$nocut) { + if ($nocut) { + $cutlink=(<<ENDCUT); +<span style="visibility: hidden;">$lt{'ct'}</span> +ENDCUT + } else { $cutlink=(<<ENDCUT); <a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a> ENDCUT } - if (!$noremove) { + if ($noremove) { + $removelink=(<<ENDREM); +<span style="visibility: hidden;">$lt{'rm'}</a> +ENDREM + } else { $removelink=(<<ENDREM); <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> ENDREM } + $renamelink=(<<ENDREN); +<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> +ENDREN $form_start = ' <form action="/adm/coursedocs" method="post"> '; @@ -2286,13 +2295,13 @@ END $line.=(<<END); <td> <div class="LC_docs_entry_move"> - <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> - <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /> + <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb'> + <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" /> </a> </div> <div class="LC_docs_entry_move"> - <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> - <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /> + <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb'> + <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" /> </a> </div> </td> @@ -2302,11 +2311,12 @@ END $selectbox $form_end </td> -<td class="LC_docs_entry_commands"> +<td class="LC_docs_entry_commands"><span class="LC_nobreak"> $removelink +$renamelink $cutlink - <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> $copylink +</span> </td> END @@ -2343,43 +2353,36 @@ END } } + my $editlink; my $orig_url = $url; $orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; - my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); - if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { - my $symb=&Apache::lonnet::symbclean( - &Apache::lonnet::declutter('uploaded/'. - $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. - $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. - '.sequence'). - '___'.$residx.'___'. - &Apache::lonnet::declutter($url)); - (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); - $url=&Apache::lonnet::clutter($url); - if ($url=~/^\/*uploaded\//) { - $url=~/\.(\w+)$/; - my $embstyle=&Apache::loncommon::fileembstyle($1); - if (($embstyle eq 'img') || ($embstyle eq 'emb')) { - $url='/adm/wrapper'.$url; - } elsif ($embstyle eq 'ssi') { - #do nothing with these - } elsif ($url!~/\.(sequence|page)$/) { - $url='/adm/coursedocs/showdoc'.$url; + $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; + if (!$supplementalflag && $residx && $symb) { + if ($container eq 'page') { + $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); + $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); + } + if ((!$isfolder) && (!$ispage)) { + (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); + $url=&Apache::lonnet::clutter($url); + if ($url=~/^\/*uploaded\//) { + $url=~/\.(\w+)$/; + my $embstyle=&Apache::loncommon::fileembstyle($1); + if (($embstyle eq 'img') || ($embstyle eq 'emb')) { + $url='/adm/wrapper'.$url; + } elsif ($embstyle eq 'ssi') { + #do nothing with these + } elsif ($url!~/\.(sequence|page)$/) { + $url='/adm/coursedocs/showdoc'.$url; + } + } elsif ($url=~m|^/ext/|) { + $url='/adm/wrapper'.$url; } - } elsif ($url=~m|^/ext/|) { - $url='/adm/wrapper'.$url; - $external = 1; - } - if (&Apache::lonnet::symbverify($symb,$url)) { - $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); - } else { - $url=''; - } - if ($container eq 'page') { - my $symb=$env{'form.pagesymb'}; - - $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); - $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); + if (&Apache::lonnet::symbverify($symb,$url)) { + $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); + } else { + $url=''; + } } } my ($rand_pick_text,$rand_order_text); @@ -2387,9 +2390,14 @@ END my $foldername=&escape($foldertitle); my $folderpath=$env{'form.folderpath'}; if ($folderpath) { $folderpath.='&' }; + if (!$allowed && $supplementalflag) { + $folderpath.=$folderarg.'&'.$foldername; + $url.='folderpath='.&escape($folderpath); + } else { # Append randompick number, hidden, and encrypted with ":" to foldername, # so it gets transferred between levels - $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx, + $folderpath.=$folderarg.'&'.$foldername. + ':'.(&LONCAPA::map::getparameter($orderidx, 'parameter_randompick'))[0] .':'.((&LONCAPA::map::getparameter($orderidx, 'parameter_hiddenresource'))[0]=~/^yes$/i) @@ -2397,28 +2405,38 @@ END 'parameter_encrypturl'))[0]=~/^yes$/i) .':'.((&LONCAPA::map::getparameter($orderidx, 'parameter_randomorder'))[0]=~/^yes$/i); - $url.='folderpath='.&escape($folderpath).$cpinfo; - my $rpicknum = (&LONCAPA::map::getparameter($orderidx, - 'parameter_randompick'))[0]; - my $rpckchk; - if ($rpicknum) { - $rpckchk = ' checked="checked"'; - } - my $formname = 'edit_rpick_'.$orderidx; - $rand_pick_text = + $url.='folderpath='.&escape($folderpath); + my $rpicknum = (&LONCAPA::map::getparameter($orderidx, + 'parameter_randompick'))[0]; + my $rpckchk; + if ($rpicknum) { + $rpckchk = ' checked="checked"'; + } + my $formname = 'edit_rpick_'.$orderidx; + $rand_pick_text = '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n". $form_common."\n". '<span class="LC_nobreak"><label><input type="checkbox" name="randpickon_'.$orderidx.'" id="rpick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="randompick_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" />'; - if ($rpicknum ne '') { - $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>'; - } - $rand_pick_text .= '</span></form>'; - my $ro_set= - ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); - $rand_order_text = + if ($rpicknum ne '') { + $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>'; + } + $rand_pick_text .= '</span></form>'; + my $ro_set= + ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); + $rand_order_text = $form_start. $form_common.' <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="'."this.form.changeparms.value='randomorder';this.form.submit()".'" '.$ro_set.' /> '.&mt('Random Order').' </label></span></form>'; + } + } elsif ($supplementalflag && !$allowed) { + $url .= ($url =~ /\?/) ? '&':'?'; + $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); + if ($title) { + $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); + } + if ($isexternal && $orderidx) { + $url .= '&idx='.$orderidx; + } } if ($ispage) { my $pagename=&escape($pagetitle); @@ -2426,23 +2444,32 @@ $form_common.' my $folderpath=$env{'form.folderpath'}; if ($folderpath) { $pagepath = $folderpath.'&' }; $pagepath.=$pagearg.'&'.$pagename; - my $symb=$env{'form.pagesymb'}; - if (!$symb) { - my $path='uploaded/'. - $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. - $env{'course.'.$env{'request.course.id'}.'.num'}.'/'; - $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', - $residx, - $path.$pagearg.'.page'); - } $url.='pagepath='.&escape($pagepath). - '&pagesymb='.&escape($symb).$cpinfo; + '&pagesymb='.&escape($symb); } - if (($external) && ($allowed)) { - my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; - $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>'; - } else { - undef($external); + if ($allowed) { + my $fileloc = + &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url)); + if ($isexternal) { + $editlink = ' '. + &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem); + } elsif (!$isfolder && !$ispage) { + my ($cfile,$home,$switchserver,$forceedit,$forceview) = + &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url); + if (($cfile ne '') && ($symb ne '' || $supplementalflag)) { + my $jscall = + &Apache::lonhtmlcommon::jump_to_editres($cfile,$home, + $switchserver, + $forceedit, + undef,$symb, + &escape($env{'form.folderpath'}), + $renametitle); + if ($jscall) { + $editlink = ' <a class="LC_docs_ext_edit" href="javascript:'. + $jscall.'" >'.&mt('Edit').'</a>'; + } + } + } } my $reinit; if ($crstype eq 'Community') { @@ -2468,7 +2495,7 @@ $form_common.' } else { $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; } - $line.=$external."</td>"; + $line.=$editlink."</td>"; $rand_pick_text = ' ' if ($rand_pick_text eq ''); $rand_order_text = ' ' if ($rand_order_text eq ''); if (($allowed) && ($folder!~/^supplemental/)) { @@ -2499,6 +2526,30 @@ ENDPARMS return $line; } +sub newmap_suffix { + my ($area,$container,$coursedom,$coursenum) = @_; + my ($prefix,$idtype,$errtext,$locknotfreed); + $prefix = 'docs'; + if ($area eq 'supplemental') { + $prefix = 'supp'; + } + $prefix .= $container; + $idtype = 'concat'; + my ($suffix,$freedlock,$error) = + &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps', + $coursedom,$coursenum); + if (!$suffix) { + $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); + if ($error) { + $errtext .= '<br />'.$error; + } + } + if ($freedlock ne 'ok') { + $locknotfreed = '<div class="LC_error">'.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course. Please contact the domain coordinator for your LON-CAPA domain.').'</div>'; + } + return ($suffix,$errtext,$locknotfreed); +} + =pod =item tiehash() @@ -3031,9 +3082,9 @@ sub init_breadcrumbs { sub create_list_elements { my @formarr = @_; my $list = ''; - for my $button (@formarr){ - for my $picture(keys %$button) { - $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); + foreach my $button (@formarr){ + foreach my $picture (keys(%{$button})) { + $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''}); } } return $list; @@ -3103,7 +3154,8 @@ sub handler { 'Adding_External_Resource','Navigate_Content', 'Adding_Folders','Docs_Overview', 'Load_Map', 'Supplemental','Score_Upload_Form','Adding_Pages', - 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', + 'Importing_LON-CAPA_Resource','Importing_IMS_Course', + 'Uploading_From_Harddrive', 'Check_Resource_Versions','Verify_Content') { $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); } @@ -3165,7 +3217,7 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['folderpath','pagepath', 'pagesymb','forcesupplement','forcestandard', - 'tools','symb','command']); + 'tools','symb','command','supppath']); # standard=1: this is a "new-style" course with an uploaded map as top level # standard=2: this is a "old-style" course, and there is nothing we can do @@ -3194,7 +3246,7 @@ sub handler { my $addentries = {}; my $container; my $containertag; - my $uploadtag; + my $pathitem; # Do we directly jump somewhere? @@ -3235,21 +3287,31 @@ sub handler { } } } - $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. - &Apache::lonhtmlcommon::entity_encode($mapresobj->title()). + $path =~ s/^\&//; + my $maptitle = $mapresobj->title(); + if ($mapurl eq 'default') { + $maptitle = 'Main Course Documents'; + } + $path .= (($path ne '')? '&' : ''). + &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. + &Apache::lonhtmlcommon::entity_encode($maptitle). ':'.$mapresobj->randompick(). ':'.$mapresobj->randomout(). ':'.$mapresobj->encrypted(). ':'.$mapresobj->randomorder(); } else { my $maptitle = &Apache::lonnet::gettitle($mapurl); - $path = '&default&...::::'. - '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. - &Apache::lonhtmlcommon::entity_encode($maptitle).'::::'; + if ($mapurl eq 'default') { + $maptitle = 'Main Course Documents'; + } + $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. + &Apache::lonhtmlcommon::entity_encode($maptitle).'::::'; + } + unless ($mapurl eq 'default') { + $path = 'default&'. + &Apache::lonhtmlcommon::entity_encode('Main Course Documents'). + '::::&'.$path; } - $path = 'default&'. - &Apache::lonhtmlcommon::entity_encode('Main Course Documents'). - $path; if ($type eq 'sequence') { $env{'form.folderpath'}=$path; $env{'form.pagepath'}=''; @@ -3276,10 +3338,10 @@ sub handler { $stored_folderpath='docs_sup_folderpath'; } -# No folderpath, no pagepath, see if we have something stored - if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) { +# No folderpath, no pagepath, and in edit mode, see if we have something stored + if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'}) && $allowed) { &Apache::loncommon::restore_course_settings($stored_folderpath, - {'folderpath' => 'scalar'}); + {'folderpath' => 'scalar'}); } # If we are not allowed to make changes, all we can see are supplemental docs @@ -3311,9 +3373,11 @@ sub handler { # Store this unless ($toolsflag) { - &Apache::loncommon::store_course_settings($stored_folderpath, - {'pagepath' => 'scalar', - 'folderpath' => 'scalar'}); + if ($allowed) { + &Apache::loncommon::store_course_settings($stored_folderpath, + {'pagepath' => 'scalar', + 'folderpath' => 'scalar'}); + } if ($env{'form.folderpath'}) { my (@folderpath)=split('&',$env{'form.folderpath'}); $env{'form.foldername'}=&unescape(pop(@folderpath)); @@ -3327,7 +3391,7 @@ sub handler { $container='page'; $containertag = '<input type="hidden" name="pagepath" value="" />'. '<input type="hidden" name="pagesymb" value="" />'; - $uploadtag = + $pathitem = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'. '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'. '<input type="hidden" name="folderpath" value="" />'; @@ -3341,7 +3405,7 @@ sub handler { } } $containertag = '<input type="hidden" name="folderpath" value="" />'; - $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; + $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; } if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { $showdoc='/'.$1; @@ -3389,7 +3453,8 @@ sub handler { $script .= &editing_js($udom,$uname,$supplementalflag). &history_tab_js(). &inject_data_js(). - &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr); + &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr). + &Apache::lonextresedit::extedit_javascript(); $addentries = { onload => "javascript:resize_scrollbox('contentscroll','1','1');", }; @@ -3397,6 +3462,10 @@ sub handler { if ($env{'docs.markedcopy_url'}) { $script .= &paste_popup_js(); } + my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. + &mt('Switch server?'); + + } # -------------------------------------------------------------------- Body tag $script = '<script type="text/javascript">'."\n" @@ -3407,22 +3476,26 @@ sub handler { # Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); - unless ($showdoc) { + + if ($showdoc) { + $r->print(&Apache::loncommon::start_page("$crstype documents",undef, + {'force_register' => $showdoc,})); + } elsif ($r->uri eq '/adm/supplemental') { + my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype); + $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef, + {'bread_crumbs' => $brcrum,})); + } else { &Apache::lonhtmlcommon::add_breadcrumb({ href=>"/adm/coursedocs",text=>"$crstype Contents"}); $r->print(&Apache::loncommon::start_page("$crstype Contents", $script, - {'force_register' => $showdoc, - 'add_entries' => $addentries, - }) + {'add_entries' => $addentries} + ) .&Apache::loncommon::help_open_menu('','',273,'RAT') .&Apache::lonhtmlcommon::breadcrumbs( 'Editing '.$crstype.' Contents', 'Docs_Adding_Course_Doc') ); - } else { - $r->print(&Apache::loncommon::start_page("$crstype documents",undef, - {'force_register' => $showdoc,})); } my %allfiles = (); @@ -3489,10 +3562,12 @@ sub handler { 'upls' => 'Upload a new supplemental '.lc($crstype).' document', 'impp' => 'Import a document', 'copm' => 'All documents out of a published map into this folder', - 'upld' => 'Import Document', + 'upfi' => 'Upload File', + 'upld' => 'Import Content', 'srch' => 'Search', 'impo' => 'Import', 'lnks' => 'Import from Stored Links', + 'impm' => 'Import from Assembled Map', 'selm' => 'Select Map', 'load' => 'Load Map', 'reco' => 'Recover Deleted Documents', @@ -3512,14 +3587,15 @@ sub handler { 'abou' => 'Personal Information Page for a User', 'imsf' => 'IMS Import', 'imsl' => 'Import IMS package', + 'cms' => 'Origin of IMS package', + 'se' => 'Select', 'file' => 'File', 'title' => 'Title', 'comment' => 'Comment', + 'url' => 'URL', + 'prev' => 'Preview', + 'lnk' => 'Add Link', 'parse' => 'Upload embedded images/multimedia files if HTML file', - 'nd' => 'Upload Document', - 'pm' => 'Published Map', - 'sd' => 'Special Document', - 'mo' => 'More Options', ); # ----------------------------------------------------------------------------- my $fileupload=(<<FIUP); @@ -3535,54 +3611,85 @@ FIUP <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'} </label> CHBO + my $imsfolder = $env{'form.folder'}; + if ($imsfolder eq '') { + $imsfolder = 'default'; + } + my $imspform=(<<IMSFORM); + <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');"> + $lt{'imsf'}</a> $help{'Importing_IMS_Course'} + <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport"> + <fieldset id="uploadimsform" style="display: none;"> + <legend>$lt{'imsf'}</legend> + $fileupload + <br /> + <p> + $lt{'cms'}: + <select name="source"> + <option value="-1" selected="selected">$lt{'se'}</option> + <option value="bb5">Blackboard 5</option> + <option value="bb6">Blackboard 6</option> + <option value="angel5">ANGEL 5.5</option> + <option value="webctce4">WebCT 4 Campus Edition</option> + </select> + <input type="hidden" name="folder" value="$imsfolder" /> + </p> + <input type="hidden" name="phase" value="one" /> + <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" /> + </fieldset> + </form> +IMSFORM - my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}"; my $fileuploadform=(<<FUFORM); - <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> + <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');"> + $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'} + <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> + <fieldset id="uploaddocform" style="display: none;"> + <legend>$lt{'upfi'}</legend> <input type="hidden" name="active" value="aa" /> $fileupload <br /> $lt{'title'}:<br /> <input type="text" size="60" name="comment" /> - $uploadtag + $pathitem <input type="hidden" name="cmd" value="upload_default" /> <br /> <span class="LC_nobreak" style="float:left"> $checkbox </span> + <br clear="all" /> + <input type="submit" value="$lt{'upld'}" /> + </fieldset> + </form> FUFORM - $fileuploadform .= $fileuploada.'</form>'; - my $simpleeditdefaultform=(<<SEDFFORM); - <form action="/adm/coursedocs" method="post" name="simpleeditdefault"> + my $importpubform=(<<SEDFFORM); + <a class="LC_menubuttons_link" href="javascript:toggleMap('map');"> + $lt{'impm'}</a>$help{'Load_Map'} + <form action="/adm/coursedocs" method="post" name="mapimportform"> + <fieldset id="importmapform" style="display: none;"> + <legend>$lt{'impm'}</legend> <input type="hidden" name="active" value="bb" /> + $lt{'copm'}<br /> + <span class="LC_nobreak"> + <input type="text" name="importmap" size="40" value="" + onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" /> + <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br /> + <input type="submit" name="loadmap" value="$lt{'load'}" /> + </fieldset> + </form> + SEDFFORM - my @simpleeditdefaultforma = ( - { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, + my @importpubforma = ( + { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" }, + { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform } ); - $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma)); - $simpleeditdefaultform .=(<<SEDFFORM); - <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" /> - $lt{'copm'}<br /> - <input type="text" size="40" name="importmap" /><br /> - <span class="LC_nobreak" style="float:left"><input type="button" - onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" - value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" /> - $help{'Load_Map'}</span> - </form> -SEDFFORM - - my $extresourcesform=(<<ERFORM); - <form action="/adm/coursedocs" method="post" name="newext"> - $uploadtag - <input type="hidden" name="importdetail" value="" /> - <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} - </form> -ERFORM - - + $importpubform = &create_form_ul(&create_list_elements(@importpubforma)); + my $extresourcesform = + &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, + $help{'Adding_External_Resource'}); if ($allowed) { my $folder = $env{'form.folder'}; if ($folder eq '') { @@ -3599,18 +3706,23 @@ ERFORM </form> HIDDENFORM - $r->print(&makesimpleeditform($uploadtag)."\n". - &makedocslogform($uploadtag."\n". + $r->print(&makesimpleeditform($pathitem)."\n". + &makedocslogform($pathitem."\n". '<input type="hidden" name="folder" value="'. $env{'form.folder'}.'" />'."\n")); } # Generate the tabs - my $mode; + my ($mode,$needs_end); if (($supplementalflag) && (!$allowed)) { - &Apache::lonnavdisplay::startContentScreen($r,'supplemental'); + my @folders = split('&',$env{'form.folderpath'}); + unless (@folders > 2) { + &Apache::lonnavdisplay::startContentScreen($r,'supplemental'); + $needs_end = 1; + } } else { $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs'))); + $needs_end = 1; } # @@ -3623,7 +3735,7 @@ HIDDENFORM $folder='default'; $savefolderpath = $env{'form.folderpath'}; $env{'form.folderpath'}='default&'.&escape(&mt('Content')); - $uploadtag = '<input type="hidden" name="folderpath" value="'. + $pathitem = '<input type="hidden" name="folderpath" value="'. &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'; } my $postexec=''; @@ -3637,27 +3749,18 @@ HIDDENFORM } else { #$postexec='self.close();'; } - my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. - '.sequence'; - my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. - '.page'; + my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence'; + my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page'; my $container='sequence'; if ($env{'form.pagepath'}) { $container='page'; } my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; - my $imspform=(<<IMSPFORM); - <form action="/adm/imsimportdocs" method="post" name="ims"> - <input type="hidden" name="folder" value="$folder" /> - <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a> - </form> -IMSPFORM - my $newnavform=(<<NNFORM); <form action="/adm/coursedocs" method="post" name="newnav"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="$lt{'navc'}=/adm/navmaps" /> <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a> @@ -3667,7 +3770,7 @@ NNFORM my $newsmppageform=(<<NSPFORM); <form action="/adm/coursedocs" method="post" name="newsmppg"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a> $help{'Simple Page'} @@ -3677,7 +3780,7 @@ NSPFORM my $newsmpproblemform=(<<NSPROBFORM); <form action="/adm/coursedocs" method="post" name="newsmpproblem"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a> $help{'Simple Problem'} @@ -3688,7 +3791,7 @@ NSPROBFORM my $newdropboxform=(<<NDBFORM); <form action="/adm/coursedocs" method="post" name="newdropbox"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a> </form> @@ -3697,7 +3800,7 @@ NDBFORM my $newexuploadform=(<<NEXUFORM); <form action="/adm/coursedocs" method="post" name="newexamupload"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a> $help{'Score_Upload_Form'} @@ -3707,7 +3810,7 @@ NEXUFORM my $newbulform=(<<NBFORM); <form action="/adm/coursedocs" method="post" name="newbul"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a> $help{'Bulletin Board'} @@ -3717,7 +3820,7 @@ NBFORM my $newaboutmeform=(<<NAMFORM); <form action="/adm/coursedocs" method="post" name="newaboutme"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="$plainname=/adm/$udom/$uname/aboutme" /> <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a> @@ -3728,7 +3831,7 @@ NAMFORM my $newaboutsomeoneform=(<<NASOFORM); <form action="/adm/coursedocs" method="post" name="newaboutsomeone"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a> </form> @@ -3738,7 +3841,7 @@ NASOFORM my $newrosterform=(<<NROSTFORM); <form action="/adm/coursedocs" method="post" name="newroster"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="$lt{'rost'}=/adm/viewclasslist" /> <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a> @@ -3770,7 +3873,7 @@ NPFORM $newfolderform=(<<NFFORM); <form action="/adm/coursedocs" method="post" name="newfolder"> - <input type="hidden" name="folderpath" value="$path" /> + $pathitem <input type="hidden" name="importdetail" value="" /> <input type="hidden" name="active" value="aa" /> <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'} @@ -3780,7 +3883,7 @@ NFFORM my $newsylform=(<<NSYLFORM); <form action="/adm/coursedocs" method="post" name="newsyl"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" /> <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a> @@ -3792,7 +3895,7 @@ NSYLFORM my $newgroupfileform=(<<NGFFORM); <form action="/adm/coursedocs" method="post" name="newgroupfiles"> <input type="hidden" name="active" value="cc" /> - $uploadtag + $pathitem <input type="hidden" name="importdetail" value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" /> <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a> @@ -3809,9 +3912,11 @@ NGFFORM my @importdoc = ( - {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform}, - {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},); - $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform; + {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}, + {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}, + {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform, + }); + $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)); @gradingforma=( {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, @@ -3832,19 +3937,19 @@ NGFFORM my %orderhash = ( 'aa' => ['Import Content',$fileuploadform], - 'bb' => ['Published Content',$simpleeditdefaultform], + 'bb' => ['Published Content',$importpubform], 'cc' => ['Grading Resources',$gradingform], ); unless ($env{'form.pagepath'}) { $orderhash{'00'} = ['Newfolder',$newfolderform]; $orderhash{'dd'} = ['Collaboration',$communityform]; - $orderhash{'ee'} = ['Special Documents',$specialdocumentsform]; + $orderhash{'ee'} = ['Special Pages',$specialdocumentsform]; } $hadchanges=0; unless (($supplementalflag || $toolsflag)) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, - $supplementalflag,\%orderhash,$iconpath); + $supplementalflag,\%orderhash,$iconpath,$pathitem); if ($error) { $r->print('<p><span class="LC_error">'.$error.'</span></p>'); } @@ -3869,16 +3974,18 @@ unless ($env{'form.pagepath'}) { $env{'form.folderpath'} = $savefolderpath; } $env{'form.pagepath'} = ''; + $pathitem = '<input type="hidden" name="folderpath" value="'. + &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'; if ($allowed) { my $folderseq= - '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. - '.sequence'; - - my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); + '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence'; - my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}"; my $supupdocform=(<<SUPDOCFORM); + <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');"> + $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'} <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> + <fieldset id="uploadsuppdocform" style="display: none;"> + <legend>$lt{'upfi'}</legend> <input type="hidden" name="active" value="ee" /> $fileupload <br /> @@ -3890,35 +3997,30 @@ unless ($env{'form.pagepath'}) { $lt{'comment'}:<br /> <textarea cols="50" rows="4" name="comment"></textarea> <br /> - <input type="hidden" name="folderpath" value="$path" /> + $pathitem <input type="hidden" name="cmd" value="upload_supplemental" /> + <input type='submit' value="$lt{'upld'}" /> + </form> SUPDOCFORM - $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>"; my $supnewfolderform=(<<SNFFORM); <form action="/adm/coursedocs" method="post" name="supnewfolder"> <input type="hidden" name="active" value="ee" /> - <input type="hidden" name="folderpath" value="$path" /> + $pathitem <input type="hidden" name="importdetail" value="" /> <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> $help{'Adding_Folders'} </form> SNFFORM - - my $supnewextform=(<<SNEFORM); - <form action="/adm/coursedocs" method="post" name="supnewext"> - <input type="hidden" name="active" value="ff" /> - <input type="hidden" name="folderpath" value="$path" /> - <input type="hidden" name="importdetail" value="" /> - <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'} - </form> -SNEFORM + my $supextform = + &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, + $help{'Adding_External_Resource'}); my $supnewsylform=(<<SNSFORM); <form action="/adm/coursedocs" method="post" name="supnewsyl"> <input type="hidden" name="active" value="ff" /> - <input type="hidden" name="folderpath" value="$path" /> + $pathitem <input type="hidden" name="importdetail" value="Syllabus=/public/$coursedom/$coursenum/syllabus" /> <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a> @@ -3929,7 +4031,7 @@ SNSFORM my $supnewaboutmeform=(<<SNAMFORM); <form action="/adm/coursedocs" method="post" name="supnewaboutme"> <input type="hidden" name="active" value="ff" /> - <input type="hidden" name="folderpath" value="$path" /> + $pathitem <input type="hidden" name="importdetail" value="$plainname=/adm/$udom/$uname/aboutme" /> <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a> @@ -3945,31 +4047,36 @@ my @specialdocs = ( =>$supnewaboutmeform}, ); my @supimportdoc = ( - {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />' - =>$supnewextform}, - ); -$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform; + {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />' + =>$supextform}, + {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' + =>$supupdocform}, + ); + +$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); my %suporderhash = ( '00' => ['Supnewfolder', $supnewfolderform], 'ee' => ['Import Content',$supupdocform], - 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))] + 'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))] ); if ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, - $supplementalflag,\%suporderhash,$iconpath); + $supplementalflag,\%suporderhash,$iconpath,$pathitem); if ($error) { $r->print('<p><span class="LC_error">'.$error.'</span></p>'); } } } elsif ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, - $supplementalflag,'',$iconpath); + $supplementalflag,'',$iconpath,$pathitem); if ($error) { $r->print('<p><span class="LC_error">'.$error.'</span></p>'); } } - $r->print(&endContentScreen()); + if ($needs_end) { + $r->print(&endContentScreen()); + } if ($allowed) { $r->print(' @@ -3983,7 +4090,7 @@ my %suporderhash = ( } elsif ($showdoc) { # -------------------------------------------------------- This is showdoc mode $r->print("<h1>".&mt('Uploaded Document').' - '. - &Apache::lonnet::gettitle($r->uri).'</h1><p>'. + &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'. &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>". &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); } @@ -4234,7 +4341,7 @@ sub generate_edit_table { $activetab = $env{'form.active'}; } my $backicon = $iconpath.'clickhere.gif'; - my $backtext = &mt('To Overview'); + my $backtext = &mt('Exit'); $form = '<div class="LC_Box" style="margin:0;">'. '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n". '<li class="goback">'. @@ -4263,7 +4370,6 @@ sub generate_edit_table { $active = 'class="active"'; } $form .= '<li style="float:right" '.$active - .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"' .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n"; } else { $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n"; @@ -4320,6 +4426,10 @@ sub editing_js { p_ctr2a => 'Cut[_98]', p_ctr2b => '?[_98]', rpck => 'Enter number to pick (e.g., 3)', + imsfile => 'You must choose an IMS package for import', + imscms => 'You must select which Course Management System was the source of the IMS package', + invurl => 'Invalid URL', + titbl => 'Title is blank', ); my $crstype = &Apache::loncommon::course_type(); @@ -4339,6 +4449,11 @@ sub editing_js { $backtourl = '/adm/supplemental'; } + my $fieldsets = "'ext','doc','ims'"; + if ($supplementalflag) { + $fieldsets = "'suppext','suppdoc'"; + } + return <<ENDNEWSCRIPT; function makenewfolder(targetform,folderseq) { var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); @@ -4356,22 +4471,6 @@ function makenewpage(targetform,folderse } } -function makenewext(targetname) { - this.document.forms.extimport.useform.value=targetname; - this.document.forms.extimport.title.value=''; - this.document.forms.extimport.url.value=''; - this.document.forms.extimport.residx.value=''; - window.open('/adm/rat/extpickframe.html'); -} - -function edittext(targetname,residx,title,url) { - this.document.forms.extimport.useform.value=targetname; - this.document.forms.extimport.residx.value=residx; - this.document.forms.extimport.url.value=url; - this.document.forms.extimport.title.value=title; - window.open('/adm/rat/extpickframe.html'); -} - function makeexamupload() { var title=prompt('$lt{"p_mxu"}'); if (title) { @@ -4436,19 +4535,48 @@ function makeabout() { } } -function makeims() { -var caller = document.forms.ims.folder.value; -var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; -newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); -newWindow.location.href = newlocation; +function toggleUpload(caller) { + var blocks = Array($fieldsets); + for (var i=0; i<blocks.length; i++) { + var disp = 'none'; + if (caller == blocks[i]) { + var curr = document.getElementById('upload'+caller+'form').style.display; + if (curr == 'none') { + disp='block'; + } + } + document.getElementById('upload'+blocks[i]+'form').style.display=disp; + } + resize_scrollbox('contentscroll','1','1'); + return; } -function finishpick() { -var title=this.document.forms.extimport.title.value; -var url=this.document.forms.extimport.url.value; -var form=this.document.forms.extimport.useform.value; -var residx=this.document.forms.extimport.residx.value; -eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); +function toggleMap(caller) { + var disp = 'none'; + if (document.getElementById('importmapform')) { + if (caller == 'map') { + var curr = document.getElementById('importmapform').style.display; + if (curr == 'none') { + disp='block'; + } + } + document.getElementById('importmapform').style.display=disp; + resize_scrollbox('contentscroll','1','1'); + } + return; +} + +function makeims(imsform) { + if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { + alert("$lt{'imsfile'}"); + return; + } + if (imsform.source.selectedIndex == 0) { + alert("$lt{'imscms'}"); + return; + } + newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes"); + imsform.submit(); } function changename(folderpath,index,oldtitle,container,pagesymb) { @@ -4602,6 +4730,8 @@ function showPage(current, pageId, nav, currentData = document.getElementById(pageId); currentData.style.display = 'block'; activeTab = pageId; + toggleUpload(); + toggleMap(); if (nav == 'mainnav') { var storedpath = "$docs_folderpath"; if (storedpath == '') {