--- loncom/interface/loncommon.pm 2008/08/28 03:04:41 1.675
+++ loncom/interface/loncommon.pm 2008/11/28 18:18:39 1.697
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.675 2008/08/28 03:04:41 raeburn Exp $
+# $Id: loncommon.pm,v 1.697 2008/11/28 18:18:39 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,6 +61,7 @@ use POSIX qw(strftime mktime);
use Apache::lonmenu();
use Apache::lonenc();
use Apache::lonlocal;
+use Apache::lonnet();
use HTML::Entities;
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
@@ -68,6 +69,7 @@ use Apache::lontexconvert();
use Apache::lonclonecourse();
use LONCAPA qw(:DEFAULT :match);
use DateTime::TimeZone;
+use DateTime::Locale::Catalog;
# ---------------------------------------------- Designs
use vars qw(%defaultdesign);
@@ -657,6 +659,57 @@ sub select_timezone {
return $output;
}
+sub select_datelocale {
+ my ($name,$selected,$onchange,$includeempty)=@_;
+ my $output='";
+ return $output;
+}
+
=pod
=item * &linked_select_forms(...)
@@ -873,7 +926,7 @@ sub help_open_topic {
if ($text ne "") {
$template .=
"
".
- "$text";
+ " | $text";
}
# Add the graphic
@@ -882,7 +935,7 @@ sub help_open_topic {
$template .= <<"ENDTEMPLATE";
ENDTEMPLATE
- if ($text ne '') { $template.=' |
' };
+ if ($text ne '') { $template.='' };
return $template;
}
@@ -1507,9 +1560,9 @@ sub create_text_file {
$fh = Apache::File->new('>/home/httpd'.$filename);
if (! defined($fh)) {
$r->log_error("Couldn't open $filename for output $!");
- $r->print("Problems occured in creating the output file. ".
- "This error has been logged. ".
- "Please alert your LON-CAPA administrator.");
+ $r->print(&mt('Problems occurred in creating the output file. '
+ .'This error has been logged. '
+ .'Please alert your LON-CAPA administrator.'));
}
return ($fh,$filename)
}
@@ -2945,7 +2998,7 @@ sub fileextensions {
sub display_languages {
my %languages=();
- foreach my $lang (&preferred_languages()) {
+ foreach my $lang (&Apache::lonlocal::preferred_languages()) {
$languages{$lang}=1;
}
&get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
@@ -2957,54 +3010,9 @@ sub display_languages {
return %languages;
}
-sub preferred_languages {
- my @languages=();
- if (($env{'request.role.adv'}) && ($env{'form.languages'})) {
- @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$env{'form.languages'}));
- }
- if ($env{'course.'.$env{'request.course.id'}.'.languages'}) {
- @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,
- $env{'course.'.$env{'request.course.id'}.'.languages'}));
- }
-
- if ($env{'environment.languages'}) {
- @languages=(@languages,
- split(/\s*(\,|\;|\:)\s*/,$env{'environment.languages'}));
- }
- my $browser=$ENV{'HTTP_ACCEPT_LANGUAGE'};
- if ($browser) {
- my @browser =
- map { (split(/\s*;\s*/,$_))[0] } (split(/\s*,\s*/,$browser));
- push(@languages,@browser);
- }
-
- foreach my $domtype ($env{'user.domain'},$env{'request.role.domain'},
- $Apache::lonnet::perlvar{'lonDefDomain'}) {
- if ($domtype ne '') {
- my %domdefs = &Apache::lonnet::get_domain_defaults($domtype);
- if ($domdefs{'lang_def'} ne '') {
- push(@languages,$domdefs{'lang_def'});
- }
- }
- }
-# turn "en-ca" into "en-ca,en"
- my @genlanguages;
- foreach my $lang (@languages) {
- unless ($lang=~/\w/) { next; }
- push(@genlanguages,$lang);
- if ($lang=~/(\-|\_)/) {
- push(@genlanguages,(split(/(\-|\_)/,$lang))[0]);
- }
- }
- #uniqueify the languages list
- my %count;
- @genlanguages = map { $count{$_}++ == 0 ? $_ : () } @genlanguages;
- return @genlanguages;
-}
-
sub languages {
my ($possible_langs) = @_;
- my @preferred_langs = &preferred_languages();
+ my @preferred_langs = &Apache::lonlocal::preferred_languages();
if (!ref($possible_langs)) {
if( wantarray ) {
return @preferred_langs;
@@ -3348,16 +3356,21 @@ sub pprmlink {
sub timehash {
- my @ltime=localtime(shift);
- return ( 'seconds' => $ltime[0],
- 'minutes' => $ltime[1],
- 'hours' => $ltime[2],
- 'day' => $ltime[3],
- 'month' => $ltime[4]+1,
- 'year' => $ltime[5]+1900,
- 'weekday' => $ltime[6],
- 'dayyear' => $ltime[7]+1,
- 'dlsav' => $ltime[8] );
+ my ($thistime) = @_;
+ my $timezone = &Apache::lonlocal::gettimezone();
+ my $dt = DateTime->from_epoch(epoch => $thistime)
+ ->set_time_zone($timezone);
+ my $wday = $dt->day_of_week();
+ if ($wday == 7) { $wday = 0; }
+ return ( 'second' => $dt->second(),
+ 'minute' => $dt->minute(),
+ 'hour' => $dt->hour(),
+ 'day' => $dt->day_of_month(),
+ 'month' => $dt->month(),
+ 'year' => $dt->year(),
+ 'weekday' => $wday,
+ 'dayyear' => $dt->day_of_year(),
+ 'dlsav' => $dt->is_dst() );
}
sub utc_string {
@@ -3367,6 +3380,24 @@ sub utc_string {
sub maketime {
my %th=@_;
+ my ($epoch_time,$timezone,$dt);
+ $timezone = &Apache::lonlocal::gettimezone();
+ eval {
+ $dt = DateTime->new( year => $th{'year'},
+ month => $th{'month'},
+ day => $th{'day'},
+ hour => $th{'hour'},
+ minute => $th{'minute'},
+ second => $th{'second'},
+ time_zone => $timezone,
+ );
+ };
+ if (!$@) {
+ $epoch_time = $dt->epoch;
+ if ($epoch_time) {
+ return $epoch_time;
+ }
+ }
return POSIX::mktime(
($th{'seconds'},$th{'minutes'},$th{'hours'},
$th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,-1));
@@ -3747,6 +3778,60 @@ sub blocking_status {
###############################################
+sub check_ip_acc {
+ my ($acc)=@_;
+ &Apache::lonxml::debug("acc is $acc");
+ if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) {
+ return 1;
+ }
+ my $allowed=0;
+ my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'};
+
+ my $name;
+ foreach my $pattern (split(',',$acc)) {
+ $pattern =~ s/^\s*//;
+ $pattern =~ s/\s*$//;
+ if ($pattern =~ /\*$/) {
+ #35.8.*
+ $pattern=~s/\*//;
+ if ($ip =~ /^\Q$pattern\E/) { $allowed=1; }
+ } elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) {
+ #35.8.3.[34-56]
+ my $low=$2;
+ my $high=$3;
+ $pattern=$1;
+ if ($ip =~ /^\Q$pattern\E/) {
+ my $last=(split(/\./,$ip))[3];
+ if ($last <=$high && $last >=$low) { $allowed=1; }
+ }
+ } elsif ($pattern =~ /^\*/) {
+ #*.msu.edu
+ $pattern=~s/\*//;
+ if (!defined($name)) {
+ use Socket;
+ my $netaddr=inet_aton($ip);
+ ($name)=gethostbyaddr($netaddr,AF_INET);
+ }
+ if ($name =~ /\Q$pattern\E$/i) { $allowed=1; }
+ } elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) {
+ #127.0.0.1
+ if ($ip =~ /^\Q$pattern\E/) { $allowed=1; }
+ } else {
+ #some.name.com
+ if (!defined($name)) {
+ use Socket;
+ my $netaddr=inet_aton($ip);
+ ($name)=gethostbyaddr($netaddr,AF_INET);
+ }
+ if ($name =~ /\Q$pattern\E$/i) { $allowed=1; }
+ }
+ if ($allowed) { last; }
+ }
+ return $allowed;
+}
+
+###############################################
+
=pod
=head1 Domain Template Functions
@@ -4493,7 +4578,6 @@ table.LC_docs_path td.LC_docs_path_compo
td.LC_table_cell_checkbox {
text-align: center;
}
-
table#LC_mainmenu td.LC_mainmenu_column {
vertical-align: top;
}
@@ -4507,7 +4591,7 @@ table#LC_mainmenu td.LC_mainmenu_column
.LC_menubuttons_link {
text-decoration: none;
}
-
+#2008--9-5: new menu style sheet.Changed category
.LC_menubuttons_category {
color: $font;
background: $pgbg;
@@ -4735,24 +4819,6 @@ table.LC_mail_list tr.LC_mail_even {
table.LC_mail_list tr.LC_mail_odd {
}
-
-table#LC_portfolio_actions {
- width: auto;
- background: $pgbg;
- border: 0px;
- border-spacing: 2px 2px;
- padding: 0px;
- margin: 0px;
- border-collapse: separate;
-}
-table#LC_portfolio_actions td.LC_label {
- background: $tabbg;
- text-align: right;
-}
-table#LC_portfolio_actions td.LC_value {
- background: $tabbg;
-}
-
table#LC_cstr_controls {
width: 100%;
border-collapse: collapse;
@@ -4771,33 +4837,25 @@ table#LC_cstr_controls tr th {
font-size: smaller;
}
-table#LC_browser {
-
-}
-table#LC_browser tr th {
- background: $table_header;
-}
-table#LC_browser tr td {
- padding: 2px;
-}
-table#LC_browser tr.LC_browser_file,
-table#LC_browser tr.LC_browser_file_published {
+table.LC_data_table tr > td.LC_browser_file,
+table.LC_data_table tr > td.LC_browser_file_published {
background: #CCFF88;
}
-table#LC_browser tr.LC_browser_file_locked,
-table#LC_browser tr.LC_browser_file_unpublished {
+table.LC_data_table tr > td.LC_browser_file_locked,
+table.LC_data_table tr > td.LC_browser_file_unpublished {
background: #FFAA99;
}
-table#LC_browser tr.LC_browser_file_obsolete {
+table.LC_data_table tr > td.LC_browser_file_obsolete {
background: #AAAAAA;
}
-table#LC_browser tr.LC_browser_file_modified,
-table#LC_browser tr.LC_browser_file_metamodified {
+table.LC_data_table tr > td.LC_browser_file_modified,
+table.LC_data_table tr > td.LC_browser_file_metamodified {
background: #FFFF77;
}
-table#LC_browser tr.LC_browser_folder {
+table.LC_data_table tr.LC_browser_folder > td {
background: #CCCCFF;
}
+
span.LC_current_location {
font-size: x-large;
background: $pgbg;
@@ -5360,6 +5418,357 @@ hr.LC_edit_problem_divide {
height: 3px;
border: 0px;
}
+img.stift{
+ border-width:0;
+ vertical-align:middle;
+}
+
+table#LC_mainmenu{
+ margin-top:10px;
+ width:80%;
+
+}
+
+table#LC_mainmenu td.LC_mainmenu_col_fieldset{
+ vertical-align: top;
+ width: 45%;
+}
+.LC_mainmenu_fieldset_category {
+ color: $font;
+ background: $pgbg;
+ font-family: $sans;
+ font-size: small;
+ font-weight: bold;
+}
+fieldset#LC_mainmenu_fieldset {
+ margin:0px 10px 10px 0px;
+
+}
+/* ---- Remove when done ----
+# The following styles is part of the redesign of LON-CAPA and are
+# subject to change during this project.
+# Don't rely on their current functionality as they might be
+# changed or removed.
+# --------------------------*/
+
+
+body {
+ font-family: Tahoma, Arial,Helvetica,sans-serif;
+ font-size: 0.85em;
+ line-height: 130%;
+ color: RGB(45, 45, 45);
+}
+
+a:link,a:visited {
+ /*color: RGB(0, 118, 127);*/
+ /*text-decoration: underline;*/
+}
+
+a:hover{
+ text-decoration:none;
+}
+/*a:hover,
+UL.smallMenu A:hover,
+UL.MenuBreadcrumbs A:hover,
+UL#TabMainMenuContent A:hover{
+ color: rgb(200, 10, 50);
+}*/
+
+h1 {
+ padding:5px 10px 5px 20px;
+ line-height:130%;
+}
+h2,h4,h6 {
+ /*color: RGB(0, 118, 127);*/
+}
+h2,h3,h4,h5,h6
+{
+margin:5px 0px 5px 0px;
+line-height:130%;
+}
+
+.right {
+ text-align: right;
+}
+
+.center {
+ text-align: center;
+}
+
+.left {
+ text-align: left;
+}
+
+
+.HeadRight {
+ text-align: right;
+ float: right;
+ margin: 0px;
+ padding: 0px;
+ right:0;
+ position:absolute;
+}
+
+img {
+/* border: 0px; */
+}
+
+.personalBgColor {
+ background: RGB(237, 239, 0) url(images/headHighlight.png) repeat-y left top;
+}
+
+p {
+ padding: 10px;
+}
+DL,UL,Div,Fieldset {
+ /*margin: 10px;*/
+ overflow:hidden;
+}
+OL.smallMenu {
+ margin: 0px 0px 0px 0px;
+}
+
+OL.smallMenu li {
+ display: inline;
+ padding: 5px 5px 0px 10px;
+ vertical-align: top;
+}
+
+OL.smallMenu li img {
+ vertical-align: bottom;
+}
+
+OL.smallMenu A {
+ font-size: 90%;
+ color: RGB(80, 80, 80);
+ text-decoration: none;
+}
+
+OL#TabMainMenuContent {
+
+ margin: 0px 0px 10px 0px;
+ padding: 0px;
+}
+
+OL#TabMainMenuContent LI {
+ display: inline;
+ vertical-align: bottom;
+ border-bottom: solid 1px RGB(175, 175, 175);
+ border-right: solid 1px RGB(175, 175, 175);
+ padding: 5px 15px 5px 15px;
+ margin-right:4px;
+ line-height: 140%;
+ font-weight: bold;
+ overflow:hidden;
+ background: RGB(211, 206, 205) URL(images/TabMenuBG.png) repeat-x left top;
+}
+
+OL#TabMainMenuContent LI A {
+ color: RGB(47, 47, 47);
+ text-decoration: none;
+}
+
+OL#TabMainMenuContent DIV.columnSection {
+ margin-bottom: 0px;
+}
+
+OL#MenuBreadcrumbs {
+ border-top: solid 1px RGB(255, 255, 255);
+ height: 20px;
+ line-height: 20px;
+ vertical-align: bottom;
+ margin: 0px 0px 30px 0px;
+ padding-left: 10px;
+ list-style-position: inside;
+ background: RGB(211, 206, 205) URL(images/TabMenuBG.png) repeat-x left
+ top;
+}
+
+OL#MenuBreadcrumbs li {
+ background: url(images/pfeil_white.png) no-repeat left center;
+ display: inline;
+ padding: 0px 0px 0px 10px;
+ vertical-align: bottom;
+ overflow:hidden;
+}
+
+OL#MenuBreadcrumbs LI A {
+ text-decoration: none;
+ font-size:90%;
+}
+
+h4.hcell {
+ padding: 3px 10px 3px 10px;
+ margin: 0px;
+ background: RGB(0, 118, 127);
+ color: white;
+ border: outset 1px;
+}
+
+DIV.DivContentBoxSpecial
+{
+ border: solid 1px RGB(100, 100, 100);
+}
+
+FIELDSET
+{
+ /*width:78%;*/
+}
+DIV.DivContentBox,
+DIV.DivContentBoxSpecial {
+ width: 80%;
+ margin:10px;
+}
+
+FIELDSET legend,DL DT {
+ font-weight: bold;
+ font-size: 110%;
+ /*padding-left: 0px;*/
+/* margin-left: 0px;*/
+}
+
+DIV.DivImportant {
+ background: url(images/important.png) no-repeat center top;
+ padding: 100px 10px 10px 10px;
+ width: 200px;
+ border: double 4px RGB(200, 200, 200);
+}
+
+
+
+DL.ListStyleClean DT {
+ padding-right: 5px;
+ display: table-header-group;
+}
+
+DL.ListStyleClean DD {
+ display: table-row;
+}
+
+.ListStyleClean,
+.ListStyleSimple,
+.ListStyleNormal,
+.ListStyleNormal_Border,
+.ListStyleSpecial
+ {
+ /*display:block; */
+ width: 400px;
+ list-style-position: inside;
+ list-style-type: none;
+ overflow: hidden;
+ padding: 0px;
+}
+
+.ListStyleClean li,
+.ListStyleSimple li,
+.ListStyleSimple DD,
+.ListStyleNormal li,
+.ListStyleNormal DD,
+.ListStyleSpecial li,
+.ListStyleSpecial DD
+ {
+ margin: 0px;
+ padding: 5px 5px 5px 10px;
+ clear: both;
+ /*display:block;*/
+}
+
+.ListStyleClean LI,
+.ListStyleClean DD {
+ padding-top: 0px;
+ padding-bottom: 0px;
+}
+
+.ListStyleSimple DD,
+.ListStyleSimple LI{
+ border-bottom: solid 1px RGB(150, 150, 150);
+}
+
+.ListStyleSpecial LI,
+.ListStyleSpecial DD {
+ list-style-type: none;
+ background-color: RGB(220, 220, 220);
+ margin-bottom: 4px;
+}
+
+table.SimpleTable *{
+ padding:10px;
+ }
+
+table.SimpleTable td {
+ vertical-align:top;
+ border:solid 1px RGB(210,210,210);
+}
+table.SimpleTable thead{
+ background:rgb(210,210,210);
+}
+
+DIV.columnSection {
+ display: block;
+ clear: both;
+ overflow: hidden;
+ margin:0px;
+}
+
+DIV.columnSection>* {
+ float: left;
+ margin: 10px 20px 10px 0px;
+ overflow:hidden;
+}
+
+DIV.columnSection>FIELDSET,
+DIV.columnSection>DIV.DivContentBox,
+DIV.columnSection>DIV.DivContentBoxSpecial
+ {
+ width: 480px;
+
+}
+
+.LC_loginpage_container {
+ text-align:left;
+ margin : 0 auto;
+ width:65%;
+ padding: 10px;
+ height: auto;
+ background-color:#FFFFFF;
+ border:1px solid #CCCCCC;
+}
+
+
+.LC_loginpage_loginContainer {
+ float:left;
+ width:60%;
+}
+
+.LC_loginpage_loginInfo {
+ margin-top:20px;
+ margin-left:20px;
+ float:left;
+ width:30%;
+ border:1px solid #CCCCCC;
+ padding:10px;
+}
+
+.LC_loginpage_space {
+ clear:both;
+ margin-bottom:20px;
+ border-bottom: 1px solid #CCCCCC;
+}
+
+.LC_loginpage_fieldset{
+ border: 1px solid #CCCCCC;
+ margin: 0 auto;
+}
+
+.LC_loginpage_legend{
+ padding: 2px;
+ margin: 0px;
+ font-size:14px;
+ font-weight:bold;
+}
+
+
+
END
}
@@ -7547,7 +7956,7 @@ sub csv_print_select_table {
&end_data_table_header_row()."\n");
foreach my $array_ref (@$d) {
my ($value,$display,$defaultcol)=@{ $array_ref };
- $r->print(&start_data_table_row().''.$display.' | ');
+ $r->print(&start_data_table_row().''.$display.' | ');
$r->print(' |