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

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

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