Exemplo n.º 1
0
 public static function initiateQueryParameters()
 {
     self::loadClass();
     // --------------------
     // -- Fetch configuration parameters from database; massage some of the values
     //    --> $_SESSION["searchConfig"]
     // --------------------
     if (!isset($_SESSION["searchConfig"])) {
         $_SESSION["searchConfig"] = $GLOBALS["searchClass"]->getSearchConfiguration();
     }
     // --------------------
     // -- Make sure that categories array is set
     //    --> $GLOBALS["nw_categories"]
     // --------------------
     if (!isset($GLOBALS["nw_categories"])) {
         $GLOBALS["nw_categories"] = search::initiateCategories($GLOBALS["searchClass"]->table);
     }
     $allowedCategories = array_keys($GLOBALS["nw_categories"]);
     // --------------------
     // -- Create cagegory GPC variable if it was not sent
     //    [Must be called before any return call!]
     //    --> $GLOBALS["ctg"]
     // --------------------
     $defaultCtg = in_array(ucfirst(SUBSITE), $allowedCategories) ? ucfirst(SUBSITE) : "";
     functions::gpc_declare_input("ctg", $defaultCtg, false, $allowedCategories);
     if (isset($_REQUEST["ctg"]) && empty($_REQUEST["ctg"])) {
         $GLOBALS["ctg"] = "";
     }
     // "entire site"
     // --------------------
     // -- Collect GPC query strings from various sources into one GPC variable
     //    --> $GLOBALS["qry"]
     //    --> $GLOBALS["sqry"]
     //    --> $GLOBALS["pqry"]
     // --------------------
     functions::gpc_declare_input("qry", "", false);
     functions::gpc_declare_input("sqry", "", false);
     functions::gpc_declare_input("pqry", "", false);
     // -- 'sqry' is used in the simple search form on pages
     if (!empty($GLOBALS["sqry"]) && defined("SEARCH_THIS_SITE") && strpos($GLOBALS["sqry"], SEARCH_THIS_SITE) === false) {
         $GLOBALS["qry"] = $GLOBALS["sqry"];
     }
     // -- 'pqry' is used in the people search form [possibly obsolete?]
     if (!empty($GLOBALS["pqry"]) && defined("SEARCH_THIS_SITE") && strpos($GLOBALS["pqry"], SEARCH_THIS_SITE) === false) {
         $GLOBALS["qry"] = $GLOBALS["pqry"];
     }
     // --------------------
     // -- Make sure that query array is set
     //    --> $GLOBALS["QUERY"]
     // --------------------
     if (!isset($GLOBALS["QUERY"])) {
         $GLOBALS["QUERY"] = search::analyzeQuery($GLOBALS["qry"], $GLOBALS["ctg"]);
     }
 }
