--- loncom/interface/londocs.pm 2009/05/04 16:45:57 1.365 +++ loncom/interface/londocs.pm 2009/10/16 19:00:44 1.393 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.365 2009/05/04 16:45:57 bisitz Exp $ +# $Id: londocs.pm,v 1.393 2009/10/16 19:00:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::Constants qw(:common :http); use Apache::imsexport; use Apache::lonnet; use Apache::loncommon; +use Apache::lonhtmlcommon; use LONCAPA::map(); use Apache::lonratedt(); use Apache::lonxml; @@ -119,8 +120,8 @@ sub dumpbutton { my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - return ''. + my $link = "".&mt('Dump '.$type.' DOCS to Construction Space').""; + return $link.' '. &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').'
'; } else { return '
'. @@ -142,7 +143,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 ''; } @@ -262,8 +263,7 @@ sub dumpcourse { sub exportbutton { my $type = &Apache::loncommon::course_type(); - return ''. + return "".&mt('IMS Export')."". &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; } @@ -277,8 +277,8 @@ sub exportcourse { my $numdisc = keys(%discussiontime); my $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'). - '

IMS Export Failed

'. + $r->print(&Apache::loncommon::start_page('Export '.$type.' to IMS Package'). + '

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

'. '
'. &mt('Unable to retrieve information about course contents'). '
'.&mt('Return to Course Editor').''); @@ -298,7 +298,17 @@ sub exportcourse { my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); if (@exportitems == 0 && @discussions == 0) { - $outcome = '
As you did not select any content items or discussions for export, an IMS package has not been created. Please go back to select either content items or discussions for export'; + $outcome = + '

' + .&mt('As you did not select any content items or discussions' + .' for export, an IMS package has not been created.') + .'

' + .'

' + .&mt('Please [_1]go back[_2] to select either content items' + .' or discussions for export.' + ,'' + ,'') + .'

'; } else { my $now = time; my %symbs; @@ -321,35 +331,51 @@ sub exportcourse { open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); close(OUTPUT); chdir $cwd; - $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) + .'

'; } + $outcome .= '

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

'; } else { - $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.').'
'; + $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.') + .'

' + .'

' + .&mt('Go Back') + .'

'; } } - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); + $r->print(&Apache::loncommon::start_page('Export '.$type.' to IMS Package')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); $r->print($outcome); $r->print(&Apache::loncommon::end_page()); } else { my $display; - $display = ''."\n"; - $display .= &mt('Choose which items you wish to export from your '.$type.'.

'); - $display .= ''. - ''. - ''. - ''. - '
 Content items'. - ''; + $display .= '
'. + ''.&mt('Content items').''. + ''. - '  
  
 Discussion posts'. - '
'. + '
'. + ''.&mt('Discussion posts').''. + ''. - '  
'; + '  '. + '
'; my $curRes; my $depth = 0; my $count = 0; @@ -358,13 +384,17 @@ sub exportcourse { my %parent = (); my %children = (); my $lastcontainer = $startcount; - my @bgcolors = ('#F6F6F6','#FFFFFF'); - $display .= ''. - '' + .''; + $display .= '' + .&Apache::loncommon::end_data_table_header_row(); while ($curRes = $it->next()) { if (ref($curRes)) { $count ++; @@ -385,16 +415,17 @@ sub exportcourse { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } } - my $color = $count%2; - $display .=''; + $display .= ' '.$curRes->title().''."\n"; + + # Existing discussion posts? if ($discussiontime{$ressymb} > 0) { $boards ++; $currelem = $count+$boards+$startcount; - $display .= ''."\n"; + $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', + $r->print(&Apache::loncommon::start_page('Export '.$type.' to IMS Package', $scripttag)); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); - $r->print($display.'
Export content item?
 '."\n"; + $display .= &Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .''.&mt('Export content item?').''; if ($numdisc > 0) { - $display.='Export discussion posts?'."\n"; + $display .= &mt('Export discussion posts?'); + } else { + $display .= ' '; } - $display.=' 
