--- loncom/interface/londocs.pm 2010/01/22 00:49:08 1.325.2.3 +++ loncom/interface/londocs.pm 2009/01/30 10:02:46 1.331 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.325.2.3 2010/01/22 00:49:08 raeburn Exp $ +# $Id: londocs.pm,v 1.331 2009/01/30 10:02:46 muellerd 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. @@ -145,7 +142,7 @@ sub dumpcourse { my ($r) = @_; my $type = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space'). - '
'); + ''); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space')); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { return ''; } @@ -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'); } @@ -281,22 +277,12 @@ sub exportcourse { my $numdisc = keys(%discussiontime); my $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { - $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'). - '

'.&mt('IMS Export Failed').'

'. - '
'); - if ($crstype eq 'Community') { - $r->print(&mt('Unable to retrieve information about community contents')); - } else { - $r->print(&mt('Unable to retrieve information about course contents')); - } - $r->print('
'); - if ($crstype eq 'Community') { - $r->print(&mt('Return to Community Editor')); - } else { - $r->print(&mt('Return to Course Editor')); - } - $r->print(''); - &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); + $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'). + '

IMS Export Failed

'. + '
'. + &mt('Unable to retrieve information about course contents'). + '
'.&mt('Return to Course Editor').''); + &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); return; } my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); @@ -335,18 +321,12 @@ sub exportcourse { open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); close(OUTPUT); chdir $cwd; - $outcome .= '

' - .&mt('[_1]Your IMS package[_2] is ready for download.' - ,'','') - .'

'; + $outcome .= &mt('Download the zip file from IMS '.lc($type).' archive
',$imszipfile,); if ($copyresult) { - $outcome .= '

' - .&mt('The following errors occurred during export - [_1]' - ,$copyresult) - .'

'; + $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult); } } else { - $outcome = '
'.&mt('Unfortunately you will not be able to retrieve an IMS archive of your course at this time, because there was a problem creating a manifest file.').'
'; + $outcome = '
'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'
'; } } $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package')); @@ -354,26 +334,22 @@ sub exportcourse { $r->print($outcome); $r->print(&Apache::loncommon::end_page()); } else { - my $display=''."\n". - '

'. - &mt('Choose which items you wish to export from your '.$crstype.'.'). - '

'. - '
'. - ''.&mt('Content items').''. - '
'); + $display .= ''. + ''. + ''. + ''. + '
 Content items'. + ''. - '  
'; - if ($numdisc > 0) { - $display .= '
'. - ''.&mt('Discussion posts').''. - ''. - '  '. - '
'; - } - $display .= ''; + '  
  
 Discussion posts'. + ''. + '  
'; my $curRes; my $depth = 0; my $count = 0; @@ -382,13 +358,13 @@ sub exportcourse { my %parent = (); my %children = (); my $lastcontainer = $startcount; - $display .= &Apache::loncommon::start_data_table() - .&Apache::loncommon::start_data_table_header_row() - .''.&mt('Export content item?').''; + my @bgcolors = ('#F6F6F6','#FFFFFF'); + $display .= ''. + ''; + $display.='Export discussion posts?'."\n"; } - $display .= &Apache::loncommon::end_data_table_header_row(); + $display.=' '; while ($curRes = $it->next()) { if (ref($curRes)) { $count ++; @@ -409,43 +385,38 @@ sub exportcourse { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } } - my $currelem = $count+$boards+$startcount; - $display .= &Apache::loncommon::start_data_table_row() - .''."\n"; - - # Existing discussion posts? - + $display .= ' '.$curRes->title().''; if ($discussiontime{$ressymb} > 0) { $boards ++; - $display .= ''."\n"; + $currelem = $count+$boards+$startcount; + $display .= ''."\n"; } else { - $display .= ''."\n"; + $display .= ''."\n"; } - $display .= &Apache::loncommon::end_data_table_row(); } } - $display .= &Apache::loncommon::end_data_table(); my $scripttag = qq| - |; $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package', $scripttag)); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); - $r->print($display. - '

'. + $r->print($display.'

Export content item?
 '."\n"; if ($numdisc > 0) { - $display .= ''.&mt('Export discussion posts?').'
'."\n" - .''."\n". + 'is_sequence()) || ($curRes->is_page())) { - $lastcontainer = $currelem; - $display .= 'onclick="javascript:propagateCheck('."'$currelem'".')"'; + my $checkitem = $count + $boards + $startcount; + $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"'; } $display .= ' />'."\n"; for (my $i=0; $i<$depth; $i++) { - $display .= ('' x2)."\n"; + $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; $children{$parent{$depth}} .= $currelem.':'; - $display .= ' '.$curRes->title().'' - .'' - .'    
'. + '

'. '

'); } @@ -533,7 +503,7 @@ sub create_ims_store { my $manifestfilename = $$tempexport.$manifest; if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) { $$manifestok=1; - print $ims_manifest + print $ims_manifest ''."\n". ' $title}); ($title) = &parse_supplemental_title($title); } elsif ($env{'docs.markedcopy_supplemental'}) { - &Apache::lonnet::delenv('docs.markedcopy_supplemental'); + &Apache::lonnet::delenv('docs\\.markedcopy_supplemental'); } $url=~s{http(:|:)//https(:|:)//}{https$2//}; @@ -1357,7 +1327,7 @@ sub do_paste_from_buffer { } # published maps can only exists once, so remove it from paste buffer when done if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) { - &Apache::lonnet::delenv('docs.markedcopy'); + &Apache::lonnet::delenv('docs\\.markedcopy'); } if ($url=~ m{/smppg$}) { my $db_name = &Apache::lonsimplepage::get_db_name($url); @@ -1805,7 +1775,7 @@ sub entryline { ' '.&mt('Random Order').' '; +'; } if ($ispage) { my $pagename=&escape($pagetitle); @@ -2030,18 +1999,18 @@ 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 - + $form_end $form_start - + $form_end $form_start $rand_order_text $form_end @@ -2124,7 +2093,7 @@ sub checkonthis { if (($errorcount) || ($warningcount)) { if ($errorcount) { - $r->print(''.&mt('bomb').''. + $r->print(''. &mt('[quant,_1,error]',$errorcount).''); } if ($warningcount) { @@ -2149,7 +2118,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').''); @@ -2514,19 +2483,14 @@ 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". '
'. '

'. +'" />

'. &mt($message,' '). -$help{'Caching'}.'

'."\n\n"); - + &mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />'). +$help{'Caching'}.'

