Annotation of loncom/interface/londocs.pm, revision 1.487

1.329     droeschl    1: # The LearningOnline Network
                      2: # Documents
                      3: #
1.487   ! raeburn     4: # $Id: londocs.pm,v 1.486 2012/05/15 01:23:04 raeburn Exp $
1.329     droeschl    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::londocs;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common :http);
                     33: use Apache::imsexport;
                     34: use Apache::lonnet;
                     35: use Apache::loncommon;
1.383     tempelho   36: use Apache::lonhtmlcommon;
1.329     droeschl   37: use LONCAPA::map();
                     38: use Apache::lonratedt();
                     39: use Apache::lonxml;
                     40: use Apache::lonclonecourse;
                     41: use Apache::lonnavmaps;
1.472     raeburn    42: use Apache::lonnavdisplay();
1.329     droeschl   43: use HTML::Entities;
                     44: use GDBM_File;
                     45: use Apache::lonlocal;
                     46: use Cwd;
                     47: use LONCAPA qw(:DEFAULT :match);
                     48: 
                     49: my $iconpath;
                     50: 
                     51: my %hash;
                     52: 
                     53: my $hashtied;
                     54: my %alreadyseen=();
                     55: 
                     56: my $hadchanges;
                     57: 
                     58: 
                     59: my %help=();
                     60: 
                     61: 
                     62: sub mapread {
                     63:     my ($coursenum,$coursedom,$map)=@_;
                     64:     return
                     65:       &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
                     66: 			     $map);
                     67: }
                     68: 
                     69: sub storemap {
                     70:     my ($coursenum,$coursedom,$map)=@_;
                     71:     my ($outtext,$errtext)=
                     72:       &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
                     73: 			      $map,1);
                     74:     if ($errtext) { return ($errtext,2); }
1.364     bisitz     75: 
1.329     droeschl   76:     $hadchanges=1;
                     77:     return ($errtext,0);
                     78: }
                     79: 
                     80: 
                     81: 
                     82: sub authorhosts {
                     83:     my %outhash=();
                     84:     my $home=0;
                     85:     my $other=0;
                     86:     foreach my $key (keys(%env)) {
                     87: 	if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
                     88: 	    my $role=$1;
                     89: 	    my $realm=$2;
                     90: 	    my ($start,$end)=split(/\./,$env{$key});
                     91: 	    if (($start) && ($start>time)) { next; }
                     92: 	    if (($end) && (time>$end)) { next; }
                     93: 	    my ($ca,$cd);
                     94: 	    if ($1 eq 'au') {
                     95: 		$ca=$env{'user.name'};
                     96: 		$cd=$env{'user.domain'};
                     97: 	    } else {
                     98: 		($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
                     99: 	    }
                    100: 	    my $allowed=0;
                    101: 	    my $myhome=&Apache::lonnet::homeserver($ca,$cd);
                    102: 	    my @ids=&Apache::lonnet::current_machine_ids();
1.484     raeburn   103: 	    foreach my $id (@ids) {
                    104:                 if ($id eq $myhome) {
                    105:                     $allowed=1;
                    106:                     last;
                    107:                 }
                    108:             }
1.329     droeschl  109: 	    if ($allowed) {
                    110: 		$home++;
1.484     raeburn   111: 		$outhash{'home_'.$ca.':'.$cd}=1;
1.329     droeschl  112: 	    } else {
1.484     raeburn   113: 		$outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329     droeschl  114: 		$other++;
                    115: 	    }
                    116: 	}
                    117:     }
                    118:     return ($home,$other,%outhash);
                    119: }
                    120: 
                    121: 
                    122: sub clean {
                    123:     my ($title)=@_;
                    124:     $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344     bisitz    125:     return $title;
1.329     droeschl  126: }
                    127: 
                    128: 
                    129: 
                    130: sub dumpcourse {
                    131:     my ($r) = @_;
1.408     raeburn   132:     my $crstype = &Apache::loncommon::course_type();
1.484     raeburn   133:     $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Content to Authoring Space')."\n".
                    134:               &Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Content to Authoring Space')."\n");
                    135:     $r->print(&startContentScreen('tools'));
1.329     droeschl  136:     my ($home,$other,%outhash)=&authorhosts();
1.484     raeburn   137:     unless ($home) {
                    138:         $r->print(&endContentScreen());
                    139:         return '';
                    140:     }
1.329     droeschl  141:     my $origcrsid=$env{'request.course.id'};
                    142:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
                    143:     if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
                    144: # Do the dumping
1.484     raeburn   145: 	unless ($outhash{'home_'.$env{'form.authorspace'}}) {
                    146:             $r->print(&endContentScreen());
                    147:             return '';
                    148:         }
1.329     droeschl  149: 	my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
                    150: 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
                    151: 	my $title=$env{'form.authorfolder'};
                    152: 	$title=&clean($title);
                    153: 	my %replacehash=();
                    154: 	foreach my $key (keys(%env)) {
                    155: 	    if ($key=~/^form\.namefor\_(.+)/) {
                    156: 		$replacehash{$1}=$env{$key};
                    157: 	    }
                    158: 	}
                    159: 	my $crs='/uploaded/'.$env{'request.course.id'}.'/';
                    160: 	$crs=~s/\_/\//g;
                    161: 	foreach my $item (keys(%replacehash)) {
                    162: 	    my $newfilename=$title.'/'.$replacehash{$item};
                    163: 	    $newfilename=~s/\.(\w+)$//;
                    164: 	    my $ext=$1;
                    165: 	    $newfilename=&clean($newfilename);
                    166: 	    $newfilename.='.'.$ext;
                    167: 	    my @dirs=split(/\//,$newfilename);
1.462     raeburn   168: 	    my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
1.329     droeschl  169: 	    my $makepath=$path;
                    170: 	    my $fail=0;
                    171: 	    for (my $i=0;$i<$#dirs;$i++) {
                    172: 		$makepath.='/'.$dirs[$i];
1.344     bisitz    173: 		unless (-e $makepath) {
                    174: 		    unless(mkdir($makepath,0777)) { $fail=1; }
1.329     droeschl  175: 		}
                    176: 	    }
                    177: 	    $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
                    178: 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
                    179: 		if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
                    180: 		    print $fh &Apache::lonclonecourse::rewritefile(
                    181:          &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
                    182: 				     (%replacehash,$crs => '')
                    183: 								    );
                    184: 		} else {
                    185: 		    print $fh
                    186:          &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
                    187: 		       }
                    188: 		$fh->close();
                    189: 	    } else {
                    190: 		$fail=1;
                    191: 	    }
                    192: 	    if ($fail) {
                    193: 		$r->print('<span class="LC_error">'.&mt('fail').'</span>');
                    194: 	    } else {
                    195: 		$r->print('<span class="LC_success">'.&mt('ok').'</span>');
                    196: 	    }
                    197: 	}
                    198:     } else {
1.484     raeburn   199:         $r->print(&mt('Searching ...').'<br />');
                    200:         $r->rflush();
1.329     droeschl  201: # Input form
1.484     raeburn   202:         $r->print('<form name="dumpdoc" action="" method="post">'."\n");
1.329     droeschl  203: 	unless ($home==1) {
1.484     raeburn   204: 	    $r->print('<div class="LC_left_float">'.
                    205: 		      '<fieldset><legend>'.
                    206:                       &mt('Select the Authoring Space').
                    207:                       '</legend><select name="authorspace">');
1.329     droeschl  208: 	}
                    209: 	foreach my $key (sort(keys(%outhash))) {
                    210: 	    if ($key=~/^home_(.+)$/) {
                    211: 		if ($home==1) {
                    212: 		    $r->print(
                    213: 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
                    214: 		} else {
                    215: 		    $r->print('<option value="'.$1.'">'.$1.' - '.
1.484     raeburn   216: 			      &Apache::loncommon::plainname(split(/\:/,$1)).'</option>');
1.329     droeschl  217: 		}
                    218: 	    }
                    219: 	}
                    220: 	unless ($home==1) {
1.484     raeburn   221: 	    $r->print('</select></fieldset></div>'."\n");
1.329     droeschl  222: 	}
                    223: 	my $title=$origcrsdata{'description'};
                    224: 	$title=~s/[\/\s]+/\_/gs;
                    225: 	$title=&clean($title);
1.484     raeburn   226: 	$r->print('<div class="LC_left_float">'.
                    227:                   '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
                    228:                   '<input type="text" size="50" name="authorfolder" value="'.
                    229:                   $title.'" />'.
                    230:                   '</fieldset></div><br clear="all" />'."\n");
1.329     droeschl  231: 	&tiehash();
1.484     raeburn   232: 	$r->print('<h4>'.&mt('Filenames in Authoring Space').'</h4>'
1.329     droeschl  233:                  .&Apache::loncommon::start_data_table()
                    234:                  .&Apache::loncommon::start_data_table_header_row()
                    235:                  .'<th>'.&mt('Internal Filename').'</th>'
                    236:                  .'<th>'.&mt('Title').'</th>'
                    237:                  .'<th>'.&mt('Save as ...').'</th>'
                    238:                  .&Apache::loncommon::end_data_table_header_row());
                    239: 	foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
                    240: 	    $r->print(&Apache::loncommon::start_data_table_row()
                    241:                      .'<td>'.$file.'</td>');
                    242: 	    my ($ext)=($file=~/\.(\w+)$/);
                    243: 	    my $title=$hash{'title_'.$hash{
                    244: 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
                    245: 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
                    246: 	    if (!$title) {
                    247: 		$title=$file;
                    248: 	    } else {
                    249: 		$title=~s|/|_|g;
                    250: 	    }
                    251: 	    $title=~s/\.(\w+)$//;
                    252: 	    $title=&clean($title);
                    253: 	    $title.='.'.$ext;
                    254: 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
                    255:                      .&Apache::loncommon::end_data_table_row());
                    256: 	}
                    257: 	$r->print(&Apache::loncommon::end_data_table());
                    258: 	&untiehash();
                    259: 	$r->print(
1.484     raeburn   260:   '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Content").'" /></p></form>');
1.329     droeschl  261:     }
1.484     raeburn   262:     $r->print(&endContentScreen());
1.329     droeschl  263: }
                    264: 
                    265: sub group_import {
                    266:     my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
                    267: 
                    268:     while (@files) {
                    269: 	my ($name, $url, $residx) = @{ shift(@files) };
1.344     bisitz    270:         if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329     droeschl  271: 	     && ($caller eq 'londocs')
                    272: 	     && (!&Apache::lonnet::stat_file($url))) {
1.364     bisitz    273: 
1.329     droeschl  274:             my $errtext = '';
                    275:             my $fatal = 0;
                    276:             my $newmapstr = '<map>'."\n".
                    277:                             '<resource id="1" src="" type="start"></resource>'."\n".
                    278:                             '<link from="1" to="2" index="1"></link>'."\n".
                    279:                             '<resource id="2" src="" type="finish"></resource>'."\n".
                    280:                             '</map>';
                    281:             $env{'form.output'}=$newmapstr;
                    282:             my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                    283:                                                 'output',$1.$2);
                    284:             if ($result != m|^/uploaded/|) {
                    285:                 $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
                    286:                 $fatal = 2;
                    287:             }
                    288:             if ($fatal) {
                    289:                 return ($errtext,$fatal);
                    290:             }
                    291:         }
                    292: 	if ($url) {
1.344     bisitz    293: 	    if (!$residx
1.329     droeschl  294: 		|| defined($LONCAPA::map::zombies[$residx])) {
                    295: 		$residx = &LONCAPA::map::getresidx($url,$residx);
                    296: 		push(@LONCAPA::map::order, $residx);
                    297: 	    }
                    298: 	    my $ext = 'false';
                    299: 	    if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
                    300: 	    $url  = &LONCAPA::map::qtunescape($url);
                    301: 	    $name = &LONCAPA::map::qtunescape($name);
1.344     bisitz    302: 	    $LONCAPA::map::resources[$residx] =
1.329     droeschl  303: 		join(':', ($name, $url, $ext, 'normal', 'res'));
                    304: 	}
                    305:     }
                    306:     return &storemap($coursenum, $coursedom, $folder.'.'.$container);
                    307: }
                    308: 
                    309: sub breadcrumbs {
1.408     raeburn   310:     my ($allowed,$crstype)=@_;
1.329     droeschl  311:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                    312:     my (@folders);
                    313:     if ($env{'form.pagepath'}) {
                    314:         @folders = split('&',$env{'form.pagepath'});
                    315:     } else {
                    316:         @folders=split('&',$env{'form.folderpath'});
                    317:     }
                    318:     my $folderpath;
                    319:     my $cpinfo='';
                    320:     my $plain='';
                    321:     my $randompick=-1;
                    322:     my $isencrypted=0;
                    323:     my $ishidden=0;
                    324:     my $is_random_order=0;
                    325:     while (@folders) {
                    326: 	my $folder=shift(@folders);
                    327:     	my $foldername=shift(@folders);
                    328: 	if ($folderpath) {$folderpath.='&';}
                    329: 	$folderpath.=$folder.'&'.$foldername;
1.472     raeburn   330:         my $url;
                    331:         if ($allowed) {
                    332:             $url = '/adm/coursedocs?folderpath=';
                    333:         } else {
                    334:             $url = '/adm/supplemental?folderpath=';
                    335:         }
                    336: 	$url .= &escape($folderpath);
                    337: 	my $name=&unescape($foldername);
1.344     bisitz    338: # randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
1.472     raeburn   339:  	$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
                    340: 	if ($1 ne '') {
                    341:            $randompick=$1;
                    342:         } else {
                    343:            $randompick=-1;
                    344:         }
                    345:         if ($2) { $ishidden=1; }
                    346:         if ($3) { $isencrypted=1; }
                    347: 	if ($4 ne '') { $is_random_order = 1; }
                    348:         if ($folder eq 'supplemental') {
                    349:             $name = &mt('Supplemental '.$crstype.' Content');
                    350:         }
                    351: 	&Apache::lonhtmlcommon::add_breadcrumb(
1.329     droeschl  352: 		      {'href'=>$url.$cpinfo,
                    353: 		       'title'=>$name,
1.367     droeschl  354: 		       'text'=>$name,
1.329     droeschl  355: 		       'no_mt'=>1,
                    356: 		       });
                    357: 	$plain.=$name.' &gt; ';
                    358:     }
                    359:     $plain=~s/\&gt\;\s*$//;
                    360:     return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
1.472     raeburn   361: 					       undef, undef, 1 ),$randompick,$ishidden,
                    362:                                                $isencrypted,$plain,$is_random_order);
1.329     droeschl  363: }
                    364: 
                    365: sub log_docs {
                    366:     return &Apache::lonnet::instructor_log('docslog',@_);
                    367: }
                    368: 
                    369: {
                    370:     my @oldresources=();
                    371:     my @oldorder=();
                    372:     my $parmidx;
                    373:     my %parmaction=();
                    374:     my %parmvalue=();
                    375:     my $changedflag;
                    376: 
                    377:     sub snapshotbefore {
                    378:         @oldresources=@LONCAPA::map::resources;
                    379:         @oldorder=@LONCAPA::map::order;
                    380:         $parmidx=undef;
                    381:         %parmaction=();
                    382:         %parmvalue=();
                    383:         $changedflag=0;
                    384:     }
                    385: 
                    386:     sub remember_parms {
                    387:         my ($idx,$parameter,$action,$value)=@_;
                    388:         $parmidx=$idx;
                    389:         $parmaction{$parameter}=$action;
                    390:         $parmvalue{$parameter}=$value;
                    391:         $changedflag=1;
                    392:     }
                    393: 
                    394:     sub log_differences {
                    395:         my ($plain)=@_;
                    396:         my %storehash=('folder' => $plain,
                    397:                        'currentfolder' => $env{'form.folder'});
                    398:         if ($parmidx) {
                    399:            $storehash{'parameter_res'}=$oldresources[$parmidx];
                    400:            foreach my $parm (keys(%parmaction)) {
                    401:               $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
                    402:               $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
                    403:            }
                    404:         }
                    405:         my $maxidx=$#oldresources;
                    406:         if ($#LONCAPA::map::resources>$#oldresources) {
                    407:            $maxidx=$#LONCAPA::map::resources;
                    408:         }
                    409:         for (my $idx=0; $idx<=$maxidx; $idx++) {
                    410:            if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
                    411:               $storehash{'before_resources_'.$idx}=$oldresources[$idx];
                    412:               $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
                    413:               $changedflag=1;
                    414:            }
                    415:            if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
                    416:               $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
                    417:               $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
                    418:               $changedflag=1;
                    419:            }
                    420:         }
                    421: 	$storehash{'maxidx'}=$maxidx;
                    422:         if ($changedflag) { &log_docs(\%storehash); }
                    423:     }
                    424: }
                    425: 
                    426: sub docs_change_log {
1.484     raeburn   427:     my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486     raeburn   428:     my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483     raeburn   429:     my $js = '<script type="text/javascript">'."\n".
                    430:              '// <![CDATA['."\n".
                    431:              &Apache::loncommon::display_filter_js('docslog')."\n".
1.486     raeburn   432:              &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483     raeburn   433:              &history_tab_js()."\n".
1.484     raeburn   434:              &Apache::lonratedt::editscript('simple')."\n".
1.483     raeburn   435:              '// ]]>'."\n".
                    436:              '</script>'."\n";
1.484     raeburn   437:     $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
                    438:     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
                    439:     $r->print(&startContentScreen('docs'));
                    440:     my %orderhash;
                    441:     my $container='sequence';
                    442:     my $pathitem;
                    443:     if ($env{'form.pagepath'}) {
                    444:         $container='page';
                    445:         $pathitem = '<input type="hidden" name="pagepath" value="'.
                    446:                     &HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />';
                    447:     } else {
                    448:         my $folderpath=$env{'form.folderpath'};
                    449:         if ($folderpath eq '') {
                    450:             $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents'));
                    451:         }
                    452:         $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
                    453:     }
                    454:     my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
                    455:     my $jumpto = $readfile;
                    456:     $jumpto =~ s{^/}{};
                    457:     my $tid = 1;
                    458:     my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype);
                    459:     $r->print($breadcrumbtrail.
                    460:               &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
                    461:               $readfile));
1.329     droeschl  462:     my %docslog=&Apache::lonnet::dump('nohist_docslog',
                    463:                                       $env{'course.'.$env{'request.course.id'}.'.domain'},
                    464:                                       $env{'course.'.$env{'request.course.id'}.'.num'});
                    465: 
                    466:     if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
                    467: 
                    468:     my %saveable_parameters = ('show' => 'scalar',);
                    469:     &Apache::loncommon::store_course_settings('docs_log',
                    470:                                               \%saveable_parameters);
                    471:     &Apache::loncommon::restore_course_settings('docs_log',
                    472:                                                 \%saveable_parameters);
                    473:     if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452     www       474: # FIXME: internationalization seems wrong here
1.329     droeschl  475:     my %lt=('hiddenresource' => 'Resources hidden',
                    476: 	    'encrypturl'     => 'URL hidden',
                    477: 	    'randompick'     => 'Randomly pick',
                    478: 	    'randomorder'    => 'Randomly ordered',
                    479: 	    'set'            => 'set to',
                    480: 	    'del'            => 'deleted');
1.484     raeburn   481:     my $filter = &Apache::loncommon::display_filter('docslog')."\n".
                    482:                  $pathitem."\n".
                    483:                  '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
                    484:                  ('&nbsp;'x2).'<input type="submit" value="'.&mt('Display').'" />';
                    485:     $r->print('<div class="LC_left_float">'.
                    486:               '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
                    487:               &makedocslogform($filter,1).
                    488:               '</fieldset></div><br clear="all" />');
1.329     droeschl  489:     $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
                    490:               '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
                    491:               &mt('After').'</th>'.
                    492:               &Apache::loncommon::end_data_table_header_row());
                    493:     my $shown=0;
                    494:     foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
                    495: 	if ($env{'form.displayfilter'} eq 'currentfolder') {
                    496: 	    if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
                    497: 	}
                    498:         my @changes=keys(%{$docslog{$id}{'logentry'}});
                    499:         if ($env{'form.displayfilter'} eq 'containing') {
                    500: 	    my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
                    501: 		&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
                    502: 	    foreach my $key (@changes) {
                    503: 		$wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
                    504: 	    }
1.344     bisitz    505: 	    if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329     droeschl  506: 	}
                    507:         my $count = 0;
                    508:         my $time =
                    509:             &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
                    510:         my $plainname =
                    511:             &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
                    512:                                           $docslog{$id}{'exe_udom'});
                    513:         my $about_me_link =
                    514:             &Apache::loncommon::aboutmewrapper($plainname,
                    515:                                                $docslog{$id}{'exe_uname'},
                    516:                                                $docslog{$id}{'exe_udom'});
                    517:         my $send_msg_link='';
                    518:         if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
                    519:              || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
                    520:             $send_msg_link ='<br />'.
                    521:                 &Apache::loncommon::messagewrapper(&mt('Send message'),
                    522:                                                    $docslog{$id}{'exe_uname'},
                    523:                                                    $docslog{$id}{'exe_udom'});
                    524:         }
                    525:         $r->print(&Apache::loncommon::start_data_table_row());
                    526:         $r->print('<td>'.$time.'</td>
                    527:                        <td>'.$about_me_link.
                    528:                   '<br /><tt>'.$docslog{$id}{'exe_uname'}.
                    529:                                   ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
                    530:                   $send_msg_link.'</td><td>'.
                    531:                   $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
                    532: # Before
                    533: 	for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
                    534: 	    my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
                    535: 	    my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
                    536: 	    if ($oldname ne $newname) {
                    537: 		$r->print(&LONCAPA::map::qtescape($oldname));
                    538: 	    }
                    539: 	}
                    540: 	$r->print('<ul>');
                    541: 	for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
                    542:             if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
                    543: 		$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
                    544: 	    }
                    545: 	}
                    546: 	$r->print('</ul>');
                    547: # After
                    548:         $r->print('</td><td>');
                    549: 
                    550: 	for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
                    551: 	    my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
                    552: 	    my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
                    553: 	    if ($oldname ne '' && $oldname ne $newname) {
                    554: 		$r->print(&LONCAPA::map::qtescape($newname));
                    555: 	    }
