--- loncom/interface/loncommon.pm 2002/04/26 18:57:27 1.36 +++ loncom/interface/loncommon.pm 2002/06/24 20:17:55 1.39 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.36 2002/04/26 18:57:27 matthew Exp $ +# $Id: loncommon.pm,v 1.39 2002/06/24 20:17:55 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -65,7 +65,7 @@ Current things done: This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org. -=head2 Subroutines +=head2 General Subroutines =over 4 @@ -79,14 +79,13 @@ use Apache::lonnet(); use POSIX qw(strftime); use Apache::Constants qw(:common); use Apache::lonmsg(); - my $readit; # ----------------------------------------------- Filetypes/Languages/Copyright my %language; my %cprtag; my %fe; my %fd; -my %fc; +my %category_extensions; # -------------------------------------------------------------- Thesaurus data my @therelated; @@ -99,6 +98,9 @@ my $thethreshold=0.1/$thefuzzy; my $theavecount; # ----------------------------------------------------------------------- BEGIN + +=pod + =item BEGIN() Initialize values from language.tab, copyright.tab, filetypes.tab, @@ -144,8 +146,8 @@ BEGIN { while (<$fh>) { next if /^\#/; chomp; - my ($key,$val)=(split(/\s+/,$_,2)); - push @{$fc{$key}},$val; + my ($extension,$category)=(split(/\s+/,$_,2)); + push @{$category_extensions{lc($category)}},$extension; } } } @@ -213,14 +215,16 @@ linked_select_forms takes the following =item $hashref, a reference to a hash containing the data for the menus. +=back + Below is an example of such a hash. Only the 'text', 'default', and 'select2' keys must appear as stated. keys(%menu) are the possible values for the first select menu. The text that coincides with the -first menu values is given in $menu{$choice1}->{'text'}. The values +first menu value is given in $menu{$choice1}->{'text'}. The values and text for the second menu are given in the hash pointed to by $menu{$choice1}->{'select2'}. - my %menu = ( A1 => { text =>"Choice A1" , +my %menu = ( A1 => { text =>"Choice A1" , default => "B3", select2 => { B1 => "Choice B1", @@ -336,6 +340,24 @@ END } # end of sub linked_select_forms { ############################################################### + +=item csv_translate($text) + +Translate $text to allow it to be output as a 'comma seperated values' +format. + +=cut + +sub csv_translate { + my $text = shift; + $text =~ s/\"/\"\"/g; + $text =~ s/\n//g; + return $text; +} + +############################################################### + +############################################################### ## Home server