version 1.164, 2007/09/27 15:36:23
|
version 1.175, 2008/06/01 00:04:39
|
Line 311 The method used to restrict user input w
|
Line 311 The method used to restrict user input w
|
sub date_setter { |
sub date_setter { |
my ($formname,$dname,$currentvalue,$special,$includeempty,$state, |
my ($formname,$dname,$currentvalue,$special,$includeempty,$state, |
$no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_; |
$no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_; |
|
my $now = time; |
my $wasdefined=1; |
my $wasdefined=1; |
if (! defined($state) || $state ne 'disabled') { |
if (! defined($state) || $state ne 'disabled') { |
$state = ''; |
$state = ''; |
Line 319 sub date_setter {
|
Line 320 sub date_setter {
|
$no_hh_mm_ss = 0; |
$no_hh_mm_ss = 0; |
} |
} |
if ($currentvalue eq 'now') { |
if ($currentvalue eq 'now') { |
$currentvalue=time; |
$currentvalue = $now; |
} |
} |
if ((!defined($currentvalue)) || ($currentvalue eq '')) { |
if ((!defined($currentvalue)) || ($currentvalue eq '')) { |
$wasdefined=0; |
$wasdefined=0; |
if ($includeempty) { |
if ($includeempty) { |
$currentvalue = 0; |
$currentvalue = 0; |
} else { |
} else { |
$currentvalue = time; |
$currentvalue = $now; |
} |
} |
} |
} |
# other potentially useful values: wkday,yrday,is_daylight_savings |
# other potentially useful values: wkday,yrday,is_daylight_savings |
|
my $tzname; |
my ($sec,$min,$hour,$mday,$month,$year)=('','',undef,'','',''); |
my ($sec,$min,$hour,$mday,$month,$year)=('','',undef,'','',''); |
if ($currentvalue) { |
if ($currentvalue) { |
($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = |
($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue); |
localtime($currentvalue); |
|
$year += 1900; |
|
} |
} |
unless ($wasdefined) { |
unless ($wasdefined) { |
|
($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($now); |
if (($defhour) || ($defmin) || ($defsec)) { |
if (($defhour) || ($defmin) || ($defsec)) { |
($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = |
|
localtime(time); |
|
$year += 1900; |
|
$sec=($defsec?$defsec:0); |
$sec=($defsec?$defsec:0); |
$min=($defmin?$defmin:0); |
$min=($defmin?$defmin:0); |
$hour=($defhour?$defhour:0); |
$hour=($defhour?$defhour:0); |
Line 463 ENDJS
|
Line 461 ENDJS
|
$cal_link = qq{<a href="javascript:$dname\_opencalendar()">}; |
$cal_link = qq{<a href="javascript:$dname\_opencalendar()">}; |
} |
} |
# |
# |
|
my $tzone = ' '.$tzname.' '; |
if ($no_hh_mm_ss) { |
if ($no_hh_mm_ss) { |
$result .= &mt('[_1] [_2] [_3] ', |
$result .= &mt('[_1] [_2] [_3] ', |
$monthselector,$dayselector,$yearselector); |
$monthselector,$dayselector,$yearselector). |
|
$tzone; |
if (!$nolink) { |
if (!$nolink) { |
$result .= &mt('[_1]Select Date[_2]',$cal_link,'</a>'); |
$result .= &mt('[_1]Select Date[_2]',$cal_link,'</a>'); |
} |
} |
} else { |
} else { |
$result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s ', |
$result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s ', |
$monthselector,$dayselector,$yearselector, |
$monthselector,$dayselector,$yearselector, |
$hourselector,$minuteselector,$secondselector); |
$hourselector,$minuteselector,$secondselector). |
|
$tzone; |
if (!$nolink) { |
if (!$nolink) { |
$result .= &mt('[_1]Select Date[_2]',$cal_link,'</a>'); |
$result .= &mt('[_1]Select Date[_2]',$cal_link,'</a>'); |
} |
} |
Line 481 ENDJS
|
Line 482 ENDJS
|
return $result; |
return $result; |
} |
} |
|
|
|
sub get_timedates { |
|
my ($epoch) = @_; |
|
my $dt = DateTime->from_epoch(epoch => $epoch) |
|
->set_time_zone(&Apache::lonlocal::gettimezone()); |
|
my $tzname = $dt->time_zone_short_name(); |
|
my $sec = $dt->second; |
|
my $min = $dt->minute; |
|
my $hour = $dt->hour; |
|
my $mday = $dt->day; |
|
my $month = $dt->month; |
|
if ($month) { |
|
$month --; |
|
} |
|
my $year = $dt->year; |
|
return ($tzname,$sec,$min,$hour,$mday,$month,$year); |
|
} |
|
|
|
sub build_url { |
|
my ($base, $fields)=@_; |
|
my $url; |
|
$url = $base.'?'; |
|
foreach my $key (keys(%$fields)) { |
|
$url.=&escape($key).'='.&escape($$fields{$key}).'&'; |
|
} |
|
$url =~ s/&$//; |
|
return $url; |
|
} |
|
|
|
|
############################################## |
############################################## |
############################################## |
############################################## |
|
|
Line 549 sub get_date_from_form {
|
Line 579 sub get_date_from_form {
|
if (defined($env{'form.'.$dname.'_month'})) { |
if (defined($env{'form.'.$dname.'_month'})) { |
my $tmpmonth = $env{'form.'.$dname.'_month'}; |
my $tmpmonth = $env{'form.'.$dname.'_month'}; |
if (($tmpmonth =~ /^\d+$/) && ($tmpmonth > 0) && ($tmpmonth < 13)) { |
if (($tmpmonth =~ /^\d+$/) && ($tmpmonth > 0) && ($tmpmonth < 13)) { |
$month = $tmpmonth - 1; |
$month = $tmpmonth; |
} |
} |
} |
} |
if (defined($env{'form.'.$dname.'_year'})) { |
if (defined($env{'form.'.$dname.'_year'})) { |
my $tmpyear = $env{'form.'.$dname.'_year'}; |
my $tmpyear = $env{'form.'.$dname.'_year'}; |
if (($tmpyear =~ /^\d+$/) && ($tmpyear > 1900)) { |
if (($tmpyear =~ /^\d+$/) && ($tmpyear >= 1970)) { |
$year = $tmpyear - 1900; |
$year = $tmpyear; |
} |
} |
} |
} |
if (($year<70) || ($year>137)) { return undef; } |
if (($year<1970) || ($year>2037)) { return undef; } |
if (defined($sec) && defined($min) && defined($hour) && |
if (defined($sec) && defined($min) && defined($hour) && |
defined($day) && defined($month) && defined($year) && |
defined($day) && defined($month) && defined($year)) { |
eval('&timelocal($sec,$min,$hour,$day,$month,$year)')) { |
my $timezone = &Apache::lonlocal::gettimezone(); |
return &timelocal($sec,$min,$hour,$day,$month,$year); |
my $dt = DateTime->new( year => $year, |
|
month => $month, |
|
day => $day, |
|
hour => $hour, |
|
minute => $min, |
|
second => $sec, |
|
time_zone => $timezone, |
|
); |
|
my $epoch_time = $dt->epoch; |
|
if ($epoch_time ne '') { |
|
return $epoch_time; |
|
} else { |
|
return undef; |
|
} |
} else { |
} else { |
return undef; |
return undef; |
} |
} |
Line 632 sub javascript_nothing {
|
Line 675 sub javascript_nothing {
|
############################################## |
############################################## |
############################################## |
############################################## |
sub javascript_docopen { |
sub javascript_docopen { |
|
my ($mimetype) = @_; |
|
$mimetype ||= 'text/html'; |
# safari does not understand document.open() and loads "text/html" |
# safari does not understand document.open() and loads "text/html" |
my $nothing = "''"; |
my $nothing = "''"; |
my $user_browser; |
my $user_browser; |
Line 645 sub javascript_docopen {
|
Line 690 sub javascript_docopen {
|
if ($user_browser eq 'safari' && $user_os =~ 'mac') { |
if ($user_browser eq 'safari' && $user_os =~ 'mac') { |
$nothing = "document.clear()"; |
$nothing = "document.clear()"; |
} else { |
} else { |
$nothing = "document.open('text/html','replace')"; |
$nothing = "document.open('$mimetype','replace')"; |
} |
} |
return $nothing; |
return $nothing; |
} |
} |
Line 682 Returns: a perl string as described.
|
Line 727 Returns: a perl string as described.
|
############################################## |
############################################## |
############################################## |
############################################## |
sub StatusOptions { |
sub StatusOptions { |
my ($status, $formName,$size,$onchange)=@_; |
my ($status, $formName,$size,$onchange,$mult)=@_; |
$size = 1 if (!defined($size)); |
$size = 1 if (!defined($size)); |
if (! defined($status)) { |
if (! defined($status)) { |
$status = 'Active'; |
$status = 'Active'; |
Line 691 sub StatusOptions {
|
Line 736 sub StatusOptions {
|
|
|
my $Str = ''; |
my $Str = ''; |
$Str .= '<select name="Status"'; |
$Str .= '<select name="Status"'; |
|
if (defined($mult)){ |
|
$Str .= ' multiple="multiple" '; |
|
} |
if(defined($formName) && $formName ne '' && ! defined($onchange)) { |
if(defined($formName) && $formName ne '' && ! defined($onchange)) { |
$Str .= ' onchange="document.'.$formName.'.submit()"'; |
$Str .= ' onchange="document.'.$formName.'.submit()"'; |
} |
} |
Line 852 sub Create_PrgWin {
|
Line 900 sub Create_PrgWin {
|
function openpopwin () { |
function openpopwin () { |
popwin=open(\'\',\'popwin\',\'width=400,height=100\');". |
popwin=open(\'\',\'popwin\',\'width=400,height=100\');". |
"popwin.document.writeln(\'".$start_page. |
"popwin.document.writeln(\'".$start_page. |
"<h4>$heading<\/h4>". |
"<h4>".&mt("$heading")."<\/h4>". |
"<form action= \"\" name=\"popremain\" method=\"post\">". |
"<form action= \"\" name=\"popremain\" method=\"post\">". |
'<input type="text" size="'.$width.'" name="remaining" value="'. |
'<input type="text" size="'.$width.'" name="remaining" value="'. |
&mt('Starting').'" /><\\/form>'.$end_page. |
&mt('Starting').'" /><\\/form>'.$end_page. |
Line 871 sub Create_PrgWin {
|
Line 919 sub Create_PrgWin {
|
} |
} |
if (!$inputname) { |
if (!$inputname) { |
$prog_state{'inputname'}=&get_uniq_name(); |
$prog_state{'inputname'}=&get_uniq_name(); |
&r_print($r,$heading.' <input type="text" name="'.$prog_state{'inputname'}. |
&r_print($r,&mt("$heading [_1]",' <input type="text" name="'.$prog_state{'inputname'}.'" size="'.$width.'" />')); |
'" size="'.$width.'" />'); |
|
} else { |
} else { |
$prog_state{'inputname'}=$inputname; |
$prog_state{'inputname'}=$inputname; |
|
|
Line 1085 ENDLINK
|
Line 1132 ENDLINK
|
} |
} |
|
|
sub htmlareaheaders { |
sub htmlareaheaders { |
if (&htmlareablocked()) { return ''; } |
return if (&htmlareablocked()); |
unless (&htmlareabrowser()) { return ''; } |
return if (!&htmlareabrowser()); |
my $lang='en'; |
|
if (&mt('htmlarea_lang') ne 'htmlarea_lang') { |
|
$lang=&mt('htmlarea_lang'); |
|
} |
|
return (<<ENDHEADERS); |
return (<<ENDHEADERS); |
<script type="text/javascript"> |
<script type="text/javascript" src="/fckeditor/fckeditor.js"></script> |
_editor_url='/htmlarea/'; |
|
_editor_lang='$lang'; |
|
</script> |
|
<script type="text/javascript" src="/htmlarea/htmlarea.js"></script> |
|
<link rel="stylesheet" type="text/css" href="/htmlarea/htmlarea.css" /> |
|
ENDHEADERS |
ENDHEADERS |
} |
} |
|
|
# ------------------------------------------------- Activate additional buttons |
|
|
|
sub htmlareaaddbuttons { |
|
if (&htmlareablocked()) { return ''; } |
|
unless (&htmlareabrowser()) { return ''; } |
|
return (<<ENDADDBUTTON); |
|
var config=new HTMLArea.Config(); |
|
config.registerButton('ed_math','LaTeX Inline', |
|
'/htmlarea/images/ed_math.gif',false, |
|
function(editor,id) { |
|
editor.surroundHTML(' <m>\$','\$</m> '); |
|
} |
|
); |
|
config.registerButton('ed_math_eqn','LaTeX Equation', |
|
'/htmlarea/images/ed_math_eqn.gif',false, |
|
function(editor,id) { |
|
editor.surroundHTML( |
|
' \\n<center><m>\\\\[','\\\\]</m></center>\\n '); |
|
} |
|
); |
|
config.toolbar.push(['ed_math','ed_math_eqn']); |
|
ENDADDBUTTON |
|
} |
|
|
|
# ----------------------------------------------------------------- Preferences |
# ----------------------------------------------------------------- Preferences |
|
|
sub disablelink { |
sub disablelink { |
Line 1143 sub enablelink {
|
Line 1157 sub enablelink {
|
return '<a href="'.&HTML::Entities::encode('/adm/preferences?action=set_wysiwyg&wysiwyg=on&returnurl=','<>&"').&escape($ENV{'REQUEST_URI'}).'">'.&mt('Enable WYSIWYG Editor').'</a>'; |
return '<a href="'.&HTML::Entities::encode('/adm/preferences?action=set_wysiwyg&wysiwyg=on&returnurl=','<>&"').&escape($ENV{'REQUEST_URI'}).'">'.&mt('Enable WYSIWYG Editor').'</a>'; |
} |
} |
|
|
|
# ------------------------------------------------- lang to use in html editor |
|
sub htmlarea_lang { |
|
my $lang='en'; |
|
if (&mt('htmlarea_lang') ne 'htmlarea_lang') { |
|
$lang=&mt('htmlarea_lang'); |
|
} |
|
return $lang; |
|
} |
|
|
# ----------------------------------------- Script to activate only some fields |
# ----------------------------------------- Script to activate only some fields |
|
|
sub htmlareaselectactive { |
sub htmlareaselectactive { |
my @fields=@_; |
my @fields=@_; |
unless (&htmlareabrowser()) { return ''; } |
unless (&htmlareabrowser()) { return ''; } |
if (&htmlareablocked()) { return '<br />'.&enablelink(@fields); } |
if (&htmlareablocked()) { return '<br />'.&enablelink(@fields); } |
my $output='<script type="text/javascript" defer="1">'. |
my $output='<script type="text/javascript" defer="1">'; |
&htmlareaaddbuttons(); |
my $lang = &htmlarea_lang(); |
foreach(@fields) { |
foreach my $field (@fields) { |
$output.="\nHTMLArea.replace('$_',config);"; |
$output.=" |
|
{ |
|
var oFCKeditor = new FCKeditor('$field'); |
|
oFCKeditor.Config['CustomConfigurationsPath'] = |
|
'/fckeditor/loncapaconfig.js'; |
|
oFCKeditor.ReplaceTextarea(); |
|
oFCKeditor.Config['AutoDetectLanguage'] = false; |
|
oFCKeditor.Config['DefaultLanguage'] = '$lang'; |
|
}"; |
} |
} |
$output.="\nwindow.status='Activated Editfields';\n</script><br />". |
$output.="\nwindow.status='Activated Editfields';\n</script><br />". |
&disablelink(@fields); |
&disablelink(@fields); |
Line 1234 returns: nothing
|
Line 1265 returns: nothing
|
if (!defined($menulink)) { $menulink=1; } |
if (!defined($menulink)) { $menulink=1; } |
if ($menulink) { |
if ($menulink) { |
my $description = 'Menu'; |
my $description = 'Menu'; |
|
my $no_mt_descr = 0; |
if (exists($env{'request.course.id'}) && |
if (exists($env{'request.course.id'}) && |
$env{'request.course.id'} ne '') { |
$env{'request.course.id'} ne '') { |
$description = |
$description = |
$env{'course.'.$env{'request.course.id'}.'.description'}; |
$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
$no_mt_descr = 1; |
} |
} |
unshift(@Crumbs,{ |
unshift(@Crumbs,{ |
href =>'/adm/menu', |
href =>'/adm/menu', |
title =>'Go to main menu', |
title =>'Go to main menu', |
target =>'_top', |
target =>'_top', |
text =>$description, |
text =>$description, |
|
no_mt =>$no_mt_descr, |
}); |
}); |
} |
} |
my $links .= |
my $links .= |
Line 1333 returns: nothing
|
Line 1367 returns: nothing
|
# row1 |
# row1 |
# row2 |
# row2 |
# row3 ... etc. |
# row3 ... etc. |
# &submit_row(0 |
# &submit_row() |
# &end_pick_box() |
# &end_pick_box() |
# |
# |
# where row1, row 2 etc. are chosen from &role_select_row,&course_select_row, |
# where row1, row 2 etc. are chosen from &role_select_row,&course_select_row, |
Line 1403 sub row_title {
|
Line 1437 sub row_title {
|
$css_value_class ||= 'LC_pick_box_value'; |
$css_value_class ||= 'LC_pick_box_value'; |
$css_value_class = 'class="'.$css_value_class.'"'; |
$css_value_class = 'class="'.$css_value_class.'"'; |
|
|
|
if ($title ne '') { |
|
$title .= ':'; |
|
} |
my $output = <<"ENDONE"; |
my $output = <<"ENDONE"; |
<tr class="LC_pick_box_row"> |
<tr class="LC_pick_box_row"> |
<td $css_title_class> |
<td $css_title_class> |
$title: |
$title |
</td> |
</td> |
<td $css_value_class> |
<td $css_value_class> |
ENDONE |
ENDONE |
Line 1473 sub course_select_row {
|
Line 1510 sub course_select_row {
|
my ($title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles, |
my ($title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles, |
$css_class) = @_; |
$css_class) = @_; |
my $output = &row_title($title,$css_class); |
my $output = &row_title($title,$css_class); |
$output .= qq| |
$output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles); |
|
$output .= &row_closure(); |
|
return $output; |
|
} |
|
|
|
sub course_selection { |
|
my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_; |
|
my $output = qq| |
<script type="text/javascript"> |
<script type="text/javascript"> |
function coursePick (formname) { |
function coursePick (formname) { |
for (var i=0; i<formname.coursepick.length; i++) { |
for (var i=0; i<formname.coursepick.length; i++) { |
Line 1546 sub course_select_row {
|
Line 1590 sub course_select_row {
|
$output .= '</tr></table><br />'; |
$output .= '</tr></table><br />'; |
} |
} |
} |
} |
$output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."'".','."'".'dccourse'."'".','."'".'dcdomain'."'".','."'".'coursedesc'."','','1'".')" />'.&mt('Pick specific course(s):').' '.$courseform.' <input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br />'."\n"; |
$output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."','dccourse','dcdomain','coursedesc','','1'".')" />'.&mt('Pick specific course(s):').' '.$courseform.' <input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br />'."\n"; |
$output .= &row_closure(); |
|
return $output; |
return $output; |
} |
} |
|
|