1.364     bisitz    556: 	}
1.329     droeschl  557: 	$r->print('<ul>');
                    558: 	for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
                    559:             if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
                    560: 		$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
                    561: 	    }
                    562: 	}
                    563: 	$r->print('</ul>');
                    564: 	if ($docslog{$id}{'logentry'}{'parameter_res'}) {
                    565: 	    $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
                    566: 	    foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
                    567: 		if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452     www       568: # FIXME: internationalization seems wrong here
1.329     droeschl  569: 		    $r->print('<li>'.
                    570: 			      &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
                    571: 				  $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
                    572: 			      .'</li>');
                    573: 		}
                    574: 	    }
                    575: 	    $r->print('</ul>');
                    576: 	}
                    577: # End
                    578:         $r->print('</td>'.&Apache::loncommon::end_data_table_row());
                    579:         $shown++;
                    580:         if (!($env{'form.show'} eq &mt('all')
                    581:               || $shown<=$env{'form.show'})) { last; }
                    582:     }
1.484     raeburn   583:     $r->print(&Apache::loncommon::end_data_table()."\n".
                    584:               &makesimpleeditform($pathitem)."\n".
                    585:               '</div></div>');
                    586:     $r->print(&endContentScreen());
1.329     droeschl  587: }
                    588: 
                    589: sub update_paste_buffer {
                    590:     my ($coursenum,$coursedom) = @_;
                    591: 
                    592:     return if (!defined($env{'form.markcopy'}));
                    593:     return if (!defined($env{'form.copyfolder'}));
                    594:     return if ($env{'form.markcopy'} < 0);
                    595: 
                    596:     my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
                    597: 				    $env{'form.copyfolder'});
1.364     bisitz    598: 
1.329     droeschl  599:     return if ($fatal);
                    600: 
                    601: # Mark for copying
                    602:     my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
                    603:     if (&is_supplemental_title($title)) {
                    604:         &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
                    605: 	($title) = &parse_supplemental_title($title);
                    606:     } elsif ($env{'docs.markedcopy_supplemental'}) {
1.346     raeburn   607:         &Apache::lonnet::delenv('docs.markedcopy_supplemental');
1.329     droeschl  608:     }
                    609:     $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
                    610: 
                    611:     &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
                    612: 			    'docs.markedcopy_url'   => $url});
                    613:     delete($env{'form.markcopy'});
                    614: }
                    615: 
                    616: sub print_paste_buffer {
                    617:     my ($r,$container) = @_;
                    618:     return if (!defined($env{'docs.markedcopy_url'}));
                    619: 
1.381     bisitz    620:     $r->print('<fieldset>'
                    621:              .'<legend>'.&mt('Clipboard').'</legend>'
                    622:              .'<form name="pasteform" action="/adm/coursedocs" method="post">'
                    623:              .'<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> '
                    624:     );
1.329     droeschl  625: 
                    626:     my $type;
                    627:     if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?:&colon;|:))//} ) {
                    628: 	$type = &mt('External Resource');
                    629: 	$r->print($type.': '.
                    630: 		  &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
                    631: 		  &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
                    632:     }  else {
                    633: 	my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
                    634: 	my $icon = &Apache::loncommon::icon($extension);
                    635: 	if ($extension eq 'sequence' &&
                    636: 	    $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
                    637: 	    $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1.380     bisitz    638: 	    $icon .= '/navmap.folder.closed.gif';
1.329     droeschl  639: 	}
                    640: 	$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
                    641: 	$r->print($icon.$type.': '.  &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
                    642:     }
                    643:     if ($container eq 'page') {
                    644: 	$r->print('
                    645: 	<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
                    646: 	<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
                    647: ');
                    648:     } else {
                    649: 	$r->print('
                    650:         <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
                    651: ');
                    652:     }
1.381     bisitz    653:     $r->print('</form></fieldset>');
1.329     droeschl  654: }
                    655: 
                    656: sub do_paste_from_buffer {
                    657:     my ($coursenum,$coursedom,$folder) = @_;
                    658: 
                    659:     if (!$env{'form.pastemarked'}) {
                    660:         return;
                    661:     }
                    662: 
                    663: # paste resource to end of list
                    664:     my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
                    665:     my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
                    666: # Maps need to be copied first
                    667:     if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
                    668: 	$title=&mt('Copy of').' '.$title;
                    669: 	my $newid=$$.int(rand(100)).time;
                    670: 	my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
                    671:         if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
                    672:             my $path = $1;
                    673:             my $prefix = $2;
                    674:             my $ancestor = $3;
                    675:             if (length($ancestor) > 10) {
                    676:                 $ancestor = substr($ancestor,-10,10);
                    677:             }
                    678:             $oldid = $path.$prefix.$ancestor;
                    679:         }
                    680:         my $counter = 0;
                    681:         my $newurl=$oldid.$newid.'.'.$ext;
                    682:         my $is_unique = &uniqueness_check($newurl);
                    683:         while (!$is_unique && $counter < 100) {
                    684:             $counter ++;
                    685:             $newid ++;
                    686:             $newurl = $oldid.$newid;
                    687:             $is_unique = &uniqueness_check($newurl);
                    688:         }
                    689:         if (!$is_unique) {
                    690:             if ($url=~/\.page$/) {
                    691:                 return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
                    692:             } else {
                    693:                 return &mt('Paste failed: an error occurred creating a unique URL for the folder');
                    694:             }
                    695:         }
                    696: 	my $storefn=$newurl;
                    697: 	$storefn=~s{^/\w+/$match_domain/$match_username/}{};
                    698: 	my $paste_map_result =
                    699:             &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
                    700: 					       &Apache::lonnet::getfile($url));
                    701:         if ($paste_map_result eq '/adm/notfound.html') {
                    702:             if ($url=~/\.page$/) {
                    703:                 return &mt('Paste failed: an error occurred saving the composite page');
                    704:             } else {
                    705:                 return &mt('Paste failed: an error occurred saving the folder');
                    706:             }
                    707:         }
                    708: 	$url = $newurl;
                    709:     }
                    710: # published maps can only exists once, so remove it from paste buffer when done
                    711:     if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
1.346     raeburn   712: 	&Apache::lonnet::delenv('docs.markedcopy');
1.329     droeschl  713:     }
                    714:     if ($url=~ m{/smppg$}) {
                    715: 	my $db_name = &Apache::lonsimplepage::get_db_name($url);
                    716: 	if ($db_name =~ /^smppage_/) {
                    717: 	    #simple pages, need to copy the db contents to a new one.
                    718: 	    my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
                    719: 	    my $now = time();
                    720: 	    $db_name =~ s{_\d*$ }{_$now}x;
                    721: 	    my $result=&Apache::lonnet::put($db_name,\%contents,
                    722: 					    $coursedom,$coursenum);
1.344     bisitz    723: 	    $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
1.329     droeschl  724: 	    $title=&mt('Copy of').' '.$title;
                    725: 	}
                    726:     }
                    727:     $title = &LONCAPA::map::qtunescape($title);
                    728:     my $ext='false';
                    729:     if ($url=~m{^http(|s)://}) { $ext='true'; }
                    730:     $url       = &LONCAPA::map::qtunescape($url);
                    731: # Now insert the URL at the bottom
                    732:     my $newidx = &LONCAPA::map::getresidx($url);
                    733:     if ($env{'docs.markedcopy_supplemental'}) {
                    734:         if ($folder =~ /^supplemental/) {
                    735:             $title = $env{'docs.markedcopy_supplemental'};
                    736:         } else {
1.344     bisitz    737:             (undef,undef,$title) =
1.329     droeschl  738:                 &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
                    739:         }
                    740:     } else {
                    741:         if ($folder=~/^supplemental/) {
                    742:            $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
                    743:                   $env{'user.domain'}.'___&&&___'.$title;
                    744:         }
                    745:     }
                    746: 
                    747:     $LONCAPA::map::resources[$newidx]= 	$title.':'.$url.':'.$ext.':normal:res';
                    748:     push(@LONCAPA::map::order, $newidx);
                    749:     return 'ok';
                    750: # Store the result
                    751: }
                    752: 
                    753: sub uniqueness_check {
                    754:     my ($newurl) = @_;
                    755:     my $unique = 1;
                    756:     foreach my $res (@LONCAPA::map::order) {
                    757:         my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
                    758:         $url=&LONCAPA::map::qtescape($url);
                    759:         if ($newurl eq $url) {
                    760:             $unique = 0;
1.344     bisitz    761:             last;
1.329     droeschl  762:         }
                    763:     }
                    764:     return $unique;
                    765: }
                    766: 
                    767: my %parameter_type = ( 'randompick'     => 'int_pos',
                    768: 		       'hiddenresource' => 'string_yesno',
                    769: 		       'encrypturl'     => 'string_yesno',
                    770: 		       'randomorder'    => 'string_yesno',);
                    771: my $valid_parameters_re = join('|',keys(%parameter_type));
                    772: # set parameters
                    773: sub update_parameter {
                    774: 
                    775:     return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
                    776: 
                    777:     my $which = $env{'form.changeparms'};
                    778:     my $idx = $env{'form.setparms'};
                    779:     if ($env{'form.'.$which.'_'.$idx}) {
                    780: 	my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
                    781: 	                                     : 'yes';
                    782: 	&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
                    783: 				      $parameter_type{$which});
                    784: 	&remember_parms($idx,$which,'set',$value);
                    785:     } else {
                    786: 	&LONCAPA::map::delparameter($idx,'parameter_'.$which);
1.364     bisitz    787: 
1.329     droeschl  788: 	&remember_parms($idx,$which,'del');
                    789:     }
                    790:     return 1;
                    791: }
                    792: 
                    793: 
                    794: sub handle_edit_cmd {
                    795:     my ($coursenum,$coursedom) =@_;
                    796:     my ($cmd,$idx)=split('_',$env{'form.cmd'});
                    797: 
                    798:     my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
                    799:     my ($title, $url, @rrest) = split(':', $ratstr);
                    800: 
                    801:     if ($cmd eq 'del') {
                    802: 	if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463     www       803: 	    ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329     droeschl  804: 	    &Apache::lonnet::removeuploadedurl($url);
                    805: 	} else {
                    806: 	    &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
                    807: 	}
                    808: 	splice(@LONCAPA::map::order, $idx, 1);
                    809: 
                    810:     } elsif ($cmd eq 'cut') {
                    811: 	&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
                    812: 	splice(@LONCAPA::map::order, $idx, 1);
                    813: 
1.344     bisitz    814:     } elsif ($cmd eq 'up'
1.329     droeschl  815: 	     && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
                    816: 	@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
                    817: 
                    818:     } elsif ($cmd eq 'down'
                    819: 	     && defined($LONCAPA::map::order[$idx+1])) {
                    820: 	@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
                    821: 
                    822:     } elsif ($cmd eq 'rename') {
                    823: 
                    824: 	my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
                    825: 	if ($comment=~/\S/) {
                    826: 	    $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
                    827: 		$comment.':'.join(':', $url, @rrest);
                    828: 	}
                    829: # Devalidate title cache
                    830: 	my $renamed_url=&LONCAPA::map::qtescape($url);
                    831: 	&Apache::lonnet::devalidate_title_cache($renamed_url);
                    832:     } else {
                    833: 	return 0;
                    834:     }
                    835:     return 1;
                    836: }
                    837: 
                    838: sub editor {
1.458     raeburn   839:     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.472     raeburn   840:         $supplementalflag,$orderhash,$iconpath)=@_;
1.329     droeschl  841:     my $container= ($env{'form.pagepath'}) ? 'page'
                    842: 		                           : 'sequence';
                    843: 
1.484     raeburn   844:     my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
                    845:         &breadcrumbs($allowed,$crstype);
                    846:     $r->print($breadcrumbtrail);
                    847: 
                    848:     my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
                    849: 
                    850:     unless ($allowed) {
                    851:         $randompick = -1;
                    852:     }
                    853: 
1.329     droeschl  854:     my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
                    855: 				    $folder.'.'.$container);
                    856:     return $errtext if ($fatal);
                    857: 
                    858:     if ($#LONCAPA::map::order<1) {
                    859: 	my $idx=&LONCAPA::map::getresidx();
                    860: 	if ($idx<=0) { $idx=1; }
                    861:        	$LONCAPA::map::order[0]=$idx;
                    862:         $LONCAPA::map::resources[$idx]='';
                    863:     }
1.364     bisitz    864: 
1.329     droeschl  865: # ------------------------------------------------------------ Process commands
                    866: 
                    867: # ---------------- if they are for this folder and user allowed to make changes
                    868:     if (($allowed) && ($env{'form.folder'} eq $folder)) {
                    869: # set parameters and change order
                    870: 	&snapshotbefore();
                    871: 
                    872: 	if (&update_parameter()) {
                    873: 	    ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
                    874: 	    return $errtext if ($fatal);
                    875: 	}
                    876: 
                    877: 	if ($env{'form.newpos'} && $env{'form.currentpos'}) {
                    878: # change order
                    879: 	    my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
                    880: 	    splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
                    881: 
                    882: 	    ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
                    883: 	    return $errtext if ($fatal);
                    884: 	}
1.364     bisitz    885: 
1.329     droeschl  886: 	if ($env{'form.pastemarked'}) {
1.344     bisitz    887:             my $paste_res =
1.329     droeschl  888:                 &do_paste_from_buffer($coursenum,$coursedom,$folder);
                    889:             if ($paste_res eq 'ok') {
                    890:                 ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
                    891:                 return $errtext if ($fatal);
                    892:             } elsif ($paste_res ne '') {
                    893:                 $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
                    894:             }
                    895: 	}
                    896: 
                    897: 	$r->print($upload_output);
                    898: 
                    899: 	if (&handle_edit_cmd()) {
                    900: 	    ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
                    901: 	    return $errtext if ($fatal);
                    902: 	}
                    903: # Group import/search
                    904: 	if ($env{'form.importdetail'}) {
                    905: 	    my @imports;
                    906: 	    foreach my $item (split(/\&/,$env{'form.importdetail'})) {
                    907: 		if (defined($item)) {
                    908: 		    my ($name,$url,$residx)=
                    909: 			map {&unescape($_)} split(/\=/,$item);
                    910: 		    push(@imports, [$name, $url, $residx]);
                    911: 		}
                    912: 	    }
                    913: 	    ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
                    914: 					    $container,'londocs',@imports);
                    915: 	    return $errtext if ($fatal);
                    916: 	}
                    917: # Loading a complete map
                    918: 	if ($env{'form.loadmap'}) {
                    919: 	    if ($env{'form.importmap'}=~/\w/) {
                    920: 		foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
                    921: 		    my ($title,$url,$ext,$type)=split(/\:/,$res);
                    922: 		    my $idx=&LONCAPA::map::getresidx($url);
                    923: 		    $LONCAPA::map::resources[$idx]=$res;
                    924: 		    $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
                    925: 		}
                    926: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    927: 					    $folder.'.'.$container);
                    928: 		return $errtext if ($fatal);
                    929: 	    } else {
                    930: 		$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364     bisitz    931: 
1.329     droeschl  932: 	    }
                    933: 	}
                    934: 	&log_differences($plain);
                    935:     }
                    936: # ---------------------------------------------------------------- End commands
                    937: # ---------------------------------------------------------------- Print screen
                    938:     my $idx=0;
                    939:     my $shown=0;
                    940:     if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381     bisitz    941: 	$r->print('<div class="LC_Box">'.
1.432     raeburn   942:           '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
                    943: 		  ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
                    944: 		  ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
                    945: 		  ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
                    946: 		  ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431     raeburn   947: 		  '</ol>');
1.381     bisitz    948:         if ($randompick>=0) {
                    949:             $r->print('<p class="LC_warning">'
                    950:                  .&mt('Caution: this folder is set to randomly pick a subset'
                    951:                      .' of resources. Adding or removing resources from this'
                    952:                      .' folder will change the set of resources that the'
                    953:                      .' students see, resulting in spurious or missing credit'
                    954:                      .' for completed problems, not limited to ones you'
                    955:                      .' modify. Do not modify the contents of this folder if'
                    956:                      .' it is in active student use.')
                    957:                  .'</p>'
                    958:             );
                    959:         }
                    960:         if ($is_random_order) {
                    961:             $r->print('<p class="LC_warning">'
                    962:                  .&mt('Caution: this folder is set to randomly order its'
                    963:                      .' contents. Adding or removing resources from this folder'
                    964:                      .' will change the order of resources shown.')
                    965:                  .'</p>'
                    966:             );
                    967:         }
                    968:         $r->print('</div>');
1.364     bisitz    969:     }
1.381     bisitz    970: 
1.458     raeburn   971:     my ($to_show,$output);
1.424     onken     972: 
                    973:     &Apache::loncommon::start_data_table_count(); #setup a row counter 
1.381     bisitz    974:     foreach my $res (@LONCAPA::map::order) {
                    975:         my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
                    976:         $name=&LONCAPA::map::qtescape($name);
                    977:         $url=&LONCAPA::map::qtescape($url);
                    978:         unless ($name) {  $name=(split(/\//,$url))[-1]; }
                    979:         unless ($name) { $idx++; next; }
                    980:         $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.408     raeburn   981:                               $coursenum,$crstype);
1.381     bisitz    982:         $idx++;
                    983:         $shown++;
1.329     droeschl  984:     }
1.424     onken     985:     &Apache::loncommon::end_data_table_count();
                    986:     
1.381     bisitz    987:     if ($shown) {
1.458     raeburn   988:         $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
                    989:                   .&Apache::loncommon::start_data_table(undef,'contentlist');
1.393     raeburn   990:         if ($allowed) {
1.458     raeburn   991:             $to_show .= &Apache::loncommon::start_data_table_header_row()
1.393     raeburn   992:                      .'<th colspan="2">'.&mt('Move').'</th>'
                    993:                      .'<th>'.&mt('Actions').'</th>'
1.458     raeburn   994:                      .'<th colspan="2">'.&mt('Document').'</th>';
1.393     raeburn   995:             if ($folder !~ /^supplemental/) {
1.458     raeburn   996:                 $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
1.393     raeburn   997:             }
1.458     raeburn   998:             $to_show .= &Apache::loncommon::end_data_table_header_row();
1.393     raeburn   999:         }
1.458     raeburn  1000:         $to_show .= $output.' '
1.393     raeburn  1001:                  .&Apache::loncommon::end_data_table()
1.458     raeburn  1002:                  .'<br style="line-height:2px;" />'
                   1003:                  .&Apache::loncommon::end_scrollbox();
1.393     raeburn  1004:     } else {
1.458     raeburn  1005:         $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
                   1006:                  .'<div class="LC_info" id="contentlist">'
1.381     bisitz   1007:                  .&mt('Currently no documents.')
1.458     raeburn  1008:                  .'</div>'
                   1009:                  .&Apache::loncommon::end_scrollbox();
                   1010:     }
                   1011:     my $tid = 1;
                   1012:     if ($supplementalflag) {
                   1013:         $tid = 2;
1.329     droeschl 1014:     }
                   1015:     if ($allowed) {
1.484     raeburn  1016:         my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
                   1017:         $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto,
                   1018:                                        $readfile));
1.329     droeschl 1019:         &print_paste_buffer($r,$container);
1.460     raeburn  1020:     } else {
1.472     raeburn  1021:         if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                   1022:             #Function Box for Supplemental Content for users with mdc priv.
                   1023:             my $funcname = &mt('Folder Editor');
                   1024:             $r->print(
                   1025:                 &Apache::loncommon::head_subbox(
                   1026:                     &Apache::lonhtmlcommon::start_funclist().
                   1027:                     &Apache::lonhtmlcommon::add_item_funclist(
                   1028:                         '<a href="/adm/coursedocs?command=direct&forcesupplement=1&'.
                   1029:                         'supppath='.&HTML::Entities::encode($env{'form.folderpath'}).'">'.
                   1030:                         '<img src="/res/adm/pages/docs.png" alt="'.$funcname.'" class="LC_icon" />'.
                   1031:                         '<span class="LC_menubuttons_inline_text">'.$funcname.'</span></a>').
                   1032:                           &Apache::lonhtmlcommon::end_funclist()));
                   1033:         }
