--- loncom/interface/loncommon.pm 2003/08/13 20:40:31 1.111 +++ loncom/interface/loncommon.pm 2003/11/10 23:25:52 1.152 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.111 2003/08/13 20:40:31 www Exp $ +# $Id: loncommon.pm,v 1.152 2003/11/10 23:25:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,29 +47,15 @@ Apache::loncommon - pile of common routi =head1 SYNOPSIS -Referenced by other mod_perl Apache modules. +Common routines for manipulating connections, student answers, + domains, common Javascript fragments, etc. -Invocation: - &Apache::loncommon::SUBROUTINENAME(ARGUMENTS); +=head1 OVERVIEW -=head1 INTRODUCTION - -Common collection of used subroutines. This collection helps remove +A collection of commonly used subroutines that don't have a natural +home anywhere else. This collection helps remove redundancy from other modules and increase efficiency of memory usage. -Current things done: - - Makes a table out of the previous homework attempts - Inputs result_from_symbread, user, domain, course_id - Reads in non-network-related .tab files - -This is part of the LearningOnline Network with CAPA project -described at http://www.lon-capa.org. - -=head2 General Subroutines - -=over 4 - =cut # End of POD header @@ -82,17 +68,20 @@ use POSIX qw(strftime mktime); use Apache::Constants qw(:common :http :methods); use Apache::lonmsg(); use Apache::lonmenu(); +use Apache::lonlocal; +use HTML::Entities; + my $readit; =pod -=item Global Variables - -=over 4 +=head1 Global Variables =cut + # ----------------------------------------------- Filetypes/Languages/Copyright my %language; +my %supported_language; my %cprtag; my %fe; my %fd; my %category_extensions; @@ -102,42 +91,19 @@ my %category_extensions; my %designhash; # ---------------------------------------------- Thesaurus variables - -=pod - -=item %Keywords - -A hash used by &keyword to determine if a word is considered a keyword. - -=item $thesaurus_db_file - -Scalar containing the full path to the thesaurus database. - -=cut +# +# %Keywords: +# A hash used by &keyword to determine if a word is considered a keyword. +# $thesaurus_db_file +# Scalar containing the full path to the thesaurus database. my %Keywords; my $thesaurus_db_file; - -=pod - -=back - -=cut - -# ----------------------------------------------------------------------- BEGIN - -=pod - -=item BEGIN() - -Initialize values from language.tab, copyright.tab, filetypes.tab, -thesaurus.tab, and filecategories.tab. - -=cut - -# ----------------------------------------------------------------------- BEGIN - +# +# Initialize values from language.tab, copyright.tab, filetypes.tab, +# thesaurus.tab, and filecategories.tab. +# BEGIN { # Variable initialization $thesaurus_db_file = $Apache::lonnet::perlvar{'lonTabDir'}."/thesaurus.db"; @@ -151,8 +117,11 @@ BEGIN { while (<$fh>) { next if /^\#/; chomp; - my ($key,$two,$country,$three,$enc,$val)=(split(/\t/,$_)); + my ($key,$two,$country,$three,$enc,$val,$sup)=(split(/\t/,$_)); $language{$key}=$val.' - '.$enc; + if ($sup) { + $supported_language{$key}=$sup; + } } } } @@ -228,21 +197,31 @@ BEGIN { } # end of unless($readit) } -# ============================================================= END BEGIN BLOCK + ############################################################### ## HTML and Javascript Helper Functions ## ############################################################### =pod -=item browser_and_searcher_javascript +=head1 General Subroutines -Returns scalar containing javascript to open a browser window -or a searcher window. Also creates +=over 4 + +=head1 HTML and Javascript Functions =over 4 -=item openbrowser(formname,elementname,only,omit) [javascript] +=item * browser_and_searcher_javascript () + +XXReturns a string +containing javascript with two functions, C and +C. Returned string does not contain EscriptE +tags. + +=over 4 + +=item * openbrowser(formname,elementname,only,omit) [javascript] inputs: formname, elementname, only, omit @@ -255,7 +234,7 @@ with the given extension. Can be a comm Specifying 'omit' will restrict the browser to NOT displaying files with the given extension. Can be a comma seperated list. -=item opensearcher(formname, elementname) [javascript] +=item * opensearcher(formname, elementname) [javascript] Inputs: formname, elementname @@ -266,11 +245,10 @@ of the element the selection from the se =cut -############################################################### sub browser_and_searcher_javascript { return <Select User"; + '","'.$udomele.'");'."'>".&mt('Select User').""; } if ($ENV{'request.role'}=~/^(au|dc|su)/) { return "Select User"; + '","'.$udomele.'",1);'."'>".&mt('Select User').""; } return ''; } sub coursebrowser_javascript { - return (<<'ENDSTDBRW'); + my ($domainfilter)=@_; + return (< var stdeditbrowser; function opencrsbrowser(formname,uname,udom) { @@ -369,6 +354,12 @@ sub coursebrowser_javascript { url += 'filter='+filter+'&'; } } + var domainfilter='$domainfilter'; + if (domainfilter != null) { + if (domainfilter != '') { + url += 'domainfilter='+domainfilter+'&'; + } + } url += 'form=' + formname + '&cnumelement='+uname+ '&cdomelement='+udom; var title = 'Course_Browser'; @@ -384,14 +375,12 @@ ENDSTDBRW sub selectcourse_link { my ($form,$unameele,$udomele)=@_; return "Select Course"; + '","'.$udomele.'");'."'>".&mt('Select Course').""; } -############################################################### - =pod -=item linked_select_forms(...) +=item * linked_select_forms(...) linked_select_forms returns a string containing a block and html for two tags +=item * $middletext, the text which appears between the tag +=item * $firstselectname, the name of the first tag +=item * $secondselectname, the name of the second \n"; my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; @@ -530,26 +518,34 @@ END foreach my $value (sort(keys(%select2))) { $result.=" \n"; } $selectform.=""; return $selectform; @@ -686,7 +776,7 @@ sub select_form { =pod -=item select_dom_form($defdom,$name,$includeempty) +=item * select_dom_form($defdom,$name,$includeempty) Returns a string containing a form input. See loncreateuser.pm for an example. @@ -758,16 +848,24 @@ sub home_server_option_list { } return $result; } -############################################################### -## End of home server