Пример #1
0
 private static function postParseAgendaRecord($thisevent)
 {
     // ------------------------------------------
     // -- 1. First adjust elements of $thisevent
     // ------------------------------------------
     // -- sanitize elements 'speaker' and 'speakerhome' (for seminars, not used for conferences)
     //    output: $thisevent["speakers"] = array("fullname","av_institute","av_salutation")
     $stmp = array();
     if (isset($thisevent["speaker"])) {
         $thisevent["speaker"] = str_replace(" and ", ", ", $thisevent["speaker"]);
         $thisevent["speaker"] = str_replace(" ", " ", $thisevent["speaker"]);
         $thisevent["speaker"] = str_replace(", ", ", ", $thisevent["speaker"]);
         $thisevent["speaker"] = str_replace(" & ", ", ", $thisevent["speaker"]);
         $stmp["nw_fullname"] = $thisevent["speaker"];
         unset($thisevent["speaker"]);
     }
     if (isset($thisevent["speakerhome"])) {
         $thisevent["speakerhome"] = str_replace("University", "U.", $thisevent["speakerhome"]);
         $stmp["av_institute"] = trim($thisevent["speakerhome"]);
         unset($thisevent["speakerhome"]);
     }
     if (!empty($stmp)) {
         $stmp["av_salutation"] = "";
     }
     if (!empty($stmp)) {
         $thisevent["speakers"][] = $stmp;
     }
     // -- standardize labels for element 'registrants'
     if (isset($thisevent["registrant"]) && is_array($thisevent["registrant"])) {
         foreach ($thisevent["registrant"] as $key => $reg) {
             if (isset($thisevent["registrant"][$key]["familyname"])) {
                 $thisevent["registrant"][$key]["av_lastname"] = $thisevent["registrant"][$key]["familyname"];
                 unset($thisevent["registrant"][$key]["familyname"]);
             }
             if (isset($thisevent["registrant"][$key]["firstname"])) {
                 $thisevent["registrant"][$key]["av_firstname"] = $thisevent["registrant"][$key]["firstname"];
                 unset($thisevent["registrant"][$key]["firstname"]);
             }
             if (isset($thisevent["registrant"][$key]["salutation"])) {
                 $thisevent["registrant"][$key]["av_salutation"] = $thisevent["registrant"][$key]["salutation"];
                 unset($thisevent["registrant"][$key]["salutation"]);
             }
             if (isset($thisevent["registrant"][$key]["institution"])) {
                 $thisevent["registrant"][$key]["av_institute"] = $thisevent["registrant"][$key]["institution"];
                 unset($thisevent["registrant"][$key]["institution"]);
             }
             if (isset($thisevent["registrant"][$key]["email"])) {
                 $thisevent["registrant"][$key]["av_email"] = $thisevent["registrant"][$key]["email"];
                 unset($thisevent["registrant"][$key]["email"]);
             }
             if (isset($thisevent["registrant"][$key]["address"])) {
                 $thisevent["registrant"][$key]["av_address"] = $thisevent["registrant"][$key]["address"];
                 unset($thisevent["registrant"][$key]["address"]);
             }
             if (isset($thisevent["registrant"][$key]["city"])) {
                 $thisevent["registrant"][$key]["av_city"] = $thisevent["registrant"][$key]["city"];
                 unset($thisevent["registrant"][$key]["city"]);
             }
             if (isset($thisevent["registrant"][$key]["country"])) {
                 $thisevent["registrant"][$key]["av_residentship"] = $thisevent["registrant"][$key]["country"];
                 unset($thisevent["registrant"][$key]["country"]);
             }
             if (isset($thisevent["registrant"][$key]["phone"])) {
                 $thisevent["registrant"][$key]["av_phone"] = $thisevent["registrant"][$key]["phone"];
                 unset($thisevent["registrant"][$key]["phone"]);
             }
             if (preg_match("/^([^-]*)-([^-]*)-([^-]*)-([^-]*)\$/", $reg["registrationdate"], $res)) {
                 $thisevent["registrant"][$key]["registrationdate"] = $res[3] . "-" . str_pad(functions::monthNameToNumber($res[2]), 2, "0", STR_PAD_LEFT) . "-" . $res[1] . "";
             }
         }
     }
     // -- sanitize element 'room'
     if (isset($thisevent["room"])) {
         $thisevent["room"] = functions::uniformRoomNames($thisevent["room"]);
     }
     // -- add element 'subpath'
     $thisevent["subpath"] = !is_null($GLOBALS["documentClass"]->getPathFromAgendaId($thisevent["id"])) ? $GLOBALS["documentClass"]->getPathFromAgendaId($thisevent["id"]) : "";
     // -- add elements '[start|end][date|time]'
     list($thisevent["startdate"], $thisevent["starttime"]) = explode(" ", $thisevent["start"]);
     list($thisevent["enddate"], $thisevent["endtime"]) = explode(" ", $thisevent["end"]);
     // -- add element 'current'
     $thisevent["current"] = functions::getCurrentStatus($thisevent["startdate"], $thisevent["enddate"]);
     // -- add element 'categoryid'
     //TODO: check if still needed anywhere
     if (0) {
         if (preg_match("/cat=(\\d*)/", $args, $res)) {
             $thisevent["categoryid"] = $res[1];
         }
     }
     // -- add element 'eventtype'
     //TODO: rewrite
     $eventyear = preg_match_all("/^(\\d{4})-/", $thisevent["start"], $m) ? $m[1][0] : FALSE;
     if (!is_null($GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "etype"))) {
         $thisevent["eventtype"] = $GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "etype");
     } elseif (($programsCategIds = self::getEventByYear("")) && isset($programsCategIds[$eventyear]) && isset($thisevent["id"]) && in_array($thisevent["id"], $programsCategIds[$eventyear])) {
         $thisevent["eventtype"] = "nordita program";
     } elseif (isset($thisevent["title"]) && strpos(strtolower($thisevent["title"]), "conference") !== false) {
         $thisevent["eventtype"] = "conference";
     } elseif (isset($thisevent["title"]) && strpos(strtolower($thisevent["title"]), "workshop") !== false) {
         $thisevent["eventtype"] = "workshop";
     } else {
         $thisevent["eventtype"] = "";
     }
     // -- add element 'period'
     $thisevent["period"] = functions::readableDateInterval($thisevent["startdate"], $thisevent["enddate"]);
     // -- add elements 'from' and 'to'
     $thisevent["from"] = strtotime($thisevent["startdate"] . " " . $thisevent["starttime"]);
     $thisevent["to"] = !empty($thisevent["endtime"]) ? strtotime($thisevent["enddate"] . " " . $thisevent["endtime"]) : $fromtime + 7200;
     // 2*60*60;
     if (in_array($thisevent["eventtype"], array("nordita program", "conference", "workshop"))) {
         $thisevent["from"] = strtotime($thisevent["startdate"] . " 23.59");
     }
     // -- add element 'image'
     $img = PATH_EVENTLOGOS . "/" . $thisevent["subpath"] . ".png";
     $thisevent["image"] = is_file(INCLEVEL . $img) ? $img : "";
     // -- add element 'blurb'
     if (!is_null($GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "blurb"))) {
         $thisevent["blurb"] = $GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "blurb");
     }
     // -- add element 'venue'
     if (!is_null($GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "venue"))) {
         $thisevent["venue"] = $GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "venue");
     }
     // -- add element 'confid_parent'
     if (!is_null($GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "confid_parent"))) {
         $thisevent["confid_parent"] = $GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "confid_parent");
     }
     // -- add element 'surveyid'
     if (!is_null($GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "surveyid"))) {
         $thisevent["surveyid"] = $GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "surveyid");
     }
     // -- add elements 'surveyresponse' and 'surveytotal'
     if (!is_null($GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "surveyresponse"))) {
         $a = explode("/", $GLOBALS["documentClass"]->getEventConfig($thisevent["subpath"], "surveyresponse"));
         if (!empty($a[1])) {
             $thisevent["surveyresponse"] = $a[0];
             $thisevent["surveytotal"] = $a[1];
         }
     }
     // -- end adjust elements of $thisevent
     // ------------------------------------------
     // ------------------------------------------
     // -- 2. Then propagate info to individual contributions, if they exist ('timetable' of programs)
     // ------------------------------------------
     //TODO: adjust to sorting in getSelectedCategories()
     /// @calledby event::outputAgendatable()
     /// @calledby event::outputColloquiumWidget()  with $agenda_selection="colloquium"
     /// @calledby event::OutputSeminarsNextweek() with $agenda_selection="nordita"
     //TODO: adjust to sorting in getEventContributions()
     /// @calledby event::outputEventInfo()
     /// @calledby event::OutputEventTimetable()
     //if (!empty($thisevent["title"])) {echo "<h3>".$thisevent["title"]."</h3>\r\n\r\n";} else {debug::rr($thisevent);}
     //if ($thisevent["id"]=="4016") {echo "----------------------------------------------------";debug::rr($thisevent);}
     if (isset($thisevent["contribution"])) {
         foreach ($thisevent["contribution"] as $idx => $cont) {
             //TODO: desparate bugfix; should be fixed in query to Agenda database
             if (!isset($cont["parent_title"]) || $cont["parent_title"] == $thisevent["title"]) {
                 // -- 'end' and '[start|end][date|time]'
                 if (!isset($cont["end"]) && isset($cont["duration"])) {
                     $dat = strtotime($cont["start"]);
                     list($dG, $di, $ds) = explode(":", $cont["duration"]);
                     $thisevent["contribution"][$idx]["end"] = date("Y-m-d G:i:s", mktime(date("G", $dat) + $dG, date("i", $dat) + $di, date("s", $dat) + $ds, date("m", $dat), date("d", $dat), date("Y", $dat)));
                 } else {
                     $thisevent["contribution"][$idx]["end"] = $cont["start"];
                 }
                 if (isset($cont["duration"])) {
                     $thisevent["contribution"][$idx]["duration"] = preg_replace("/:([^:]*)\$/", "", $cont["duration"]);
                 }
                 if (strpos($cont["start"], " ") === false) {
                     $thisevent["contribution"][$idx]["startdate"] = "";
                     $thisevent["contribution"][$idx]["starttime"] = "";
                 } else {
                     list($thisevent["contribution"][$idx]["startdate"], $thisevent["contribution"][$idx]["starttime"]) = explode(" ", $cont["start"]);
                 }
                 if (!empty($thisevent["contribution"][$idx]["starttime"])) {
                     $thisevent["contribution"][$idx]["starttime"] = preg_replace("/:..\$/mU", "", $thisevent["contribution"][$idx]["starttime"]);
                 }
                 list($thisevent["contribution"][$idx]["enddate"], $thisevent["contribution"][$idx]["endtime"]) = explode(" ", $thisevent["contribution"][$idx]["end"]);
                 if (!empty($thisevent["contribution"][$idx]["endtime"])) {
                     $thisevent["contribution"][$idx]["endtime"] = preg_replace("/:..\$/mU", "", $thisevent["contribution"][$idx]["endtime"]);
                 }
                 // -- 'title' and 'title_plain'
                 //TODO
                 //$preamble = "Nordita Program";
                 $preamble = "Program Talk";
                 //$preamble = "[" . $cont["parent_title"] . "]";
                 if (!empty($cont["title"]) && !empty($cont["parent_title"]) && $cont["parent_title"] != "Parent conference is not set") {
                     $thisevent["contribution"][$idx]["title"] = "<span class='agenda-programtalk'><span>" . $preamble . "</span></span> " . $cont["title"];
                     $thisevent["contribution"][$idx]["title_plain"] = $cont["title"];
                 } else {
                     $thisevent["contribution"][$idx]["title"] = "";
                     $thisevent["contribution"][$idx]["title_plain"] = "";
                 }
                 if (isset($thisevent["contribution"][$idx]["subject"])) {
                     unset($thisevent["contribution"][$idx]["subject"]);
                 }
                 // -- 'current'
                 if (date("Y-m-d") > $thisevent["contribution"][$idx]["end"]) {
                     $thisevent["contribution"][$idx]["current"] = "past";
                     // past
                 } elseif (date("Y-m-d") < $cont["start"]) {
                     $thisevent["contribution"][$idx]["current"] = "future";
                     // future
                 } else {
                     $thisevent["contribution"][$idx]["current"] = "current";
                     // current
                 }
                 // -- sanitize element 'room'
                 if (!isset($cont["room"]) && isset($thisevent["room"])) {
                     $thisevent["contribution"][$idx]["room"] = functions::uniformRoomNames($thisevent["room"]);
                 } elseif (isset($cont["room"])) {
                     $thisevent["contribution"][$idx]["room"] = functions::uniformRoomNames($cont["room"]);
                 } else {
                     //TODO: better default room?
                     $thisevent["contribution"][$idx]["room"] = "";
                 }
                 // -- 'eventtype'
                 if (!isset($cont["eventtype"]) && !empty($thisevent["contribution"][$idx]["eventtype"])) {
                     $thisevent["contribution"][$idx]["eventtype"] = $thisevent["eventtype"];
                 }
                 // -- add element 'period'
                 $thisevent["contribution"][$idx]["period"] = functions::readableDateInterval($thisevent["contribution"][$idx]["startdate"], $thisevent["contribution"][$idx]["enddate"]);
                 // -- add element 'parent_id'
                 $thisevent["contribution"][$idx]["parent_id"] = $thisevent["id"];
                 // -- add elements 'from' and 'to'
                 $thisevent["contribution"][$idx]["from"] = strtotime($thisevent["contribution"][$idx]["startdate"] . " " . $thisevent["contribution"][$idx]["starttime"]);
                 $thisevent["contribution"][$idx]["to"] = !empty($thisevent["contribution"][$idx]["endtime"]) ? strtotime($thisevent["contribution"][$idx]["startdate"] . " " . $thisevent["contribution"][$idx]["endtime"]) : $fromtime + 7200;
                 // 2*60*60;
                 // -- 'speakers' [after creation of 'parent_id' element]
                 //@@
                 /* keep if this format of names is needed in the future */
                 /*   input:  $cont["speakers"] = array(index=>string)    */
                 /*   output: $...["speakers"][] = array("fullname","av_salutation","av_institute") */
                 if (isset($cont["speakers"]) && count($cont["speakers"])) {
                     unset($thisevent["contribution"][$idx]["speakers"]);
                     foreach ($cont["speakers"] as $i => $name) {
                         $tmp = $res = array();
                         if (preg_match("/^([^,. ]*\\.)\\s*(.*)\$/", $name, $res)) {
                             $tmp["nw_fullname"] = functions::straightenName($res[2]);
                             $tmp["av_salutation"] = $res[1];
                         } else {
                             $tmp["nw_fullname"] = functions::straightenName($name);
                         }
                         $tmp["av_institute"] = "";
                         $thisevent["contribution"][$idx]["speakers"][$i] = $tmp;
                     }
                 }
                 /* keep if this is format of names is needed in the future */
                 /*
                 if ($show_speaker_institute) {
                   $speaker = self::getEventContributionsSpeakers($thisevent["contribution"][$idx]);
                   if (!empty($speaker)) {
                     if (isset($cont["speakers"])) unset($thisevent["contribution"][$idx]["speakers"]);
                     $thisevent["contribution"][$idx]["speakers"] = $speaker;
                   }
                 }
                 */
                 //if (isset($cont["submitter"]))
                 //  $cont["submitter"] = functions::uniformName($cont["submitter"]);
                 //if (isset($cont["primary_author"]))
                 //  $cont["primary_author"] = functions::uniformName($cont["primary_author"]);
                 /*
                 // -- 'session_chair' [after creation of 'parent_id' element]
                 
                 if ($r=preg_grep("/co-author_/",array_keys($cont))) {
                   $key = array_pop($r);
                   if (!empty($cont[$key])) {
                     $thisevent["contribution"][$idx]["session_chair"] = $cont[$key];
                   }
                 }
                 */
                 // -- 'slides'
                 /* keep if this is format of slides is needed in the future */
                 /*
                 if ($show_slides) {
                   if (($slides = self::getEventContributionsSlides($thisevent["contribution"][$idx]))
                       && !empty($slides)
                      ) {
                     $thisevent["contribution"][$idx]["slides"] = $slides;
                   }
                 }
                 */
             }
             // end if-foreach
         }
     }
     // -- end propagation to contributions
     // ------------------------------------------
     // ------------------------------------------
     // -- 3. ....
     // ------------------------------------------
     //TODO: this doesn't work if method is called with $show_contributions=FALSE
     if (!empty($thisevent["contribution"])) {
         $thisevent["timetableexists"] = count($thisevent["contribution"]);
     }
     return $thisevent;
 }