'."\n\n"); } @@ -2554,6 +2518,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', @@ -2607,6 +2572,8 @@ sub handler { my $showdoc=0; my $containertag; my $uploadtag; + + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['folderpath','pagepath', 'pagesymb']); @@ -2679,11 +2646,7 @@ sub handler { $script .= &editing_js($udom,$uname); } # -------------------------------------------------------------------- Body tag - $script = ''."\n"; + $script = ''; my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}]; $r->print(&Apache::loncommon::start_page("$type Documents", $script, {'force_register' => $showdoc, @@ -2783,9 +2746,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', @@ -2798,26 +2760,99 @@ sub handler { 'extr' => 'External Resource', 'syll' => 'Syllabus', 'navc' => 'Navigate Contents', - 'sipa' => 'Simple Course Page', + 'sipa' => 'Simple Page', 'sipr' => 'Simple Problem', 'drbx' => 'Drop Box', 'scuf' => 'Score Upload Form', - 'bull' => 'Discussion Board', - 'mypi' => 'My Personal Information Page', - 'grpo' => 'Group Portfolios', + 'bull' => 'Bulletin Board', + 'mypi' => 'My Personal Info', + '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', @@ -2837,41 +2872,8 @@ sub handler { $containertag = ''; $uploadtag = ''; } - - $r->print(< - - - - - $containertag - -
- - $uploadtag -
-
-
- -
- $help{'Verify_Content'} -
-
- $help{'Check_Resource_Versions'} -
- $dumpbut - $exportbut -
- -
-
- - -
-
-
-
 
-ENDCOURSEVERIFY + ##############alter hashaufruf + $r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env)); $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', &mt('Editing the Table of Contents for your '.$type))); } @@ -2891,12 +2893,7 @@ ENDCOURSEVERIFY } my $postexec=''; if ($folder eq 'default') { - $r->print(''."\n" - ); + $r->print(''); } else { #$postexec='self.close();'; } @@ -2919,223 +2916,267 @@ ENDCOURSEVERIFY $container='page'; } my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; + + + + 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 Info'} + + +NAMFORM + + my $newaboutsomeoneform=(< + $uploadtag + + + + + +NASOFORM + + + my $newrosterform=(< + $uploadtag + + + + $help{'Course Roster'} + + +NROSTFORM + $r->print(< - + -$lt{'file'}:
-
- -
-$lt{'title'}:
- -$uploadtag - -
- - - -
-
- - - $help{'Uploading_From_Harddrive'} - -
+$fileuploadform -
-$lt{'pubd'}
-$uploadtag - -
- - -$help{'Importing_LON-CAPA_Resource'} - -
- -
-

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

