Exemplo n.º 1
0
 public static function OutputEventList($eventlistSelect = "", $showForm = true, $eventlistDisplayinfo = "")
 {
     // -----------------------
     // Execution preceded by call in document->buildConfigOfPageUpdate():
     //
     // if (isset($_REQUEST["eventlist_select"])) {
     //   $this->setConfig("url",functions::callMethod("event","lib/event","getEventListUrl"));
     // }
     //
     // followed by possible redirect to approporiate page.
     // Any other 'eventlist*' GPC data are stored in session variables.
     // -----------------------
     $allowed = array("eventlist_select" => array("a" => array("label" => "All events", "hline" => "Event", "etype" => array("", "program", "workshop", "conference", "meeting", "school"), "xtra" => array("lbe2012")), "p" => array("label" => "Programs", "hline" => "Program", "etype" => array("program"), "xtra" => array("")), "v" => array("label" => "Workshops, Conferences, Meetings", "hline" => "Workshop, Conference, or Meeting", "etype" => array("workshop", "conference", "meeting"), "xtra" => array("")), "s" => array("label" => "Schools", "hline" => "School", "etype" => array("school"), "xtra" => array("lbe2012"))), "eventlist_displayinfo" => array("f" => "Full", "m" => "Medium", "b" => "Brief"), "eventlist_period" => array("a" => "All", "f" => "Current & Future"));
     // -----------------------------------
     // GPC input
     // -----------------------------------
     if (!isset($_REQUEST["eventlist_select"]) && in_array($eventlistSelect, array_keys($allowed["eventlist_select"]))) {
         $GLOBALS["eventlist_select"] = $eventlistSelect;
     } else {
         functions::gpc_declare_input("eventlist_select", "a", false, array_keys($allowed["eventlist_select"]), true);
         // must read from SESSION
     }
     if (!empty($eventlistDisplayinfo) && empty($_REQUEST["eventlist_displayinfo"])) {
         $_REQUEST["eventlist_displayinfo"] = $eventlistDisplayinfo;
     }
     functions::gpc_declare_input("eventlist_displayinfo", "f", false, array_keys($allowed["eventlist_displayinfo"]), true);
     // must read from SESSION
     functions::gpc_declare_input("eventlist_period", "a", false, array_keys($allowed["eventlist_period"]), true);
     // must read from SESSION
     // -----------------------------------
     // -- Obtain Data
     // -----------------------------------
     if (in_array($GLOBALS["eventlist_displayinfo"], array("m", "b"))) {
         $eventArray = self::getEventByTime();
     } else {
         $eventArray = self::getEventByNow();
     }
     // -----------------------------------
     // -- Output Error if No Events Found
     // -----------------------------------
     if (empty($eventArray)) {
         return "<p class='box error padding background'><strong>&#187; ERROR:</strong> <em>No events found</em>." . (isset($GLOBALS["nw_debug"]["fromcache_get"]) ? " [" . $GLOBALS["nw_debug"]["fromcache_get"] . "]" : "") . "</p>\r\n\r\n";
     }
     // -----------------------------------
     // -- Construct Poster Link
     // -----------------------------------
     $posterlink = "";
     //TODO: seems logical links won't do here
     //$posterfilename = PATH_DOCS . "/nordita_programs_presentation.pdf";
     //$posterfilename = PATH_DOCS . "/nordita_programs_presentation_2015_A3.pdf";
     $posterfilename = self::getProgramPosterPath();
     if (file_exists(INCLEVEL . $posterfilename)) {
         $posterlink = "<div class='only_online bold' style='width:100%;text-align:right;margin-bottom:1em;'><a href='" . $posterfilename . "'>Download Nordita Events Poster</a></div>\r\n";
     }
     // -----------------------------------
     // -- Construct Menu
     // -----------------------------------
     if (!$showForm) {
         $menutxt = "";
     } else {
         $menutxt = "        <form id='selectmenu' " . "action='" . $GLOBALS["documentClass"]->getPagePath() . "/index.php' " . "method='post' class='only_online'>\r\n" . "          <table>\r\n" . "            <tr>\r\n" . "              <td>\r\n" . "          <div class='input shadow-whiteinset'>" . "<span>Show:</span>\r\n";
         //"<span>Show events:</span>\r\n";
         foreach ($allowed["eventlist_select"] as $key => $value) {
             $menutxt .= "            <input type='radio' name='eventlist_select' value='" . $key . "'" . ($GLOBALS["eventlist_select"] == $key ? "  checked" : "") . ">&nbsp;" . $value["label"] . "\r\n";
         }
         $menutxt .= "          </div>\r\n" . "              </td>\r\n" . "              <td colspan='2'>\r\n" . "          <div>\r\n" . "            <input type='submit' value='Select' style='font-size:1.2em!important'>\r\n" . "            <input type='hidden' name='eventlist' value='1'>\r\n" . "          </div>\r\n" . "              </td>\r\n" . "            </tr>\r\n" . "            <tr>\r\n" . "              <td class='align-right'>\r\n" . "          <div class='input shadow-whiteinset'>" . "<span>Info:</span>\r\n";
         //"<span>Display information:</span>\r\n";
         foreach ($allowed["eventlist_displayinfo"] as $key => $value) {
             $menutxt .= "            <input type='radio' name='eventlist_displayinfo' value='" . $key . "'" . ($GLOBALS["eventlist_displayinfo"] == $key ? "  checked" : "") . "> " . $value . "\r\n";
         }
         $menutxt .= "          </div>\r\n" . "          <div class='input shadow-whiteinset'>" . "<span>Period:</span>\r\n";
         //"<span>Display information:</span>\r\n";
         foreach ($allowed["eventlist_period"] as $key => $value) {
             $menutxt .= "            <input type='radio' name='eventlist_period' value='" . $key . "'" . ($GLOBALS["eventlist_period"] == $key ? "  checked" : "") . "> " . $value . "\r\n";
         }
         $menutxt .= "          </div>\r\n" . "              </td>\r\n" . "            </tr>\r\n" . "          </table>\r\n" . "        </form>\r\n" . "\r\n";
     }
     // -----------------------------------
     // -- If 'medium' or 'brief' output has been requested
     // -----------------------------------
     if (in_array($GLOBALS["eventlist_displayinfo"], array("b", "m"))) {
         $medium = $GLOBALS["eventlist_displayinfo"] == "m" ? true : false;
         $stdout = "";
         $year = 0;
         // numeric zero
         foreach ($eventArray as $key => $darray) {
             if ($key != "past" || $GLOBALS["eventlist_period"] == "a") {
                 foreach ($darray as $events) {
                     foreach ($events as $thisevent) {
                         if (in_array($thisevent["eventtype"], $allowed["eventlist_select"][$GLOBALS["eventlist_select"]]["etype"])) {
                             if ($medium && substr($thisevent["startdate"], 0, 4) != $year) {
                                 $year = substr($thisevent["startdate"], 0, 4);
                                 $stdout .= "          <h3 class='program'>" . $year . "</h3>\r\n" . "\r\n";
                             }
                             $stdout .= event::outputEventListSingle($thisevent, "", "", 1, 1, 0, $medium);
                         }
                     }
                 }
             }
         }
         if ($medium) {
             return $posterlink . "      <div class='eventlist'>\r\n\r\n" . $menutxt . $stdout . "      </div>\r\n\r\n";
         } else {
             return $posterlink . $menutxt . $stdout;
         }
     }
     // -----------------------------------
     // -- If 'full' output has been requested (default) -- Highlight Current Event
     // -----------------------------------
     $allcurrent = array();
     if (isset($eventArray["current"]) && is_array($eventArray["current"])) {
         ksort($eventArray["current"]);
         foreach ($eventArray["current"] as $c1) {
             foreach ($c1 as $c2) {
                 if (is_array($c2) && in_array($c2["eventtype"], $allowed["eventlist_select"][$GLOBALS["eventlist_select"]]["etype"])) {
                     $allcurrent[] = $c2;
                 }
             }
         }
     }
     $currentlabel = isset($allowed["eventlist_select"][$eventlistSelect]["hline"]) ? $allowed["eventlist_select"][$eventlistSelect]["hline"] : "Event";
     if (is_array($allcurrent) && count($allcurrent) > 1) {
         $currentlabel .= "s";
     }
     $currentevent = "      <div class='eventlist'>\r\n" . "\r\n" . "        <div class='col-content-center'>\r\n" . "\r\n" . "          <h2>Current " . $currentlabel . "</h2>\r\n" . "\r\n";
     if (!is_array($allcurrent) || empty($allcurrent)) {
         $currentevent .= "          <div class='box warning padding background'><em>There is currently no " . ($GLOBALS["eventlist_select"] == "a" ? "event" : join(", ", $allowed["eventlist_select"][$GLOBALS["eventlist_select"]]["etype"])) . " running at Nordita.</em></div>\r\n\r\n";
     } else {
         foreach ($allcurrent as $current) {
             $currentevent .= event::outputEventListSingle($current, "event-box widebox", "subbox", 1, 0, 1, 0);
         }
     }
     $currentevent .= "        </div>\r\n" . "\r\n";
     // -----------------------------------
     // -- If 'full' output has been requested (default) -- List Remaining Events
     // -----------------------------------
     if (isset($eventArray["future"])) {
         ksort($eventArray["future"]);
     }
     if (isset($eventArray["past"])) {
         krsort($eventArray["past"]);
     }
     $periods[] = "future";
     if ($GLOBALS["eventlist_period"] == "a") {
         $periods[] = "past";
     }
     $eventlist = "";
     foreach ($periods as $idx => $timescale) {
         $year = 0;
         // numeric zero
         $eventlist .= (count($periods) > 1 ? "        <div class='col-content-" . ($idx == 0 ? "left" : "right") . "'>\r\n" : "") . "\r\n" . "          <h2>" . ucfirst($timescale) . " Events</h2>\r\n" . "\r\n";
         if (isset($eventArray[$timescale])) {
             foreach ($eventArray[$timescale] as $date => $progs) {
                 foreach ($progs as $thisevent) {
                     if (in_array($thisevent["eventtype"], $allowed["eventlist_select"][$GLOBALS["eventlist_select"]]["etype"]) || in_array($thisevent["subpath"], $allowed["eventlist_select"][$GLOBALS["eventlist_select"]]["xtra"])) {
                         if (substr($thisevent["startdate"], 0, 4) != $year) {
                             $year = substr($thisevent["startdate"], 0, 4);
                             $eventlist .= "          <h3 class='program'>" . $year . "</h3>\r\n" . "\r\n";
                         }
                         $eventlist .= event::outputEventListSingle($thisevent, "event-box", "subbox", 1, 0, 1, 0);
                     }
                 }
                 // end foreach
             }
             // end foreach
         } else {
             $eventlist .= "<div class='box error padding background'>Could not find any events</strong></div>\r\n";
         }
         // end if
         if (count($periods) > 1) {
             $eventlist .= "        </div>\r\n";
         }
     }
     $eventlist .= "\r\n" . "      </div> <!-- eventlist -->\r\n" . "\r\n";
     return $posterlink . $currentevent . $menutxt . $eventlist;
 }