1.460     raeburn  1034:         $r->print($to_show);
1.329     droeschl 1035:     }
                   1036:     return;
                   1037: }
                   1038: 
                   1039: sub process_file_upload {
                   1040:     my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
                   1041: # upload a file, if present
1.440     raeburn  1042:     my ($parseaction,$showupload,$nextphase,$mimetype);
                   1043:     if ($env{'form.parserflag'}) {
1.329     droeschl 1044:         $parseaction = 'parse';
                   1045:     }
                   1046:     my $folder=$env{'form.folder'};
                   1047:     if ($folder eq '') {
                   1048:         $folder='default';
                   1049:     }
                   1050:     if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
                   1051:         my $errtext='';
                   1052:         my $fatal=0;
                   1053:         my $container='sequence';
                   1054:         if ($env{'form.pagepath'}) {
                   1055:             $container='page';
                   1056:         }
                   1057:         ($errtext,$fatal)=
                   1058:               &mapread($coursenum,$coursedom,$folder.'.'.$container);
                   1059:         if ($#LONCAPA::map::order<1) {
                   1060:             $LONCAPA::map::order[0]=1;
                   1061:             $LONCAPA::map::resources[1]='';
                   1062:         }
                   1063:         if ($fatal) {
1.457     raeburn  1064:             $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
1.440     raeburn  1065:             return;
1.329     droeschl 1066:         }
                   1067:         my $destination = 'docs/';
                   1068:         if ($folder =~ /^supplemental/) {
                   1069:             $destination = 'supplemental/';
                   1070:         }
                   1071:         if (($folder eq 'default') || ($folder eq 'supplemental')) {
                   1072:             $destination .= 'default/';
                   1073:         } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
                   1074:             $destination .=  $2.'/';
                   1075:         }
1.440     raeburn  1076: # this is for a course, not a user, so set context to coursedoc.
1.329     droeschl 1077:         my $newidx=&LONCAPA::map::getresidx();
                   1078:         $destination .= $newidx;
1.439     raeburn  1079:         my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329     droeschl 1080: 						$parseaction,$allfiles,
1.440     raeburn  1081: 						$codebase,undef,undef,undef,undef,
                   1082:                                                 undef,undef,\$mimetype);
                   1083:         if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
                   1084:             my $stored = $1;
                   1085:             $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
                   1086:                           $stored.'</span>').'</p>';
                   1087:         } else {
                   1088:             my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
                   1089:             
1.457     raeburn  1090:             $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440     raeburn  1091:             return;
                   1092:         }
1.329     droeschl 1093:         my $ext='false';
                   1094:         if ($url=~m{^http://}) { $ext='true'; }
                   1095: 	$url     = &LONCAPA::map::qtunescape($url);
                   1096:         my $comment=$env{'form.comment'};
                   1097: 	$comment = &LONCAPA::map::qtunescape($comment);
                   1098:         if ($folder=~/^supplemental/) {
                   1099:               $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
                   1100:                   $env{'user.domain'}.'___&&&___'.$comment;
                   1101:         }
                   1102: 
                   1103:         $LONCAPA::map::resources[$newidx]=
                   1104: 	    $comment.':'.$url.':'.$ext.':normal:res';
                   1105:         $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
                   1106:         ($errtext,$fatal)=&storemap($coursenum,$coursedom,
                   1107: 				    $folder.'.'.$container);
                   1108:         if ($fatal) {
1.457     raeburn  1109:             $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440     raeburn  1110:             return;
1.329     droeschl 1111:         } else {
1.440     raeburn  1112:             if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
                   1113:                 $$upload_output = $showupload;
1.384     raeburn  1114:                 my $total_embedded = scalar(keys(%{$allfiles}));
1.329     droeschl 1115:                 if ($total_embedded > 0) {
1.440     raeburn  1116:                     my $uploadphase = 'upload_embedded';
                   1117:                     my $primaryurl = &HTML::Entities::encode($url,'<>&"');
                   1118: 		    my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); 
                   1119:                     my ($embedded,$num) = 
                   1120:                         &Apache::loncommon::ask_for_embedded_content(
                   1121:                             '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
                   1122:                     if ($embedded) {
                   1123:                         if ($num) {
                   1124:                             $$upload_output .=
                   1125: 			         '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
                   1126:                             $nextphase = $uploadphase;
                   1127:                         } else {
                   1128:                             $$upload_output .= $embedded;
                   1129:                         }
                   1130:                     } else {
                   1131:                         $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
                   1132:                     }
1.329     droeschl 1133:                 } else {
1.440     raeburn  1134:                     $$upload_output .= &mt('No embedded items identified').'<br />';
1.329     droeschl 1135:                 }
1.457     raeburn  1136:                 $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.476     raeburn  1137:             } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
                   1138:                 $nextphase = 'decompress_uploaded';
                   1139:                 my $position = scalar(@LONCAPA::map::order)-1;
                   1140:                 my $noextract = &return_to_editor();
                   1141:                 my $archiveurl = &HTML::Entities::encode($url,'<>&"');
                   1142:                 my %archiveitems = (
                   1143:                     folderpath => $env{'form.folderpath'},
                   1144:                     pagepath   => $env{'form.pagepath'},
                   1145:                     cmd        => $nextphase,
                   1146:                     newidx     => $newidx,
                   1147:                     position   => $position,
                   1148:                     phase      => $nextphase,
1.477     raeburn  1149:                     comment    => $comment,
1.480     raeburn  1150:                 );
                   1151:                 my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
                   1152:                 my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx); 
1.476     raeburn  1153:                 $$upload_output = $showupload.
                   1154:                                   &Apache::loncommon::decompress_form($mimetype,
                   1155:                                       $archiveurl,'/adm/coursedocs',$noextract,
1.480     raeburn  1156:                                       \%archiveitems,\@current);
1.329     droeschl 1157:             }
                   1158:         }
                   1159:     }
1.440     raeburn  1160:     return $nextphase;
1.329     droeschl 1161: }
                   1162: 
1.480     raeburn  1163: sub get_dir_list {
                   1164:     my ($url,$coursenum,$coursedom,$newidx) = @_;
                   1165:     my ($destination,$dir_root) = &embedded_destination();
                   1166:     my ($dirlistref,$listerror) =  
                   1167:         &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
                   1168:     my @dir_lines;
                   1169:     my $dirptr=16384;
                   1170:     if (ref($dirlistref) eq 'ARRAY') {
                   1171:         foreach my $dir_line (sort
                   1172:                           {
                   1173:                               my ($afile)=split('&',$a,2);
                   1174:                               my ($bfile)=split('&',$b,2);
                   1175:                               return (lc($afile) cmp lc($bfile));
                   1176:                           } (@{$dirlistref})) {
                   1177:             my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
                   1178:             $filename =~ s/\s+$//;
                   1179:             next if ($filename =~ /^\.\.?$/); 
                   1180:             my $isdir = 0;
                   1181:             if ($dirptr&$testdir) {
                   1182:                 $isdir = 1;
                   1183:             }
                   1184:             push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
                   1185:         }
                   1186:     }
                   1187:     return @dir_lines;
                   1188: }
                   1189: 
