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

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

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