--- loncom/interface/londocs.pm 2009/05/21 02:47:48 1.325.2.1 +++ loncom/interface/londocs.pm 2009/02/19 10:51:40 1.347 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.325.2.1 2009/05/21 02:47:48 raeburn Exp $ +# $Id: londocs.pm,v 1.347 2009/02/19 10:51:40 weissno Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,7 +59,6 @@ my $hadchanges; my %help=(); - sub mapread { my ($coursenum,$coursedom,$map)=@_; return @@ -120,11 +119,9 @@ sub dumpbutton { my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - return '
'. - ''. - &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'). - '
'; + &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'); } else { return '
'. &mt('Dump '.$type. @@ -136,7 +133,7 @@ sub dumpbutton { sub clean { my ($title)=@_; $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; - return $title; + return $title; } @@ -178,8 +175,8 @@ sub dumpcourse { my $fail=0; for (my $i=0;$i<$#dirs;$i++) { $makepath.='/'.$dirs[$i]; - unless (-e $makepath) { - unless(mkdir($makepath,0777)) { $fail=1; } + unless (-e $makepath) { + unless(mkdir($makepath,0777)) { $fail=1; } } } $r->print('
'.$item.' => '.$newfilename.': '); @@ -265,10 +262,9 @@ sub dumpcourse { sub exportbutton { my $type = &Apache::loncommon::course_type(); - return '
'. - ''. - &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; + &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); } @@ -401,10 +397,10 @@ sub exportcourse { $display .= ''."\n"; } if ($curRes->is_sequence()) { - $display .= ' '."\n"; + $display .= ' '."\n"; $lastcontainer = $count + $startcount + $boards; } elsif ($curRes->is_page()) { - $display .= ' '."\n"; + $display .= ' '."\n"; $lastcontainer = $count + $startcount + $boards; } my $currelem = $count+$boards+$startcount; @@ -478,7 +474,7 @@ function containerCheck(item) { $scripttag)); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); $r->print($display.''. - '

'. + '

'. '

'); } @@ -763,7 +759,7 @@ sub replicate_content { if ($caller eq 'templateupload') { $url = $symb; $url =~ s#//#/#g; - } else { + } else { ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); } my $content; @@ -803,9 +799,9 @@ sub replicate_content { $$message = 'Could not render '.$url.' server message - '.$rtncode."
\n"; } } elsif ($caller eq 'noedit') { -# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. +# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. $repstatus = 'ok'; - $content = 'Not the owner of this resource'; + $content = 'Not the owner of this resource'; } if ($repstatus eq 'ok') { print $copiedfile $content; @@ -856,8 +852,8 @@ sub extract_media { } } if ($caller eq 'resource') { - my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; - my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); + my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; + my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); $embed_content = &Apache::lonnet::getfile($embed_path); unless ($embed_content eq -1) { $repstatus = 'ok'; @@ -925,7 +921,7 @@ sub group_import { while (@files) { my ($name, $url, $residx) = @{ shift(@files) }; - if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) + if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs') && (!&Apache::lonnet::stat_file($url))) { @@ -948,7 +944,7 @@ sub group_import { } } if ($url) { - if (!$residx + if (!$residx || defined($LONCAPA::map::zombies[$residx])) { $residx = &LONCAPA::map::getresidx($url,$residx); push(@LONCAPA::map::order, $residx); @@ -957,7 +953,7 @@ sub group_import { if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } $url = &LONCAPA::map::qtunescape($url); $name = &LONCAPA::map::qtunescape($name); - $LONCAPA::map::resources[$residx] = + $LONCAPA::map::resources[$residx] = join(':', ($name, $url, $ext, 'normal', 'res')); } } @@ -988,9 +984,9 @@ sub breadcrumbs { my $url='/adm/coursedocs?folderpath='. &escape($folderpath); my $name=&unescape($foldername); -# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername +# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; - if ($1 ne '') { + if ($1 ne '') { $randompick=$1; } else { $randompick=-1; @@ -1129,7 +1125,7 @@ sub docs_change_log { foreach my $key (@changes) { $wholeentry.=':'.$docslog{$id}{'logentry'}{$key}; } - if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } + if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } } my $count = 0; my $time = @@ -1342,7 +1338,7 @@ sub do_paste_from_buffer { $db_name =~ s{_\d*$ }{_$now}x; my $result=&Apache::lonnet::put($db_name,\%contents, $coursedom,$coursenum); - $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; + $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; $title=&mt('Copy of').' '.$title; } } @@ -1356,7 +1352,7 @@ sub do_paste_from_buffer { if ($folder =~ /^supplemental/) { $title = $env{'docs.markedcopy_supplemental'}; } else { - (undef,undef,$title) = + (undef,undef,$title) = &parse_supplemental_title($env{'docs.markedcopy_supplemental'}); } } else { @@ -1380,7 +1376,7 @@ sub uniqueness_check { $url=&LONCAPA::map::qtescape($url); if ($newurl eq $url) { $unique = 0; - last; + last; } } return $unique; @@ -1434,7 +1430,7 @@ sub handle_edit_cmd { &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); splice(@LONCAPA::map::order, $idx, 1); - } elsif ($cmd eq 'up' + } elsif ($cmd eq 'up' && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) { @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1]; @@ -1501,7 +1497,7 @@ sub editor { } if ($env{'form.pastemarked'}) { - my $paste_res = + my $paste_res = &do_paste_from_buffer($coursenum,$coursedom,$folder); if ($paste_res eq 'ok') { ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); @@ -1664,7 +1660,7 @@ sub process_file_upload { '; $phase_status = 'phasetwo'; - $$upload_output .= + $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.
'. &Apache::loncommon::ask_for_embedded_content( '/adm/coursedocs',$state,$allfiles,$codebase); @@ -1767,19 +1763,19 @@ sub entryline { my $incindex=$index+1; my $selectbox=''; if (($folder!~/^supplemental/) && - ($#LONCAPA::map::order>0) && + ($#LONCAPA::map::order>0) && ((split(/\:/, - $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1] - ne '') && + $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1] + ne '') && ((split(/\:/, - $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1] + $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1] ne '')) { $selectbox= ''. ' '.&mt('Random Order').' '; +'; } if ($ispage) { my $pagename=&escape($pagetitle); @@ -2004,9 +2000,9 @@ END 'hd' => 'Hidden', 'ec' => 'URL hidden'); my $enctext= - ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':''); + ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':''); my $hidtext= - ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':''); + ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); $line.=(< $form_start @@ -2098,7 +2094,7 @@ sub checkonthis { if (($errorcount) || ($warningcount)) { if ($errorcount) { - $r->print(''. + $r->print(''. &mt('[quant,_1,error]',$errorcount).''); } if ($warningcount) { @@ -2123,7 +2119,7 @@ sub checkonthis { unless ($url=~/\$/) { $r->print(''.&mt('not found').''); } else { - $r->print(''.&mt('unable to verify variable URL').''); + $r->print(''.&mt('unable to verify variable URL').''); } } else { $r->print(''.&mt('access denied').''); @@ -2257,7 +2253,7 @@ sub checkversions { if ($haschanged) { if (&Apache::lonnet::put('resourceversions',\%newsetversions, $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { + $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { $r->print('