1.329     droeschl 1190: sub is_supplemental_title {
                   1191:     my ($title) = @_;
                   1192:     return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
                   1193: }
                   1194: 
                   1195: sub parse_supplemental_title {
                   1196:     my ($title) = @_;
                   1197: 
                   1198:     my ($foldertitle,$renametitle);
                   1199:     if ($title =~ /&amp;&amp;&amp;/) {
                   1200: 	$title = &HTML::Entites::decode($title);
                   1201:     }
                   1202:  if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
                   1203: 	$renametitle=$4;
                   1204: 	my ($time,$uname,$udom) = ($1,$2,$3);
                   1205: 	$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                   1206: 	my $name =  &Apache::loncommon::plainname($uname,$udom);
                   1207: 	$name = &HTML::Entities::encode($name,'"<>&\'');
1.418     raeburn  1208:         $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
1.329     droeschl 1209: 	$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
                   1210: 	    $name.': <br />'.$foldertitle;
                   1211:     }
                   1212:     if (wantarray) {
                   1213: 	return ($title,$foldertitle,$renametitle);
1.364     bisitz   1214:     }
1.329     droeschl 1215:     return $title;
                   1216: }
                   1217: 
                   1218: # --------------------------------------------------------------- An entry line
                   1219: 
                   1220: sub entryline {
1.408     raeburn  1221:     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
1.329     droeschl 1222:     my ($foldertitle,$pagetitle,$renametitle);
                   1223:     if (&is_supplemental_title($title)) {
                   1224: 	($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
                   1225: 	$pagetitle = $foldertitle;
                   1226:     } else {
                   1227: 	$title=&HTML::Entities::encode($title,'"<>&\'');
                   1228: 	$renametitle=$title;
                   1229: 	$foldertitle=$title;
                   1230: 	$pagetitle=$title;
                   1231:     }
                   1232: 
                   1233:     my $orderidx=$LONCAPA::map::order[$index];
1.364     bisitz   1234: 
1.329     droeschl 1235: 
                   1236:     $renametitle=~s/\\/\\\\/g;
                   1237:     $renametitle=~s/\&quot\;/\\\"/g;
                   1238:     $renametitle=~s/ /%20/g;
1.379     bisitz   1239:     my $line=&Apache::loncommon::start_data_table_row();
1.478     raeburn  1240:     my ($form_start,$form_end,$form_common);
1.329     droeschl 1241: # Edit commands
                   1242:     my ($container, $type, $esc_path, $path, $symb);
                   1243:     if ($env{'form.folderpath'}) {
                   1244: 	$type = 'folder';
                   1245:         $container = 'sequence';
                   1246: 	$esc_path=&escape($env{'form.folderpath'});
                   1247: 	$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
                   1248: 	# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
                   1249:     }
                   1250:     if ($env{'form.pagepath'}) {
                   1251:         $type = $container = 'page';
1.440     raeburn  1252:         $esc_path=&escape($env{'form.pagepath'});
1.329     droeschl 1253: 	$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
                   1254:         $symb=&escape($env{'form.pagesymb'});
                   1255:     }
                   1256:     my $cpinfo='';
                   1257:     if ($allowed) {
                   1258: 	my $incindex=$index+1;
                   1259: 	my $selectbox='';
1.471     raeburn  1260: 	if (($#LONCAPA::map::order>0) &&
1.329     droeschl 1261: 	    ((split(/\:/,
1.344     bisitz   1262: 	     $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
                   1263: 	     ne '') &&
1.329     droeschl 1264: 	    ((split(/\:/,
1.344     bisitz   1265: 	     $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329     droeschl 1266: 	     ne '')) {
                   1267: 	    $selectbox=
                   1268: 		'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373     bisitz   1269: 		'<select name="newpos" onchange="this.form.submit()">';
1.329     droeschl 1270: 	    for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
                   1271: 		if ($i==$incindex) {
1.358     bisitz   1272: 		    $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329     droeschl 1273: 		} else {
                   1274: 		    $selectbox.='<option value="'.$i.'">'.$i.'</option>';
                   1275: 		}
                   1276: 	    }
                   1277: 	    $selectbox.='</select>';
                   1278: 	}
                   1279: 	my %lt=&Apache::lonlocal::texthash(
                   1280:                 'up' => 'Move Up',
                   1281: 		'dw' => 'Move Down',
                   1282: 		'rm' => 'Remove',
                   1283:                 'ct' => 'Cut',
                   1284: 		'rn' => 'Rename',
                   1285: 		'cp' => 'Copy');
                   1286: 	my $nocopy=0;
                   1287:         my $nocut=0;
                   1288:         if ($url=~/\.(page|sequence)$/) {
                   1289: 	    if ($url =~ m{/res/}) {
                   1290: 		# no copy for published maps
                   1291: 		$nocopy = 1;
                   1292: 	    } else {
                   1293: 		foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
                   1294: 		    my ($title,$url,$ext,$type)=split(/\:/,$item);
                   1295: 		    if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
                   1296: 			$nocopy=1;
                   1297: 			last;
                   1298: 		    }
                   1299: 		}
                   1300: 	    }
                   1301: 	}
1.344     bisitz   1302:         if ($url=~/^\/res\/lib\/templates\//) {
                   1303:            $nocopy=1;
1.329     droeschl 1304:            $nocut=1;
                   1305:         }
                   1306:         my $copylink='&nbsp;';
                   1307:         my $cutlink='&nbsp;';
1.364     bisitz   1308: 
1.329     droeschl 1309: 	my $skip_confirm = 0;
                   1310: 	if ( $folder =~ /^supplemental/
                   1311: 	     || ($url =~ m{( /smppg$
                   1312: 			    |/syllabus$
                   1313: 			    |/aboutme$
                   1314: 			    |/navmaps$
                   1315: 			    |/bulletinboard$
                   1316: 			    |\.html$
                   1317: 			    |^/adm/wrapper/ext)}x)) {
                   1318: 	    $skip_confirm = 1;
                   1319: 	}
                   1320: 
                   1321: 	if (!$nocopy) {
                   1322: 	    $copylink=(<<ENDCOPY);
1.484     raeburn  1323: <a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$symb','$folder');" class="LC_docs_copy">$lt{'cp'}</a>
1.329     droeschl 1324: ENDCOPY
                   1325:         }
                   1326: 	if (!$nocut) {
                   1327: 	    $cutlink=(<<ENDCUT);
1.484     raeburn  1328: <a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$symb','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a>
1.329     droeschl 1329: ENDCUT
                   1330:         }
1.478     raeburn  1331: 	$form_start = '
                   1332:    <form action="/adm/coursedocs" method="post">
                   1333: ';
                   1334:         $form_common=(<<END);
1.329     droeschl 1335:    <input type="hidden" name="${type}path" value="$path" />
                   1336:    <input type="hidden" name="${type}symb" value="$symb" />
                   1337:    <input type="hidden" name="setparms" value="$orderidx" />
                   1338:    <input type="hidden" name="changeparms" value="0" />
                   1339: END
                   1340:         $form_end = '</form>';
                   1341: 	$line.=(<<END);
                   1342: <td>
1.379     bisitz   1343: <div class="LC_docs_entry_move">
                   1344:   <a href='/adm/coursedocs?cmd=up_$index&amp;${type}path=$esc_path&amp;${type}symb=$symb$cpinfo'>
                   1345:     <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" />
                   1346:   </a>
                   1347: </div>
                   1348: <div class="LC_docs_entry_move">
                   1349:   <a href='/adm/coursedocs?cmd=down_$index&amp;${type}path=$esc_path&amp;${type}symb=$symb$cpinfo'>
                   1350:     <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" />
                   1351:   </a>
                   1352: </div>
1.329     droeschl 1353: </td>
                   1354: <td>
                   1355:    $form_start
1.478     raeburn  1356:    $form_common
1.329     droeschl 1357:    $selectbox
                   1358:    $form_end
                   1359: </td>
                   1360: <td class="LC_docs_entry_commands">
                   1361:    <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
                   1362: $cutlink
                   1363:    <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
                   1364: $copylink
                   1365: </td>
                   1366: END
                   1367: 
                   1368:     }
                   1369: # Figure out what kind of a resource this is
                   1370:     my ($extension)=($url=~/\.(\w+)$/);
                   1371:     my $uploaded=($url=~/^\/*uploaded\//);
                   1372:     my $icon=&Apache::loncommon::icon($url);
                   1373:     my $isfolder=0;
                   1374:     my $ispage=0;
                   1375:     my $folderarg;
                   1376:     my $pagearg;
                   1377:     my $pagefile;
                   1378:     if ($uploaded) {
1.472     raeburn  1379:         if (($extension eq 'sequence') || ($extension eq 'page')) {
                   1380:             $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
                   1381:             my $containerarg = $1;
                   1382: 	    if ($extension eq 'sequence') {
                   1383: 	        $icon=$iconpath.'navmap.folder.closed.gif';
                   1384:                 $folderarg=$containerarg;
                   1385:                 $isfolder=1;
                   1386:             } else {
                   1387:                 $icon=$iconpath.'page.gif';
                   1388:                 $pagearg=$containerarg;
                   1389:                 $ispage=1;
                   1390:             }
                   1391:             if ($allowed) {
                   1392:                 $url='/adm/coursedocs?';
                   1393:             } else {
                   1394:                 $url='/adm/supplemental?';
                   1395:             }
1.329     droeschl 1396: 	} else {
                   1397: 	    &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
                   1398: 	}
                   1399:     }
1.364     bisitz   1400: 
1.329     droeschl 1401:     my $orig_url = $url;
1.340     raeburn  1402:     $orig_url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
1.329     droeschl 1403:     my $external = ($url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/});
                   1404:     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
                   1405: 	my $symb=&Apache::lonnet::symbclean(
                   1406:           &Apache::lonnet::declutter('uploaded/'.
                   1407:            $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
                   1408:            $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
                   1409:            '.sequence').
                   1410:            '___'.$residx.'___'.
                   1411: 	   &Apache::lonnet::declutter($url));
                   1412: 	(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
                   1413: 	$url=&Apache::lonnet::clutter($url);
                   1414: 	if ($url=~/^\/*uploaded\//) {
                   1415: 	    $url=~/\.(\w+)$/;
                   1416: 	    my $embstyle=&Apache::loncommon::fileembstyle($1);
                   1417: 	    if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
                   1418: 		$url='/adm/wrapper'.$url;
                   1419: 	    } elsif ($embstyle eq 'ssi') {
                   1420: 		#do nothing with these
                   1421: 	    } elsif ($url!~/\.(sequence|page)$/) {
                   1422: 		$url='/adm/coursedocs/showdoc'.$url;
                   1423: 	    }
1.344     bisitz   1424: 	} elsif ($url=~m|^/ext/|) {
1.329     droeschl 1425: 	    $url='/adm/wrapper'.$url;
                   1426: 	    $external = 1;
                   1427: 	}
                   1428:         if (&Apache::lonnet::symbverify($symb,$url)) {
                   1429: 	    $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
                   1430:         } else {
                   1431:             $url='';
                   1432:         }
                   1433: 	if ($container eq 'page') {
                   1434: 	    my $symb=$env{'form.pagesymb'};
1.364     bisitz   1435: 
1.329     droeschl 1436: 	    $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
                   1437: 	    $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
                   1438: 	}
                   1439:     }
1.478     raeburn  1440:     my ($rand_pick_text,$rand_order_text);
1.329     droeschl 1441:     if ($isfolder || $extension eq 'sequence') {
                   1442: 	my $foldername=&escape($foldertitle);
                   1443: 	my $folderpath=$env{'form.folderpath'};
                   1444: 	if ($folderpath) { $folderpath.='&' };
1.344     bisitz   1445: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329     droeschl 1446: # so it gets transferred between levels
                   1447: 	$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
                   1448:                                               'parameter_randompick'))[0]
                   1449:                                                .':'.((&LONCAPA::map::getparameter($orderidx,
                   1450:                                               'parameter_hiddenresource'))[0]=~/^yes$/i)
                   1451:                                                .':'.((&LONCAPA::map::getparameter($orderidx,
                   1452:                                               'parameter_encrypturl'))[0]=~/^yes$/i)
                   1453:                                                .':'.((&LONCAPA::map::getparameter($orderidx,
                   1454:                                               'parameter_randomorder'))[0]=~/^yes$/i);
                   1455: 	$url.='folderpath='.&escape($folderpath).$cpinfo;
1.478     raeburn  1456:         my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
                   1457:                                                    'parameter_randompick'))[0];
                   1458:         my $rpckchk;
                   1459:         if ($rpicknum) {
                   1460:             $rpckchk = ' checked="checked"';
                   1461:         }
                   1462:         my $formname = 'edit_rpick_'.$orderidx;
                   1463: 	$rand_pick_text = 
                   1464: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
                   1465: $form_common."\n".
                   1466: '<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.'" />';
                   1467:         if ($rpicknum ne '') {
                   1468:             $rand_pick_text .= ':&nbsp;<a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
                   1469:         }
                   1470:         $rand_pick_text .= '</span></form>';
1.329     droeschl 1471:     	my $ro_set=
                   1472: 	    ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
1.478     raeburn  1473: 	$rand_order_text = 
                   1474: $form_start.
                   1475: $form_common.'
                   1476: <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>';
1.329     droeschl 1477:     }
                   1478:     if ($ispage) {
                   1479:         my $pagename=&escape($pagetitle);
                   1480:         my $pagepath;
                   1481:         my $folderpath=$env{'form.folderpath'};
                   1482:         if ($folderpath) { $pagepath = $folderpath.'&' };
                   1483:         $pagepath.=$pagearg.'&'.$pagename;
                   1484: 	my $symb=$env{'form.pagesymb'};
                   1485: 	if (!$symb) {
                   1486: 	    my $path='uploaded/'.
                   1487: 		$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
                   1488: 		$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
                   1489: 	    $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
                   1490: 					       $residx,
                   1491: 					       $path.$pagearg.'.page');
                   1492: 	}
                   1493: 	$url.='pagepath='.&escape($pagepath).
                   1494: 	    '&amp;pagesymb='.&escape($symb).$cpinfo;
                   1495:     }
1.396     raeburn  1496:     if (($external) && ($allowed)) {
1.329     droeschl 1497: 	my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
                   1498: 	$external = '&nbsp;<a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
                   1499:     } else {
                   1500: 	undef($external);
                   1501:     }
1.408     raeburn  1502:     my $reinit;
                   1503:     if ($crstype eq 'Community') {
                   1504:         $reinit = &mt('(re-initialize community to access)');
                   1505:     } else {
                   1506:         $reinit = &mt('(re-initialize course to access)');
                   1507:     }  
1.469     www      1508:     $line.='<td>';
1.472     raeburn  1509:     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469     www      1510:        $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
                   1511:     } elsif ($url) {
1.484     raeburn  1512:        $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes',
1.470     raeburn  1513:                                              '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469     www      1514:     } else {
                   1515:        $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
                   1516:     }
                   1517:     $line.='</td><td>';
1.472     raeburn  1518:     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469     www      1519:        $line.='<a href="'.$url.'">'.$title.'</a>';
                   1520:     } elsif ($url) {
1.484     raeburn  1521:        $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes',
1.470     raeburn  1522:                                              $title,600,500);
1.469     www      1523:     } else {
                   1524:        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
                   1525:     }
                   1526:     $line.=$external."</td>";
1.478     raeburn  1527:     $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');
                   1528:     $rand_order_text = '&nbsp;' if ($rand_order_text eq '');
1.329     droeschl 1529:     if (($allowed) && ($folder!~/^supplemental/)) {
                   1530:  	my %lt=&Apache::lonlocal::texthash(
                   1531:  			      'hd' => 'Hidden',
                   1532:  			      'ec' => 'URL hidden');
                   1533: 	my $enctext=
1.358     bisitz   1534: 	    ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
1.329     droeschl 1535: 	my $hidtext=
1.358     bisitz   1536: 	    ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
1.329     droeschl 1537: 	$line.=(<<ENDPARMS);
                   1538:   <td class="LC_docs_entry_parameter">
                   1539:     $form_start
1.478     raeburn  1540:     $form_common
1.369     bisitz   1541:     <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1.329     droeschl 1542:     $form_end
1.458     raeburn  1543:     <br />
1.329     droeschl 1544:     $form_start
1.478     raeburn  1545:     $form_common
1.369     bisitz   1546:     <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1.329     droeschl 1547:     $form_end
                   1548:   </td>
1.478     raeburn  1549:   <td class="LC_docs_entry_parameter">$rand_pick_text<br />
                   1550:                                       $rand_order_text</td>
1.329     droeschl 1551: ENDPARMS
                   1552:     }
1.379     bisitz   1553:     $line.=&Apache::loncommon::end_data_table_row();
1.329     droeschl 1554:     return $line;
                   1555: }
                   1556: 
                   1557: =pod
                   1558: 
                   1559: =item tiehash()
                   1560: 
                   1561: tie the hash
                   1562: 
                   1563: =cut
                   1564: 
                   1565: sub tiehash {
                   1566:     my ($mode)=@_;
                   1567:     $hashtied=0;
                   1568:     if ($env{'request.course.fn'}) {
                   1569: 	if ($mode eq 'write') {
                   1570: 	    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
                   1571: 		    &GDBM_WRCREAT(),0640)) {
                   1572:                 $hashtied=2;
                   1573: 	    }
                   1574: 	} else {
                   1575: 	    if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
                   1576: 		    &GDBM_READER(),0640)) {
                   1577:                 $hashtied=1;
                   1578: 	    }
                   1579: 	}
1.364     bisitz   1580:     }
1.329     droeschl 1581: }
                   1582: 
                   1583: sub untiehash {
                   1584:     if ($hashtied) { untie %hash; }
                   1585:     $hashtied=0;
                   1586:     return OK;
                   1587: }
                   1588: 
                   1589: 
                   1590: 
                   1591: 
                   1592: sub checkonthis {
                   1593:     my ($r,$url,$level,$title)=@_;
                   1594:     $url=&unescape($url);
                   1595:     $alreadyseen{$url}=1;
                   1596:     $r->rflush();
                   1597:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
                   1598:        $r->print("\n<br />");
                   1599:        if ($level==0) {
                   1600:            $r->print("<br />");
                   1601:        }
                   1602:        for (my $i=0;$i<=$level*5;$i++) {
                   1603:            $r->print('&nbsp;');
                   1604:        }
                   1605:        $r->print('<a href="'.$url.'" target="cat">'.
                   1606: 		 ($title?$title:$url).'</a> ');
                   1607:        if ($url=~/^\/res\//) {
                   1608: 	  my $result=&Apache::lonnet::repcopy(
                   1609:                               &Apache::lonnet::filelocation('',$url));
                   1610:           if ($result eq 'ok') {
                   1611:              $r->print('<span class="LC_success">'.&mt('ok').'</span>');
                   1612:              $r->rflush();
                   1613:              &Apache::lonnet::countacc($url);
                   1614:              $url=~/\.(\w+)$/;
                   1615:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
                   1616: 		 $r->print('<br />');
                   1617:                  $r->rflush();
                   1618:                  for (my $i=0;$i<=$level*5;$i++) {
                   1619:                      $r->print('&nbsp;');
                   1620:                  }
                   1621:                  $r->print('- '.&mt('Rendering:').' ');
                   1622: 		 my ($errorcount,$warningcount)=split(/:/,
                   1623: 	       &Apache::lonnet::ssi_body($url,
                   1624: 			       ('grade_target'=>'web',
                   1625: 				'return_only_error_and_warning_counts' => 1)));
                   1626:                  if (($errorcount) ||
                   1627:                      ($warningcount)) {
                   1628: 		     if ($errorcount) {
1.369     bisitz   1629:                         $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329     droeschl 1630:                           &mt('[quant,_1,error]',$errorcount).'</span>');
                   1631:                      }
                   1632: 		     if ($warningcount) {
                   1633:                         $r->print('<span class="LC_warning">'.
                   1634:                           &mt('[quant,_1,warning]',$warningcount).'</span>');
                   1635:                      }
                   1636:                  } else {
                   1637:                      $r->print('<span class="LC_success">'.&mt('ok').'</span>');
                   1638:                  }
                   1639:                  $r->rflush();
                   1640:              }
                   1641: 	     my $dependencies=
                   1642:                 &Apache::lonnet::metadata($url,'dependencies');
                   1643:              foreach my $dep (split(/\,/,$dependencies)) {
                   1644: 		 if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
                   1645:                     &checkonthis($r,$dep,$level+1);
                   1646:                  }
                   1647:              }
                   1648:           } elsif ($result eq 'unavailable') {
                   1649:              $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
                   1650:           } elsif ($result eq 'not_found') {
                   1651: 	      unless ($url=~/\$/) {
                   1652: 		  $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
                   1653: 	      } else {
1.366     bisitz   1654: 		  $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329     droeschl 1655: 	      }
                   1656:           } else {
                   1657:              $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
                   1658:           }
                   1659:        }
                   1660:     }
                   1661: }
                   1662: 
                   1663: 
                   1664: 
                   1665: =pod
                   1666: 
                   1667: =item list_symbs()
                   1668: 
1.485     raeburn  1669: List Content Identifiers
1.329     droeschl 1670: 
                   1671: =cut
                   1672: 
                   1673: sub list_symbs {
                   1674:     my ($r) = @_;
                   1675: 
1.408     raeburn  1676:     my $crstype = &Apache::loncommon::course_type();
1.484     raeburn  1677:     $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
                   1678:     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
                   1679:     $r->print(&startContentScreen('tools'));
1.329     droeschl 1680:     my $navmap = Apache::lonnavmaps::navmap->new();
                   1681:     if (!defined($navmap)) {
                   1682:         $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
                   1683:                   '<div class="LC_error">'.
                   1684:                   &mt('Unable to retrieve information about course contents').
                   1685:                   '</div>');
1.408     raeburn  1686:         &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329     droeschl 1687:     } else {
1.484     raeburn  1688:         $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
                   1689:                   &Apache::loncommon::start_data_table().
                   1690:                   &Apache::loncommon::start_data_table_header_row().
                   1691:                   '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
                   1692:                   &Apache::loncommon::end_data_table_header_row()."\n");
                   1693:         my $count;
1.329     droeschl 1694:         foreach my $res ($navmap->retrieveResources()) {
1.484     raeburn  1695:             $r->print(&Apache::loncommon::start_data_table_row().
                   1696:                       '<td>'.$res->compTitle().'</td>'.
                   1697:                       '<td>'.$res->symb().'</td>'.
                   1698:                       &Apache::loncommon::start_data_table_row());
                   1699:             $count ++;
                   1700:         }
                   1701:         if (!$count) {
                   1702:             $r->print(&Apache::loncommon::start_data_table_row().
                   1703:                       '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
                   1704:                       &Apache::loncommon::end_data_table_row()); 
1.329     droeschl 1705:         }
1.484     raeburn  1706:         $r->print(&Apache::loncommon::end_data_table());
1.329     droeschl 1707:     }
                   1708: }
                   1709: 
                   1710: 
                   1711: sub verifycontent {
                   1712:     my ($r) = @_;
1.408     raeburn  1713:     my $crstype = &Apache::loncommon::course_type();
1.484     raeburn  1714:     $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
                   1715:     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
                   1716:     $r->print(&startContentScreen('tools'));
                   1717:     $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>'); 
1.329     droeschl 1718:    $hashtied=0;
                   1719:    undef %alreadyseen;
                   1720:    %alreadyseen=();
                   1721:    &tiehash();
1.484     raeburn  1722:    
1.329     droeschl 1723:    foreach my $key (keys(%hash)) {
                   1724:        if ($hash{$key}=~/\.(page|sequence)$/) {
                   1725: 	   if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
                   1726: 	       $r->print('<hr /><span class="LC_error">'.
1.419     bisitz   1727: 			 &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329     droeschl 1728: 			 &unescape($hash{$key}).'</span><br />'.
1.419     bisitz   1729: 			 &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329     droeschl 1730: 	   }
                   1731:        }
                   1732:        if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
                   1733:            &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
                   1734:        }
                   1735:    }
                   1736:    &untiehash();
1.442     www      1737:    $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.329     droeschl 1738: }
                   1739: 
                   1740: 
                   1741: sub devalidateversioncache {
                   1742:     my $src=shift;
                   1743:     &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
                   1744: 					  &Apache::lonnet::clutter($src));
                   1745: }
                   1746: 
                   1747: sub checkversions {
                   1748:     my ($r) = @_;
1.408     raeburn  1749:     my $crstype = &Apache::loncommon::course_type();
                   1750:     $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
                   1751:     $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
1.484     raeburn  1752:     $r->print(&startContentScreen('tools'));
1.442     www      1753: 
1.329     droeschl 1754:     my $header='';
                   1755:     my $startsel='';
                   1756:     my $monthsel='';
                   1757:     my $weeksel='';
                   1758:     my $daysel='';
                   1759:     my $allsel='';
                   1760:     my %changes=();
                   1761:     my $starttime=0;
                   1762:     my $haschanged=0;
                   1763:     my %setversions=&Apache::lonnet::dump('resourceversions',
                   1764: 			  $env{'course.'.$env{'request.course.id'}.'.domain'},
                   1765: 			  $env{'course.'.$env{'request.course.id'}.'.num'});
                   1766: 
                   1767:     $hashtied=0;
                   1768:     &tiehash();
                   1769:     my %newsetversions=();
                   1770:     if ($env{'form.setmostrecent'}) {
                   1771: 	$haschanged=1;
                   1772: 	foreach my $key (keys(%hash)) {
                   1773: 	    if ($key=~/^ids\_(\/res\/.+)$/) {
                   1774: 		$newsetversions{$1}='mostrecent';
                   1775:                 &devalidateversioncache($1);
                   1776: 	    }
                   1777: 	}
                   1778:     } elsif ($env{'form.setcurrent'}) {
                   1779: 	$haschanged=1;
                   1780: 	foreach my $key (keys(%hash)) {
                   1781: 	    if ($key=~/^ids\_(\/res\/.+)$/) {
                   1782: 		my $getvers=&Apache::lonnet::getversion($1);
                   1783: 		if ($getvers>0) {
                   1784: 		    $newsetversions{$1}=$getvers;
                   1785: 		    &devalidateversioncache($1);
                   1786: 		}
                   1787: 	    }
                   1788: 	}
                   1789:     } elsif ($env{'form.setversions'}) {
                   1790: 	$haschanged=1;
                   1791: 	foreach my $key (keys(%env)) {
                   1792: 	    if ($key=~/^form\.set_version_(.+)$/) {
                   1793: 		my $src=$1;
                   1794: 		if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
                   1795: 		    $newsetversions{$src}=$env{$key};
                   1796: 		    &devalidateversioncache($src);
                   1797: 		}
                   1798: 	    }
                   1799: 	}
                   1800:     }
                   1801:     if ($haschanged) {
                   1802:         if (&Apache::lonnet::put('resourceversions',\%newsetversions,
                   1803: 			  $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344     bisitz   1804: 			  $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479     golterma 1805: 	    $r->print(&Apache::loncommon::confirmwrapper(
                   1806:                 &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329     droeschl 1807: 	} else {
1.479     golterma 1808: 	    $r->print(&Apache::loncommon::confirmwrapper(
                   1809:                 &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329     droeschl 1810: 	}
                   1811: 	&mark_hash_old();
                   1812:     }
                   1813:     &changewarning($r,'');
                   1814:     if ($env{'form.timerange'} eq 'all') {
                   1815: # show all documents
1.408     raeburn  1816: 	$header=&mt('All Documents in '.$crstype);
1.329     droeschl 1817: 	$allsel=1;
                   1818: 	foreach my $key (keys(%hash)) {
                   1819: 	    if ($key=~/^ids\_(\/res\/.+)$/) {
                   1820: 		my $src=$1;
                   1821: 		$changes{$src}=1;
                   1822: 	    }
                   1823: 	}
                   1824:     } else {
                   1825: # show documents which changed
                   1826: 	%changes=&Apache::lonnet::dump
                   1827: 	 ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
                   1828:                      $env{'course.'.$env{'request.course.id'}.'.num'});
                   1829: 	my $firstkey=(keys(%changes))[0];
                   1830: 	unless ($firstkey=~/^error\:/) {
                   1831: 	    unless ($env{'form.timerange'}) {
                   1832: 		$env{'form.timerange'}=604800;
                   1833: 	    }
                   1834: 	    my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
                   1835: 		.&mt('seconds');
                   1836: 	    if ($env{'form.timerange'}==-1) {
                   1837: 		$seltext='since start of course';
                   1838: 		$startsel='selected';
                   1839: 		$env{'form.timerange'}=time;
                   1840: 	    }
                   1841: 	    $starttime=time-$env{'form.timerange'};
                   1842: 	    if ($env{'form.timerange'}==2592000) {
                   1843: 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                   1844: 		$monthsel='selected';
                   1845: 	    } elsif ($env{'form.timerange'}==604800) {
                   1846: 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                   1847: 		$weeksel='selected';
                   1848: 	    } elsif ($env{'form.timerange'}==86400) {
                   1849: 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                   1850: 		$daysel='selected';
                   1851: 	    }
                   1852: 	    $header=&mt('Content changed').' '.$seltext;
                   1853: 	} else {
                   1854: 	    $header=&mt('No content modifications yet.');
                   1855: 	}
                   1856:     }
                   1857:     %setversions=&Apache::lonnet::dump('resourceversions',
                   1858: 			  $env{'course.'.$env{'request.course.id'}.'.domain'},
                   1859: 			  $env{'course.'.$env{'request.course.id'}.'.num'});
                   1860:     my %lt=&Apache::lonlocal::texthash
1.408     raeburn  1861: 	      ('st' => 'Version changes since start of '.$crstype,
1.329     droeschl 1862: 	       'lm' => 'Version changes since last Month',
                   1863: 	       'lw' => 'Version changes since last Week',
                   1864: 	       'sy' => 'Version changes since Yesterday',
                   1865:                'al' => 'All Resources (possibly large output)',
1.484     raeburn  1866:                'cd' => 'Change display', 
1.329     droeschl 1867: 	       'sd' => 'Display',
                   1868: 	       'fi' => 'File',
                   1869: 	       'md' => 'Modification Date',
                   1870:                'mr' => 'Most recently published Version',
1.408     raeburn  1871: 	       've' => 'Version used in '.$crstype,
                   1872:                'vu' => 'Set Version to be used in '.$crstype,
                   1873: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329     droeschl 1874: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
                   1875: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479     golterma 1876: 	       'di' => 'Differences',
1.484     raeburn  1877: 	       'save' => 'Save changes',
                   1878:                'vers' => 'Version choice(s) for specific resources', 
1.479     golterma 1879: 	       'act' => 'Actions');
1.329     droeschl 1880:     $r->print(<<ENDHEADERS);
1.484     raeburn  1881: <h4 class="LC_info">$header</h4>
1.329     droeschl 1882: <form action="/adm/coursedocs" method="post">
                   1883: <input type="hidden" name="versions" value="1" />
1.484     raeburn  1884: <div class="LC_left_float">
1.479     golterma 1885: <fieldset>
1.484     raeburn  1886: <legend>$lt{'cd'}</legend>
1.329     droeschl 1887: <select name="timerange">
                   1888: <option value='all' $allsel>$lt{'al'}</option>
                   1889: <option value="-1" $startsel>$lt{'st'}</option>
                   1890: <option value="2592000" $monthsel>$lt{'lm'}</option>
                   1891: <option value="604800" $weeksel>$lt{'lw'}</option>
                   1892: <option value="86400" $daysel>$lt{'sy'}</option>
                   1893: </select>
                   1894: <input type="submit" name="display" value="$lt{'sd'}" />
1.484     raeburn  1895: </fieldset>
                   1896: </div>
                   1897: <div class="LC_left_float">
                   1898: <fieldset>
                   1899: <legend>$lt{'act'}</legend>
                   1900: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
                   1901: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
                   1902: </fieldset>
                   1903: </div>
                   1904: <br clear="all" />
                   1905: <hr />
                   1906: <h4>$lt{'vers'}</h4>
1.479     golterma 1907: <input type="submit" name="setversions" value="$lt{'save'}" />
1.329     droeschl 1908: <table border="0">
                   1909: ENDHEADERS
1.479     golterma 1910:     #number of columns for version history
                   1911:     my $num_ver_col = 1;
                   1912:     $r->print(
                   1913:     &Apache::loncommon::start_data_table().
                   1914:     &Apache::loncommon::start_data_table_header_row().
                   1915:     '<th>'.&mt('Resources').'</th>'.
                   1916:     "<th>$lt{'mr'}</th>".
                   1917:     "<th>$lt{'ve'}</th>".
                   1918:     "<th>$lt{'vu'}</th>".
                   1919:     '<th colspan="'.$num_ver_col.'">'.&mt('History').'</th>'.
                   1920:     '</b>');
1.329     droeschl 1921:     foreach my $key (sort(keys(%changes))) {
                   1922: 	if ($changes{$key}>$starttime) {
                   1923: 	    my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
                   1924: 	    my $currentversion=&Apache::lonnet::getversion($key);
                   1925: 	    if ($currentversion<0) {
1.479     golterma 1926:                 $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
1.329     droeschl 1927: 	    }
                   1928: 	    my $linkurl=&Apache::lonnet::clutter($key);
1.479     golterma 1929:         $r->print(
                   1930:             &Apache::loncommon::end_data_table_header_row().
                   1931:             &Apache::loncommon::start_data_table_row().
                   1932:             '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br>'.
                   1933:             '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
                   1934:             '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br>('.
                   1935:             &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
                   1936:             '<td align="right">');
1.329     droeschl 1937: # Used in course
                   1938: 	    my $usedversion=$hash{'version_'.$linkurl};
                   1939: 	    if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.479     golterma 1940:                 if($usedversion != $currentversion){
                   1941:                     $r->print('<span class="LC_warning">'.$usedversion.'</span>');
                   1942:                 }else{
                   1943:                     $r->print($usedversion);
                   1944:                 }
1.329     droeschl 1945: 	    } else {
                   1946: 		$r->print($currentversion);
                   1947: 	    }
1.479     golterma 1948: 	    $r->print('</td><td title="'.$lt{'vu'}.'">');
1.329     droeschl 1949: # Set version
                   1950: 	    $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
                   1951: 						      'set_version_'.$linkurl,
1.428     raeburn  1952: 						      {'select_form_order' =>
1.329     droeschl 1953: 						       ['',1..$currentversion,'mostrecent'],
                   1954: 						       '' => '',
1.411     bisitz   1955: 						       'mostrecent' => &mt('most recent'),
1.428     raeburn  1956: 						       map {$_,$_} (1..$currentversion)}));
1.329     droeschl 1957: 	    my $lastold=1;
                   1958: 	    for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                   1959: 		my $url=$root.'.'.$prevvers.'.'.$extension;
                   1960: 		if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
                   1961: 		    $starttime) {
                   1962: 		    $lastold=$prevvers;
                   1963: 		}
                   1964: 	    }
1.364     bisitz   1965:             #
1.329     droeschl 1966:             # Code to figure out how many version entries should go in
                   1967:             # each of the four columns
                   1968:             my $entries_per_col = 0;
                   1969:             my $num_entries = ($currentversion-$lastold);
1.479     golterma 1970:             if ($num_entries % $num_ver_col == 0) {
                   1971:                 $entries_per_col = $num_entries/$num_ver_col;
1.329     droeschl 1972:             } else {
1.479     golterma 1973:                 $entries_per_col = $num_entries/$num_ver_col + 1;
1.329     droeschl 1974:             }
                   1975:             my $entries_count = 0;
1.479     golterma 1976:             $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1.329     droeschl 1977:             my $cols_output = 1;
                   1978:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
                   1979: 		my $url=$root.'.'.$prevvers.'.'.$extension;
                   1980: 		$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
                   1981: 			  '">'.&mt('Version').' '.$prevvers.'</a> ('.
                   1982: 			  &Apache::lonlocal::locallocaltime(
                   1983:                                 &Apache::lonnet::metadata($url,
                   1984:                                                           'lastrevisiondate')
                   1985:                                                             ).
                   1986: 			  ')');
                   1987: 		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
                   1988:                     $r->print(' <a href="/adm/diff?filename='.
                   1989: 			      &Apache::lonnet::clutter($root.'.'.$extension).
                   1990: 			      '&versionone='.$prevvers.
1.462     raeburn  1991: 			      '" target="diffs">'.&mt('Diffs').'</a>');
1.329     droeschl 1992: 		}
                   1993: 		$r->print('</span><br />');
                   1994:                 if (++$entries_count % $entries_per_col == 0) {
1.479     golterma 1995:                     $r->print('</span></td>');
                   1996:                     if ($cols_output != $num_ver_col) {
                   1997:                         $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1.329     droeschl 1998:                         $cols_output++;
                   1999:                     }
                   2000:                 }
                   2001: 	    }
1.479     golterma 2002:             while($cols_output++ < $num_ver_col) {
                   2003:                 $r->print('</span></td><td>');
1.329     droeschl 2004:             }
                   2005: 	}
                   2006:     }
1.479     golterma 2007:     $r->print('</td>'.&Apache::loncommon::end_data_table_row().
                   2008:             &Apache::loncommon::end_data_table().
                   2009:             '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />');
1.329     droeschl 2010: 
                   2011:     &untiehash();
                   2012: }
                   2013: 
                   2014: sub mark_hash_old {
                   2015:     my $retie_hash=0;
                   2016:     if ($hashtied) {
                   2017: 	$retie_hash=1;
                   2018: 	&untiehash();
                   2019:     }
                   2020:     &tiehash('write');
                   2021:     $hash{'old'}=1;
                   2022:     &untiehash();
                   2023:     if ($retie_hash) { &tiehash(); }
                   2024: }
                   2025: 
                   2026: sub is_hash_old {
                   2027:     my $untie_hash=0;
                   2028:     if (!$hashtied) {
                   2029: 	$untie_hash=1;
                   2030: 	&tiehash();
                   2031:     }
                   2032:     my $return=$hash{'old'};
                   2033:     if ($untie_hash) { &untiehash(); }
                   2034:     return $return;
                   2035: }
                   2036: 
                   2037: sub changewarning {
                   2038:     my ($r,$postexec,$message,$url)=@_;
                   2039:     if (!&is_hash_old()) { return; }
                   2040:     my $pathvar='folderpath';
                   2041:     my $path=&escape($env{'form.folderpath'});
                   2042:     if (!defined($url)) {
                   2043: 	if (defined($env{'form.pagepath'})) {
                   2044: 	    $pathvar='pagepath';
                   2045: 	    $path=&escape($env{'form.pagepath'});
                   2046: 	    $path.='&amp;pagesymb='.&escape($env{'form.pagesymb'});
                   2047: 	}
                   2048: 	$url='/adm/coursedocs?'.$pathvar.'='.$path;
                   2049:     }
                   2050:     my $course_type = &Apache::loncommon::course_type();
                   2051:     if (!defined($message)) {
                   2052: 	$message='Changes will become active for your current session after [_1], or the next time you log in.';
                   2053:     }
                   2054:     $r->print("\n\n".
1.372     bisitz   2055: '<script type="text/javascript">'."\n".
                   2056: '// <![CDATA['."\n".
                   2057: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
                   2058: '// ]]>'."\n".
1.369     bisitz   2059: '</script>'."\n".
1.375     tempelho 2060: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329     droeschl 2061: '<input type="hidden" name="orgurl" value="'.$url.
1.372     bisitz   2062: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329     droeschl 2063: &mt($message,' <input type="hidden" name="'.
                   2064:     $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369     bisitz   2065:     &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372     bisitz   2066: $help{'Caching'}.'</p></form>'."\n\n");
1.329     droeschl 2067: }
                   2068: 
                   2069: 
                   2070: sub init_breadcrumbs {
                   2071:     my ($form,$text)=@_;
                   2072:     &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484     raeburn  2073:     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405     bisitz   2074: 					    text=>&Apache::loncommon::course_type().' Editor',
1.329     droeschl 2075: 					    faq=>273,
                   2076: 					    bug=>'Instructor Interface',
                   2077:                                             help => 'Docs_Adding_Course_Doc'});
                   2078:     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
                   2079: 					    text=>$text,
                   2080: 					    faq=>273,
                   2081: 					    bug=>'Instructor Interface'});
                   2082: }
                   2083: 
1.441     www      2084: # subroutine to list form elements
                   2085: sub create_list_elements {
                   2086:    my @formarr = @_;
                   2087:    my $list = '';
                   2088:    for my $button (@formarr){
                   2089:         for my $picture(keys %$button) {
                   2090:             $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
                   2091:         }
                   2092:    }
                   2093:    return $list;
                   2094: }
1.329     droeschl 2095: 
1.441     www      2096: # subroutine to create ul from list elements
                   2097: sub create_form_ul {
                   2098:    my $list = shift;
                   2099:    my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
                   2100:    return $ul;
                   2101: }
1.329     droeschl 2102: 
1.442     www      2103: #
                   2104: # Start tabs
                   2105: #
                   2106: 
                   2107: sub startContentScreen {
1.484     raeburn  2108:     my ($mode) = @_;
                   2109:     my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472     raeburn  2110:     if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484     raeburn  2111:         $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Overview').'&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
                   2112:         $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
                   2113:         $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Index').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
                   2114:         $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
                   2115:     } else {
                   2116:         $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
                   2117:         $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
                   2118:         $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Utilities').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
                   2119:                    '><a href="/adm/coursedocs?tools=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Utilities').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>';
                   2120:     }
                   2121:     $output .= "\n".'</ul>'."\n";
                   2122:     $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
                   2123:                '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
                   2124:                '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
                   2125:     return $output;
1.442     www      2126: }
                   2127: 
                   2128: #
                   2129: # End tabs
                   2130: #
                   2131: 
                   2132: sub endContentScreen {
1.484     raeburn  2133:     return '</div></div></div>';
1.442     www      2134: }
1.329     droeschl 2135: 
1.446     www      2136: sub supplemental_base {
1.472     raeburn  2137:     return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
1.446     www      2138: }
                   2139: 
1.329     droeschl 2140: sub handler {
                   2141:     my $r = shift;
                   2142:     &Apache::loncommon::content_type($r,'text/html');
                   2143:     $r->send_http_header;
                   2144:     return OK if $r->header_only;
1.484     raeburn  2145: 
                   2146: # get course data
1.408     raeburn  2147:     my $crstype = &Apache::loncommon::course_type();
1.484     raeburn  2148:     my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
                   2149:     my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
                   2150: 
                   2151: # graphics settings
                   2152:     $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329     droeschl 2153: 
1.443     www      2154: #
1.329     droeschl 2155: # --------------------------------------------- Initialize help topics for this
                   2156:     foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
                   2157: 	               'Adding_External_Resource','Navigate_Content',
                   2158: 	               'Adding_Folders','Docs_Overview', 'Load_Map',
                   2159: 	               'Supplemental','Score_Upload_Form','Adding_Pages',
                   2160: 	               'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
                   2161: 	               'Check_Resource_Versions','Verify_Content') {
                   2162: 	$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
                   2163:     }
                   2164:     # Composite help files
                   2165:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
                   2166: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
                   2167:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
                   2168: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
                   2169:     $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
                   2170: 		    'Option_Response_Simple');
                   2171:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
                   2172: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347     weissno  2173:     $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329     droeschl 2174: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353     weissno  2175:     $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329     droeschl 2176:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
                   2177: 
1.472     raeburn  2178:     
                   2179:     my $allowed;
                   2180: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
                   2181:     unless ($r->uri eq '/adm/supplemental') {
                   2182:         # does this user have privileges to modify content.  
                   2183:         $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
                   2184:     }
                   2185: 
1.484     raeburn  2186:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
                   2187:                                             'inhibitmenu']);
                   2188:   if ($allowed && $env{'form.chooseserver'}) {
                   2189:       &choose_dump_server($r);
                   2190:       return OK;
                   2191:   } elsif ($allowed && $env{'form.verify'}) {
1.329     droeschl 2192:       &init_breadcrumbs('verify','Verify Content');
                   2193:       &verifycontent($r);
                   2194:   } elsif ($allowed && $env{'form.listsymbs'}) {
1.484     raeburn  2195:       &init_breadcrumbs('listsymbs','List Content IDs');
1.329     droeschl 2196:       &list_symbs($r);
                   2197:   } elsif ($allowed && $env{'form.docslog'}) {
                   2198:       &init_breadcrumbs('docslog','Show Log');
1.484     raeburn  2199:       my $folder = $env{'form.folder'};
                   2200:       if ($folder eq '') {
                   2201:           $folder='default';
                   2202:       }
                   2203:       &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329     droeschl 2204:   } elsif ($allowed && $env{'form.versions'}) {
                   2205:       &init_breadcrumbs('versions','Check/Set Resource Versions');
                   2206:       &checkversions($r);
                   2207:   } elsif ($allowed && $env{'form.dumpcourse'}) {
1.484     raeburn  2208:       &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329     droeschl 2209:       &dumpcourse($r);
                   2210:   } elsif ($allowed && $env{'form.exportcourse'}) {
1.377     bisitz   2211:       &init_breadcrumbs('exportcourse','IMS Export');
1.475     raeburn  2212:       &Apache::imsexport::exportcourse($r);
1.329     droeschl 2213:   } else {
1.445     www      2214: #
                   2215: # Done catching special calls
1.484     raeburn  2216: # The whole rest is for course and supplemental documents and utilities menu
1.445     www      2217: # Get the parameters that may be needed
                   2218: #
                   2219:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                   2220:                                             ['folderpath','pagepath',
1.466     www      2221:                                              'pagesymb','forcesupplement','forcestandard',
1.484     raeburn  2222:                                              'tools','symb','command']);
1.445     www      2223: 
                   2224: # standard=1: this is a "new-style" course with an uploaded map as top level
                   2225: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329     droeschl 2226: 
                   2227:     my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445     www      2228: 
1.484     raeburn  2229: # Decide whether this should display supplemental or main content or utilities
1.445     www      2230: # supplementalflag=1: show supplemental documents
                   2231: # supplementalflag=0: show standard documents
1.484     raeburn  2232: # toolsflag=1: show utilities
1.445     www      2233: 
                   2234: 
                   2235:     my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
                   2236:     if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
                   2237:        $supplementalflag=0;
                   2238:     }
                   2239:     if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
                   2240:     if ($env{'form.forcestandard'})   { $supplementalflag=0; }
                   2241:     unless ($allowed) { $supplementalflag=1; }
                   2242:     unless ($standard) { $supplementalflag=1; }
1.484     raeburn  2243:     my $toolsflag=0;
                   2244:     if ($env{'form.tools'}) { $toolsflag=1; }
1.445     www      2245: 
1.329     droeschl 2246:     my $script='';
                   2247:     my $showdoc=0;
1.457     raeburn  2248:     my $addentries = {};
1.475     raeburn  2249:     my $container;
1.329     droeschl 2250:     my $containertag;
                   2251:     my $uploadtag;
                   2252: 
1.464     www      2253: # Do we directly jump somewhere?
1.466     www      2254: 
1.464     www      2255:    if ($env{'form.command'} eq 'direct') {
1.468     raeburn  2256:        my ($mapurl,$id,$resurl);
1.472     raeburn  2257:        if ($env{'form.symb'} ne '') {
1.468     raeburn  2258:            ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
                   2259:            if ($resurl=~/\.(sequence|page)$/) {
                   2260:                $mapurl=$resurl;
                   2261:            } elsif ($resurl eq 'adm/navmaps') {
                   2262:                $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
                   2263:            }
1.472     raeburn  2264:            my $mapresobj;
                   2265:            my $navmap = Apache::lonnavmaps::navmap->new();
                   2266:            if (ref($navmap)) {
                   2267:                $mapresobj = $navmap->getResourceByUrl($mapurl);
                   2268:            }
                   2269:            $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
                   2270:            my $type=$2;
                   2271:            my $path;
                   2272:            if (ref($mapresobj)) {
                   2273:                my $pcslist = $mapresobj->map_hierarchy();
                   2274:                if ($pcslist ne '') {
                   2275:                    foreach my $pc (split(/,/,$pcslist)) {
                   2276:                        next if ($pc <= 1);
                   2277:                        my $res = $navmap->getByMapPc($pc);
                   2278:                        if (ref($res)) {
                   2279:                            my $thisurl = $res->src();
                   2280:                            $thisurl=~s{^.*/([^/]+)\.\w+$}{$1}; 
                   2281:                            my $thistitle = $res->title();
                   2282:                            $path .= '&'.
                   2283:                                     &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
                   2284:                                     &Apache::lonhtmlcommon::entity_encode($thistitle).
                   2285:                                     ':'.$res->randompick().
                   2286:                                     ':'.$res->randomout().
                   2287:                                     ':'.$res->encrypted().
                   2288:                                     ':'.$res->randomorder();
                   2289:                        }
1.467     raeburn  2290:                    }
                   2291:                }
1.472     raeburn  2292:                $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
1.467     raeburn  2293:                     &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
                   2294:                     ':'.$mapresobj->randompick().
                   2295:                     ':'.$mapresobj->randomout().
                   2296:                     ':'.$mapresobj->encrypted().
                   2297:                     ':'.$mapresobj->randomorder();
1.472     raeburn  2298:            } else {
                   2299:                my $maptitle = &Apache::lonnet::gettitle($mapurl);
                   2300:                $path = '&default&...::::'.
                   2301:                    '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
                   2302:                    &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
                   2303:            }
                   2304:            $path = 'default&'.
                   2305:                    &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
                   2306:                    $path;
                   2307:            if ($type eq 'sequence') {
                   2308:                $env{'form.folderpath'}=$path;
                   2309:                $env{'form.pagepath'}='';
                   2310:            } else {
                   2311:                $env{'form.pagepath'}=$path;
                   2312:                $env{'form.folderpath'}='';
                   2313:            }
                   2314:        } elsif ($env{'form.supppath'} ne '') {
                   2315:            $env{'form.folderpath'}=$env{'form.supppath'};
1.466     www      2316:        }
1.472     raeburn  2317:    } elsif ($env{'form.command'} eq 'editdocs') {
                   2318:         $env{'form.folderpath'} = 'default&'.
                   2319:                                   &Apache::lonhtmlcommon::entity_encode('Main Course Content');
                   2320:         $env{'form.pagepath'}='';
                   2321:    } elsif ($env{'form.command'} eq 'editsupp') {
                   2322:         $env{'form.folderpath'} = 'default&'.
                   2323:                                   &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
                   2324:         $env{'form.pagepath'}='';
1.464     www      2325:    }
                   2326: 
