CheckConfig($arCallFunction, $arCallArgs) && $this->CheckLogin("read")) { if (!$PHP_SELF) { global $PHP_SELF; } function AddSpan($from, $to) { global $ARCurrent; debug("pcalendar/day.html:addspan($from,$to)","class"); // always return lowest possible number to span the time. $i=0; $spannumber=-1; while ($spannumber==-1) { if ($ARCurrent->spanlist[$i]) { // existing spanlevel $last=0; $temp=$ARCurrent->spanlist[$i]; ksort($temp); while (list($start, $end)=each($temp)) { if (($start>=$to) && ($last<=$from)) { $ARCurrent->spanlist[$i][$from]=$to; $spannumber=$i; break; } if ($end) { $last=$end; } } if ($last && $last<=$from) { $ARCurrent->spanlist[$i][$from]=$to; $spannumber=$i; } } else { // new spanlevel $ARCurrent->spanlist[$i][$from]=$to; $spannumber=$i; $ARCurrent->totalspan=$i; } $i++; } return $spannumber; } function AddTime($from, $to, $priority, $path="", $name="", $summary="") { /* add an item to the ARCurrent->timelist. arguments: $from, $to: int - unix timestamp if $from>$to -> no time! date only item if $from==$to -> no timespan, just a reminder or something, don't add a span else -> timespan, add item, add end timemarker, add span */ global $ARCurrent, $PHP_SELF; debug("pcalendar/day.html:AddTime($from, $to, $path, $name, $summary)","class"); if ($from>$to) { // 'no time' entry. pile at ARCurrent->timelist[0], no span, no start, no end time. $i=@count($ARCurrent->timelist[0]); if ($path) { $ARCurrent->timelist[0][$i]["text"]="date."&arReturnPage=". RawUrlEncode($PHP_SELF."?date=".$ARCurrent->date)."\">$name"; } $ARCurrent->timelist[0][$i]["summary"]=$summary; $ARCurrent->timelist[0][$i]["priority"]=$priority; } else if ($from==$to) { // no span, no end time. $i=@count($ARCurrent->timelist[$from]); if ($i && !$ARCurrent->timelist[$from][$i-1]["text"]) { // There already is an entry in the ARCurrent->timelist from $from, but // there's no text -> it's an 'end time' ($to). Use it instead. $i--; } if (!$i || $path) { // new entry // if !$i then add regardless wether there's no text // no path means this item is a time marker only. // if $path then add at $i, in previous if statement $i already set // to the 'time marker'. if ($path) { $ARCurrent->timelist[$from][$i]["text"]="date."&arReturnPage=". RawUrlEncode($PHP_SELF."?date=".$ARCurrent->date)."\">$name"; } $ARCurrent->timelist[$from][$i]["summary"]=$summary; $ARCurrent->timelist[$from][$i]["priority"]=$priority; } } else { // normal entry, start time, end time, span $spannumber=AddSpan($from, $to); $i=@count($ARCurrent->timelist[$from]); if ($i && !$ARCurrent->timelist[$from][$i-1]["text"]) { // There already is an entry in the ARCurrent->timelist from $from, but // there's no text -> it's an 'end time' ($to). Use it instead. $i--; } if ($ARCurrent->timelist[$from][$i]["span"][$spannumber]=="close") { $ARCurrent->timelist[$from][$i]["span"][$spannumber]="close_open"; } else { $ARCurrent->timelist[$from][$i]["span"][$spannumber]="open"; } if ($path) { $ARCurrent->timelist[$from][$i]["text"]="date."&arReturnPage=". RawUrlEncode($PHP_SELF."?date=".$ARCurrent->date)."\">$name"; } $ARCurrent->timelist[$from][$i]["summary"]=$summary; $ARCurrent->timelist[$from][$i]["priority"]=$priority; $i=@count($ARCurrent->timelist[$to]); if ($i) { // && !$ARCurrent->timelist[$to][$i-1]["text"]) { $i--; } if ($ARCurrent->timelist[$to][$i]["span"][$spannumber]=="open") { $ARCurrent->timelist[$to][$i]["span"][$spannumber]="close_open"; } else { $ARCurrent->timelist[$to][$i]["span"][$spannumber]="close"; } } } if (!$date) { $date=time(); } $ARCurrent->date=$date; $date_arr=getdate($date); $start=mktime(0,0,0,$date_arr["mon"],$date_arr["mday"],$date_arr["year"])-2; $end=mktime(0,0,0,$date_arr["mon"],$date_arr["mday"]+1,$date_arr["year"])-3; // prepopulate ARCurrent->timelist with all hours from 8:00 to 18:00 for ($i=8; $i<19; $i++) { $hour=mktime($i,0,0,$date_arr["mon"],$date_arr["mday"],$date_arr["year"]); AddTime($hour, $hour, 0); } // if no_time is set, endtime is starttime - 1 second. if starttime is 0:0h // then endtime will be in the previous day! thus the -2 and -3 above. unset($ARBeenHere["populate"]); $this->populate($start, $end, $data->min_priority["day"], "system.add.time.phtml","from=$start&to=$end"); // ayatem.add.time.phtml calls AddTime, obviously :) // now display the list ?> >
">< ">>
totalspan; $i++) { $span[$i]="blank"; } ksort($ARCurrent->timelist); $open=0; $dottedline="\n"; while (list($from,$items)=@each($ARCurrent->timelist)) { $from_fmt=strftime("%H:%M",$from); while (list($key, $item)=@each($items)) { $change=0; $row=""; // now check spans; if ($item["span"] && is_array($item["span"])) { end($item["span"]); if (key($item["span"])>$levels) { $levels=key($item["span"]); } } $row.="\n"; $row.="\n"; $row.=$dottedline; if (!(!$change && $open) || ($item["text"])) { echo $row; if ($item["summary"] && ($item["priority"]>=$data->min_priority["month"])) { echo "\n"; echo $dottedline; } } } } ?>
dir->images."calendar/dots.gif\">dir->images."dot.gif\" height=\"1\" width=\"1\">
"; for ($i=0; $i<=$ARCurrent->totalspan; $i++) { $row.="dir->images."calendar/span"; $action=$item["span"][$i]; switch ($action) { case "open" : $span[$i]=""; $display="open"; $open++; $change++; break; case "close" : $span[$i]="blank"; $display="close"; $open--; $change++; break; case "close_open" : $span[$i]=""; $display="close_open"; $change++; break; default : $display=$span[$i]; break; } $row.=$display.".gif\" alt=\"\" width=\"5\" height=\"100%\">"; } $row.=""; // now display time if ($from) { // notime items dont display the time $row.=""; $row.="store->root.$this->path."classic.new.phtml?arNewType=pcalitem&". "arNewFilename={5:id}&starttime=$from&next=form&". "arReturnPage=".RawUrlEncode($PHP_SELF."?date=$date"). "\">$from_fmt"; $row.=""; } $row.="dir->images."dot.gif\" width=\"1\" height=\"17\">"; // now display text $row.=""; $row.=$item["text"]; $row.=""; $row.="
"; for ($i=0; $i<=$ARCurrent->totalspan; $i++) { echo "dir->images."calendar/span".$span[$i].".gif\" width=\"5\" height=\"100%\" alt=\"\">"; } echo "dir->images."dot.gif\" width=\"1\" height=\"17\">"; echo "".$item["summary"].""; echo "