[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Sat, 14 Aug 2010 04:32:04 -0000


raeburn		Sat Aug 14 04:32:04 2010 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/interface	loncommon.pm 
  Log:
  - Backport 1.969, 1.970, 1.971, 1.972, 1.973, 1.975, 1.976.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.948.2.6 loncom/interface/loncommon.pm:1.948.2.7
--- loncom/interface/loncommon.pm:1.948.2.6	Tue May 18 03:48:44 2010
+++ loncom/interface/loncommon.pm	Sat Aug 14 04:32:03 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.948.2.6 2010/05/18 03:48:44 raeburn Exp $
+# $Id: loncommon.pm,v 1.948.2.7 2010/08/14 04:32:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -900,7 +900,7 @@
             $langchoices{$code} = &plainlanguagedescription($id);
         }
     }
-    return &select_form($selected,$name,%langchoices);
+    return &select_form($selected,$name,\%langchoices);
 }
 
 =pod
@@ -1072,7 +1072,7 @@
 
 =pod
 
-=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height)
+=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid)
 
 Returns a string corresponding to an HTML link to the given help
 $topic, where $topic corresponds to the name of a .tex file in
@@ -1095,7 +1095,7 @@
 =cut
 
 sub help_open_topic {
-    my ($topic, $text, $stayOnPage, $width, $height) = @_;
+    my ($topic, $text, $stayOnPage, $width, $height, $imgid) = @_;
     $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);
     $width = 350 if (not defined $width);
@@ -1124,12 +1124,15 @@
     # (Always) Add the graphic
     my $title = &mt('Online Help');
     my $helpicon=&lonhttpdurl("/adm/help/help.png");
+    if ($imgid ne '') {
+        $imgid = ' id="'.$imgid.'"';
+    }
     $template.=' <a target="_top" href="'.$link.'" title="'.$title.'">'
               .'<img src="'.$helpicon.'" border="0"'
               .' alt="'.&mt('Help: [_1]',$topic).'"'
-              .' title="'.$title.'" style="vertical-align:middle;"' 
+              .' title="'.$title.'" style="vertical-align:middle;"'.$imgid
               .' /></a>';
-    if ($text ne "") {	
+    if ($text ne "") {
         $template.='</span>';
     }
     return $template;
@@ -1800,7 +1803,7 @@
 	return &multiple_select_form($name,$value,4,\%domains);
     } else {
 	$domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
-	return &select_form($name,$value,%domains);
+	return &select_form($name,$value,\%domains);
     }
 }
 
@@ -1862,29 +1865,36 @@
 
 =pod
 
-=item * &select_form($defdom,$name,%hash)
+=item * &select_form($defdom,$name,$hashref,$onchange)
 
 Returns a string containing a <select name='$name' size='1'> form to 
-allow a user to select options from a hash option_name => displayed text.  
+allow a user to select options from a ref to a hash containing:
+option_name => displayed text. An optional $onchange can include
+a javascript onchange item, e.g., onchange="this.form.submit();"
+
 See lonrights.pm for an example invocation and use.
 
 =cut
 
 #-------------------------------------------
 sub select_form {
-    my ($def,$name,%hash) = @_;
-    my $selectform = "<select name=\"$name\" size=\"1\">\n";
+    my ($def,$name,$hashref,$onchange) = @_;
+    return unless (ref($hashref) eq 'HASH');
+    if ($onchange) {
+        $onchange = ' onchange="'.$onchange.'"';
+    }
+    my $selectform = "<select name=\"$name\" size=\"1\"$onchange>\n";
     my @keys;
-    if (exists($hash{'select_form_order'})) {
-	@keys=@{$hash{'select_form_order'}};
+    if (exists($hashref->{'select_form_order'})) {
+        @keys=@{$hashref->{'select_form_order'}};
     } else {
-	@keys=sort(keys(%hash));
+        @keys=sort(keys(%{$hashref}));
     }
     foreach my $key (@keys) {
         $selectform.=
 	    '<option value="'.&HTML::Entities::encode($key,'"<>&').'" '.
             ($key eq $def ? 'selected="selected" ' : '').
-                ">".$hash{$key}."</option>\n";
+                ">".$hashref->{$key}."</option>\n";
     }
     $selectform.="</select>";
     return $selectform;
@@ -1902,9 +1912,9 @@
            &mt('Filter [_1]',
 	   &select_form($env{'form.displayfilter'},
 			'displayfilter',
-			('currentfolder' => 'Current folder/page',
+			{'currentfolder' => 'Current folder/page',
 			 'containing' => 'Containing phrase',
-			 'none' => 'None'))).
+			 'none' => 'None'})).
 			 '<input type="text" name="containingphrase" size="30" value="'.&HTML::Entities::encode($env{'form.containingphrase'}).'" /></span>';
 }
 
@@ -3247,7 +3257,7 @@
     my ($name,$value)=@_;
     return &select_form($value,$name,
 			'' => &mt('Any category'),
-			map { $_,$_ } sort(keys(%category_extensions)));
+			{'' => &mt('Any category'), map { $_,$_ } sort(keys(%category_extensions))});
 }
 
 =pod
@@ -6146,6 +6156,30 @@
   text-decoration: none;
 }
 
+ol.LC_docs_parameters {
+  margin-left: 0;
+  padding: 0;
+  list-style: none;
+}
+
+ol.LC_docs_parameters li {
+  margin: 0;
+  padding-right: 20px;
+  display: inline;
+}
+
+ol.LC_docs_parameters li:before {
+  content: "\\002022 \\0020";
+}
+
+li.LC_docs_parameters_title {
+  font-weight: bold;
+}
+
+ol.LC_docs_parameters li.LC_docs_parameters_title:before {
+  content: "";
+}
+
 ul#LC_secondary_menu {
   clear: both;
   color: $fontmenu;
@@ -6319,6 +6353,14 @@
   font-size:90%;
 }
 
+ol#LC_MenuBreadcrumbs h1 {
+  display: inline;
+  font-size: 90%;
+  line-height: 2.5em;
+  margin: 0;
+  padding: 0;
+}
+
 ol#LC_PathBreadcrumbs li a {
   text-decoration:none;
   font-size:100%;
@@ -6661,10 +6703,6 @@
 sub xml_begin {
     my $output='';
 
-    if ($env{'internal.start_page'}==1) {
-	&Apache::lonhtmlcommon::init_htmlareafields();
-    }
-
     if ($env{'browser.mathml'}) {
 	$output='<?xml version="1.0"?>'
             #.'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'."\n"
@@ -8196,6 +8234,10 @@
     return;
 }
 
+sub get_standard_codeitems {
+    return ('Year','Semester','Department','Number','Section');
+}
+
 =pod
 
 =head1 Slot Helpers