1.445     www      2327: # Where do we store these for when we come back?
                   2328:     my $stored_folderpath='docs_folderpath';
                   2329:     if ($supplementalflag) {
                   2330:        $stored_folderpath='docs_sup_folderpath';
                   2331:     }
1.464     www      2332: 
1.329     droeschl 2333: # No folderpath, no pagepath, see if we have something stored
                   2334:     if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
1.445     www      2335:         &Apache::loncommon::restore_course_settings($stored_folderpath,
1.329     droeschl 2336:                                               {'folderpath' => 'scalar'});
                   2337:     }
1.446     www      2338:    
                   2339: # If we are not allowed to make changes, all we can see are supplemental docs
1.409     raeburn  2340:     if (!$allowed) {
1.446     www      2341:         $env{'form.pagepath'}='';
                   2342:         unless ($env{'form.folderpath'} =~ /^supplemental/) {
                   2343:             $env{'form.folderpath'} = &supplemental_base();
1.409     raeburn  2344:         }
                   2345:     }
1.446     www      2346: # If we still not have a folderpath, see if we can resurrect at pagepath
1.409     raeburn  2347:     if (!$env{'form.folderpath'} && $allowed) {
1.445     www      2348:         &Apache::loncommon::restore_course_settings($stored_folderpath,
1.329     droeschl 2349:                                               {'pagepath' => 'scalar'});
                   2350:     }
1.446     www      2351: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329     droeschl 2352:     if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446     www      2353:         $env{'form.folderpath'} = &supplemental_base()
                   2354:                                   .'&'.
1.329     droeschl 2355:                                   $env{'form.folderpath'};
                   2356:     }
1.446     www      2357: # If after all of this, we still don't have any paths, make them
                   2358:     unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
                   2359:        if ($supplementalflag) {
                   2360:           $env{'form.folderpath'}=&supplemental_base();
                   2361:        } else {
                   2362:           $env{'form.folderpath'}='default';
                   2363:        }
1.472     raeburn  2364:     }
1.446     www      2365: 
1.445     www      2366: # Store this
1.484     raeburn  2367:     unless ($toolsflag) {
                   2368:         &Apache::loncommon::store_course_settings($stored_folderpath,
                   2369:                                                   {'pagepath' => 'scalar',
                   2370:                                                    'folderpath' => 'scalar'});
                   2371:         if ($env{'form.folderpath'}) {
                   2372: 	    my (@folderpath)=split('&',$env{'form.folderpath'});
                   2373: 	    $env{'form.foldername'}=&unescape(pop(@folderpath));
                   2374: 	    $env{'form.folder'}=pop(@folderpath);
                   2375:             $container='sequence';
                   2376:         }
                   2377:         if ($env{'form.pagepath'}) {
                   2378:             my (@pagepath)=split('&',$env{'form.pagepath'});
                   2379:             $env{'form.pagename'}=&unescape(pop(@pagepath));
                   2380:             $env{'form.folder'}=pop(@pagepath);
                   2381:             $container='page';
                   2382:             $containertag = '<input type="hidden" name="pagepath" value="" />'.
                   2383: 	                    '<input type="hidden" name="pagesymb" value="" />';
                   2384:             $uploadtag = 
                   2385:                 '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
                   2386: 	        '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
                   2387:                 '<input type="hidden" name="folderpath" value="" />';
                   2388:         } else {
                   2389:             my $folderpath=$env{'form.folderpath'};
                   2390:             if (!$folderpath) {
                   2391:                 if ($env{'form.folder'} eq '' ||
                   2392:                     $env{'form.folder'} eq 'supplemental') {
                   2393:                     $folderpath='default&'.
                   2394:                         &escape(&mt('Main '.$crstype.' Documents'));
                   2395:                 }
                   2396:             }
                   2397:             $containertag = '<input type="hidden" name="folderpath" value="" />';
                   2398:             $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
                   2399:         }
                   2400:         if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
                   2401:            $showdoc='/'.$1;
                   2402:         }
                   2403:         if ($showdoc) { # got called in sequence from course
                   2404: 	    $allowed=0; 
                   2405:         } else {
                   2406:             if ($allowed) {
                   2407:                 &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                   2408:                 $script=&Apache::lonratedt::editscript('simple');
1.433     raeburn  2409:             }
                   2410:         }
1.329     droeschl 2411:     }
                   2412: 
1.344     bisitz   2413: # get personal data
1.329     droeschl 2414:     my $uname=$env{'user.name'};
                   2415:     my $udom=$env{'user.domain'};
                   2416:     my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
                   2417: 
                   2418:     if ($allowed) {
1.484     raeburn  2419:         if ($toolsflag) {
                   2420:             $script .= &inject_data_js();
                   2421:             my ($home,$other,%outhash)=&authorhosts();
                   2422:             if (!$home && $other) {
                   2423:                 my @hosts;
                   2424:                 foreach my $aurole (keys(%outhash)) {
                   2425:                     unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
                   2426:                         push(@hosts,$outhash{$aurole});
                   2427:                     }
                   2428:                 }
                   2429:                 $script .= &dump_switchserver_js(@hosts); 
                   2430:             }
1.458     raeburn  2431:         } else {
1.484     raeburn  2432:             my @tabids;
                   2433:             if ($supplementalflag) {
                   2434:                 @tabids = ('002','ee2','ff2');
                   2435:             } else {
                   2436:                 @tabids = ('aa1','bb1','cc1','ff1');
                   2437:                 unless ($env{'form.pagepath'}) {
                   2438:                     unshift(@tabids,'001');
                   2439:                     push(@tabids,('dd1','ee1'));
                   2440:                 }
1.458     raeburn  2441:             }
1.484     raeburn  2442:             my $tabidstr = join("','",@tabids);
                   2443: 	    $script .= &editing_js($udom,$uname,$supplementalflag).
                   2444:                        &history_tab_js().
                   2445:                        &inject_data_js().
1.485     raeburn  2446:                        &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);
1.484     raeburn  2447:             $addentries = {
1.485     raeburn  2448:                             onload   => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484     raeburn  2449:                           };
1.458     raeburn  2450:         }
1.329     droeschl 2451:     }
                   2452: # -------------------------------------------------------------------- Body tag
1.369     bisitz   2453:     $script = '<script type="text/javascript">'."\n"
1.372     bisitz   2454:               .'// <![CDATA['."\n"
                   2455:               .$script."\n"
                   2456:               .'// ]]>'."\n"
                   2457:               .'</script>'."\n";
1.385     bisitz   2458: 
                   2459:     # Breadcrumbs
                   2460:     &Apache::lonhtmlcommon::clear_breadcrumbs();
1.446     www      2461:     unless ($showdoc) {
1.392     raeburn  2462:         &Apache::lonhtmlcommon::add_breadcrumb({
1.446     www      2463:             href=>"/adm/coursedocs",text=>"$crstype Contents"});
1.392     raeburn  2464: 
1.446     www      2465:         $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.457     raeburn  2466:                                                  {'force_register' => $showdoc,
                   2467:                                                   'add_entries'    => $addentries,
                   2468:                                                  })
1.392     raeburn  2469:                  .&Apache::loncommon::help_open_menu('','',273,'RAT')
                   2470:                  .&Apache::lonhtmlcommon::breadcrumbs(
1.484     raeburn  2471:                      'Editing '.$crstype.' Contents',
1.392     raeburn  2472:                      'Docs_Adding_Course_Doc')
                   2473:         );
1.446     www      2474:     } else {
1.408     raeburn  2475:         $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
1.402     raeburn  2476:                                                 {'force_register' => $showdoc,}));
1.392     raeburn  2477:     }
1.364     bisitz   2478: 
1.329     droeschl 2479:   my %allfiles = ();
                   2480:   my %codebase = ();