'."\n". - ''."\n" + .'is_sequence()) || ($curRes->is_page())) { my $checkitem = $count + $boards + $startcount; - $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"'; + $display .= 'onclick="javascript:propagateCheck('."'$checkitem'".')"'; } $display .= ' />'."\n"; for (my $i=0; $i<$depth; $i++) { - $display .= ''."\n"; + $display .= '' + .''."\n"; } if ($curRes->is_sequence()) { $display .= ' '."\n"; @@ -405,19 +436,25 @@ sub exportcourse { } my $currelem = $count+$boards+$startcount; $children{$parent{$depth}} .= $currelem.':'; - $display .= ' '.$curRes->title().'  ' + .'' + .'  
'. + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); + $r->print($display. '

'. '

'); + &mt('Export').'" />

'); } } @@ -995,24 +1032,19 @@ sub breadcrumbs { if ($3) { $isencrypted=1; } if ($4 ne '') { $is_random_order = 1; } if ($folder eq 'supplemental') { - if ($allowed) { - $name = &mt('Supplemental '.$type.' Documents'); - } else { - $name = &mt($type.' Documents'); - } + $name = &mt('Supplemental '.$type.' Documents'); } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, 'title'=>$name, - 'text'=>''. - $name.'', + 'text'=>$name, 'no_mt'=>1, }); $plain.=$name.' > '; } $plain=~s/\>\;\s*$//; return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - 'LC_docs_path', undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); + undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); } sub log_docs { @@ -1236,10 +1268,11 @@ sub print_paste_buffer { my ($r,$container) = @_; return if (!defined($env{'docs.markedcopy_url'})); - $r->print(<

-ENDPASTE - $r->print(' '); + $r->print('

' + .''.&mt('Clipboard').'' + .'
' + .' ' + ); my $type; if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { @@ -1253,7 +1286,7 @@ ENDPASTE if ($extension eq 'sequence' && $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) { $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); - $icon .= '/folder_closed.gif'; + $icon .= '/navmap.folder.closed.gif'; } $icon = ''; $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); @@ -1268,7 +1301,7 @@ ENDPASTE '); } - $r->print('

'); + $r->print('
'); } sub do_paste_from_buffer { @@ -1456,7 +1489,6 @@ sub handle_edit_cmd { sub editor { my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_; - my $container= ($env{'form.pagepath'}) ? 'page' : 'sequence'; @@ -1551,34 +1583,70 @@ sub editor { my $idx=0; my $shown=0; if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) { - $r->print('

'.&mt('Parameters').':

' + .'
' + .'
'); # --------------------------------------------------------- Standard documents my $savefolderpath; my $active = 'style="display: none;"'; if($activeClass == 0){ $active = 'style="display: block;"'; } + if ($allowed) { $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=~/^supplemental/) { $folder='default'; @@ -2925,7 +3036,12 @@ HIDDENFORM } my $postexec=''; if ($folder eq 'default') { - $r->print(''); + $r->print(''."\n" + ); } else { #$postexec='self.close();'; } @@ -2943,197 +3059,202 @@ HIDDENFORM my $recoverform=(< - + $lt{'reco'} RFORM my $imspform=(< - + $lt{'imsf'} IMSPFORM my $newnavform=(< + $uploadtag - - + $lt{'navc'} $help{'Navigate_Content'} - NNFORM my $newsmppageform=(< + $uploadtag - - $help{'Simple Page'} - + $lt{'sipa'} + $help{'Simple Page'} NSPFORM my $newsmpproblemform=(< + $uploadtag - - $help{'Simple Problem'} - + $lt{'sipr'} + $help{'Simple Problem'} NSPROBFORM my $newdropboxform=(< + $uploadtag - - - + $lt{'drbx'} NDBFORM my $newexuploadform=(< + $uploadtag - - + $lt{'scuf'} $help{'Score_Upload_Form'} - NEXUFORM my $newbulform=(< + $uploadtag - - + $lt{'bull'} $help{'Bulletin Board'} - NBFORM my $newaboutmeform=(< + $uploadtag - - + $lt{'mypi'} $help{'My Personal Information Page'} - NAMFORM my $newaboutsomeoneform=(< + $uploadtag - - - + $lt{'abou'} NASOFORM my $newrosterform=(< + $uploadtag - - + $lt{'rost'} $help{'Course Roster'} - NROSTFORM my $specialdocumentsform; +my @specialdocumentsforma; my $newfolderform; +my $newfolderb; unless ($env{'form.pagepath'}) { my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); - + my $newpageform=(< - - $help{'Adding_Pages'} - + + $lt{'newp'} + $help{'Adding_Pages'} NPFORM + $newfolderform=(< - - $help{'Adding_Folders'} - + + $lt{'newf'}$help{'Adding_Folders'} NFFORM my $newsylform=(< + $uploadtag - - + $lt{'syll'} $help{'Syllabus'} - + NSYLFORM my $newgroupfileform=(< + $uploadtag - - + $lt{'grpo'} $help{'Group Portfolio'} - NGFFORM - - $specialdocumentsform="
$newpageform
$newsylform
$newgroupfileform"; + @specialdocumentsforma=( + {'pic06'=>$newpageform}, + {'pic07'=>$newsylform}, + {'pic08'=>$newgroupfileform}, + ); + } - $specialdocumentsform.="
$newnavform
$newsmppageform -
$newsmpproblemform
$newdropboxform -
$newexuploadform
$newbulform -
$newaboutmeform
$newaboutsomeoneform -
$newrosterform"; + push @specialdocumentsforma, ({'pic09'=>$newnavform}, + {'pic10'=>$newsmppageform}, + {'pic11'=>$newsmpproblemform}, + {'pic12'=>$newdropboxform}, + {'pic13'=>$newexuploadform}, + {'pic14'=>$newbulform}, + {'pic15'=>$newaboutmeform}, + {'pic16'=>$newaboutsomeoneform}, + {'pic17'=>$newrosterform},); + + $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma)); + if($env{'form.pagepath'}) { - $specialdocumentsform="
$newsmpproblemform
$newexuploadform"; + + @specialdocumentsforma=( + {'pic32'=>$newsmpproblemform}, + {'pic33'=>$newexuploadform} + ); + $specialdocumentsform= create_form_ul(create_list_elements(@specialdocumentsforma)); } +my @tools = ( + {'pic18'=>$extresourcesform}, + {'pic19'=>$imspform}, + {'pic20'=>$recoverform}, + ); + my %orderhash = ( - 'aa' => ['New Document',$fileuploadform.'
'.$newfolderform], - 'bb' => ['Published Documents',$simpleeditdefaultform], + '00' => ['Newfolder',$newfolderform], + 'aa' => ['Upload Document',$fileuploadform], + 'bb' => ['Published Resources',$simpleeditdefaultform], 'cc' => ['Special Documents',$specialdocumentsform], - 'dd' => ['Tools',$extresourcesform.'
'.$imspform.'
'.$recoverform.'
'.&generate_admin_options($containertag,$uploadtag,\%help,\%env)], - 'zz' => ['Hide all Options'], + 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options($containertag,$uploadtag,\%help,\%env)], ); my $tid='1'; my $varcd = 'Main Course Documents'; -$r->print(&generate_edit_table($tid,$varcd,\%orderhash)); $hadchanges=0; my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); if ($error) { @@ -3144,7 +3265,10 @@ $r->print(&generate_edit_table($tid,$var } &changewarning($r,''); +$r->print(&generate_edit_table($tid,$varcd,\%orderhash)); + $r->print('
'); + } if ($env{'form.pagepath'}) { } # ----------------------------------------------------- Supplemental documents @@ -3152,7 +3276,7 @@ $r->print('
'); if($activeClass == 1){ $active = 'style="display: block;"'; } - $r->print('
'); + $r->print('
'); my $folder=$env{'form.folder'}; unless ($folder=~/^supplemental/) { $folder='supplemental'; @@ -3161,7 +3285,7 @@ $r->print('
'); (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) { $env{'form.folderpath'} = 'supplemental&'. &escape(&mt('Supplemental '.$type.' Documents')); - }else{ + } elsif ($allowed) { $env{'form.folderpath'} = $savefolderpath; } $env{'form.pagepath'} = ''; @@ -3172,8 +3296,12 @@ $r->print('
'); my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); + my @supupdocform = ( + {'pic27'=>"$help{'Uploading_From_Harddrive'}"}, + ); my $supupdocform=(< +
+ $fileupload

@@ -3182,86 +3310,86 @@ $r->print('
');

$lt{'comment'}:
- +
- - - $help{'Uploading_From_Harddrive'} - - SUPDOCFORM + $supupdocform .= create_form_ul(create_list_elements(@supupdocform)).""; my $supnewfolderform=(< + - - $help{'Adding_Folders'} - + $lt{'newf'} + $help{'Adding_Folders'} SNFFORM - + my $supnewextform=(< + - - $help{'Adding_External_Resource'} - + $lt{'extr'} $help{'Adding_External_Resource'} SNEFORM my $supnewsylform=(< + - - + $lt{'syll'} $help{'Syllabus'} - SNSFORM my $supnewaboutmeform=(< +
+ - - + $lt{'mypi'} $help{'My Personal Information Page'} -
SNAMFORM - +my @specialdocs = ( + {'pic29'=>$supnewextform}, + {'pic30'=>$supnewsylform}, + {'pic31'=>$supnewaboutmeform}, + ); my %suporderhash = ( - 'ee' => ['New Document',$supupdocform.'
'.$supnewfolderform], - 'ff' => ['Special Documents',$supnewextform.'
'.$supnewsylform.'
'.$supnewaboutmeform], - 'zz' => ['Hide all Options'], + '00' => ['Supnewfolder', $supnewfolderform], + 'ee' => ['Upload Document',$supupdocform], + 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))] ); -my $tid='2'; -my $varscd = 'Supplemental Course Documents'; + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); + if ($error) { + $r->print('

'.$error.'

'); + } + my $tid='2'; + my $varscd = 'Supplemental Course Documents'; + $r->print(&generate_edit_table($tid,$varscd,\%suporderhash)); + } else { + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); + if ($error) { + $r->print('

'.$error.'

'); + } + } + -$r->print(&generate_edit_table($tid,$varscd,\%suporderhash)); -my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); - if ($error) { - $r->print('

'.$error.'

'); - } -$r->print(''); - } $r->print(''); +$r->print(''); + + if ($allowed) { $r->print('
@@ -3297,17 +3425,18 @@ sub generate_admin_options { my %env = %{$env_ref}; my $dumpbut=&dumpbutton(); my $exportbut=&exportbutton(); - return (< - $help{'Verify_Content'}
- $help{'Check_Resource_Versions'}
- $dumpbut - $exportbut - -
- - -ENDOPTIONFORM + my @list = ( + {'pic21'=>"$lt{'vc'}$help{'Verify_Content'}"}, + {'pic22'=>"$lt{'cv'}$help{'Check_Resource_Versions'}"}, + ); + if($dumpbut ne ''){ + push @list, {'pic23'=>$dumpbut}; + } + push @list, ({'pic24'=>$exportbut}, + {'pic25'=>"$lt{'ls'}"}, + {'pic26'=>"$lt{'sl'}"}, + ); + return '
'.create_form_ul(create_list_elements(@list)).'
'; } @@ -3316,21 +3445,38 @@ sub generate_edit_table { my ($tid,$varcd,$orderhash_ref) = @_; my %orderhash = %{$orderhash_ref}; my $form; - - $form = '

'.&mt($varcd).'

'; + my $activetab; + my $active; + if($env{'form.active'} ne ''){ + $activetab = $env{'form.active'}; + } + $form = '
'; $form .= ''; $form .= '
'; foreach my $field (keys(%orderhash)){ - if($field ne 'zz'){ - $form .= ''; + if($field ne '00'){ + if($activetab eq '' || $activetab ne $field){ + $active = 'style="display: none;"'; + }elsif($activetab eq $field){ + $active = 'style="display:block;"'; + } + $form .= '
'.${$orderhash{$field}}[1] + .'
'; } } $form .= '
'; @@ -3543,13 +3689,21 @@ function unselectInactive(nav) { currentNav = document.getElementById(nav); currentLis = currentNav.getElementsByTagName('LI'); for (i = 0; i < currentLis.length; i++) { - currentLis[i].className = 'i'; + if(currentLis[i].className == 'right active' || currentLis[i].className == 'right'){ + currentLis[i].className = 'right'; + }else{ + currentLis[i].className = 'i'; + } } } function hideAll(current, nav, data) { unselectInactive(nav); -current.className = 'active'; +if(current.className == 'right'){ + current.className = 'right active' + }else{ + current.className = 'active'; +} currentData = document.getElementById(data); currentDivs = currentData.getElementsByTagName('DIV'); for (i = 0; i < currentDivs.length; i++) { @@ -3559,8 +3713,25 @@ for (i = 0; i < currentDivs.length; i++) } } +function openTabs(pageId) { + tabnav = document.getElementById(pageId).getElementsByTagName('UL'); + if(tabnav.length > 2 ){ + currentNav = document.getElementById(tabnav[1].id); + currentLis = currentNav.getElementsByTagName('LI'); + for(i = 0; i< currentLis.length; i++){ + if(currentLis[i].className == 'active') { + funcString = currentLis[i].onclick.toString(); + tab = funcString.split('"'); + currentData = document.getElementById(tab[1]); + currentData.style.display = 'block'; + } + } + } +} + function showPage(current, pageId, nav, data) { hideAll(current, nav, data); + openTabs(pageId); unselectInactive(nav); current.className = 'active'; currentData = document.getElementById(pageId); @@ -3568,6 +3739,13 @@ function showPage(current, pageId, nav, return false; } +function injectData(current, hiddenField, name, value) { + currentElement = document.getElementById(hiddenField); + currentElement.name = name; + currentElement.value = value; + current.submit(); +} + ENDNEWSCRIPT } 1;