-
+$simpleeditdefaultform
-
- -
+$recoverform ENDFORM unless ($env{'form.pagepath'}) { $r->print(< -
-$uploadtag - - - $help{'Adding_External_Resource'} - -
-
- - -
+$extresourcesform +
+$imspform ENDFORM } $r->print(''); 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'} - -
+ + + + 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 + + + my $specialdocumentsform=(< +$newfolderform +
+$newpageform +
+$newsylform +
+$newnavform +
+$newsmppageform +
+$newsmpproblemform +
+$newdropboxform +
+$newexuploadform +
+$newbulform +
+$newaboutmeform +
+$newaboutsomeoneform +
+$newgroupfileform +
+$newrosterform ENDFORM - } + +$r->print($specialdocumentsform); + +my %orderhash = ( + 'aa_eins' => 'New Document', + 'bb_zwei' => 'Published Documents', + 'cc_drei' => 'Special Documents', + 'dd_vier' => 'More Options', + 'zz_hide' => 'Hide all Option', + ); +my %namehash = ( + 'New Document' => $fileuploadform, + 'Published Documents' => $simpleeditdefaultform, + 'Special Documents' => $specialdocumentsform, + 'More Options' => $extresourcesform.'
'.$imspform.'
'.$recoverform, + 'drei' => 'dr', + ); +my $varcd = 'Course Documents'; +$r->print(&generate_edit_table($varcd,\%namehash,\%orderhash)); + + } if ($env{'form.pagepath'}) { $r->print(< -$uploadtag - - -$help{'Simple Problem'} - - -
-$uploadtag - - - -$help{'Score_Upload_Form'} - -
+$newsmpproblemform +
+$newexuploadform ENDBLOCK } $r->print(''."\n". ''); +#$r->print(&generate_edit_table(\%namehash,\%orderhash)); $r->print(''); } # ----------------------------------------------------- Supplemental documents @@ -3162,71 +3203,96 @@ ENDBLOCK '.sequence'; my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); + + 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 Info'} + + +SNAMFORM + $r->print(< -$lt{'upls'} -$lt{'spec'} - +
    +
  • $lt{'nd'}
  • +
  • $lt{'sd'}
  • +
  • $lt{'hao'}
  • +
+ + -
-
- +$supupdocform +
+$supnewfolderform
+$supnewextform
- - - -

-$lt{'comment'}:
- +$supnewsylform
- - - - - $help{'Uploading_From_Harddrive'} - - -
-
- - - - $help{'Adding_Folders'} - -
-
- - - - $help{'Adding_External_Resource'} - -
-
- - - - -$help{'Syllabus'} - -
-
- - - - -$help{'My Personal Info'} - -
+$supnewaboutmeform
ENDSUPFORM @@ -3242,6 +3308,7 @@ ENDSUPFORM '); } + } else { unless ($upload_result eq 'phasetwo') { # -------------------------------------------------------- This is showdoc mode @@ -3256,6 +3323,82 @@ ENDSUPFORM return OK; } +sub generate_admin_options { + my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_; + my %lt = %{$lt_ref}; + my %help = %{$help_ref}; + my %env = %{$env_ref}; + my $dumpbut=&dumpbutton(); + my $exportbut=&exportbutton(); + return (< + + + + + $containertag + +
+ + $uploadtag +
+
+
    +
  • + $help{'Verify_Content'} +
  • +
  • + $help{'Check_Resource_Versions'} +
  • +
  • + $dumpbut +
  • +
  • + $exportbut +
  • +
  • + +
  • +
  • + + +
  • +
+
+
 
+ENDOPTIONFORM + +} + + +sub generate_edit_table { + my ($varcd,$namehash_ref,$orderhash_ref) = @_; + #my %optionhash = %{$optionhash_ref}; #id verlinkt mit inhalt + #my %tablehash = %{$tablehash_ref}; + my %namehash = %{$namehash_ref}; #name verlinkt mit id + my %orderhash = %{$orderhash_ref}; #name mit kürzel verlinkt mit name + #my %tablehash = %{$tablehash_ref}; + my $form; + + #foreach my $id (keys(%tablehash)){ + $form = '

'.&mt('Upload '.$varcd).'

'; + + $form .= '
    '; + foreach my $name (sort(keys(%orderhash))){ + if($name eq 'zz_hide'){ + $form .= '
  • '.&mt($orderhash{$name}).'
  • '; + }else{ + $form .= '
  • '.&mt($orderhash{$name}).'
  • '; + } + } + $form .= '
    '; + foreach my $field (keys(%namehash)){ + $form .= ''; + } + $form .= '
'; +#} + return $form; +} sub editing_js { my ($udom,$uname) = @_; @@ -3266,10 +3409,10 @@ 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', + p_mbb => 'Title for the Bulletin Board', p_mab => "Enter user:domain for User's 'About Me' Page", p_mab2 => "About [_99]", p_mab_alrt1 => 'Not a valid user:domain', @@ -3458,6 +3601,22 @@ function markcopy(folderpath,index,oldti this.document.forms.renameform.submit(); } +function hideAll() { + currentData = document.getElementById('content'); + currentDivs = currentData.getElementsByTagName('div'); + for (i = 0; i < currentDivs.length; i++) { + currentDivs[i].style.display = 'none'; + } +} + +function showPage(current, pageId) { + hideAll(); + current.className = 'active'; + currentData = document.getElementById(pageId); + currentData.style.display = 'block'; + return false; +} + ENDNEWSCRIPT } 1;