1.440     raeburn  2481:   my ($upload_result,$upload_output,$uploadphase);
1.329     droeschl 2482:   if ($allowed) {
                   2483:       if (($env{'form.uploaddoc.filename'}) &&
                   2484: 	  ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440     raeburn  2485:           my $context = $1; 
                   2486:           # Process file upload - phase one - upload and parse primary file.
1.329     droeschl 2487: 	  undef($hadchanges);
1.440     raeburn  2488:           $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
                   2489:                                               \%allfiles,\%codebase,$context);
1.329     droeschl 2490: 	  if ($hadchanges) {
                   2491: 	      &mark_hash_old();
                   2492: 	  }
1.440     raeburn  2493:           $r->print($upload_output);
                   2494:       } elsif ($env{'form.phase'} eq 'upload_embedded') {
                   2495:           # Process file upload - phase two - upload embedded objects 
                   2496:           $uploadphase = 'check_embedded';
                   2497:           my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');   
                   2498:           my $state = &embedded_form_elems($uploadphase,$primaryurl,
                   2499:                                            $env{'form.newidx'});
                   2500:           my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
                   2501:           my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
                   2502:           my ($destination,$dir_root) = &embedded_destination();
                   2503:           my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
                   2504:           my $actionurl = '/adm/coursedocs';
                   2505:           my ($result,$flag) = 
                   2506:               &Apache::loncommon::upload_embedded('coursedoc',$destination,
                   2507:                   $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
                   2508:                   $actionurl);
                   2509:           $r->print($result.&return_to_editor());
                   2510:       } elsif ($env{'form.phase'} eq 'check_embedded') {
                   2511:           # Process file upload - phase three - modify references in HTML file
                   2512:           $uploadphase = 'modified_orightml';
                   2513:           my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
                   2514:           my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
                   2515:           my ($destination,$dir_root) = &embedded_destination();
1.482     raeburn  2516:           my $result = 
                   2517:               &Apache::loncommon::modify_html_refs('coursedoc',$destination,
                   2518:                                                    $docuname,$docudom,undef,
                   2519:                                                    $dir_root);
                   2520:           $r->print($result.&return_to_editor());   
1.476     raeburn  2521:       } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
                   2522:           $uploadphase = 'decompress_phase_one';
                   2523:           $r->print(&decompression_phase_one().
                   2524:                     &return_to_editor());
                   2525:       } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
                   2526:           $uploadphase = 'decompress_phase_two';
                   2527:           $r->print(&decompression_phase_two().
                   2528:                     &return_to_editor());
1.329     droeschl 2529:       }
                   2530:   }
                   2531: 
1.484     raeburn  2532:   if ($allowed && $toolsflag) {
                   2533:       $r->print(&startContentScreen('tools'));
                   2534:       $r->print(&generate_admin_menu($crstype));
                   2535:       $r->print(&endContentScreen());
                   2536:   } elsif ((!$showdoc) && (!$uploadphase)) {
1.329     droeschl 2537: # -----------------------------------------------------------------------------
                   2538:        my %lt=&Apache::lonlocal::texthash(
1.408     raeburn  2539:                 'uplm' => 'Upload a new main '.lc($crstype).' document',
                   2540:                 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
1.329     droeschl 2541:                 'impp' => 'Import a document',
                   2542: 		'copm' => 'All documents out of a published map into this folder',
1.417     droeschl 2543:                 'upld' => 'Import Document',
1.329     droeschl 2544:                 'srch' => 'Search',
                   2545:                 'impo' => 'Import',
1.487   ! raeburn  2546: 		'lnks' => 'Import from Stored Links',
1.329     droeschl 2547:                 'selm' => 'Select Map',
                   2548:                 'load' => 'Load Map',
1.419     bisitz   2549:                 'reco' => 'Recover Deleted Documents',
1.329     droeschl 2550:                 'newf' => 'New Folder',
                   2551:                 'newp' => 'New Composite Page',
                   2552:                 'extr' => 'External Resource',
                   2553:                 'syll' => 'Syllabus',
1.425     raeburn  2554:                 'navc' => 'Table of Contents',
1.343     biermanm 2555:                 'sipa' => 'Simple Course Page',
1.329     droeschl 2556:                 'sipr' => 'Simple Problem',
                   2557:                 'drbx' => 'Drop Box',
1.451     www      2558:                 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336     schafran 2559:                 'bull' => 'Discussion Board',
1.347     weissno  2560:                 'mypi' => 'My Personal Information Page',
1.353     weissno  2561:                 'grpo' => 'Group Portfolio',
1.329     droeschl 2562:                 'rost' => 'Course Roster',
1.348     weissno  2563: 				'abou' => 'Personal Information Page for a User',
1.377     bisitz   2564:                 'imsf' => 'IMS Import',
                   2565:                 'imsl' => 'Import IMS package',
1.329     droeschl 2566:                 'file' =>  'File',
                   2567:                 'title' => 'Title',
                   2568:                 'comment' => 'Comment',
1.403     raeburn  2569:                 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.368     truskell 2570: 		'nd' => 'Upload Document',
1.329     droeschl 2571: 		'pm' => 'Published Map',
                   2572: 		'sd' => 'Special Document',
                   2573: 		'mo' => 'More Options',
                   2574: 					  );
                   2575: # -----------------------------------------------------------------------------
                   2576: 	my $fileupload=(<<FIUP);
                   2577: 	$lt{'file'}:<br />
                   2578: 	<input type="file" name="uploaddoc" size="40" />
                   2579: FIUP
                   2580: 
                   2581: 	my $checkbox=(<<CHBO);
                   2582: 	<!-- <label>$lt{'parse'}?
                   2583: 	<input type="checkbox" name="parserflag" />
                   2584: 	</label> -->
                   2585: 	<label>
                   2586: 	<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
                   2587: 	</label>
                   2588: CHBO
                   2589: 
1.458     raeburn  2590:     my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
1.329     droeschl 2591: 	my $fileuploadform=(<<FUFORM);
                   2592: 	<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.371     tempelho 2593: 	<input type="hidden" name="active" value="aa" />
1.329     droeschl 2594: 	$fileupload
                   2595: 	<br />
                   2596: 	$lt{'title'}:<br />
1.458     raeburn  2597: 	<input type="text" size="60" name="comment" />
1.329     droeschl 2598: 	$uploadtag
                   2599: 	<input type="hidden" name="cmd" value="upload_default" />
                   2600: 	<br />
1.458     raeburn  2601: 	<span class="LC_nobreak" style="float:left">
1.329     droeschl 2602: 	$checkbox
                   2603: 	</span>
1.383     tempelho 2604: FUFORM
1.459     raeburn  2605:     $fileuploadform .= $fileuploada.'</form>';
1.329     droeschl 2606: 
                   2607: 	my $simpleeditdefaultform=(<<SEDFFORM);
                   2608: 	<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.371     tempelho 2609: 	<input type="hidden" name="active" value="bb" />
1.383     tempelho 2610: SEDFFORM
                   2611: 	my @simpleeditdefaultforma = ( 
1.423     onken    2612: 	{ '<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>" },
                   2613: 	{ '<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'}" },
1.487   ! raeburn  2614: 	{ '<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>" },
1.383     tempelho 2615: 	);
1.443     www      2616: 	$simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
1.383     tempelho 2617: 	$simpleeditdefaultform .=(<<SEDFFORM);
1.459     raeburn  2618: 	<hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />
1.329     droeschl 2619: 	$lt{'copm'}<br />
                   2620: 	<input type="text" size="40" name="importmap" /><br />
1.458     raeburn  2621: 	<span class="LC_nobreak" style="float:left"><input type="button"
1.369     bisitz   2622: 	onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.329     droeschl 2623: 	value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
                   2624: 	$help{'Load_Map'}</span>
                   2625: 	</form>
                   2626: SEDFFORM
                   2627: 
1.442     www      2628:       my $extresourcesform=(<<ERFORM);
                   2629:       <form action="/adm/coursedocs" method="post" name="newext">
                   2630:       $uploadtag
                   2631:       <input type="hidden" name="importdetail" value="" />
                   2632:       <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
                   2633:       </form>
1.329     droeschl 2634: ERFORM
                   2635: 
1.442     www      2636: 
1.329     droeschl 2637:     if ($allowed) {
                   2638: 	&update_paste_buffer($coursenum,$coursedom);
1.337     ehlerst  2639: 	$r->print(<<HIDDENFORM);
                   2640: 	<form name="renameform" method="post" action="/adm/coursedocs">
                   2641:    <input type="hidden" name="title" />
                   2642:    <input type="hidden" name="cmd" />
                   2643:    <input type="hidden" name="markcopy" />
                   2644:    <input type="hidden" name="copyfolder" />
                   2645:    $containertag
                   2646:  </form>
1.484     raeburn  2647: 
1.337     ehlerst  2648: HIDDENFORM
1.484     raeburn  2649:         $r->print(&makesimpleeditform($uploadtag)."\n".
                   2650:                   &makedocslogform($uploadtag."\n".
                   2651:                                    '<input type="hidden" name="folder" value="'.
                   2652:                                    $env{'form.folder'}.'" />'."\n"));
1.329     droeschl 2653:     }
1.442     www      2654: 
                   2655: # Generate the tabs
1.472     raeburn  2656:     my $mode;
                   2657:     if (($supplementalflag) && (!$allowed)) {
                   2658:         &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
                   2659:     } else {
1.484     raeburn  2660:         $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.472     raeburn  2661:     }
1.443     www      2662: 
1.442     www      2663: #
                   2664: 
                   2665:     my $savefolderpath;
                   2666: 
1.395     raeburn  2667:     if ($allowed) {
1.329     droeschl 2668:        my $folder=$env{'form.folder'};
1.443     www      2669:        if ($folder eq '' || $supplementalflag) {
1.329     droeschl 2670:            $folder='default';
1.356     tempelho 2671: 	   $savefolderpath = $env{'form.folderpath'};
1.442     www      2672: 	   $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
1.329     droeschl 2673:            $uploadtag = '<input type="hidden" name="folderpath" value="'.
                   2674: 	       &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
                   2675:        }
                   2676:        my $postexec='';
                   2677:        if ($folder eq 'default') {
1.372     bisitz   2678:            $r->print('<script type="text/javascript">'."\n"
                   2679:                     .'// <![CDATA['."\n"
                   2680:                     .'this.window.name="loncapaclient";'."\n"
                   2681:                     .'// ]]>'."\n"
                   2682:                     .'</script>'."\n"
1.369     bisitz   2683:        );
1.329     droeschl 2684:        } else {
                   2685:            #$postexec='self.close();';
                   2686:        }
                   2687:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   2688:                      '.sequence';
                   2689:        my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   2690:                      '.page';
                   2691: 	my $container='sequence';
                   2692: 	if ($env{'form.pagepath'}) {
                   2693: 	    $container='page';
                   2694: 	}
                   2695: 	my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
                   2696: 
                   2697: 	my $imspform=(<<IMSPFORM);
                   2698: 	<form action="/adm/imsimportdocs" method="post" name="ims">
                   2699: 	<input type="hidden" name="folder" value="$folder" />
1.423     onken    2700: 	<a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>
1.329     droeschl 2701: 	</form>
                   2702: IMSPFORM
                   2703: 
                   2704: 	my $newnavform=(<<NNFORM);
                   2705: 	<form action="/adm/coursedocs" method="post" name="newnav">
1.371     tempelho 2706: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2707: 	$uploadtag
                   2708: 	<input type="hidden" name="importdetail" 
                   2709: 	value="$lt{'navc'}=/adm/navmaps" />
1.423     onken    2710: 	<a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329     droeschl 2711: 	$help{'Navigate_Content'}
                   2712: 	</form>
                   2713: NNFORM
                   2714: 	my $newsmppageform=(<<NSPFORM);
                   2715: 	<form action="/adm/coursedocs" method="post" name="newsmppg">
1.371     tempelho 2716: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2717: 	$uploadtag
                   2718: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2719: 	<a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383     tempelho 2720: 	$help{'Simple Page'}
1.329     droeschl 2721: 	</form>
                   2722: NSPFORM
                   2723: 
                   2724: 	my $newsmpproblemform=(<<NSPROBFORM);
                   2725: 	<form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371     tempelho 2726: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2727: 	$uploadtag
                   2728: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2729: 	<a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.383     tempelho 2730: 	$help{'Simple Problem'}
1.329     droeschl 2731: 	</form>
                   2732: 
                   2733: NSPROBFORM
                   2734: 
                   2735: 	my $newdropboxform=(<<NDBFORM);
                   2736: 	<form action="/adm/coursedocs" method="post" name="newdropbox">
1.371     tempelho 2737: 	<input type="hidden" name="active" value="cc" />
1.344     bisitz   2738: 	$uploadtag
1.329     droeschl 2739: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2740: 	<a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.344     bisitz   2741: 	</form>
1.329     droeschl 2742: NDBFORM
                   2743: 
                   2744: 	my $newexuploadform=(<<NEXUFORM);
                   2745: 	<form action="/adm/coursedocs" method="post" name="newexamupload">
1.371     tempelho 2746: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2747: 	$uploadtag
                   2748: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2749: 	<a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329     droeschl 2750: 	$help{'Score_Upload_Form'}
                   2751: 	</form>
                   2752: NEXUFORM
                   2753: 
                   2754: 	my $newbulform=(<<NBFORM);
                   2755: 	<form action="/adm/coursedocs" method="post" name="newbul">
1.371     tempelho 2756: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2757: 	$uploadtag
                   2758: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2759: 	<a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329     droeschl 2760: 	$help{'Bulletin Board'}
                   2761: 	</form>
                   2762: NBFORM
                   2763: 
                   2764: 	my $newaboutmeform=(<<NAMFORM);
                   2765: 	<form action="/adm/coursedocs" method="post" name="newaboutme">
1.371     tempelho 2766: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2767: 	$uploadtag
                   2768: 	<input type="hidden" name="importdetail" 
                   2769: 	value="$plainname=/adm/$udom/$uname/aboutme" />
1.423     onken    2770: 	<a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347     weissno  2771: 	$help{'My Personal Information Page'}
1.329     droeschl 2772: 	</form>
                   2773: NAMFORM
                   2774: 
                   2775: 	my $newaboutsomeoneform=(<<NASOFORM);
                   2776: 	<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371     tempelho 2777: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2778: 	$uploadtag
                   2779: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2780: 	<a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329     droeschl 2781: 	</form>
                   2782: NASOFORM
                   2783: 
                   2784: 
                   2785: 	my $newrosterform=(<<NROSTFORM);
                   2786: 	<form action="/adm/coursedocs" method="post" name="newroster">
1.371     tempelho 2787: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2788: 	$uploadtag
                   2789: 	<input type="hidden" name="importdetail" 
                   2790: 	value="$lt{'rost'}=/adm/viewclasslist" />
1.423     onken    2791: 	<a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.329     droeschl 2792: 	$help{'Course Roster'}
                   2793: 	</form>
                   2794: NROSTFORM
                   2795: 
1.342     ehlerst  2796: my $specialdocumentsform;
1.383     tempelho 2797: my @specialdocumentsforma;
1.451     www      2798: my $gradingform;
                   2799: my @gradingforma;
                   2800: my $communityform;
                   2801: my @communityforma;
1.351     ehlerst  2802: my $newfolderform;
1.390     tempelho 2803: my $newfolderb;
1.342     ehlerst  2804: 
1.451     www      2805: 	my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383     tempelho 2806: 	
1.329     droeschl 2807: 	my $newpageform=(<<NPFORM);
                   2808: 	<form action="/adm/coursedocs" method="post" name="newpage">
                   2809: 	<input type="hidden" name="folderpath" value="$path" />
                   2810: 	<input type="hidden" name="importdetail" value="" />
1.371     tempelho 2811: 	<input type="hidden" name="active" value="cc" />
1.423     onken    2812: 	<a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383     tempelho 2813: 	$help{'Adding_Pages'}
1.329     droeschl 2814: 	</form>
                   2815: NPFORM
1.390     tempelho 2816: 
                   2817: 
1.351     ehlerst  2818: 	$newfolderform=(<<NFFORM);
1.329     droeschl 2819: 	<form action="/adm/coursedocs" method="post" name="newfolder">
                   2820: 	<input type="hidden" name="folderpath" value="$path" />
                   2821: 	<input type="hidden" name="importdetail" value="" />
1.371     tempelho 2822: 	<input type="hidden" name="active" value="aa" />
1.422     onken    2823: 	<a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329     droeschl 2824: 	</form>
                   2825: NFFORM
                   2826: 
                   2827: 	my $newsylform=(<<NSYLFORM);
                   2828: 	<form action="/adm/coursedocs" method="post" name="newsyl">
1.371     tempelho 2829: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2830: 	$uploadtag
                   2831: 	<input type="hidden" name="importdetail" 
                   2832: 	value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423     onken    2833: 	<a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329     droeschl 2834: 	$help{'Syllabus'}
1.383     tempelho 2835: 
1.329     droeschl 2836: 	</form>
                   2837: NSYLFORM
1.364     bisitz   2838: 
1.329     droeschl 2839: 	my $newgroupfileform=(<<NGFFORM);
                   2840: 	<form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371     tempelho 2841: 	<input type="hidden" name="active" value="cc" />
1.329     droeschl 2842: 	$uploadtag
                   2843: 	<input type="hidden" name="importdetail"
                   2844: 	value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423     onken    2845: 	<a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353     weissno  2846: 	$help{'Group Portfolio'}
1.329     droeschl 2847: 	</form>
                   2848: NGFFORM
1.383     tempelho 2849: 	@specialdocumentsforma=(
1.421     onken    2850: 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'"  onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.417     droeschl 2851: 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451     www      2852: 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
                   2853:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
                   2854:         );
                   2855:         $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
                   2856: 
1.434     raeburn  2857: 
                   2858:         my @importdoc = (
                   2859:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
                   2860:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
1.459     raeburn  2861:         $fileuploadform =  &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;
1.434     raeburn  2862: 
1.451     www      2863:         @gradingforma=(
                   2864:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
                   2865:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
                   2866:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
                   2867: 
                   2868:         );
                   2869:         $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
                   2870: 
                   2871:         @communityforma=(
                   2872:        {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
                   2873:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
                   2874:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
                   2875:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
                   2876:         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
                   2877:         );
                   2878:         $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383     tempelho 2879: 
1.330     tempelho 2880: my %orderhash = (
1.417     droeschl 2881:                 'aa' => ['Import Documents',$fileuploadform],
1.377     bisitz   2882:                 'bb' => ['Published Resources',$simpleeditdefaultform],
1.451     www      2883:                 'cc' => ['Grading Resources',$gradingform],
1.330     tempelho 2884:                 );
1.451     www      2885: unless ($env{'form.pagepath'}) {
1.434     raeburn  2886:     $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484     raeburn  2887:     $orderhash{'dd'} = ['Collaboration',$communityform];
1.451     www      2888:     $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
1.434     raeburn  2889: }
                   2890: 
1.341     ehlerst  2891:  $hadchanges=0;
1.484     raeburn  2892:        unless (($supplementalflag || $toolsflag)) {
1.458     raeburn  2893:           my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472     raeburn  2894:                               $supplementalflag,\%orderhash,$iconpath);
1.443     www      2895:           if ($error) {
                   2896:              $r->print('<p><span class="LC_error">'.$error.'</span></p>');
                   2897:           }
                   2898:           if ($hadchanges) {
                   2899:              &mark_hash_old();
                   2900:           }
1.341     ehlerst  2901: 
1.443     www      2902:           &changewarning($r,'');
                   2903:         }
1.458     raeburn  2904:     }
1.442     www      2905: 
1.443     www      2906: # Supplemental documents start here
                   2907: 
1.329     droeschl 2908:        my $folder=$env{'form.folder'};
1.443     www      2909:        unless ($supplementalflag) {
1.329     droeschl 2910: 	   $folder='supplemental';
                   2911:        }
                   2912:        if ($folder =~ /^supplemental$/ &&
                   2913: 	   (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446     www      2914:           $env{'form.folderpath'} = &supplemental_base();
1.393     raeburn  2915:        } elsif ($allowed) {
1.356     tempelho 2916: 	  $env{'form.folderpath'} = $savefolderpath;
1.329     droeschl 2917:        }
1.362     ehlerst  2918:        $env{'form.pagepath'} = '';
1.329     droeschl 2919:        if ($allowed) {
                   2920: 	   my $folderseq=
                   2921: 	       '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                   2922: 	       '.sequence';
                   2923: 
                   2924: 	   my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
                   2925: 
1.400     droeschl 2926: 	my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";
1.329     droeschl 2927: 	my $supupdocform=(<<SUPDOCFORM);
1.383     tempelho 2928: 	<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.371     tempelho 2929: 	<input type="hidden" name="active" value="ee" />	
1.329     droeschl 2930: 	$fileupload
                   2931: 	<br />
                   2932: 	<br />
                   2933: 	<span class="LC_nobreak">
                   2934: 	$checkbox
                   2935: 	</span>
                   2936: 	<br /><br />
                   2937: 	$lt{'comment'}:<br />
1.383     tempelho 2938: 	<textarea cols="50" rows="4" name="comment"></textarea>
1.329     droeschl 2939: 	<br />
                   2940: 	<input type="hidden" name="folderpath" value="$path" />
                   2941: 	<input type="hidden" name="cmd" value="upload_supplemental" />
                   2942: SUPDOCFORM
1.443     www      2943: 	$supupdocform .=  &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";
1.329     droeschl 2944: 
                   2945: 	my $supnewfolderform=(<<SNFFORM);
                   2946: 	<form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371     tempelho 2947: 	<input type="hidden" name="active" value="ee" />
1.329     droeschl 2948: 	<input type="hidden" name="folderpath" value="$path" />
                   2949: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2950: 	<a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> 
1.383     tempelho 2951: 	$help{'Adding_Folders'}
1.329     droeschl 2952: 	</form>
                   2953: SNFFORM
1.383     tempelho 2954: 	
1.329     droeschl 2955: 
                   2956: 	my $supnewextform=(<<SNEFORM);
                   2957: 	<form action="/adm/coursedocs" method="post" name="supnewext">
1.371     tempelho 2958: 	<input type="hidden" name="active" value="ff" />
1.329     droeschl 2959: 	<input type="hidden" name="folderpath" value="$path" />
                   2960: 	<input type="hidden" name="importdetail" value="" />
1.423     onken    2961: 	<a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}
1.329     droeschl 2962: 	</form>
                   2963: SNEFORM
                   2964: 
                   2965: 	my $supnewsylform=(<<SNSFORM);
                   2966: 	<form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371     tempelho 2967: 	<input type="hidden" name="active" value="ff" />
1.329     droeschl 2968: 	<input type="hidden" name="folderpath" value="$path" />
                   2969: 	<input type="hidden" name="importdetail" 
                   2970: 	value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423     onken    2971: 	<a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329     droeschl 2972: 	$help{'Syllabus'}
                   2973: 	</form>
                   2974: SNSFORM
                   2975: 
                   2976: 	my $supnewaboutmeform=(<<SNAMFORM);
1.383     tempelho 2977: 	<form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371     tempelho 2978: 	<input type="hidden" name="active" value="ff" />
1.329     droeschl 2979: 	<input type="hidden" name="folderpath" value="$path" />
                   2980: 	<input type="hidden" name="importdetail" 
                   2981: 	value="$plainname=/adm/$udom/$uname/aboutme" />
1.423     onken    2982: 	<a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347     weissno  2983: 	$help{'My Personal Information Page'}
1.329     droeschl 2984: 	</form>
                   2985: SNAMFORM
                   2986: 
1.333     muellerd 2987: 
1.383     tempelho 2988: my @specialdocs = (
1.417     droeschl 2989: 		{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
                   2990:             =>$supnewsylform},
                   2991: 		{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
                   2992:             =>$supnewaboutmeform},
1.383     tempelho 2993: 		);
1.417     droeschl 2994: my @supimportdoc = (
                   2995: 		{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
                   2996:             =>$supnewextform},
                   2997:         );
1.459     raeburn  2998: $supupdocform =  &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;
1.333     muellerd 2999: my %suporderhash = (
1.390     tempelho 3000: 		'00' => ['Supnewfolder', $supnewfolderform],
1.417     droeschl 3001:                 'ee' => ['Import Documents',$supupdocform],
1.443     www      3002:                 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
1.333     muellerd 3003:                 );
1.443     www      3004:         if ($supplementalflag) {
1.458     raeburn  3005:            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472     raeburn  3006:                                $supplementalflag,\%suporderhash,$iconpath);
1.443     www      3007:            if ($error) {
                   3008:               $r->print('<p><span class="LC_error">'.$error.'</span></p>');
                   3009:            }
1.393     raeburn  3010:         }
1.443     www      3011:     } elsif ($supplementalflag) {
1.458     raeburn  3012:         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472     raeburn  3013:                             $supplementalflag,'',$iconpath);
1.393     raeburn  3014:         if ($error) {
                   3015:             $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383     tempelho 3016:         }
1.393     raeburn  3017:     }
1.389     tempelho 3018: 
1.484     raeburn  3019:     $r->print(&endContentScreen());
1.383     tempelho 3020: 
1.329     droeschl 3021:     if ($allowed) {
                   3022: 	$r->print('
                   3023: <form method="post" name="extimport" action="/adm/coursedocs">
                   3024:   <input type="hidden" name="title" />
                   3025:   <input type="hidden" name="url" />
                   3026:   <input type="hidden" name="useform" />
                   3027:   <input type="hidden" name="residx" />
                   3028: </form>');
                   3029:     }
1.484     raeburn  3030:   } elsif ($showdoc) {
1.329     droeschl 3031: # -------------------------------------------------------- This is showdoc mode
1.484     raeburn  3032:       $r->print("<h1>".&mt('Uploaded Document').' - '.
1.329     droeschl 3033: 		&Apache::lonnet::gettitle($r->uri).'</h1><p>'.
                   3034: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484     raeburn  3035:                 &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329     droeschl 3036:   }
                   3037:  }
                   3038:  $r->print(&Apache::loncommon::end_page());
                   3039:  return OK;
1.364     bisitz   3040: }
1.329     droeschl 3041: 
1.440     raeburn  3042: sub embedded_form_elems {
                   3043:     my ($phase,$primaryurl,$newidx) = @_;
                   3044:     my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
                   3045:     return <<STATE;
                   3046:     <input type="hidden" name="folderpath" value="$folderpath" />
                   3047:     <input type="hidden" name="cmd" value="upload_embedded" />
                   3048:     <input type="hidden" name="newidx" value="$newidx" />
                   3049:     <input type="hidden" name="phase" value="$phase" />
                   3050:     <input type="hidden" name="primaryurl" value="$primaryurl" />
                   3051: STATE
                   3052: }
                   3053: 
                   3054: sub embedded_destination {
                   3055:     my $folder=$env{'form.folder'};
                   3056:     my $destination = 'docs/';
                   3057:     if ($folder =~ /^supplemental/) {
                   3058:         $destination = 'supplemental/';
                   3059:     }
                   3060:     if (($folder eq 'default') || ($folder eq 'supplemental')) {
                   3061:         $destination .= 'default/';
                   3062:     } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
                   3063:         $destination .=  $2.'/';
                   3064:     }
                   3065:     $destination .= $env{'form.newidx'};
                   3066:     my $dir_root = '/userfiles';
                   3067:     return ($destination,$dir_root);
                   3068: }
                   3069: 
                   3070: sub return_to_editor {
                   3071:     my $actionurl = '/adm/coursedocs';
                   3072:     return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n". 
                   3073:            '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
                   3074:            '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
                   3075:            '</a></p>';
                   3076: }
                   3077: 
