--- loncom/interface/lonhtmlcommon.pm 2012/11/29 20:13:43 1.333 +++ loncom/interface/lonhtmlcommon.pm 2013/05/03 21:57:13 1.344 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.333 2012/11/29 20:13:43 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.344 2013/05/03 21:57:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -209,10 +209,21 @@ dependencies for a web page uploaded dir =cut sub dependencycheck_js { - my ($symb,$title,$url) = @_; - my $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"'). - '&title='.&HTML::Entities::encode($title,'<>&"'). - '&url='.&HTML::Entities::encode($url,'<>&"'); + my ($symb,$title,$url,$folderpath,$uri) = @_; + my $link; + if ($symb) { + $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"'); + } elsif ($folderpath) { + $link = '/adm/dependencies?folderpath='.&HTML::Entities::encode($folderpath,'<>&"'); + $url = $uri; + } elsif ($uri =~ m{^/public/$match_domain/$match_courseid/syllabus$}) { + $link = '/adm/dependencies'; + } + $link .= (($link=~/\?/)?'&':'?').'title='. + &HTML::Entities::encode($title,'<>&"'); + if ($url) { + $link .= '&url='.&HTML::Entities::encode($url,'<>&"'); + } return < // 'Plain text', + 'rich' => 'Rich formatting', + 'plain_title' => 'Disable rich text formatting and edit in plain text', + 'rich_title' => 'Enable rich text formatting (bold, italic, etc.)', + ); + $output.=' function containsBlockHtml(id) { @@ -1299,14 +1318,14 @@ sub htmlareaselectactive { var rt_enabled = $(this).hasClass("LC_enable_rt"); if (rt_enabled) { startRichEditor(id); - $("#LC_rt_"+id).html("« Plain text"); - $("#LC_rt_"+id).attr("title", "Disable rich text formatting and edit in plain text"); + $("#LC_rt_"+id).html("« '.$lt{'plain'}.'"); + $("#LC_rt_"+id).attr("title", "'.$lt{'plain_title'}.'"); $("#LC_rt_"+id).addClass("LC_disable_rt"); $("#LC_rt_"+id).removeClass("LC_enable_rt"); } else { destroyRichEditor(id); - $("#LC_rt_"+id).html("Rich formatting »"); - $("#LC_rt_"+id).attr("title", "Enable rich text formatting (bold, italic, etc.)"); + $("#LC_rt_"+id).html("'.$lt{'rich'}.' »"); + $("#LC_rt_"+id).attr("title", "'.$lt{'rich_title'}.'"); $("#LC_rt_"+id).addClass("LC_enable_rt"); $("#LC_rt_"+id).removeClass("LC_disable_rt"); }'; @@ -1327,12 +1346,12 @@ sub htmlareaselectactive { var id = $(this).attr("id"); var rt_enabled = containsBlockHtml(id); if(rt_enabled) { - $(this).before("
« Plain text
"); + $(this).before("
« '.$lt{'plain'}.'
"); startRichEditor(id); $("#LC_rt_"+id).click(editorHandler); } else { - $(this).before("
Rich formatting »
"); + $(this).before("
'.$lt{'rich'}.' »
"); $("#LC_rt_"+id).click(editorHandler); }'; if ($dragmath_prefix ne '') { @@ -1346,13 +1365,13 @@ sub htmlareaselectactive { }); $(".LC_richDefaultOn").each(function() { var id = $(this).attr("id"); - $(this).before("
« Plain text
"); + $(this).before("
« '.$lt{'plain'}.'
"); startRichEditor(id); $("#LC_rt_"+id).click(editorHandler); }); $(".LC_richDefaultOff").each(function() { var id = $(this).attr("id"); - $(this).before("
Rich formatting »
"); + $(this).before("
'.$lt{'rich'}.' »
"); $("#LC_rt_"+id).click(editorHandler); }); @@ -1387,7 +1406,8 @@ sub htmlareaselectactive { # is used to determine when the countdown timer turns red to warn the user # to think about submitting. - my $dueDateLayout = &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} [_1]',""); + my $dueDateLayout = &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} [_1]', + ""); my $early = '- '.&mt('Submit Early').''; my $pastdue = '- '.&mt('Past Due').''; $output .= < "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ; - &render_advtools(\$links); + my $nav_and_tools = 0; + foreach my $item ('navigation','tools') { + if (ref($tools{$item}) eq 'ARRAY') { + $nav_and_tools += scalar(@{$tools{$item}}) + } + } + if (($links ne '') || ($nav_and_tools)) { + &render_tools(\$links); + $links = &htmltag('div', $links, + { id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ; + } + my $adv_tools = 0; + if (ref($tools{'advtools'}) eq 'ARRAY') { + $adv_tools = scalar(@{$tools{'advtools'}}); + } + if (($links ne '') || ($adv_tools)) { + &render_advtools(\$links); + } # Return the @Crumbs stack to what we started with push(@Crumbs,$last); @@ -1885,13 +1918,13 @@ returns: nothing sub docs_breadcrumbs { my ($allowed,$crstype,$contenteditor,$title,$precleared)=@_; - my ($folderpath,@folders); - if ($env{'form.pagepath'}) { - @folders = split('&',$env{'form.pagepath'}); - } else { - @folders = split('&',$env{'form.folderpath'}); + my ($folderpath,@folders,$supplementalflag); + @folders = split('&',$env{'form.folderpath'}); + if ($env{'form.folderpath'} =~ /^supplemental/) { + $supplementalflag = 1; } my $plain=''; + my $container = 'sequence'; my ($randompick,$isencrypted,$ishidden,$is_random_order) = (-1,0,0,0); my @docs_crumbs; while (@folders) { @@ -1907,18 +1940,21 @@ sub docs_breadcrumbs { } $url .= &escape($folderpath); my $name=&unescape($foldername); -# each of randompick number, hidden, encrypted, random order are -# appended with ":"s to the foldername - $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; - if ($contenteditor) { - if ($1 ne '') { - $randompick=$1; - } else { - $randompick=-1; +# each of randompick number, hidden, encrypted, random order, is_page +# are appended with ":"s to the foldername + $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//; + unless ($supplementalflag) { + if ($contenteditor) { + if ($1 ne '') { + $randompick=$1; + } else { + $randompick=-1; + } + if ($2) { $ishidden=1; } + if ($3) { $isencrypted=1; } + if ($4 ne '') { $is_random_order = 1; } + if ($5 == 1) {$container = 'page'; } } - if ($2) { $ishidden=1; } - if ($3) { $isencrypted=1; } - if ($4 ne '') { $is_random_order = 1; } } if ($folder eq 'supplemental') { $name = &mt('Supplemental '.$crstype.' Contents'); @@ -1955,7 +1991,7 @@ sub docs_breadcrumbs { return (&breadcrumbs(undef,undef,$menulink,'nohelp',undef,undef, $contenteditor), $randompick,$ishidden,$isencrypted,$plain, - $is_random_order); + $is_random_order,$container); } else { return \@docs_crumbs; } @@ -2188,11 +2224,11 @@ sub course_selection { my $courseform=''.&Apache::loncommon::selectcourse_link ($formname,'pickcourse','pickdomain','coursedesc','',1,$crstype).''; - $output .= ''.$allcrs.'
'; + $output .= '
'; if ($totcodes > 0) { my $numtitles = @$codetitles; if ($numtitles > 0) { - $output .= ''.&mt('Pick courses by category:').'
'; + $output .= '
'; $output .= '
'.$$codetitles[0].'
'."\n". '

'; } } - $output .= ''.$pickspec.' '.$courseform.'  selected.
'."\n"; + $output .= + '' + .' '.$courseform.'  ' + .&mt('[_1] selected.', + '' + .'') + .'
'."\n"; return $output; } @@ -3018,7 +3062,10 @@ PARAMSONE } if ((chkh == 1) || (listwchange)) { var primaryheight = document.getElementById('LC_nav_bar').offsetHeight; - var secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight; + var secondaryheight; + if (document.getElementById('LC_secondary_menu') != null) { + secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight; + } var crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight; var dccidheight = 0; if (document.getElementById('dccid') != null) { @@ -3109,7 +3156,7 @@ ENDUTILITY sub jump_to_editres { my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath, - $title,$idx,$suppurl) = @_; + $title,$idx,$suppurl,$todocs) = @_; my $jscall; if ($switchserver) { if ($home) { @@ -3153,6 +3200,9 @@ sub jump_to_editres { if ($forcereg) { $cfile .= (($cfile=~/\?/)?'&':'?').'register=1'; } + if ($todocs) { + $cfile .= (($cfile=~/\?/)?'&':'?').'todocs=1'; + } } $jscall = "go('$cfile')"; } @@ -3525,6 +3575,40 @@ sub funclist_from_array { { listattr => {class => 'LC_funclist'} }); } +=pod + +=item &actionbox( \@array ) + +Constructs a XHTML list from \@array with the first item being visually +highlighted and set to the value 'Actions'. The list is wrapped in a division. + +The actionlist is used to offer contextual actions, mostly at the bottom +of a page, on which the outcome of an processed action is shown, +e.g. a file operation in Construction Space. + +=over + +=item \@array + +A reference to the array containing text. Details: sub funclist_from_array + +=back + +Returns: XHTML div as string. + +=back + +=cut + +sub actionbox { + my ($items) = @_; + return unless(ref($items) eq 'ARRAY'); + return + '
' + .&funclist_from_array($items, {legend => &mt('Actions')}) + .'
'; +} + 1; __END__