--- loncom/interface/lonhtmlcommon.pm 2010/03/19 22:34:23 1.182.4.13 +++ loncom/interface/lonhtmlcommon.pm 2010/10/04 14:34:46 1.284 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.182.4.13 2010/03/19 22:34:23 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.284 2010/10/04 14:34:46 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,26 +62,30 @@ use Apache::lonlocal; use Apache::lonnet; use LONCAPA; +sub java_not_enabled { + return "\n".''. + &mt('The required Java applet could not be started. Please make sure to have Java installed and active in your browser.'). + "\n"; +} + sub coursepreflink { - my ($text,$category)=@_; - if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { - return ''.$text.''; - } else { - return ''; - } + my ($text,$category)=@_; + if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { + return '&"').'">'.$text.''; + } else { + return ''; + } } sub raw_href_to_link { - my ($message)=@_; - $message=~s/(https?\:\/\/[^\s\'\"\<]+)([\s\<]|$)/$1<\/tt><\/a>$2/gi; - return $message; + my ($message)=@_; + $message=~s/(https?\:\/\/[^\s\'\"\<]+)([\s\<]|$)/$1<\/tt><\/a>$2/gi; + return $message; } ############################################## ############################################## -=pod - =item confirm_success Successful completion of an operation message @@ -122,11 +126,11 @@ sub dragmath_button { my ($textarea,$helpicon) = @_; my $help_text; if ($helpicon) { - $help_text = &Apache::loncommon::help_open_topic('Authoring_Math_Editor'); + $help_text = &Apache::loncommon::help_open_topic('Authoring_Math_Editor',undef,undef,undef,undef,'mathhelpicon_'.$textarea); } my $buttontext=&mt('Edit Math'); return <$help_text + $help_text ENDDRAGMATH } @@ -138,7 +142,6 @@ ENDDRAGMATH Javascript used to open pop-up window containing dragmath applet which can be used to paste LaTeX into a textarea. - =cut sub dragmath_js { @@ -175,10 +178,10 @@ sub authorbombs { $url=&Apache::lonnet::declutter($url); my ($udom,$uname)=($url=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)/}); my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom); - foreach (keys %bombs) { - if ($_=~/^$udom\/$uname\//) { + foreach my $bomb (keys(%bombs)) { + if ($bomb =~ /^$udom\/$uname\//) { return ''. + '">'.&mt('Bomb').''. &Apache::loncommon::help_open_topic('About_Bombs'); } } @@ -257,7 +260,7 @@ sub get_recent { # Begin filling return_hash with any 'always_include' option my %time_hash = (); my %return_hash = (); - foreach my $item (keys %recent) { + foreach my $item (keys(%recent)) { my ($thistime,$thisvalue)=(split(/\&/,$recent{$item})); if ($thistime eq 'always_include') { $return_hash{$item} = &unescape($thisvalue); @@ -382,7 +385,8 @@ dname_hour, dname_min, and dname_sec. The current setting for this time parameter. A unix format time (time in seconds since the beginning of Jan 1st, 1970, GMT. -An undefined value is taken to indicate the value is the current time. +An undefined value is taken to indicate the value is the current time +unless it is requested to leave it empty. See $includeempty. Also, to be explicit, a value of 'now' also indicates the current time. =item $special @@ -392,6 +396,9 @@ the date_setter. See lonparmset for exa =item $includeempty +If it is set (true) and no date/time value is provided, +the date/time fields are left empty. + =item $state Specifies the initial state of the form elements. Either 'disabled' or empty. @@ -411,7 +418,11 @@ sub date_setter { my ($formname,$dname,$currentvalue,$special,$includeempty,$state, $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_; my $now = time; - my $wasdefined=1; + + my $tzname; + my ($sec,$min,$hour,$mday,$month,$year) = ('', '', undef,''.''.''); + #other potentially useful values: wkday,yrday,is_daylight_savings + if (! defined($state) || $state ne 'disabled') { $state = ''; } @@ -419,33 +430,24 @@ sub date_setter { $no_hh_mm_ss = 0; } if ($currentvalue eq 'now') { - $currentvalue = $now; + $currentvalue = $now; } - if ((!defined($currentvalue)) || ($currentvalue eq '')) { - $wasdefined=0; - if ($includeempty) { - $currentvalue = 0; - } else { - $currentvalue = $now; - } + + # Default value: Set empty date field to current time + # unless empty inclusion is requested + if ((!$includeempty) && (!$currentvalue)) { + $currentvalue = $now; } - # other potentially useful values: wkday,yrday,is_daylight_savings - my $tzname; - my ($sec,$min,$hour,$mday,$month,$year)=('','',undef,'','',''); + # Do we have a date? Split it! if ($currentvalue) { - ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue); - } - unless ($wasdefined) { - if (($defhour) || ($defmin) || ($defsec)) { - ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($now); - $sec=($defsec?$defsec:0); - $min=($defmin?$defmin:0); - $hour=($defhour?$defhour:0); - } elsif (!$includeempty) { - $sec=0; - $min=0; - $hour=0; - } + ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue); + + #No values provided for hour, min, sec? Use default 0 + if (($defhour) || ($defmin) || ($defsec)) { + $sec = ($defsec ? $defsec : 0); + $min = ($defmin ? $defmin : 0); + $hour = ($defhour ? $defhour : 0); + } } my $result = "\n\n"; $result .= < ENDJS - $result .= ' '; + $result .= ' '; my $monthselector = qq{\n|; +