Exemplo n.º 2
0
 private static function outputPeopleLayoutBox($userarray = array())
 {
     if (empty($userarray)) {
         return BLURB_SORRY_PEOPLE_SEARCH . "<!-- outputPeopleLayoutBox -->\r\n";
     }
     $stdout = "";
     // ---------------------------------------------------------------------------
     // SET WHICH COLUMNS TO DISPLAY
     // ---------------------------------------------------------------------------
     $fields = array("nw_fullname_reverse");
     $defaultSortby = "nw_fullname_reverse_sortable";
     // ---------------------------------------------------------------------------
     // REARRANGE DATA INTO CONVENIENT OUTPUT ARRAYS
     // Input: $userarray[username][fieldname] = array(record)
     // Output: $peopleEntries[][][]
     // ---------------------------------------------------------------------------
     if (!class_exists("search", FALSE)) {
         require_once PATH_CLASSES . "/lib/search.php";
     }
     if (!isset($GLOBALS["QUERY"])) {
         search::analyzeQuery();
     }
     $userarray = self::adaptForOutput($userarray, "", "", $fields);
     $userarrayMod = $userarray;
     foreach ($userarray as $usr => $entry) {
         // -- Trim CV field around matches
         if (isset($entry["nw_cv"]["plain"]) && !empty($entry["nw_cv"]["plain"]) && isset($GLOBALS["QUERY"]["_andor"])) {
             $userarrayMod[$usr]["nw_cv"]["plain"] = "...&nbsp;" . search::chopMatchText($GLOBALS["QUERY"]["_andor"], $entry["nw_cv"]["plain"]);
             //$userarrayMod[$usr]["nw_cv"]["plain"] = search::trimMatchText($entry["nw_cv"]["plain"]);
         }
         // -- Mark hits as bold
         foreach ($entry as $key => $val) {
             if ($key == "nw_email_plain" && !empty($val)) {
                 list($u, $d) = explode("@", $val);
                 $userarrayMod[$usr][$key] = search::auxOutputFormat(htmlspecialchars_decode(strip_tags($u)), $GLOBALS["QUERY"]["_andor"]) . "@" . $d;
             } elseif ($key == "nw_cv" && isset($val["plain"])) {
                 $userarrayMod[$usr][$key]["plain"] = search::auxOutputFormat(htmlspecialchars_decode(strip_tags($val["plain"])), $GLOBALS["QUERY"]["_andor"]);
             } elseif (!in_array($key, array("nw_image_small", "nw_user"))) {
                 $userarrayMod[$usr][$key] = search::auxOutputFormat(htmlspecialchars_decode(strip_tags($val)), $GLOBALS["QUERY"]["_andor"]);
             }
         }
         // -- Obscurify e-mail addresses
         $a = explode("@", $userarrayMod[$usr]["nw_email_plain"]);
         if (count($a) == 2) {
             $userarrayMod[$usr]["nw_email_plain"] = $a[0] . functions::obscurify_email("@" . $a[1]);
         }
     }
     // ---------------------------------------------------------------------------
     // OUTPUT TO SCREEN
     // ---------------------------------------------------------------------------
     $stdout .= " <div id='people-list'>\r\n" . "\r\n" . (!empty($doctitle) ? " <h2>" . $doctitle . "</h2>\r\n" : "") . "\r\n" . " <table class='box'>\r\n";
     foreach ($userarrayMod as $usr => $entry) {
         $stdout .= "   <tr>\r\n" . "     <td class='img' style='width:60px!important'>\r\n" . "       <a href='people/staff/index.php?" . "u=" . $entry["nw_user"] . "'>" . "<img src='" . $entry["nw_image_small"] . "' alt='' class='darkshadow'></a>\r\n" . "     </td>\r\n" . "     <td>\r\n" . "       <p class='fullname'><a href='people/staff/index.php?" . "u=" . $entry["nw_user"] . "'>" . str_replace("&nbsp;", " ", $entry["nw_fullname"]) . "</a></p>\r\n" . (!empty($entry["nw_leaveofabsence"]) ? " <p>&#187; <em>" . $entry["nw_leaveofabsence"] . "</em></p>\r\n" : "") . "       <p>" . $entry["nw_employeeTitle"] . "</p>\r\n" . "       <p>" . $entry["nw_groupShort"] . "</p>\r\n" . (!empty($entry["nw_email"]) ? "       <p><em>E-mail</em>: " . $entry["nw_email_plain"] . "</p>\r\n" : "") . (!empty($entry["nw_office"]) ? "       <p><em>Room</em>: " . $entry["nw_office"] . "</p>\r\n" : "") . (!empty($entry["nw_phone_linked"]) ? "       <p><em>Phone</em>: " . $entry["nw_phone_linked"] . "</p>\r\n" : "") . (!empty($entry["nw_city"]) ? "       <p><em>Nordita&nbsp;branch</em>: " . $entry["nw_city"] . "</p>\r\n" : "&nbsp;") . (isset($entry["nw_cv"]["plain"]) && !empty($entry["nw_cv"]["plain"]) && strpos($entry["nw_cv"]["plain"], "<strong>") !== false ? "       <dl><dt><em>CV and Research Interests</em>:</dt><dd>" . $entry["nw_cv"]["plain"] . "</dd></dl>\r\n" : "&nbsp;") . "     </td>\r\n" . "   </tr>\r\n";
     }
     // end foreach
     $stdout .= " </table>\r\n" . "\r\n" . " </div> <!-- people-list -->\r\n";
     // -------------------------------------------------
     return $stdout;
 }
Exemplo n.º 3
0
   foreach (array("Main","Guests","Organizers","Nordic","Intranet","Newstaff","Administrators","Board") as $mycat) {
     $key = array_search($mycat,$_SDATA["categories"]);
     if ($key !== false) {
       $ctemp[] = $mycat;
       unset($_SDATA["categories"][$key]);
     }
   }
   $_SDATA["categories"] = array_merge($ctemp,$_SDATA["categories"]);
 */
 // --------------------
 // -- Assemble array with analyzed query data from GPC string
 //    --> $GLOBALS["QUERY"]
 // --------------------
 $GLOBALS["nw_categories"] = search::initiateCategories($_DDATA["tablename"]);
 search::initiateQueryParameters();
 $GLOBALS["QUERY"] = search::analyzeQuery($GLOBALS["qry"], $GLOBALS["ctg"]);
 /*
   // --------------------
   // -- Create cagegory GPC variable if it was not sent
   //    --> $_REQUEST['ctg']
   // --------------------
 
   $_REQUEST['ctg'] = (isset($_REQUEST['ctg'])) ?
     $_REQUEST['ctg']
     : ( (in_array(ucfirst(SUBSITE),$_SDATA["categories"])) ? ucfirst(SUBSITE) : "" );
 
   if (!in_array($_REQUEST['ctg'], $_SDATA["categories"])) $_REQUEST['ctg'] = "";
 */
 // --------------------
 // -- Trim cache size if it is time to do so; otherwise mail query statistics if this is requested.
 // --------------------