1.476     raeburn  3078: sub decompression_info {
                   3079:     my ($destination,$dir_root) = &embedded_destination();
                   3080:     my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
                   3081:     my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
                   3082:     my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
                   3083:     my $container='sequence';
1.480     raeburn  3084:     my ($pathitem,$hiddenelem);
                   3085:     my @hiddens = ('newidx','comment','position');
1.476     raeburn  3086:     if ($env{'form.pagepath'}) {
                   3087:         $container='page';
1.480     raeburn  3088:         $pathitem = 'pagepath';
1.476     raeburn  3089:     } else {
1.480     raeburn  3090:         $pathitem = 'folderpath';
1.476     raeburn  3091:     }
1.480     raeburn  3092:     unshift(@hiddens,$pathitem);
                   3093:     foreach my $item (@hiddens) {
                   3094:         if ($env{'form.'.$item}) {
                   3095:             $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
                   3096:                            $env{'form.'.$item}.'" />'."\n";
                   3097:         }
1.477     raeburn  3098:     }
1.476     raeburn  3099:     return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
                   3100:             $hiddenelem);
                   3101: }
                   3102: 
                   3103: sub decompression_phase_one {
                   3104:     my ($dir,$file,$warning,$error,$output);
                   3105:     my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
                   3106:         &decompression_info();
                   3107:     if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/docs/\E(?:default|supplemental|\d+).*/([^/]+)$}) {
                   3108:         $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
                   3109:     } else {
                   3110:         my $file = $1;
1.481     raeburn  3111:         $output = 
                   3112:             &Apache::loncommon::process_decompression($docudom,$docuname,$file,
                   3113:                                                       $destination,$dir_root,
                   3114:                                                       $hiddenelem);
                   3115:         if ($env{'form.autoextract_camtasia'}) {
                   3116:             $output .= &remove_archive($docudom,$docuname,$container);
                   3117:         }
1.476     raeburn  3118:     }
                   3119:     if ($error) {
                   3120:         $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
                   3121:                    $error.'</p>'."\n";
                   3122:     }
                   3123:     if ($warning) {
                   3124:         $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
                   3125:     }
                   3126:     return $output;
                   3127: }
                   3128: 
                   3129: sub decompression_phase_two {
                   3130:     my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
                   3131:         &decompression_info();
1.481     raeburn  3132:     my $output;
1.480     raeburn  3133:     if ($env{'form.archivedelete'}) {
1.481     raeburn  3134:         $output = &remove_archive($docudom,$docuname,$container);
1.480     raeburn  3135:     }
                   3136:     $output .= 
1.481     raeburn  3137:         &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476     raeburn  3138:                                                     $destination,$dir_root,$hiddenelem);
                   3139:     return $output;
                   3140: }
                   3141: 
1.480     raeburn  3142: sub remove_archive {
                   3143:     my ($docudom,$docuname,$container) = @_;
                   3144:     my $map = $env{'form.folder'}.'.'.$container;
1.481     raeburn  3145:     my ($output,$delwarning,$delresult,$url);
1.480     raeburn  3146:     my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
                   3147:     if ($fatal) {
                   3148:         if ($container eq 'page') {
                   3149:             $delwarning = &mt('An error occurred retrieving the contents of the current page.');
                   3150:         } else {
                   3151:             $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
                   3152:         }
                   3153:         $delwarning .= &mt('As a result the archive file has not been removed.');
                   3154:     } else {
                   3155:         my $currcmd = $env{'form.cmd'};
                   3156:         my $position = $env{'form.position'};
                   3157:         if ($position > 0) { 
                   3158:             $env{'form.cmd'} = 'del_'.$position;
                   3159:             my ($title,$url,@rrest) = 
                   3160:                 split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
                   3161:             if (&handle_edit_cmd($docuname,$docudom)) {
                   3162:                 ($errtext,$fatal) = &storemap($docuname,$docudom,$map);
                   3163:                 if ($fatal) {
                   3164:                     if ($container eq 'page') {
                   3165:                         $delwarning = &mt('An error occurred updating the contents of the current page.');
                   3166:                     } else {
                   3167:                         $delwarning = &mt('An error occurred updating the contents of the current folder.');
                   3168:                     }
                   3169:                 } else {
1.481     raeburn  3170:                     $delresult = &mt('Archive file removed.');
1.480     raeburn  3171:                 }
                   3172:             }
                   3173:         }
                   3174:         $env{'form.cmd'} = $currcmd;
                   3175:     }
                   3176:     if ($delwarning) {
                   3177:         $output = '<p class="LC_warning">'.
                   3178:                    $delwarning.
                   3179:                    '</p>';
                   3180:     }
                   3181:     if ($delresult) {
                   3182:         $output .= '<p class="LC_info">'.
                   3183:                    $delresult.
                   3184:                    '</p>';
                   3185:     }
1.481     raeburn  3186:     return $output;
1.480     raeburn  3187: }
                   3188: 
1.484     raeburn  3189: sub generate_admin_menu {
                   3190:     my ($crstype) = @_;
                   3191:     my $lc_crstype = lc($crstype);
                   3192:     my ($home,$other,%outhash)=&authorhosts();
                   3193:     my %lt=&Apache::lonlocal::texthash (
                   3194:                                          'vc'   => 'Verify Content',
                   3195:                                          'cv'   => 'Check/Set Resource Versions',
                   3196:                                          'ls'   => 'List Resource Identifiers',
                   3197:                                          'imse' => 'Export contents to IMS Archive',
                   3198:                                          'dcd'  => "Dump $crstype Content to Authoring Space",
                   3199:                                        );
                   3200:     my ($candump,$dumpurl);
                   3201:     if ($home + $other > 0) {
                   3202:         $candump = 'F';
                   3203:         if ($home) {
                   3204:             $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
                   3205:         } else {
                   3206:             my @hosts;
                   3207:             foreach my $aurole (keys(%outhash)) {
                   3208:                 unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
                   3209:                     push(@hosts,$outhash{$aurole});
                   3210:                 }  
                   3211:             }
                   3212:             if (@hosts == 1) {
                   3213:                 my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
                   3214:                                '&amp;role='.
                   3215:                                &HTML::Entities::encode($env{'request.role'},'"<>&').'&amp;origurl='.
                   3216:                                &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
                   3217:                 $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
                   3218:             } else {
                   3219:                 $dumpurl = "javascript:choose_switchserver_window()";
                   3220:             }
                   3221:         }
                   3222:     }
                   3223:     my @menu=
                   3224:         ({  categorytitle=>'Administration',
                   3225:             items =>[
                   3226:                 {   linktext   => $lt{'vc'},
                   3227:                     url        => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
                   3228:                     permission => 'F',
                   3229:                     help       => 'Verify_Content',
                   3230:                     icon       => 'verify.png',
                   3231:                     linktitle  => 'Verify contents can be retrieved/rendered',
                   3232:                 },
                   3233:                 {   linktext => $lt{'cv'},
                   3234:                     url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
                   3235:                     permission => 'F',
                   3236:                     help       => 'Check_Resource_Versions',
                   3237:                     icon       => 'resversion.png',
                   3238:                     linktitle  => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
                   3239:                 },
                   3240:                 {   linktext   => $lt{'ls'},
                   3241:                     url        => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
                   3242:                     permission => 'F',
                   3243:                     #help => '',
                   3244:                     icon       => 'symbs.png',
                   3245:                     linktitle  => "List the unique identifier used for each resource instance in your $lc_crstype"
                   3246:                 },
                   3247:                 ]
                   3248:         },
                   3249:         {   categorytitle=>'Export',
                   3250:             items =>[
                   3251:                 {   linktext   => $lt{'imse'},
                   3252:                     url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
                   3253:                     permission => 'F',
                   3254:                     help       => 'Docs_Export_Course_Docs',
                   3255:                     icon       => 'imsexport.png',
                   3256:                     linktitle  => $lt{'imse'},
                   3257:                 },
                   3258:                 {   linktext   => $lt{'dcd'},
                   3259:                     url        => $dumpurl,
                   3260:                     permission => $candump,
                   3261:                     #help => '',
                   3262:                     icon       => 'dump.png',
                   3263:                     linktitle  => $lt{'dcd'},
                   3264:                 },
                   3265:                 ]
                   3266:         });
                   3267:     return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
                   3268:            '<input type="hidden" id="dummy" />'."\n".
                   3269:            &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
                   3270:            '</form>';
1.329     droeschl 3271: }
                   3272: 
                   3273: sub generate_edit_table {
1.484     raeburn  3274:     my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_;
1.406     raeburn  3275:     return unless(ref($orderhash_ref) eq 'HASH');
1.342     ehlerst  3276:     my %orderhash = %{$orderhash_ref};
1.344     bisitz   3277:     my $form;
1.371     tempelho 3278:     my $activetab;
                   3279:     my $active;
                   3280:     if($env{'form.active'} ne ''){
                   3281:         $activetab = $env{'form.active'};
                   3282:     }
1.472     raeburn  3283:     my $backicon = $iconpath.'clickhere.gif';
1.481     raeburn  3284:     my $backtext = &mt('To Overview');
1.458     raeburn  3285:     $form = '<div class="LC_Box" style="margin:0;">'.
1.484     raeburn  3286:              '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
1.472     raeburn  3287:              '<li class="goback">'.
                   3288:              '<a href="javascript:toContents('."'$jumpto'".');">'.
1.473     raeburn  3289:              '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
1.484     raeburn  3290:              '  alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n";
                   3291:     if ($tid == 1) {
                   3292:         $form .= '<li>'.
                   3293:                  '<a href="javascript:groupopen('."'$readfile'".',1);">'.
                   3294:                  &mt('Undo Delete').'</a></li>'."\n";
                   3295:         if ($env{'form.docslog'}) {
                   3296:             $form .= '<li class="active">';
                   3297:         } else {
                   3298:             $form .= '<li>';
                   3299:         }
                   3300:         $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
                   3301:                   &mt('History').'</a></li>'."\n";
                   3302:         if ($env{'form.docslog'}) {
                   3303:             $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
                   3304:                   &mt('Edit').'</a></li>'."\n";
                   3305:         }
                   3306:     }
1.458     raeburn  3307:     foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390     tempelho 3308:         if($name ne '00'){
1.371     tempelho 3309:             if($activetab eq '' || $activetab ne $name){
                   3310:                $active = '';
                   3311:             }elsif($activetab eq $name){
                   3312:                $active = 'class="active"';
                   3313:             }
1.458     raeburn  3314:             $form .= '<li style="float:right" '.$active
1.429     droeschl 3315:                 .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'
1.484     raeburn  3316:                 .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
1.390     tempelho 3317:         } else {
1.484     raeburn  3318: 	    $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390     tempelho 3319: 
                   3320: 	}
1.329     droeschl 3321:     }
1.484     raeburn  3322:     $form .= '</ul>'."\n";
                   3323:     $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458     raeburn  3324: 
                   3325:     if ($to_show ne '') {
1.484     raeburn  3326:         $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n";
1.458     raeburn  3327:     }
1.363     ehlerst  3328:     foreach my $field (keys(%orderhash)){
1.390     tempelho 3329: 	if($field ne '00'){
1.422     onken    3330:             if($activetab eq '' || $activetab ne $field){
1.458     raeburn  3331:                 $active = 'style="display: none;float:left"';
1.422     onken    3332:             }elsif($activetab eq $field){
1.458     raeburn  3333:                 $active = 'style="display:block;float:left"';
1.422     onken    3334:             }
                   3335:             $form .= '<div id="'.$field.$tid.'"'
                   3336:                     .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484     raeburn  3337:                     .'</div>'."\n";
1.363     ehlerst  3338:         }
                   3339:     }
1.484     raeburn  3340:     unless ($env{'form.docslog'}) {
                   3341:         $form .= '</div></div>'."\n";
                   3342:     }
