--- loncom/interface/lonhtmlcommon.pm 2012/01/02 05:07:06 1.298
+++ loncom/interface/lonhtmlcommon.pm 2012/12/22 14:45:35 1.339
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.298 2012/01/02 05:07:06 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.339 2012/12/22 14:45:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,7 +61,7 @@ use Time::HiRes;
use Apache::lonlocal;
use Apache::lonnet;
use HTML::Entities();
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub java_not_enabled {
return "\n".''.
@@ -95,7 +95,7 @@ sub direct_parm_link {
$filter=&entity_encode($filter);
$part=&entity_encode($part);
if (($symb) && (&Apache::lonnet::allowed('opa')) && ($target ne 'tex')) {
- return "$linktext";
+ return "$linktext";
} else {
return $linktext;
}
@@ -103,7 +103,7 @@ sub direct_parm_link {
##############################################
##############################################
-=item confirm_success
+=item &confirm_success()
Successful completion of an operation message
@@ -129,7 +129,7 @@ sub confirm_success {
=pod
-=item dragmath_button
+=item &dragmath_button()
Creates a button that launches a dragmath popup-window, in which an
expression can be edited and pasted as LaTeX into a specified textarea.
@@ -155,10 +155,11 @@ ENDDRAGMATH
=pod
-=item dragmath_js
+=item &dragmath_js()
Javascript used to open pop-up window containing dragmath applet which
can be used to paste LaTeX into a textarea.
+
=cut
sub dragmath_js {
@@ -177,13 +178,67 @@ sub dragmath_js {
ENDDRAGMATHJS
}
+##############################################
+##############################################
+
+=pod
+
+=item &dependencies_button()
+
+Creates a button that launches a popup-window, in which dependencies
+for the web page in the main window can be added to, replaced or deleted.
+
+=cut
+
+sub dependencies_button {
+ my $buttontext=&mt('Manage Dependencies');
+ return <<"END";
+
+END
+}
+
+##############################################
+
+=pod
+
+=item &dependencycheck_js()
+
+Javascript used to open pop-up window containing interface to manage
+dependencies for a web page uploaded diretcly to a course.
+
+=cut
+
+sub dependencycheck_js {
+ 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;
+ }
+ $link .= (($link=~/\?/)?'&':'?').'title='.
+ &HTML::Entities::encode($title,'<>&"');
+ if ($url) {
+ $link .= '&url='.&HTML::Entities::encode($url,'<>&"');
+ }
+ return <",
+ if ((&show_return_link) && (!$CourseBreadcrumbs) && (ref($last) eq 'HASH')) {
+ my $alttext = &mt('Go Back');
+ $links=&htmltag( 'a','
',
{ href => '/adm/flip?postdata=return:',
- title => &mt("Back to most recent content resource") });
- $links=&htmltag('li',$links);
+ title => &mt('Back to most recent content resource'),
+ class => 'LC_menubuttons_link',
+ });
+ $links=&htmltag('li',$links);
}
$links.= join "",
map {
@@ -1493,8 +1719,11 @@ returns: nothing
# last breadcrumb is the first order heading of a page
# for course breadcrumbs it's just bold
- $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',
- $lasttext), {title => $lasttext});
+
+ if ($lasttext ne '') {
+ $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',
+ $lasttext), {title => $lasttext});
+ }
my $icons = '';
$faq = $last->{'faq'} if (exists($last->{'faq'}));
@@ -1513,31 +1742,53 @@ returns: nothing
$faq,$bug);
}
#
-
- unless ($CourseBreadcrumbs) {
- $links = &htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" });
- } else {
- $links = &htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" });
+
+ if ($links ne '') {
+ unless ($CourseBreadcrumbs) {
+ $links = &htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" });
+ } else {
+ $links = &htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" });
+ }
}
+
if ($component) {
$links = &htmltag('span',
( $no_mt ? $component : mt($component) ).
( $icons ? $icons : '' ),
{ class => 'LC_breadcrumbs_component' } )
- .$links;
+ .$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);
}
-
- &render_tools(\$links);
- $links = &htmltag('div', $links,
- { id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ;
- &render_advtools(\$links);
# Return the @Crumbs stack to what we started with
push(@Crumbs,$last);
shift(@Crumbs);
+
+
# Return the breadcrumb's line
+
+
+
return "$links";
}
@@ -1550,7 +1801,7 @@ returns: nothing
push(@Crumbs,@_);
}
-=item add_breadcrumb_tool($category, $html)
+=item &add_breadcrumb_tool($category, $html)
Adds $html to $category of the breadcrumb toolbar container.
@@ -1565,7 +1816,7 @@ Currently there are 3 possible values fo
left of breadcrumbs line
=item tools
-right of breadcrumbs line
+remaining items in right of breadcrumbs line
=item advtools
advanced tools shown in a separate box below breadcrumbs line
@@ -1593,7 +1844,7 @@ returns: nothing
push @{$tools{$category}}, @html;
}
-=item clear_breadcrumb_tools()
+=item &clear_breadcrumb_tools()
Clears the breadcrumb toolbar container.
@@ -1605,7 +1856,7 @@ returns: nothing
undef(%tools);
}
-=item render_tools(\$breadcrumbs)
+=item &render_tools(\$breadcrumbs)
Creates html for breadcrumb tools (categories navigation and tools) and inserts
\$breadcrumbs at the correct position.
@@ -1614,6 +1865,7 @@ input: \$breadcrumbs - a reference to th
breadcrumbs.
returns: nothing
+
=cut
#TODO might split this in separate functions for each category
@@ -1629,7 +1881,9 @@ returns: nothing
{ listattr => { class=>'LC_breadcrumb_tools_outerlist' } });
}
-=item render_advtools(\$breadcrumbs)
+=pod
+
+=item &render_advtools(\$breadcrumbs)
Creates html for advanced tools (category advtools) and inserts \$breadcrumbs
at the correct position.
@@ -1638,6 +1892,7 @@ input: \$breadcrumbs - a reference to th
breadcrumbs (after render_tools call).
returns: nothing
+
=cut
sub render_advtools {
@@ -1651,6 +1906,82 @@ returns: nothing
} # End of scope for @Crumbs
+sub docs_breadcrumbs {
+ my ($allowed,$crstype,$contenteditor,$title,$precleared)=@_;
+ my ($folderpath,@folders);
+ my @folders = split('&',$env{'form.folderpath'});
+ my $plain='';
+ my $container = 'sequence';
+ my ($randompick,$isencrypted,$ishidden,$is_random_order) = (-1,0,0,0);
+ my @docs_crumbs;
+ while (@folders) {
+ my $folder=shift(@folders);
+ my $foldername=shift(@folders);
+ if ($folderpath) {$folderpath.='&';}
+ $folderpath.=$folder.'&'.$foldername;
+ my $url;
+ if ($allowed) {
+ $url = '/adm/coursedocs?folderpath=';
+ } else {
+ $url = '/adm/supplemental?folderpath=';
+ }
+ $url .= &escape($folderpath);
+ my $name=&unescape($foldername);
+# each of randompick number, hidden, encrypted, random order, is_page
+# are appended with ":"s to the foldername
+ $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//;
+ 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 ($folder eq 'supplemental') {
+ $name = &mt('Supplemental '.$crstype.' Contents');
+ }
+ if ($contenteditor) {
+ $plain.=$name.' > ';
+ }
+ push(@docs_crumbs,
+ {'href' => $url,
+ 'title' => $name,
+ 'text' => $name,
+ 'no_mt' => 1,
+ });
+ }
+ if ($title) {
+ push(@docs_crumbs,
+ {'title' => $title,
+ 'text' => $title,
+ 'no_mt' => 1,}
+ );
+ }
+ if (wantarray) {
+ unless ($precleared) {
+ &clear_breadcrumbs();
+ }
+ &add_breadcrumb(@docs_crumbs);
+ if ($contenteditor) {
+ $plain=~s/\>\;\s*$//;
+ }
+ my $menulink = 0;
+ if (!$allowed && !$contenteditor) {
+ $menulink = 1;
+ }
+ return (&breadcrumbs(undef,undef,$menulink,'nohelp',undef,undef,
+ $contenteditor),
+ $randompick,$ishidden,$isencrypted,$plain,
+ $is_random_order,$container);
+ } else {
+ return \@docs_crumbs;
+ }
+}
+
############################################################
############################################################
@@ -1711,15 +2042,19 @@ returns: nothing
my @row_count;
sub start_pick_box {
- my ($css_class) = @_;
+ my ($css_class,$id) = @_;
if (defined($css_class)) {
$css_class = 'class="'.$css_class.'"';
} else {
$css_class= 'class="LC_pick_box"';
}
+ my $table_id;
+ if (defined($id)) {
+ $table_id = ' id="'.$id.'"';
+ }
unshift(@row_count,0);
my $output = <<"END";
-
'.&mt('Folder:').' | '.$folder.' | '. + ''.&mt('Folder:').' | '.$folder.' | '. &Apache::loncommon::end_data_table_row(); unless ($onlyfolderflag) { $return.=&Apache::loncommon::start_data_table_row(). - ''.&mt('Resource:').' | '.&Apache::lonnet::gettitle($symb).' | '. + ''.&mt('Resource:').' | '.&Apache::lonnet::gettitle($symb).' | '. + &Apache::loncommon::end_data_table_row(); + } + if ($stuvcurrent ne '') { + $return .= &Apache::loncommon::start_data_table_row(). + ''.&mt("Student's current version:").' | '.$stuvcurrent.' | '. + &Apache::loncommon::end_data_table_row(); + } + if ($stuvdisp ne '') { + $return .= &Apache::loncommon::start_data_table_row(). + ''.&mt("Student's version displayed:").' | '.$stuvdisp.' | '. &Apache::loncommon::end_data_table_row(); } $return.=&Apache::loncommon::end_data_table(); } else { $return='
---|