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

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

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