--- loncom/interface/lonhtmlcommon.pm 2009/11/18 11:47:32 1.245 +++ loncom/interface/lonhtmlcommon.pm 2010/01/07 16:15:59 1.259 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.245 2009/11/18 11:47:32 droeschl Exp $ +# $Id: lonhtmlcommon.pm,v 1.259 2010/01/07 16:15:59 faziophi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,22 @@ use Apache::lonlocal; use Apache::lonnet; use LONCAPA; + +sub coursepreflink { + 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; +} + ############################################## ############################################## @@ -111,7 +127,7 @@ sub dragmath_button { } my $buttontext=&mt('Edit Math'); return <$help_text + $help_text ENDDRAGMATH } @@ -222,6 +238,9 @@ sub select_recent { unless ($value =~/^error\:/) { my $escaped = &Apache::loncommon::escape_url($value); &Apache::loncommon::inhibit_menu_check(\$escaped); + if ($area eq 'residx') { + next if ((!&Apache::lonnet::allowed('bre',$value)) && (!&Apache::lonnet::allowed('bro',$value))); + } $return.="\n'; @@ -364,7 +383,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 @@ -374,6 +394,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. @@ -393,7 +416,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 = ''; } @@ -401,33 +428,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) { - ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($now); - if (($defhour) || ($defmin) || ($defsec)) { - $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 .= <'.$prefix.'/'; - if (($env{'user.adv'}) | ($env{'user.author'})) { - my $path=$prefix.'/'; - foreach my $dir (split('/',$uri)) { + my $output=''; + $output.=$prefix.'/'; + if (($env{'user.adv'}) || ($env{'user.author'})) { + my $path=$prefix.'/'; + foreach my $dir (split('/',$uri)) { if (! $dir) { next; } $path .= $dir; - if ($path eq $uri) { - if ($skiplast) { - $output.=$dir; + if ($path eq $uri) { + if ($skiplast) { + $output.=$dir; last; - } - } else { - $path.='/'; - } + } + } else { + $path.='/'; + } my $href_path = &HTML::Entities::encode($path,'<>&"'); - &Apache::loncommon::inhibit_menu_check(\$href_path); - if ($form) { - my $href = 'javascript:'.$form.".action='".$href_path."';".$form.'.submit();'; - $output.=qq{$dir/}; - } else { - $output.=qq{$dir/}; - } - } + &Apache::loncommon::inhibit_menu_check(\$href_path); + if ($form) { + my $href = 'javascript:'.$form.".action='".$href_path."';".$form.'.submit();'; + $output.=qq{$dir/}; + } else { + $output.=qq{$dir/}; + } + } } else { - foreach my $dir (split('/',$uri)) { + foreach my $dir (split('/',$uri)) { if (! $dir) { next; } - $output.=$dir.'/'; - } + $output.=$dir.'/'; + } } if ($uri !~ m|/$|) { $output=~s|/$||; } - return $output.''.($noformat?'':'
'); + $output.=''; + + return $output; } # --------------------- A function that generates a window for the spellchecker @@ -1224,11 +1240,19 @@ ENDLINK } sub htmlareaheaders { - return if (&htmlareablocked()); - return if (!&htmlareabrowser()); - return (< -ENDHEADERS + +ENDEDITOR + } + $s.=(< + + +ENDJQUERY + return $s; } # ----------------------------------------------------------------- Preferences @@ -1267,16 +1291,98 @@ sub htmlareaselectactive { my $output='