1.329     droeschl 3343:     return $form;
                   3344: }
                   3345: 
                   3346: sub editing_js {
1.472     raeburn  3347:     my ($udom,$uname,$supplementalflag) = @_;
1.329     droeschl 3348:     my $now = time();
                   3349:     my %lt = &Apache::lonlocal::texthash(
                   3350:                                           p_mnf => 'Name of New Folder',
                   3351:                                           t_mnf => 'New Folder',
                   3352:                                           p_mnp => 'Name of New Page',
                   3353:                                           t_mnp => 'New Page',
1.451     www      3354:                                           p_mxu => 'Title for the External Score',
1.349     biermanm 3355:                                           p_msp => 'Name of Simple Course Page',
1.329     droeschl 3356:                                           p_msb => 'Title for the Problem',
                   3357:                                           p_mdb => 'Title for the Drop Box',
1.336     schafran 3358:                                           p_mbb => 'Title for the Discussion Board',
1.348     weissno  3359:                                           p_mab => "Enter user:domain for User's Personal Information Page",
1.352     bisitz   3360:                                           p_mab2 => 'Personal Information Page of ',
1.329     droeschl 3361:                                           p_mab_alrt1 => 'Not a valid user:domain',
                   3362:                                           p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
                   3363:                                           p_chn => 'New Title',
                   3364:                                           p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
                   3365:                                           p_rmr2a => 'Remove[_99]',
                   3366:                                           p_rmr2b => '?[_99]',
                   3367:                                           p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
                   3368:                                           p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
                   3369:                                           p_ctr2a => 'Cut[_98]',
1.478     raeburn  3370:                                           p_ctr2b => '?[_98]',
                   3371:                                           rpck    => 'Enter number to pick (e.g., 3)',
1.329     droeschl 3372:                                         );
                   3373: 
1.433     raeburn  3374:     my $crstype = &Apache::loncommon::course_type();
1.434     raeburn  3375:     my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
                   3376:     my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"');
                   3377:     my $main_container_page;
                   3378:     if ($docs_folderpath eq '') {
                   3379:         if ($docs_pagepath ne '') {
                   3380:             $main_container_page = 1;
                   3381:         }
                   3382:     }
1.433     raeburn  3383:     my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
1.446     www      3384:     my $toplevelsupp = &supplemental_base();
1.433     raeburn  3385: 
1.472     raeburn  3386:     my $backtourl = '/adm/navmaps';
                   3387:     if ($supplementalflag) {
                   3388:         $backtourl = '/adm/supplemental';
                   3389:     }
                   3390: 
1.329     droeschl 3391:     return <<ENDNEWSCRIPT;
                   3392: function makenewfolder(targetform,folderseq) {
                   3393:     var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
                   3394:     if (foldername) {
                   3395:        targetform.importdetail.value=escape(foldername)+"="+folderseq;
                   3396:         targetform.submit();
                   3397:     }
                   3398: }
                   3399: 
                   3400: function makenewpage(targetform,folderseq) {
                   3401:     var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
                   3402:     if (pagename) {
                   3403:         targetform.importdetail.value=escape(pagename)+"="+folderseq;
                   3404:         targetform.submit();
                   3405:     }
                   3406: }
                   3407: 
                   3408: function makenewext(targetname) {
                   3409:     this.document.forms.extimport.useform.value=targetname;
                   3410:     this.document.forms.extimport.title.value='';
                   3411:     this.document.forms.extimport.url.value='';
                   3412:     this.document.forms.extimport.residx.value='';
                   3413:     window.open('/adm/rat/extpickframe.html');
                   3414: }
                   3415: 
                   3416: function edittext(targetname,residx,title,url) {
                   3417:     this.document.forms.extimport.useform.value=targetname;
                   3418:     this.document.forms.extimport.residx.value=residx;
                   3419:     this.document.forms.extimport.url.value=url;
                   3420:     this.document.forms.extimport.title.value=title;
                   3421:     window.open('/adm/rat/extpickframe.html');
                   3422: }
                   3423: 
                   3424: function makeexamupload() {
                   3425:    var title=prompt('$lt{"p_mxu"}');
1.344     bisitz   3426:    if (title) {
1.329     droeschl 3427:     this.document.forms.newexamupload.importdetail.value=
                   3428: 	escape(title)+'=/res/lib/templates/examupload.problem';
                   3429:     this.document.forms.newexamupload.submit();
                   3430:    }
                   3431: }
                   3432: 
                   3433: function makesmppage() {
                   3434:    var title=prompt('$lt{"p_msp"}');
1.344     bisitz   3435:    if (title) {
1.329     droeschl 3436:     this.document.forms.newsmppg.importdetail.value=
                   3437: 	escape(title)+'=/adm/$udom/$uname/$now/smppg';
                   3438:     this.document.forms.newsmppg.submit();
                   3439:    }
                   3440: }
                   3441: 
                   3442: function makesmpproblem() {
                   3443:    var title=prompt('$lt{"p_msb"}');
1.344     bisitz   3444:    if (title) {
1.329     droeschl 3445:     this.document.forms.newsmpproblem.importdetail.value=
                   3446: 	escape(title)+'=/res/lib/templates/simpleproblem.problem';
                   3447:     this.document.forms.newsmpproblem.submit();
                   3448:    }
                   3449: }
                   3450: 
                   3451: function makedropbox() {
                   3452:    var title=prompt('$lt{"p_mdb"}');
1.344     bisitz   3453:    if (title) {
1.329     droeschl 3454:     this.document.forms.newdropbox.importdetail.value=
                   3455:         escape(title)+'=/res/lib/templates/DropBox.problem';
                   3456:     this.document.forms.newdropbox.submit();
                   3457:    }
                   3458: }
                   3459: 
                   3460: function makebulboard() {
                   3461:    var title=prompt('$lt{"p_mbb"}');
                   3462:    if (title) {
                   3463:     this.document.forms.newbul.importdetail.value=
                   3464: 	escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
                   3465:     this.document.forms.newbul.submit();
                   3466:    }
                   3467: }
                   3468: 
                   3469: function makeabout() {
                   3470:    var user=prompt("$lt{'p_mab'}");
                   3471:    if (user) {
                   3472:        var comp=new Array();
                   3473:        comp=user.split(':');
                   3474:        if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
                   3475: 	   if ((comp[0]) && (comp[1])) {
                   3476: 	       this.document.forms.newaboutsomeone.importdetail.value=
                   3477: 		   '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335     ehlerst  3478:        this.document.forms.newaboutsomeone.submit();
                   3479:    } else {
                   3480:        alert("$lt{'p_mab_alrt1'}");
1.329     droeschl 3481:    }
1.335     ehlerst  3482: } else {
                   3483:    alert("$lt{'p_mab_alrt2'}");
                   3484: }
                   3485: }
1.329     droeschl 3486: }
                   3487: 
                   3488: function makeims() {
1.335     ehlerst  3489: var caller = document.forms.ims.folder.value;
                   3490: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
                   3491: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
                   3492: newWindow.location.href = newlocation;
1.329     droeschl 3493: }
                   3494: 
                   3495: function finishpick() {
1.335     ehlerst  3496: var title=this.document.forms.extimport.title.value;
                   3497: var url=this.document.forms.extimport.url.value;
                   3498: var form=this.document.forms.extimport.useform.value;
                   3499: var residx=this.document.forms.extimport.residx.value;
                   3500: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
1.329     droeschl 3501: }
                   3502: 
                   3503: function changename(folderpath,index,oldtitle,container,pagesymb) {
1.335     ehlerst  3504: var title=prompt('$lt{"p_chn"}',oldtitle);
                   3505: if (title) {
                   3506: this.document.forms.renameform.markcopy.value=-1;
                   3507: this.document.forms.renameform.title.value=title;
                   3508: this.document.forms.renameform.cmd.value='rename_'+index;
                   3509: if (container == 'sequence') {
                   3510:     this.document.forms.renameform.folderpath.value=folderpath;
                   3511: }
                   3512: if (container == 'page') {
                   3513:     this.document.forms.renameform.pagepath.value=folderpath;
                   3514:     this.document.forms.renameform.pagesymb.value=pagesymb;
                   3515: }
                   3516: this.document.forms.renameform.submit();
                   3517: }
1.329     droeschl 3518: }
                   3519: 
                   3520: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
1.335     ehlerst  3521: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
                   3522: this.document.forms.renameform.markcopy.value=-1;
                   3523: this.document.forms.renameform.cmd.value='del_'+index;
                   3524: if (container == 'sequence') {
                   3525:     this.document.forms.renameform.folderpath.value=folderpath;
                   3526: }
                   3527: if (container == 'page') {
                   3528:     this.document.forms.renameform.pagepath.value=folderpath;
                   3529:     this.document.forms.renameform.pagesymb.value=pagesymb;
                   3530: }
                   3531: this.document.forms.renameform.submit();
                   3532: }
1.329     droeschl 3533: }
                   3534: 
                   3535: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
1.335     ehlerst  3536: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
                   3537: this.document.forms.renameform.cmd.value='cut_'+index;
                   3538: this.document.forms.renameform.markcopy.value=index;
                   3539: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
                   3540: if (container == 'sequence') {
                   3541:     this.document.forms.renameform.folderpath.value=folderpath;
                   3542: }
                   3543: if (container == 'page') {
                   3544:     this.document.forms.renameform.pagepath.value=folderpath;
                   3545:     this.document.forms.renameform.pagesymb.value=pagesymb;
                   3546: }
                   3547: this.document.forms.renameform.submit();
                   3548: }
1.329     droeschl 3549: }
                   3550: 
                   3551: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
1.335     ehlerst  3552: this.document.forms.renameform.markcopy.value=index;
                   3553: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
                   3554: if (container == 'sequence') {
                   3555: this.document.forms.renameform.folderpath.value=folderpath;
                   3556: }
                   3557: if (container == 'page') {
                   3558: this.document.forms.renameform.pagepath.value=folderpath;
                   3559: this.document.forms.renameform.pagesymb.value=pagesymb;
                   3560: }
                   3561: this.document.forms.renameform.submit();
1.329     droeschl 3562: }
                   3563: 
1.478     raeburn  3564: function updatePick(targetform,index,caller) {
                   3565:     var pickitem = document.getElementById('rpick_'+index);
                   3566:     var picknumitem = document.getElementById('rpicknum_'+index);
                   3567:     if (pickitem.checked) {
                   3568:         var picknum=prompt('$lt{"rpck"}',picknumitem.value);
                   3569:         if (picknum == '' || picknum == null) {
                   3570:             if (caller == 'check') {
                   3571:                 pickitem.checked=false;
                   3572:                 return;
                   3573:             }
                   3574:         } else {
                   3575:             picknum.toString();
                   3576:             var regexdigit=/^\\d+\$/;
                   3577:             if (regexdigit.test(picknum)) {
                   3578:                 picknumitem.value = picknum;
                   3579:                 targetform.changeparms.value='randompick';
                   3580:                 targetform.submit();
                   3581:             } else {
                   3582:                 if (caller == 'check') {
                   3583:                     pickitem.checked=false;
                   3584:                 }
                   3585:                 return;
                   3586:             }
                   3587:         }
                   3588:     } else {
                   3589:         picknumitem.value = 0;
                   3590:         targetform.changeparms.value='randompick';
                   3591:         targetform.submit();
                   3592:     }
                   3593: }
                   3594: 
1.334     muellerd 3595: function unselectInactive(nav) {
1.335     ehlerst  3596: currentNav = document.getElementById(nav);
                   3597: currentLis = currentNav.getElementsByTagName('LI');
                   3598: for (i = 0; i < currentLis.length; i++) {
1.472     raeburn  3599:         if (currentLis[i].className == 'goback') {
                   3600:             currentLis[i].className = 'goback';
                   3601:         } else {
                   3602: 	    if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374     tempelho 3603: 		currentLis[i].className = 'right';
1.472     raeburn  3604: 	    } else {
1.374     tempelho 3605: 		currentLis[i].className = 'i';
1.472     raeburn  3606: 	    }
                   3607:         }
1.335     ehlerst  3608: }
1.332     tempelho 3609: }
                   3610: 
1.334     muellerd 3611: function hideAll(current, nav, data) {
1.335     ehlerst  3612: unselectInactive(nav);
1.374     tempelho 3613: if(current.className == 'right'){
                   3614: 	current.className = 'right active'
                   3615: 	}else{
                   3616: 	current.className = 'active';
                   3617: }
1.335     ehlerst  3618: currentData = document.getElementById(data);
                   3619: currentDivs = currentData.getElementsByTagName('DIV');
                   3620: for (i = 0; i < currentDivs.length; i++) {
                   3621: 	if(currentDivs[i].className == 'LC_ContentBox'){
1.333     muellerd 3622: 		currentDivs[i].style.display = 'none';
1.330     tempelho 3623: 	}
                   3624: }
1.335     ehlerst  3625: }
1.330     tempelho 3626: 
1.374     tempelho 3627: function openTabs(pageId) {
                   3628: 	tabnav = document.getElementById(pageId).getElementsByTagName('UL');	
1.383     tempelho 3629: 	if(tabnav.length > 2 ){
1.389     tempelho 3630: 		currentNav = document.getElementById(tabnav[1].id);
1.374     tempelho 3631: 		currentLis = currentNav.getElementsByTagName('LI');
                   3632: 		for(i = 0; i< currentLis.length; i++){
                   3633: 			if(currentLis[i].className == 'active') {
1.375     tempelho 3634: 				funcString = currentLis[i].onclick.toString();
                   3635: 				tab = funcString.split('"');
1.420     onken    3636:                                 if(tab.length < 2) {
                   3637:                                    tab = funcString.split("'");
                   3638:                                 }
1.375     tempelho 3639: 				currentData = document.getElementById(tab[1]);
                   3640:         			currentData.style.display = 'block';
1.374     tempelho 3641: 			}	
                   3642: 		}
                   3643: 	}
                   3644: }
                   3645: 
1.334     muellerd 3646: function showPage(current, pageId, nav, data) {
                   3647: 	hideAll(current, nav, data);
1.375     tempelho 3648: 	openTabs(pageId);
1.334     muellerd 3649: 	unselectInactive(nav);
1.330     tempelho 3650: 	current.className = 'active';
                   3651: 	currentData = document.getElementById(pageId);
                   3652: 	currentData.style.display = 'block';
1.458     raeburn  3653:         activeTab = pageId;
1.433     raeburn  3654:         if (nav == 'mainnav') {
                   3655:             var storedpath = "$docs_folderpath";
                   3656:             if (storedpath == '') {
                   3657:                 storedpath = "$docs_pagepath";
                   3658:             }
1.434     raeburn  3659:             var storedpage = "$main_container_page";
1.433     raeburn  3660:             var reg = new RegExp("^supplemental");
                   3661:             if (pageId == 'mainCourseDocuments') {
1.434     raeburn  3662:                 if (storedpage == 1) {
                   3663:                     document.simpleedit.folderpath.value = '';
                   3664:                     document.uploaddocument.folderpath.value = '';
                   3665:                 } else {
                   3666:                     if (reg.test(storedpath)) {
                   3667:                         document.simpleedit.folderpath.value = '$toplevelmain';
                   3668:                         document.uploaddocument.folderpath.value = '$toplevelmain';
                   3669:                         document.newext.folderpath.value = '$toplevelmain';
                   3670:                     } else {
                   3671:                         document.simpleedit.folderpath.value = storedpath;
                   3672:                         document.uploaddocument.folderpath.value = storedpath;
                   3673:                         document.newext.folderpath.value = storedpath;
                   3674:                     }
1.433     raeburn  3675:                 }
                   3676:             } else {
1.434     raeburn  3677:                 if (reg.test(storedpath)) {
                   3678:                     document.simpleedit.folderpath.value = storedpath;
                   3679:                     document.supuploaddocument.folderpath.value = storedpath;
                   3680:                     document.supnewext.folderpath.value = storedpath;
                   3681:                 } else {
1.433     raeburn  3682:                     document.simpleedit.folderpath.value = '$toplevelsupp';
                   3683:                     document.supuploaddocument.folderpath.value = '$toplevelsupp';
                   3684:                     document.supnewext.folderpath.value = '$toplevelsupp';
                   3685:                 }
                   3686:             }
                   3687:         }
1.485     raeburn  3688:         resize_scrollbox('contentscroll','1','0');
1.330     tempelho 3689: 	return false;
                   3690: }
1.329     droeschl 3691: 
1.472     raeburn  3692: function toContents(jumpto) {
                   3693:     var newurl = '$backtourl';
                   3694:     if (jumpto != '') {
                   3695:         newurl = newurl+'?postdata='+jumpto;
                   3696: ;
                   3697:     }
                   3698:     location.href=newurl;
                   3699: }
                   3700: 
1.329     droeschl 3701: ENDNEWSCRIPT
                   3702: }
1.457     raeburn  3703: 
1.483     raeburn  3704: sub history_tab_js {
                   3705:     return <<"ENDHIST";
                   3706: function toggleHistoryDisp(choice) {
                   3707:     document.docslogform.docslog.value = choice;
                   3708:     document.docslogform.submit();
                   3709:     return;
                   3710: }
                   3711: 
                   3712: ENDHIST
                   3713: }
                   3714: 
1.484     raeburn  3715: sub inject_data_js {
                   3716:     return <<ENDINJECT;
                   3717: 
                   3718: function injectData(current, hiddenField, name, value) {
                   3719:         currentElement = document.getElementById(hiddenField);
                   3720:         currentElement.name = name;
                   3721:         currentElement.value = value;
                   3722:         current.submit();
                   3723: }
                   3724: 
                   3725: ENDINJECT
                   3726: }
                   3727: 
                   3728: sub dump_switchserver_js {
                   3729:     my @hosts = @_;
                   3730:     my %lt = &Apache::lonlocal::texthash(
                   3731:         dump => 'Dumping to Authoring Space requires switching server.',
                   3732:         swit => 'Switch server?',
                   3733:         duco => 'Dump content to Authoring Space',
                   3734:         yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
                   3735:         chos => 'Choose server',
                   3736:     );
                   3737:     my $role = $env{'request.role'};
                   3738:     my $js = <<"ENDSWJS";
                   3739: <script type="text/javascript">
                   3740: function write_switchserver() {
                   3741:     var server;
                   3742:     if (document.setserver.posshosts.length > 0) {
                   3743:         for (var i=0; i<document.setserver.posshosts.length; i++) {
                   3744:             if (document.setserver.posshosts[i].checked) {
                   3745:                 server = document.setserver.posshosts[i].value;
                   3746:             }
                   3747:        }
                   3748:        opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
                   3749:     }
                   3750:     window.close();
                   3751: }
                   3752: </script>
                   3753: 
                   3754: ENDSWJS
                   3755: 
                   3756:     my $startpage = &Apache::loncommon::start_page('Choose server',$js,
                   3757:                                                    {'only_body' => 1,
                   3758:                                                     'js_ready'  => 1,});
                   3759:     my $endpage = &Apache::loncommon::end_page({'js_ready'  => 1});
                   3760: 
                   3761:     my $hostpicker;
                   3762:     my $count = 0;
                   3763:     foreach my $host (sort(@hosts)) {
                   3764:         my $checked;
                   3765:         if ($count == 0) {
                   3766:             $checked = ' checked="checked"';
                   3767:         }
                   3768:         $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
                   3769:                        $host.'"'.$checked.' />'.$host.'</label>&nbsp;&nbsp;';
                   3770:         $count++;
                   3771:     }
                   3772:     
                   3773:     return <<"ENDSWITCHJS";
                   3774: 
                   3775: function dump_needs_switchserver(url) {
                   3776:     if (url!='' && url!= null) {
                   3777:         if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
                   3778:             go(url);
                   3779:         }
                   3780:     }
                   3781:     return;
                   3782: }
                   3783: 
                   3784: function choose_switchserver_window() {
                   3785:     newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
                   3786:     newWindow.document.open();
                   3787:     newWindow.document.writeln('$startpage');
                   3788:     newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
                   3789:        '<p>$lt{'yone'}<\\/p>\\n'+
                   3790:        '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
                   3791:        '<form name="setserver" method="post" action="" \\/>\\n'+
                   3792:        '$hostpicker\\n'+
                   3793:        '<br \\/><br \\/>\\n'+
                   3794:        '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
                   3795:        'onclick="write_switchserver();" \\/>\\n'+
                   3796:        '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
                   3797:     newWindow.document.writeln('$endpage');
                   3798:     newWindow.document.close();
                   3799:     newWindow.focus();
                   3800: }
                   3801: 
                   3802: ENDSWITCHJS
                   3803: }
                   3804: 
                   3805: sub makedocslogform {
                   3806:     my ($formelems,$docslog) = @_;
                   3807:     return <<"LOGSFORM";
                   3808:  <form action="/adm/coursedocs" method="post" name="docslogform">
                   3809:    <input type="hidden" name="docslog" value="$docslog" />
                   3810:    $formelems
                   3811:  </form>
                   3812: LOGSFORM
                   3813: }
                   3814: 
                   3815: sub makesimpleeditform {
                   3816:     my ($formelems) = @_;
                   3817:     return <<"SIMPFORM";
                   3818:  <form name="simpleedit" method="post" action="/adm/coursedocs">
                   3819:    <input type="hidden" name="importdetail" value="" />
                   3820:    $formelems
                   3821:  </form>
                   3822: SIMPFORM
                   3823: }
                   3824: 
1.329     droeschl 3825: 1;
                   3826: __END__
                   3827: 
                   3828: 
                   3829: =head1 NAME
                   3830: 
                   3831: Apache::londocs.pm
                   3832: 
                   3833: =head1 SYNOPSIS
                   3834: 
                   3835: This is part of the LearningOnline Network with CAPA project
                   3836: described at http://www.lon-capa.org.
                   3837: 
                   3838: =head1 SUBROUTINES
                   3839: 
                   3840: =over
                   3841: 
                   3842: =item %help=()
                   3843: 
                   3844: Available help topics
                   3845: 
                   3846: =item mapread()
                   3847: 
1.344     bisitz   3848: Mapread read maps into LONCAPA::map:: global arrays
1.329     droeschl 3849: @order and @resources, determines status
                   3850: sets @order - pointer to resources in right order
                   3851: sets @resources - array with the resources with correct idx
                   3852: 
                   3853: =item authorhosts()
                   3854: 
                   3855: Return hash with valid author names
                   3856: 
                   3857: =item clean()
                   3858: 
                   3859: =item dumpcourse()
                   3860: 
                   3861:     Actually dump course
                   3862: 
                   3863: =item group_import()
                   3864: 
                   3865:     Imports the given (name, url) resources into the course
                   3866:     coursenum, coursedom, and folder must precede the list
                   3867: 
                   3868: =item breadcrumbs()
                   3869: 
                   3870: =item log_docs()
                   3871: 
                   3872: =item docs_change_log()
                   3873: 
                   3874: =item update_paste_buffer()
                   3875: 
                   3876: =item print_paste_buffer()
                   3877: 
                   3878: =item do_paste_from_buffer()
                   3879: 
                   3880: =item update_parameter()
                   3881: 
                   3882: =item handle_edit_cmd()
                   3883: 
                   3884: =item editor()
                   3885: 
                   3886: =item process_file_upload()
                   3887: 
                   3888: =item process_secondary_uploads()
                   3889: 
                   3890: =item is_supplemental_title()
                   3891: 
                   3892: =item parse_supplemental_title()
                   3893: 
                   3894: =item entryline()
                   3895: 
                   3896: =item tiehash()
                   3897: 
                   3898: =item untiehash()
                   3899: 
                   3900: =item checkonthis()
                   3901: 
                   3902: check on this
                   3903: 
                   3904: =item verifycontent()
                   3905: 
                   3906: Verify Content
                   3907: 
                   3908: =item devalidateversioncache() & checkversions()
                   3909: 
                   3910: Check Versions
                   3911: 
                   3912: =item mark_hash_old()
                   3913: 
                   3914: =item is_hash_old()
                   3915: 
                   3916: =item changewarning()
                   3917: 
                   3918: =item init_breadcrumbs()
                   3919: 
                   3920: Breadcrumbs for special functions
                   3921: 
1.484     raeburn  3922: =item create_list_elements()
                   3923: 
                   3924: =item create_form_ul()
                   3925: 
                   3926: =item startContentScreen() 
                   3927: 
                   3928: =item endContentScreen()
                   3929: 
                   3930: =item supplemental_base()
                   3931: 
                   3932: =item embedded_form_elems()
                   3933: 
                   3934: =item embedded_destination()
                   3935: 
                   3936: =item return_to_editor()
                   3937: 
                   3938: =item decompression_info()
                   3939: 
                   3940: =item decompression_phase_one()
                   3941: 
                   3942: =item decompression_phase_two()
                   3943: 
                   3944: =item remove_archive()
                   3945: 
                   3946: =item generate_admin_menu()
                   3947: 
                   3948: =item generate_edit_table()
                   3949: 
                   3950: =item editing_js()
                   3951: 
                   3952: =item history_tab_js()
                   3953: 
                   3954: =item inject_data_js()
                   3955: 
                   3956: =item dump_switchserver_js()
                   3957: 
1.485     raeburn  3958: =item resize_scrollbox_js()
1.484     raeburn  3959: 
                   3960: =item makedocslogform()
                   3961: 
1.485     raeburn  3962: =item makesimpleeditform()
                   3963: 
1.329     droeschl 3964: =back
                   3965: 
                   3966: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>