'.&mt('Your Version Settings have been Saved').'

'); } else { $r->print('

'.&mt('An Error Occured while Attempting to Save your Version Settings').'

'); @@ -2409,7 +2405,7 @@ ENDHEADERS $entries_per_col = $num_entries/4 + 1; } my $entries_count = 0; - $r->print(''); + $r->print(''); my $cols_output = 1; for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -2488,7 +2484,7 @@ sub changewarning { $message='Changes will become active for your current session after [_1], or the next time you log in.'; } $r->print("\n\n". -''."\n". +''."\n". '
'. '

'. @@ -2523,6 +2519,7 @@ sub handler { return OK if $r->header_only; my $type = &Apache::loncommon::course_type(); + # --------------------------------------------- Initialize help topics for this foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', 'Adding_External_Resource','Navigate_Content', @@ -2541,7 +2538,7 @@ sub handler { 'Option_Response_Simple'); $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); - $help{'My Personal Info'} = &Apache::loncommon::help_open_topic( + $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic( 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); $help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); @@ -2576,6 +2573,8 @@ sub handler { my $showdoc=0; my $containertag; my $uploadtag; + + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['folderpath','pagepath', 'pagesymb']); @@ -2617,15 +2616,15 @@ sub handler { $showdoc='/'.$1; } unless ($showdoc) { # got called from remote - if (($env{'form.folder'}=~/^(?:group|default)_/) || + if (($env{'form.folder'}=~/^(?:group|default)_/) || ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) { $forcestandard = 1; } $forcesupplement=($env{'form.folder'}=~/^supplemental_/); - if ($allowed) { + if ($allowed) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); - $script=&Apache::lonratedt::editscript('simple'); + $script=&Apache::lonratedt::editscript('simple'); } } else { # got called in sequence from course $allowed=0; @@ -2635,7 +2634,7 @@ sub handler { my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; -# get personal data +# get personal data my $uname=$env{'user.name'}; my $udom=$env{'user.domain'}; my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom)); @@ -2661,7 +2660,7 @@ sub handler { if ($allowed) { if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) { -# Process file upload - phase one - upload and parse primary file. +# Process file upload - phase one - upload and parse primary file. undef($hadchanges); $upload_result = &process_file_upload(\$upload_output,$coursenum, $coursedom,\%allfiles, @@ -2686,8 +2685,8 @@ sub handler { $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx); $origname{$i} = &unescape($env{'form.embedded_orig_'.$i}); if (exists($env{'form.embedded_codebase_'.$i})) { - $javacodebase = &unescape($env{'form.embedded_codebase_'.$i}); - $origname{$i} =~ s#^\Q$javacodebase\E/##; + $javacodebase = &unescape($env{'form.embedded_codebase_'.$i}); + $origname{$i} =~ s#^\Q$javacodebase\E/##; } my @attributes = (); if ($env{'form.embedded_attrib_'.$i} =~ /:/) { @@ -2724,7 +2723,7 @@ sub handler { } if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) { } - $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi; + $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi; } if (exists($codebase{$item})) { $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs @@ -2736,7 +2735,7 @@ sub handler { my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult); } else { - &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); + &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); } } } @@ -2748,9 +2747,8 @@ sub handler { 'uplm' => 'Upload a new main '.lc($type).' document', 'upls' => 'Upload a new supplemental '.lc($type).' document', 'impp' => 'Import a document', - 'pubd' => 'Published documents', + 'pubd' => 'Published Documents', 'copm' => 'All documents out of a published map into this folder', - 'spec' => 'Special documents', 'upld' => 'Upload Document', 'srch' => 'Search', 'impo' => 'Import', @@ -2769,20 +2767,93 @@ sub handler { 'scuf' => 'Score Upload Form', 'bull' => 'Discussion Board', 'mypi' => 'My Personal Information Page', - 'grpo' => 'Group Portfolios', + 'grpo' => 'Group Files', 'rost' => 'Course Roster', 'abou' => 'About User', 'imsf' => 'Import IMS package', 'file' => 'File', 'title' => 'Title', 'comment' => 'Comment', - 'parse' => 'If HTML file, upload embedded images/multimedia files' + 'parse' => 'Upload embedded images/multimedia files if HTML file!', + 'nd' => 'New Document', + 'pm' => 'Published Map', + 'sd' => 'Special Document', + 'mo' => 'More Options', + 'hao' => 'Hide all Options' ); # ----------------------------------------------------------------------------- + my $fileupload=(< + +FIUP + + my $checkbox=(<$lt{'parse'}? + + --> + +CHBO + + my $fileuploadform=(< + $fileupload +
+ $lt{'title'}:
+ + $uploadtag + +
+ + $checkbox + +
+
+ + + $help{'Uploading_From_Harddrive'} + + +FUFORM + + my $simpleeditdefaultform=(< + $lt{'pubd'}
+ $uploadtag + +
+ + + $help{'Importing_LON-CAPA_Resource'} + +
+ +
+

+ $lt{'copm'}
+
+ + $help{'Load_Map'} +

+ +SEDFFORM + + my $extresourcesform=(< + $uploadtag + + + $help{'Adding_External_Resource'} + + +ERFORM + if ($allowed) { &update_paste_buffer($coursenum,$coursedom); - my $dumpbut=&dumpbutton(); - my $exportbut=&exportbutton(); my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', @@ -2802,51 +2873,49 @@ sub handler { $containertag = ''; $uploadtag = ''; } - - $r->print(< - - - - - $containertag - -
- - $uploadtag -
-
-
- -
- $help{'Verify_Content'} -
-
- $help{'Check_Resource_Versions'} -
- $dumpbut - $exportbut -
- -
-
- - -
-
-
-
 
-ENDCOURSEVERIFY - $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', - &mt('Editing the Table of Contents for your '.$type))); + $r->print(< + + + + + $containertag + +
+ + $uploadtag +
+HIDDENFORM + } +# --------------------------------------------------------- Main tab structure + my $activeClass = 1; + $r->print('
'); # --------------------------------------------------------- Standard documents - $r->print(''); - if (($standard) && ($allowed) && (!$forcesupplement)) { - $r->print(' - - - - - - -'."\n". -'
'); -# '

'.&mt('Main Course Documents'). -# ($allowed?' '.$help{'Main_Course_Documents'}:'').'

'); + my $active = 'style="display: none;"'; + if($activeClass == 0){ + $active = 'style="display: block;"'; + } + $r->print('
'); + $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', + &mt('Editing the Table of Contents for your '.$type))); my $folder=$env{'form.folder'}; if ($folder eq '' || $folder eq 'supplemental') { $folder='default'; @@ -2860,16 +2929,6 @@ ENDCOURSEVERIFY } else { #$postexec='self.close();'; } - $hadchanges=0; - my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed, - $upload_output,$type); - if ($error) { - $r->print('

'.$error.'

'); - } - if ($hadchanges) { - &mark_hash_old(); - } - &changewarning($r,$postexec); my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. @@ -2879,230 +2938,230 @@ ENDCOURSEVERIFY $container='page'; } my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; - $r->print(< -
$lt{'uplm'}$lt{'impp'}$lt{'spec'}
-$lt{'file'}:
-
- -
-$lt{'title'}:
- -$uploadtag - -
- - - -
-
- - - $help{'Uploading_From_Harddrive'} - -
-
-
-$lt{'pubd'}
-$uploadtag - -
- - -$help{'Importing_LON-CAPA_Resource'} - -
- -
-

-$lt{'copm'}
-
- -$help{'Load_Map'} -

-
-
-
- -
-ENDFORM - unless ($env{'form.pagepath'}) { - $r->print(< -
-$uploadtag - - - $help{'Adding_External_Resource'} - -
-
- - -
-ENDFORM - } - $r->print('
'); + + + + my $recoverform=(< + + +RFORM + + my $imspform=(< + + + +IMSPFORM + + my $newnavform=(< + $uploadtag + + + + $help{'Navigate_Content'} + + +NNFORM + my $newsmppageform=(< + $uploadtag + + + $help{'Simple Page'} + + +NSPFORM + + my $newsmpproblemform=(< + $uploadtag + + + $help{'Simple Problem'} + + + +NSPROBFORM + + my $newdropboxform=(< + $uploadtag + + + + + +NDBFORM + + my $newexuploadform=(< + $uploadtag + + + + $help{'Score_Upload_Form'} + + +NEXUFORM + + my $newbulform=(< + $uploadtag + + + + $help{'Bulletin Board'} + + +NBFORM + + my $newaboutmeform=(< + $uploadtag + + + + $help{'My Personal Information Page'} + + +NAMFORM + + my $newaboutsomeoneform=(< + $uploadtag + + + + + +NASOFORM + + + my $newrosterform=(< + $uploadtag + + + + $help{'Course Roster'} + + +NROSTFORM + +my $specialdocumentsform; + unless ($env{'form.pagepath'}) { my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); - $r->print(<
- - - -$help{'Adding_Folders'} - -
-
- - - -$help{'Adding_Pages'} - -
-
-$uploadtag - - - - $help{'Syllabus'} - -
-
-$uploadtag - - - -$help{'Navigate_Content'} - -
-
-$uploadtag - - - $help{'Simple Page'} - -
-
-$uploadtag - - -$help{'Simple Problem'} - -
-
-$uploadtag - - - - -
-
-$uploadtag - - - -$help{'Score_Upload_Form'} - -
-
-$uploadtag - - - -$help{'Bulletin Board'} - -
-
-$uploadtag - - - -$help{'My Personal Info'} - -
-
-$uploadtag - - - - -
-
-$uploadtag - - - -$help{'Group Files'} - -
-
-$uploadtag - - - -$help{'Course Roster'} - -
-ENDFORM + + my $newpageform=(< + + + + $help{'Adding_Pages'} + + +NPFORM + + my $newfolderform=(< + + + + $help{'Adding_Folders'} + + +NFFORM + + my $newsylform=(< + $uploadtag + + + + $help{'Syllabus'} + + +NSYLFORM + + my $newgroupfileform=(< + $uploadtag + + + + $help{'Group Files'} + + +NGFFORM + + $specialdocumentsform="
$newfolderform
$newpageform
$newsylform
$newgroupfileform"; + } + $specialdocumentsform.="
$newnavform
$newsmppageform +
$newsmpproblemform
$newdropboxform +
$newexuploadform
$newbulform +
$newaboutmeform
$newaboutsomeoneform +
$newrosterform"; +if($env{'form.pagepath'}) { + $specialdocumentsform="
$newsmpproblemform
$newexuploadform"; +} + +my %orderhash = ( + 'aa' => 'New Document', + 'bb' => 'Published Documents', + 'cc' => 'Special Documents', + 'dd' => 'More Options', + 'zz' => 'Hide all Options', + ); +my %namehash = ( + 'New Document' => $fileuploadform, + 'Published Documents' => $simpleeditdefaultform, + 'Special Documents' => $specialdocumentsform, + 'More Options' => $extresourcesform.'
'.$imspform.'
'.$recoverform, + ); +my $tid='1'; +my $content='content'; +my $navigation='navigation'; +my $varcd = 'Main Course Documents'; +$r->print(&generate_edit_table($tid,$content,$navigation,$varcd,\%namehash,\%orderhash)); + $hadchanges=0; + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); + if ($error) { + $r->print('

'.$error.'

'); + } + if ($hadchanges) { + &mark_hash_old(); } + + &changewarning($r,''); +$r->print(''); if ($env{'form.pagepath'}) { - $r->print(< -$uploadtag - - -$help{'Simple Problem'} - - -
-$uploadtag - - - -$help{'Score_Upload_Form'} - -
-ENDBLOCK } - $r->print('
'); - $r->print(''); } # ----------------------------------------------------- Supplemental documents if (!$forcestandard) { - $r->print(''); -# '

'.&mt('Supplemental Course Documents'). -# ($allowed?' '.$help{'Supplemental'}:'').'

'); + my $active = 'style="display: none;"'; + if($activeClass == 1){ + $active = 'style="display: block;"'; + } + $r->print('
'); my $folder=$env{'form.folder'}; unless ($folder=~/^supplemental/) { $folder='supplemental'; @@ -3112,87 +3171,114 @@ ENDBLOCK $env{'form.folderpath'} = 'supplemental&'. &escape(&mt('Supplemental '.$type.' Documents')); } - my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); - if ($error) { - $r->print('

'.$error.'

'); - } if ($allowed) { my $folderseq= '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. '.sequence'; my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); - $r->print(< -$lt{'upls'} -$lt{'spec'} - - -
- -
-
- - - -

-$lt{'comment'}:
- -
- - - - - $help{'Uploading_From_Harddrive'} - -
- - -
- - - - $help{'Adding_Folders'} - -
-
- - - - $help{'Adding_External_Resource'} - -
-
- - - - -$help{'Syllabus'} - -
-
- - - - -$help{'My Personal Info'} - -
- - -ENDSUPFORM + + my $supupdocform=(< + $fileupload +
+
+ + $checkbox + +

+ $lt{'comment'}:
+ +
+ + + + + $help{'Uploading_From_Harddrive'} + + +SUPDOCFORM + + my $supnewfolderform=(< + + + + $help{'Adding_Folders'} + + +SNFFORM + + + my $supnewextform=(< + + + + $help{'Adding_External_Resource'} + + +SNEFORM + + my $supnewsylform=(< + + + + + $help{'Syllabus'} + + +SNSFORM + + my $supnewaboutmeform=(< + + + + + $help{'My Personal Information Page'} + + +SNAMFORM + + + +my %suporderhash = ( + 'ee' => 'New Document', + 'ff' => 'Special Documents', + 'zz' => 'Hide all Options', + ); + +my %supnamehash = ( + 'New Document' => $supupdocform, + 'Special Documents' => $supnewfolderform.'
'.$supnewextform.'
'.$supnewsylform.'
'.$supnewaboutmeform, + ); + +my $tid='2'; +my $content='content'; +my $navigation='navigation'; +my $varscd = 'Supplemental Course Documents'; + +$r->print(&generate_edit_table($tid,$content,$navigation,$varscd,\%supnamehash,\%suporderhash)); +my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); + if ($error) { + $r->print('

'.$error.'

'); } - } - $r->print(''); +$r->print('
'); + } + } +$r->print(''); +$r->print('
'); if ($allowed) { $r->print('
@@ -3216,6 +3302,72 @@ ENDSUPFORM return OK; } +sub generate_admin_options { + my ($containertag,$uploadtag,$help_ref,$env_ref) = @_; + my %lt=&Apache::lonlocal::texthash( + 'vc' => 'Verify Content', + 'cv' => 'Check/Set Resource Versions', + 'ls' => 'List Symbs', + 'sl' => 'Show Log' + ); + my %help = %{$help_ref}; + my %env = %{$env_ref}; + my $dumpbut=&dumpbutton(); + my $exportbut=&exportbutton(); + return (< +
    +
  • + $help{'Verify_Content'} +
  • +
  • + $help{'Check_Resource_Versions'} +
  • +
  • + $dumpbut +
  • +
  • + $exportbut +
  • +
  • + +
  • +
  • + + +
  • +
+ + +ENDOPTIONFORM + +} + + +sub generate_edit_table { + my ($tid,$content,$navigation,$varcd,$namehash_ref,$orderhash_ref) = @_; + my %namehash = %{$namehash_ref}; + my %orderhash = %{$orderhash_ref}; + my $form; + + $form = '

'.&mt($varcd).'

'; + $form .= '
    '; + foreach my $name (sort(keys(%orderhash))){ + if($name eq 'zz'){ + $form .= '
  • '.&mt($orderhash{$name}).'
  • '; + }else{ + $form .= '
  • '.&mt($orderhash{$name}).'
  • '; + } + } + $form .= '
'; + $form .= '
'; + foreach my $field (keys(%namehash)){ + $form .= ''; + } + $form .= '
'; + + return $form; +} sub editing_js { my ($udom,$uname) = @_; @@ -3226,7 +3378,7 @@ sub editing_js { p_mnp => 'Name of New Page', t_mnp => 'New Page', p_mxu => 'Title for the Uploaded Score', - p_msp => 'Name of the Simple Course Page', + p_msp => 'Title for the Page', p_msb => 'Title for the Problem', p_mdb => 'Title for the Drop Box', p_mbb => 'Title for the Discussion Board', @@ -3279,7 +3431,7 @@ function edittext(targetname,residx,titl function makeexamupload() { var title=prompt('$lt{"p_mxu"}'); - if (title) { + if (title) { this.document.forms.newexamupload.importdetail.value= escape(title)+'=/res/lib/templates/examupload.problem'; this.document.forms.newexamupload.submit(); @@ -3288,7 +3440,7 @@ function makeexamupload() { function makesmppage() { var title=prompt('$lt{"p_msp"}'); - if (title) { + if (title) { this.document.forms.newsmppg.importdetail.value= escape(title)+'=/adm/$udom/$uname/$now/smppg'; this.document.forms.newsmppg.submit(); @@ -3297,7 +3449,7 @@ function makesmppage() { function makesmpproblem() { var title=prompt('$lt{"p_msb"}'); - if (title) { + if (title) { this.document.forms.newsmpproblem.importdetail.value= escape(title)+'=/res/lib/templates/simpleproblem.problem'; this.document.forms.newsmpproblem.submit(); @@ -3306,7 +3458,7 @@ function makesmpproblem() { function makedropbox() { var title=prompt('$lt{"p_mdb"}'); - if (title) { + if (title) { this.document.forms.newdropbox.importdetail.value= escape(title)+'=/res/lib/templates/DropBox.problem'; this.document.forms.newdropbox.submit(); @@ -3331,91 +3483,120 @@ function makeabout() { if ((comp[0]) && (comp[1])) { this.document.forms.newaboutsomeone.importdetail.value= '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; - this.document.forms.newaboutsomeone.submit(); - } else { - alert("$lt{'p_mab_alrt1'}"); - } - } else { - alert("$lt{'p_mab_alrt2'}"); - } + this.document.forms.newaboutsomeone.submit(); + } else { + alert("$lt{'p_mab_alrt1'}"); } +} else { + alert("$lt{'p_mab_alrt2'}"); +} +} } function makeims() { - var caller = document.forms.ims.folder.value; - var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; - newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); - newWindow.location.href = newlocation; +var caller = document.forms.ims.folder.value; +var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; +newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); +newWindow.location.href = newlocation; } function finishpick() { - var title=this.document.forms.extimport.title.value; - var url=this.document.forms.extimport.url.value; - var form=this.document.forms.extimport.useform.value; - var residx=this.document.forms.extimport.residx.value; - eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); +var title=this.document.forms.extimport.title.value; +var url=this.document.forms.extimport.url.value; +var form=this.document.forms.extimport.useform.value; +var residx=this.document.forms.extimport.residx.value; +eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); } function changename(folderpath,index,oldtitle,container,pagesymb) { - var title=prompt('$lt{"p_chn"}',oldtitle); - if (title) { - this.document.forms.renameform.markcopy.value=-1; - this.document.forms.renameform.title.value=title; - this.document.forms.renameform.cmd.value='rename_'+index; - if (container == 'sequence') { - this.document.forms.renameform.folderpath.value=folderpath; - } - if (container == 'page') { - this.document.forms.renameform.pagepath.value=folderpath; - this.document.forms.renameform.pagesymb.value=pagesymb; - } - this.document.forms.renameform.submit(); - } +var title=prompt('$lt{"p_chn"}',oldtitle); +if (title) { +this.document.forms.renameform.markcopy.value=-1; +this.document.forms.renameform.title.value=title; +this.document.forms.renameform.cmd.value='rename_'+index; +if (container == 'sequence') { + this.document.forms.renameform.folderpath.value=folderpath; +} +if (container == 'page') { + this.document.forms.renameform.pagepath.value=folderpath; + this.document.forms.renameform.pagesymb.value=pagesymb; +} +this.document.forms.renameform.submit(); +} } function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) { - if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { - this.document.forms.renameform.markcopy.value=-1; - this.document.forms.renameform.cmd.value='del_'+index; - if (container == 'sequence') { - this.document.forms.renameform.folderpath.value=folderpath; - } - if (container == 'page') { - this.document.forms.renameform.pagepath.value=folderpath; - this.document.forms.renameform.pagesymb.value=pagesymb; - } - this.document.forms.renameform.submit(); - } +if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { +this.document.forms.renameform.markcopy.value=-1; +this.document.forms.renameform.cmd.value='del_'+index; +if (container == 'sequence') { + this.document.forms.renameform.folderpath.value=folderpath; +} +if (container == 'page') { + this.document.forms.renameform.pagepath.value=folderpath; + this.document.forms.renameform.pagesymb.value=pagesymb; +} +this.document.forms.renameform.submit(); +} } function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) { - if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { - this.document.forms.renameform.cmd.value='cut_'+index; - this.document.forms.renameform.markcopy.value=index; - this.document.forms.renameform.copyfolder.value=folder+'.'+container; - if (container == 'sequence') { - this.document.forms.renameform.folderpath.value=folderpath; - } - if (container == 'page') { - this.document.forms.renameform.pagepath.value=folderpath; - this.document.forms.renameform.pagesymb.value=pagesymb; - } - this.document.forms.renameform.submit(); - } +if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { +this.document.forms.renameform.cmd.value='cut_'+index; +this.document.forms.renameform.markcopy.value=index; +this.document.forms.renameform.copyfolder.value=folder+'.'+container; +if (container == 'sequence') { + this.document.forms.renameform.folderpath.value=folderpath; +} +if (container == 'page') { + this.document.forms.renameform.pagepath.value=folderpath; + this.document.forms.renameform.pagesymb.value=pagesymb; +} +this.document.forms.renameform.submit(); +} } function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) { - this.document.forms.renameform.markcopy.value=index; - this.document.forms.renameform.copyfolder.value=folder+'.'+container; - if (container == 'sequence') { - this.document.forms.renameform.folderpath.value=folderpath; - } - if (container == 'page') { - this.document.forms.renameform.pagepath.value=folderpath; - this.document.forms.renameform.pagesymb.value=pagesymb; - } - this.document.forms.renameform.submit(); +this.document.forms.renameform.markcopy.value=index; +this.document.forms.renameform.copyfolder.value=folder+'.'+container; +if (container == 'sequence') { +this.document.forms.renameform.folderpath.value=folderpath; +} +if (container == 'page') { +this.document.forms.renameform.pagepath.value=folderpath; +this.document.forms.renameform.pagesymb.value=pagesymb; +} +this.document.forms.renameform.submit(); +} + +function unselectInactive(nav) { +currentNav = document.getElementById(nav); +currentLis = currentNav.getElementsByTagName('LI'); +for (i = 0; i < currentLis.length; i++) { + currentLis[i].className = 'i'; +} +} + +function hideAll(current, nav, data) { +unselectInactive(nav); +current.className = 'active'; +currentData = document.getElementById(data); +currentDivs = currentData.getElementsByTagName('DIV'); +for (i = 0; i < currentDivs.length; i++) { + if(currentDivs[i].className == 'LC_ContentBox'){ + currentDivs[i].style.display = 'none'; + } +} +} + +function showPage(current, pageId, nav, data) { + hideAll(current, nav, data); + unselectInactive(nav); + current.className = 'active'; + currentData = document.getElementById(pageId); + currentData.style.display = 'block'; + return false; } ENDNEWSCRIPT @@ -3443,7 +3624,7 @@ Available help topics =item mapread() -Mapread read maps into LONCAPA::map:: global arrays +Mapread read maps into LONCAPA::map:: global arrays @order and @resources, determines status sets @order - pointer to resources in right order sets @resources - array with the resources with correct idx