Пример #2
0
 public function getEventSessions($confId)
 {
     $session = $convener = array();
     // --------------------------
     // -- Session chairs (conveners)
     $sql = "SELECT " . "  P.av_firstname," . "  P.av_lastname," . "  P.av_salutation," . "  P.av_institute," . "  P.person_type, " . "  P.parent_id " . "FROM " . "  person as P " . "WHERE " . "  (P.event_id='" . $confId . "') " . "  AND (P.person_type='convener') " . "  AND (NOT ISNULL(P.parent_id))";
     $res = $this->query($sql, IS_TESTSERVER);
     // includes a call to connect
     if ($this->num_rows($res)) {
         while ($r = $this->next_record_assoc($res)) {
             if (!empty($r["parent_id"])) {
                 $convener[$r["person_type"]][$r["parent_id"]][] = array("nw_fullname" => $r["av_firstname"] . " " . $r["av_lastname"], "av_institute" => $r["av_institute"], "av_salutation" => $r["av_salutation"]);
             }
         }
         // end while
     }
     // --------------------------
     // -- Sessions
     $sql = "SELECT " . "  S.session_id," . "  S.title," . "  S.start," . "  S.end " . "FROM " . "  event AS E " . "  LEFT JOIN session as S on E.event_id=S.event_id " . "WHERE " . "  E.event_id='" . $confId . "'";
     $res = $this->query($sql, IS_TESTSERVER);
     // includes a call to connect
     if ($this->num_rows($res)) {
         while ($r = $this->next_record_assoc($res)) {
             if (!empty($r["start"])) {
                 list($startdate, $starttime) = explode(" ", $r["start"]);
                 list($enddate, $endtime) = explode(" ", $r["end"]);
                 $from = strtotime($r["start"]);
                 $to = strtotime($r["end"]);
                 $session[] = array("id" => $r["session_id"], "title" => preg_replace("/^(\\[.*\\])\\s*/", "", $r["title"]), "event_id" => $confId, "start" => $r["start"], "end" => $r["end"], "current" => functions::getCurrentStatus($r["start"], $r["end"]), "period" => functions::readableDateInterval($startdate, $enddate), "duration" => ceil(($to - $from) / 60), "starttime" => $starttime, "startdate" => $startdate, "endtime" => $endtime, "enddate" => $enddate, "from" => $from, "to" => $to, "conveners" => isset($convener["convener"][$r["session_id"]]) ? $convener["convener"][$r["session_id"]] : array());
             }
         }
         // end while
     }
     ksort($session);
     return $session;
 }