-
+
ENDFORM
}
@@ -142,11 +142,11 @@ sub emptycell {
sub normalcell {
my ($day,$month,$year,$text)=@_;
my $output='';
- foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
- if ($_) {
+ my @items=&order($text);
+ foreach my $item (@items) {
+ if ($item) {
my $internalflag=0;
- my ($courseid,$start,$end,@msg)=split(/\@/,$_);
- my $msg=join('@',@msg);
+ my ($courseid,$start,$end,$msg)=split(/\@/,$item,4);
if ($msg=~/INTERNAL\:/) {
$msg=~s/INTERNAL\://gs;
$internalflag=1;
@@ -184,10 +184,10 @@ sub normalcell {
sub plaincell {
my ($text)=@_;
my $output='';
- foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
- if ($_) {
- my ($courseid,$start,$end,@msg)=split(/\@/,$_);
- my $msg=join('@',@msg);
+ my @items=&order($text);
+ foreach my $item (@items) {
+ if ($item) {
+ my ($courseid,$start,$end,$msg)=split(/\@/,$item,4);
my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
'\n'.&Apache::lonlocal::locallocaltime($start);
if ($start!=$end) {
@@ -208,10 +208,10 @@ sub plaincell {
sub listcell {
my ($text)=@_;
my $output='';
- foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
- if ($_) {
- my ($courseid,$start,$end,@msg)=split(/\@/,$_);
- my $msg=join('@',@msg);
+ my @items=&order($text);
+ foreach my $item (@items) {
+ if ($item) {
+ my ($courseid,$start,$end,$msg)=split(/\@/,$item,4);
$msg=~s/INTERNAL\://gs;
my $fullmsg=&Apache::lonlocal::locallocaltime($start);
if ($start!=$end) {
@@ -226,6 +226,19 @@ sub listcell {
return $output;
}
+sub order {
+ my ($text)=@_;
+ my @items = split(/___&&&___/,$text);
+ sort {
+ my (undef,$astart,$aend)=split(/\@/,$a);
+ my (undef,$bstart,$bend)=split(/\@/,$b);
+ if ($astart != $bstart) {
+ return $astart <=> $bstart;
+ }
+ return $aend <=> $bend;
+ } @items;
+}
+
sub nextday {
my %th=@_;
$th{'day'}++;
@@ -242,11 +255,11 @@ sub showday {
$tk-=$oneday;
$nextday+=$oneday;
}
- foreach (keys %allcal) {
- my ($course,$startdate,$enddate)=($_=~/^(\w+)\@(\d+)\_(\d+)$/);
- if (($startdate<$nextday) && ($enddate>$tk)) {
+ foreach my $item (keys(%allcal)) {
+ my ($course,$startdate,$enddate)=($item=~/^(\w+)\@(\d+)\_(\d+)$/);
+ if (($startdate<$nextday) && ($enddate>=$tk)) {
$outp.='___&&&___'.$course.'@'.$startdate.'@'.$enddate.'@'.
- $allcal{$_};
+ $allcal{$item};
}
}
unless ($mode) {