function loadSearch($args, $bare = false, $onlyIDs = false, $publicOnly = false) { /* * Three basic steps are involved here: * * 1. Execute the query, which results in a list of record IDs * (this step includes authentication, i.e. the results will be only * those records visible to the user). * * 2. Load the core, public data for each record, whether it be from the * cache or from the database. * * 3. Load the user-dependent data for each record (bookmark, tags, comments etc.). * This step is optional - some applications may need only the core data. In this * case they should specify $bare = true. */ if (!@$args["q"]) { return array("error" => "no query specified"); } if (is_logged_in() && @$args["w"] === "bookmark") { $searchType = BOOKMARK; } else { $searchType = BOTH; } $fresh = !!@$args["f"]; $noCache = @$args["nocache"] == 1; $query = REQUEST_to_query("select SQL_CALC_FOUND_ROWS rec_ID ", $searchType, $args, null, $publicOnly); $res = mysql_query($query); if (mysql_error()) { } $fres = mysql_query('select found_rows()'); $resultCount = mysql_fetch_row($fres); $resultCount = $resultCount[0]; if ($onlyIDs) { $row = mysql_fetch_assoc($res); $ids = "" . ($row["rec_ID"] ? $row["rec_ID"] : ""); while ($row = mysql_fetch_assoc($res)) { $ids .= $row["rec_ID"] ? "," . $row["rec_ID"] : ""; } return array("resultCount" => $resultCount, "recordCount" => strlen($ids) ? count(explode(",", $ids)) : 0, "recIDs" => $ids); } else { $recs = array(); while ($row = mysql_fetch_assoc($res)) { if (mysql_error()) { } if ($noCache) { $record = loadRecord_NoCache($row["rec_ID"], $bare); } else { $record = loadRecord($row["rec_ID"], $fresh, $bare); } if (array_key_exists("error", $record)) { return array("error" => $record["error"]); } array_push($recs, $record); } return array("resultCount" => $resultCount, "recordCount" => count($recs), "records" => $recs); } }
function prepareQuery($params, $squery, $search_type, $detailsTable, $where, $order = null, $limit = null) { $squery = REQUEST_to_query($squery, $search_type, $params); //remove order by $pos = strpos($squery, " order by "); if ($pos > 0) { $squery = substr($squery, 0, $pos); } //$squery = str_replace(" where ", ",".$detailsTable." where ", $squery); $squery = preg_replace('/ where /', $detailsTable . " where ", $squery, 1); //add our where clause and limit if ($where) { $squery = $squery . $where; } if ($order) { $squery = $squery . " order by " . $order; } if ($limit) { $squery = $squery . " limit " . $limit; } return $squery; }
if ($_REQUEST['w'] == 'b' || $_REQUEST['w'] == 'biblio') { // records entries I haven't bookmarked yet $search_type = BIBLIO; } else { if ($_REQUEST['w'] == 'a' || $_REQUEST['w'] == 'all') { // all records entries $search_type = BOTH; } else { return; } } } // wwgd mysql_connection_select(DATABASE); $rectype = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_Name', '1'); $res = mysql_query(REQUEST_to_query('select distinct rec_ID, rec_URL, rec_ScratchPad, rec_RecTypeID ', $search_type)); while ($row = mysql_fetch_assoc($res)) { print_biblio($row); } function print_biblio($bib) { global $rectype; $output = ''; $output .= print_bib_details($bib['rec_ID'], $bib['rec_RecTypeID'], array()); if ($bib['rec_URL']) { $output .= '%U ' . $bib['rec_URL'] . "\n"; } $kwds = mysql__select_array('usrBookmarks left join usrRecTagLinks on rtl_RecID = bkm_RecID left join usrTags on tag_ID = rtl_TagID', 'tag_Text', 'bkm_recID = ' . $bib['rec_ID'] . ' and bkm_UGrpID = ' . get_user_id() . ' and tag_Text != "" and tag_Text is not null'); if (count($kwds)) { $output .= '%K ' . join(', ', $kwds) . "\n";
$_REQUEST['w'] = 'all'; } if (!@$_REQUEST['q'] || @$_REQUEST['ver'] && intval(@$_REQUEST['ver']) < SEARCH_VERSION) { construct_legacy_search(); } // migration path if (!@$_REQUEST['q'] && !@$_REQUEST['s']) { return; } // wwgd if ($_REQUEST['w'] == 'B' || $_REQUEST['w'] == 'bookmark') { $search_type = BOOKMARK; } else { $search_type = BOTH; } // all records mysql_connection_select(DATABASE); if (preg_match('/\\b_BROKEN_\\b/', $_REQUEST['q'])) { $broken = 1; $_REQUEST['q'] = preg_replace('/\\b_BROKEN_\\b/', '', $_REQUEST['q']); } $query = REQUEST_to_query("select rec_ID, bkm_ID ", $search_type); if (@$broken) { $query = str_replace(' where ', ' where (to_days(now()) - to_days(rec_URLLastVerified) >= 8) and ', $query); } $res = mysql_query($query); $ids = array(); while ($row = mysql_fetch_assoc($res)) { array_push($ids, array("recID" => $row["rec_ID"], "bkmk_id" => $row["bkm_ID"])); } print json_format($ids);
function prepareQuery($squery, $search_type, $joinTable, $where, $limit) { $squery = REQUEST_to_query($squery, $search_type, '', null, false); //public only //remove order by $pos = strpos($squery, " order by "); if ($pos > 0) { $squery = substr($squery, 0, $pos); } //$squery = str_replace(" where ", $joinTable." where ", $squery); $squery = preg_replace('/ where /', $joinTable . " where ", $squery, 1); //add our where clause and limit $squery = $squery . $where . " limit " . $limit; return $squery; }
/** * Returns array of mapobjects $mapobjects = array( "records"=>$geoRecords, "geoObjects"=>$geoObjects, "cntWithGeo"=>$cnt_geo, "cntWithTime"=>$cnt_time, "layers"=>$layers); */ function getMapObjects($request) { $imagelayerRT = defined('RT_IMAGE_LAYER') ? RT_IMAGE_LAYER : 0; $KMLlayerRT = defined('RT_KML_LAYER') ? RT_KML_LAYER : 0; mysql_connection_select(DATABASE); if (array_key_exists('layers', $request)) { //special mode - load ALL image layers and kml records only - for general drop down list on map $request['ver'] = "1"; $request['q'] = "type:" . $imagelayerRT . "," . $KMLlayerRT; $search_type = BOTH; } else { if (!@$request['q'] || @$request['ver'] && intval(@$request['ver']) < SEARCH_VERSION) { construct_legacy_search(); } // migration path if (@$request['w'] && ($request['w'] == 'B' || $request['w'] == 'bookmark')) { $search_type = BOOKMARK; } else { $search_type = BOTH; } // all records } if (!array_key_exists("limit", $request)) { //not defined $limit = intval(@$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["display-preferences"]['report-output-limit']); if (!$limit || $limit < 1) { $limit = 1000; //default limit in dispPreferences } $request["limit"] = $limit; //force limit } // find all matching records $cols = "rec_ID as bibID, rec_RecTypeID as rectype, rec_Title as title, rec_URL as URL"; $query = REQUEST_to_query("select {$cols} ", $search_type); /*****DEBUG****/ // error_log("query=".$query); /*****DEBUG****/ //error_log(">>>>>>>>>>>>>>>>>>>>>>>".$search_type."<<<<<<".$query); $res = mysql_query($query); if (mysql_error()) { print mysql_error(); } $records = array(); $bibIDs = array(); $imageLayers = array(); // list of ids of map image layers $geoObjects = array(); // coordinates $geoBibIDs = array(); // list of id of records that have geo references while ($bib = mysql_fetch_assoc($res)) { $bibID = $bib["bibID"]; if (!$bibID) { continue; } $records[$bibID] = $bib; array_push($bibIDs, $bibID); if ($bib["rectype"] == $imagelayerRT) { //map image layer array_push($imageLayers, $bibID); $geoBibIDs[$bibID] = $bibID; } } foreach ($bibIDs as $bibID) { //0 DT_SHORT_SUMMARY //1 DT_EXTENDED_DESCRIPTION //2 - record URL //3 DT_FILE_RESOURCE //REMOVED 4 DT_LOGO_IMAGE //REMOVED 5 DT_THUMBNAIL //REMOVED 6 DT_IMAGES //4 7 DT_MAP_IMAGE_LAYER_REFERENCE //5 8 DT_KML //6 9 DT_KML_FILE //7 10 record type //d.dtl_UploadedFileID,e.dtl_UploadedFileID,f.dtl_UploadedFileID, // 0 1 2 3 4 imagelayer 5 kmltext 6 kmlfile 7 8 $squery = "select a.dtl_Value, b.dtl_Value, rec_URL, c.dtl_UploadedFileID, g.dtl_Value, h.dtl_Value, i.dtl_UploadedFileID, rec_RecTypeID, rec_Title, j.dtl_Value\n\t\tfrom Records\n\t\tleft join recDetails a on a.dtl_RecID=rec_ID and a.dtl_DetailTypeID=" . (defined('DT_SHORT_SUMMARY') ? DT_SHORT_SUMMARY : "0") . " left join recDetails b on b.dtl_RecID=rec_ID and b.dtl_DetailTypeID=" . (defined('DT_EXTENDED_DESCRIPTION') ? DT_EXTENDED_DESCRIPTION : "0") . " left join recDetails c on c.dtl_RecID=rec_ID and c.dtl_DetailTypeID=" . (defined('DT_FILE_RESOURCE') ? DT_FILE_RESOURCE : "0") . " left join recDetails g on g.dtl_RecID=rec_ID and g.dtl_DetailTypeID=" . (defined('DT_MAP_IMAGE_LAYER_REFERENCE') ? DT_MAP_IMAGE_LAYER_REFERENCE : "0") . " left join recDetails h on h.dtl_RecID=rec_ID and h.dtl_DetailTypeID=" . (defined('DT_KML') ? DT_KML : "0") . " left join recDetails i on i.dtl_RecID=rec_ID and i.dtl_DetailTypeID=" . (defined('DT_KML_FILE') ? DT_KML_FILE : "0") . " left join recDetails j on j.dtl_RecID=rec_ID and j.dtl_DetailTypeID=" . (defined('DT_SHOW_IN_MAP_BG_LIST') ? DT_SHOW_IN_MAP_BG_LIST : "0") . " where rec_ID={$bibID}"; //*****DEBUG****//error_log(">>>>>>QUERY=".$squery); $res = mysql_query($squery); $row = mysql_fetch_row($res); if ($row) { $records[$bibID]["recID"] = $bibID; $records[$bibID]["rectype"] = $row[7]; $records[$bibID]["description"] = $row[0] ? $row[0] : ($row[1] ? $row[1] : ""); $records[$bibID]["url"] = $row[2]; //($row[2] ? "'".$row[2]."' target='_blank'" :"'javascript:void(0);'"); //'javascript:{this.href="'+$row[2]+'"}' : 'javascript:{return false;}');//javascript:void(0)}'); $records[$bibID]["icon_url"] = HEURIST_ICON_SITE_PATH . $row[7] . ".png"; $thumb_url = getThumbnailURL($bibID); //function from uploadFile.php if ($thumb_url == "") { //if thumb not defined - use rectype default thumb $thumb_url = HEURIST_ICON_SITE_PATH . "thumb/th_" . $row[7] . ".png"; } $records[$bibID]["thumb_url"] = $thumb_url; if ($row[4] && is_numeric($row[4]) && !in_array($row[4], $imageLayers)) { //DT_MAP_IMAGE_LAYER_REFERENCE array_push($imageLayers, $row[4]); } $kml_path = getKmlFilePath($row[3]); //DT_FILE_RESOURCE //*****DEBUG****//error_log(">>>>>>".$row[3]."=".$kml_path); // removed by SAW as DT_KML_FILE changed from a file base type to blocktext // if($kml_path==null){ // $kml_path = getKmlFilePath($row[6]); //DT_KML_FILE // } if ($kml_path != null) { array_push($geoObjects, array("bibID" => $bibID, "type" => "kmlfile", "fileid" => $kml_path, "title" => $row[8], "isbackground" => $row[9])); $geoBibIDs[$bibID] = $bibID; } else { if ($row[5]) { //DT_KML dtl_value contains KML saw TODO: modify to check that text is valid KML. array_push($geoObjects, array("bibID" => $bibID, "type" => "kml", "recid" => $bibID, "title" => $row[8])); $geoBibIDs[$bibID] = $bibID; } } } } //for if ($bibIDs && count($bibIDs) > 0) { // Find the records that actually have any geographic data to plot $res = mysql_query("select dtl_RecID, dtl_Value, astext(dtl_Geo), astext(envelope(dtl_Geo)) from recDetails where dtl_Geo is not null and dtl_RecID in (" . join(",", $bibIDs) . ")"); if (mysql_error()) { error_log("ERROR in ShowMap=" . mysql_error()); } if ($res) { while ($val = mysql_fetch_row($res)) { // get the bounding box if (preg_match("/POLYGON\\(\\((\\S+)\\s+(\\S+),\\s*(\\S+)\\s+(\\S+),\\s*(\\S+)\\s+(\\S+),\\s*(\\S+)\\s+(\\S+),\\s*\\S+\\s+\\S+\\)\\)/i", $val[3], $matches)) { $bbox = array("w" => floatval($matches[1]), "s" => floatval($matches[2]), "e" => floatval($matches[5]), "n" => floatval($matches[6])); } else { $bbox = null; } $geoobj = parseValueFromDb($val[0], $val[1], $val[2], $bbox); if ($geoobj) { array_push($geoObjects, $geoobj); $geoBibIDs[$val[0]] = $val[0]; } /*****DEBUG****/ //error_log("ADDED1:".is_string($val[0])." ".$geoBibIDs[$val[0]]); /*****DEBUG****/ //error_log("1>>>>>>".$geoBibIDs[$val[0]]); /*****DEBUG****/ //error_log("2>>>>>>".$geoBibIDs["97025"]); /*****DEBUG****/ //error_log("3>>>>>>".$geoBibIDs[$bibID]); } } } //$bibIDs!=null // OLD WAY TO STORE GEO DATA - directly in dtl_value as dettypes: 210(long) and 211(lat) /* removed by SAW as 211 is an old magic number not brought forward. $res = mysql_query("select LAT.dtl_RecID, LNG.dtl_Value, LAT.dtl_Value from recDetails LAT, recDetails LNG where LAT.dtl_DetailTypeID=211 and LNG.dtl_DetailTypeID=210 and LAT.dtl_RecID=LNG.dtl_RecID and LNG.dtl_RecID in (" . join(",", $bibIDs) . ")"); if($res){ while ($val = mysql_fetch_row($res)) { array_push($geoObjects, array("bibID" => $val[0], "type" => "point", "geo" => array("x" => floatval($val[1]), "y" => floatval($val[2])))); $geoBibIDs[$val[0]] = $val[0]; } } */ // some records may contain reference to map image layer record (dettype 588), // but we may have such records in search result as well rectype=$imagelayerRT if ($bibIDs && count($bibIDs) > 0) { $squery = "select rec_ID from Records\n\t\t\t\t\t\t\t where rec_ID in (" . join(",", $bibIDs) . ") and rec_RecTypeID={$imagelayerRT}"; /*****DEBUG****/ //error_log($squery); $res = mysql_query($squery); if ($res) { while ($val = mysql_fetch_row($res)) { array_push($imageLayers, $val[0]); $geoBibIDs[$val[0]] = $val[0]; } } } $layers = array(); //find image layers if (count($imageLayers) > 0) { $squery = "select rec_ID, a.dtl_Value as title," . " (select trm_Label from defTerms where trm_ID=b.dtl_Value) as type," . " c.dtl_Value as url," . " (select trm_Label from defTerms where trm_ID=d.dtl_Value) as mime_type," . " e.dtl_Value as min_zoom, f.dtl_Value as max_zoom, g.dtl_Value as copyright, j.dtl_Value as isbackground" . " from Records" . " left join recDetails a on a.dtl_RecID=rec_ID and a.dtl_DetailTypeID=" . (defined('DT_SHORT_NAME') ? DT_SHORT_NAME : "0") . " left join recDetails b on b.dtl_RecID=rec_ID and b.dtl_DetailTypeID=" . (defined('DT_MAP_IMAGE_LAYER_SCHEMA') ? DT_MAP_IMAGE_LAYER_SCHEMA : "0") . " left join recDetails c on c.dtl_RecID=rec_ID and c.dtl_DetailTypeID=" . (defined('DT_SERVICE_URL') ? DT_SERVICE_URL : "0") . " left join recDetails d on d.dtl_RecID=rec_ID and d.dtl_DetailTypeID=" . (defined('DT_MIME_TYPE') ? DT_MIME_TYPE : "0") . " left join recDetails e on e.dtl_RecID=rec_ID and e.dtl_DetailTypeID=" . (defined('DT_MINMUM_ZOOM_LEVEL') ? DT_MINMUM_ZOOM_LEVEL : "0") . " left join recDetails f on f.dtl_RecID=rec_ID and f.dtl_DetailTypeID=" . (defined('DT_MAXIMUM_ZOOM_LEVEL') ? DT_MAXIMUM_ZOOM_LEVEL : "0") . " left join recDetails g on g.dtl_RecID=rec_ID and g.dtl_DetailTypeID=" . (defined('DT_ALTERNATE_NAME') ? DT_ALTERNATE_NAME : "0") . " left join recDetails j on j.dtl_RecID=rec_ID and j.dtl_DetailTypeID=" . (defined('DT_SHOW_IN_MAP_BG_LIST') ? DT_SHOW_IN_MAP_BG_LIST : "0") . " where rec_ID in (" . join(",", $imageLayers) . ")"; /*****DEBUG****/ //error_log($squery); $res = mysql_query($squery); /*****DEBUG****/ //error_log(mysql_error()); while ($rec = mysql_fetch_assoc($res)) { //find the extent for image layer if ($rec['type'] == "maptiler") { $manifest_file = $rec['url'] . "tilemapresource.xml"; } else { if ($rec['type'] == "virtual earth") { $manifest_file = $rec['url'] . "MapCruncherMetadata.xml"; } else { $rec['error'] = "Wrong or non supported map type " . $rec['type']; } } if (!$rec['url']) { $rec['error'] = "URL is not defined for image layer"; } else { if ($manifest_file) { $manifest = simplexml_load_file($manifest_file); if ($manifest == null || is_string($manifest)) { //manifest not found $rec['error'] = "Can not load manifest file image layer. " . $manifest_file; } else { if ($rec['type'] == "maptiler") { foreach ($manifest->children() as $f_gen) { if ($f_gen->getName() == "BoundingBox") { $arr = $f_gen->attributes(); $rec['extent'] = $arr['miny'] . ',' . $arr['minx'] . ',' . $arr['maxy'] . ',' . $arr['maxx']; //warning!!! wrong labels in these manifests!!!! break; } } } else { $rect = findXMLelement($manifest, 0, array("LayerList", "Layer", "SourceMapRecordList", "SourceMapRecord", "MapRectangle")); if ($rect) { $rec['extent'] = ""; foreach ($rect->children() as $pnt) { $arr = $pnt->attributes(); $lon = $arr['lon']; $lat = $arr['lat']; $rec['extent'] = $rec['extent'] . $lon . "," . $lat . ","; } //$rec['extent'] = $sw['lon'].','.$sw['lat'].','.$ne['lon'].','.$ne['lat']; } } if (!array_key_exists('extent', $rec)) { $rec['error'] = "Can not find bounds parameters in manifest file"; } } } } if (!$rec['max_zoom']) { $rec['max_zoom'] = 19; } array_push($layers, $rec); } } //count($imageLayers)>0 // Find time extents -- must have at least a start time (end time is optional) // check for specific details first //saw TODO; modify this for handle durations with a start or end date $timeObjects = array(); if (defined('DT_START_DATE') && defined('DT_END_DATE') && $bibIDs && count($bibIDs) > 0) { $squery = "select START.dtl_RecID, START.dtl_Value, END.dtl_Value " . "from recDetails START left join recDetails END on START.dtl_RecID=END.dtl_RecID " . "and END.dtl_DetailTypeID=" . DT_END_DATE . " where START.dtl_DetailTypeID=" . DT_START_DATE . " and (START.dtl_Value || END.dtl_Value) " . "and START.dtl_RecID in (" . join(",", $bibIDs) . ")"; $res = mysql_query($squery); while ($val = mysql_fetch_row($res)) { if ($val[1] || $val[2]) { $timeObjects[$val[0]] = array($val[1], $val[2]); /*****DEBUG****/ //error_log("XXXX>>>>>> ". $val[0]." ".$val[1]." ".$val[2] ); } } } // $timeObjects = array(); //" //select d.dtl_RecID, min(d.dtl_Value), max(d.dtl_Value), min(y.dtl_Value), max(y.dtl_Value) //from recDetails b, recDetails y //" $anyDateBibIDs = array(); //no date enabled foreach ($bibIDs as $bibID) { if (!array_key_exists($bibID, $timeObjects)) { array_push($anyDateBibIDs, $bibID); } } // now process those records that don't have specific start and end dates - // try to extract date from details if (count($anyDateBibIDs) > 0) { $dates = array(); $years = array(); $res = mysql_query("select rec_ID, min(d.dtl_Value), max(d.dtl_Value)\n\t\t\t\t\t\t\tfrom Records\n\t\t\t\t\t\t\tcross join defDetailTypes dt\n\t\t\t\t\t\t\tleft join recDetails d on d.dtl_RecID = rec_ID and d.dtl_DetailTypeID = dt.dty_ID\n\t\t\t\t\t\t\twhere rec_ID in (" . join(",", $anyDateBibIDs) . ")\n\t\t\t\t\t\t\tand dt.dty_Type = 'date'\n\t\t\t\t\t\t\tgroup by rec_ID"); if ($res) { while ($val = mysql_fetch_row($res)) { if ($val[1] && preg_match("/^\\d+\\s*bc/i", $val[1])) { // convert BC to a - sign $val[1] = -preg_replace("/\\s*bc/i", "", $val[1]) + 1; } if ($val[2] && preg_match("/^\\d+\\s*bc/i", $val[2])) { // convert BC to a - sign $val[2] = -preg_replace("/\\s*bc/i", "", $val[2]) + 1; } $dates[$val[0]] = array($val[1], $val[1] !== $val[2] ? $val[2] : null); } } $res = mysql_query("select rec_ID, min(d.dtl_Value), max(d.dtl_Value)\n\t\tfrom Records\n\t\tcross join defDetailTypes yt\n\t\tleft join recDetails y on y.dtl_RecID = rec_ID and y.dtl_DetailTypeID = yt.dty_ID\n\t\twhere rec_ID in (" . join(",", $anyDateBibIDs) . ")\n\t\tand yt.dty_Type = 'year'\n\t\tgroup by rec_ID"); if ($res) { while ($val = mysql_fetch_row($res)) { if ($val[1] && preg_match("/^\\d+\\s*bc/i", $val[1])) { // convert BC to a - sign $val[1] = -preg_replace("/\\s*bc/i", "", $val[1]) + 1; } if ($val[2] && preg_match("/^\\d+\\s*bc/i", $val[2])) { // convert BC to a - sign $val[2] = -preg_replace("/\\s*bc/i", "", $val[2]) + 1; } $years[$val[0]] = array($val[1], $val[1] !== $val[2] ? $val[2] : null); } } foreach ($anyDateBibIDs as $bibID) { $sd = @$dates[$bibID][0] ? $dates[$bibID][0] : null; $ed = @$dates[$bibID][1] ? $dates[$bibID][1] : null; $sy = @$years[$bibID][0] ? $years[$bibID][0] : null; $ey = @$years[$bibID][1] ? $years[$bibID][1] : null; if (!$sd && !$ed && $sy && $sy == $ey) { $ey = $sy + 1; } $s = $sd ? $sd : $sy; $e = $ed ? $ed : $ey; if ($s >= $e) { $e = null; } $timeObjects[$bibID] = array($s, $e); } } //if //sort($geoBibIDs); $geoRecords = array(); $cnt_geo = 0; $cnt_time = 0; //foreach ($geoBibIDs as $bibID) { foreach ($bibIDs as $bibID) { //loop for all records // $bibID = ""+$bibID; /*****DEBUG****/ //error_log("2>>>>>>".$geoBibIDs["97025"]); /*****DEBUG****/ //error_log("3>>>>>>".$bibID." ".$geoBibIDs[$bibID]." time=".array_key_exists($bibID, $timeObjects) ); $isNotGeoLoc = !@$geoBibIDs[$bibID]; if (!$isNotGeoLoc || array_key_exists($bibID, $timeObjects)) { /*****DEBUG****/ //error_log(">>>>>".$bibID."=".$geoBibIDs[$bibID]."<<<<<<".(!@$geoBibIDs[$bibID])."<<<<<<"); $geoRecords[$bibID] = $records[$bibID]; if ($isNotGeoLoc) { /*****DEBUG****/ //error_log(">>>>>PUSH EMPTY"); //no geo data - only timedata array_push($geoObjects, array("bibID" => $bibID, "type" => "none")); //empty georeference $geoBibIDs[$bibID] = $bibID; } else { $cnt_geo++; } if (array_key_exists($bibID, $timeObjects)) { list($start, $end) = $timeObjects[$bibID]; $geoRecords[$bibID]["start"] = $start; if ($end) { $geoRecords[$bibID]["end"] = $end; } $cnt_time++; } } } //count($geoRecords) $mapobjects = array("records" => $geoRecords, "geoObjects" => $geoObjects, "cntWithGeo" => $cnt_geo, "cntWithTime" => $cnt_time, "layers" => $layers); return $mapobjects; }
$search_type = BOOKMARK; $query = 'select distinct bkm_ID '; } else { if (!@$_REQUEST['w'] || $_REQUEST['w'] == 'a' || $_REQUEST['w'] == 'all') { // all records entries $search_type = BOTH; $query = 'select distinct rec_ID '; } else { return; // wwgd } } if (@$where) { $query = REQUEST_to_query($query, $search_type, NULL, "0"); } else { $query = REQUEST_to_query($query, $search_type); } if (preg_match('/.* order by (.*)/', $query, $matches)) { $order_col = $matches[1]; if ($search_type == BOTH || !preg_match('/bib_/', $order_col)) { define('rss_search-order', $order_col); } $query = substr($query, 0, strlen($query) - strlen(' order by ' . $matches[1])); } // hack! Instead of stupidly searching the useless usrBookmarks (bookmarks) table, give us rec_ids instead $query = str_replace("select distinct bkm_ID from", "select distinct rec_ID from", $query); $SEARCHES['rss_search'] = $query; /*****DEBUG****/ //error_log("query = ".$query); $template = file_get_contents('searchRSSTemplate.xml'); $lexer = new Lexer($template);
require_once "encodePolyline.php"; header("Content-type: text/javascript"); mysql_connection_select(DATABASE); if (!@$_REQUEST['q'] || @$_REQUEST['ver'] && intval(@$_REQUEST['ver']) < SEARCH_VERSION) { construct_legacy_search(); } // migration path if ($_REQUEST['w'] == 'B' || $_REQUEST['w'] == 'bookmark') { $search_type = BOOKMARK; } else { $search_type = BOTH; } // all records // find all matching records $cols = "rec_ID as bibID, rec_RecTypeID as rectype, rec_Title as title, rec_URL as URL"; $query = REQUEST_to_query("select {$cols} ", $search_type); /*****DEBUG****/ //error_log($query); $res = mysql_query($query); print mysql_error(); $records = array(); $bibIDs = array(); while ($bib = mysql_fetch_assoc($res)) { $bibID = $bib["bibID"]; if (!$bibID) { continue; } $records[$bibID] = $bib; array_push($bibIDs, $bibID); } foreach ($bibIDs as $bibID) {
mysql_connection_select(DATABASE); if (!array_key_exists('q', @$_REQUEST) || @$_REQUEST['ver'] && intval(@$_REQUEST['ver']) < SEARCH_VERSION) { construct_legacy_search(); } // migration path // if (! @$_REQUEST['q']) return; // wwgd $limit = RESULT_LIMIT; if (intval(@$_REQUEST["l"]) > 0) { $limit = intval($_REQUEST["l"]); } $searchID = "search"; if (@$_REQUEST["searchID"]) { $searchID = $_REQUEST["searchID"]; } $colNames = array("rec_ID", "rec_Title", "rec_URL", "rec_RecTypeID"); $query = REQUEST_to_query("select " . join(", ", $colNames) . " ", BOTH); if (@$_REQUEST["r"] == "recent") { $query = preg_replace("/\\swhere\\s/", " where (TOPBIBLIO.rec_RecTypeID!=1) AND " . "(TOPBIBLIO.rec_ID in (select distinct rre_RecID from usrRecentRecords where rre_UGrpID = " . get_user_id() . ")) and ", $query); // saw CHECK ME: this code assumes order by is last clause of query $query = preg_replace("/(.*)\\sorder by.*/", "\$1 order by TOPBIBLIO.rec_Modified desc", $query); } else { $query = preg_replace("/\\swhere\\s/", " where (TOPBIBLIO.rec_RecTypeID!=1) AND ", $query); } $query .= " limit {$limit}"; header("Content-type: text/javascript"); ?> ({ "searchID": "<?php echo slash($searchID); ?> ",
* * @copyright (C) 2005-2010 University of Sydney Digital Innovation Unit. * @link: http://HeuristScholar.org * @license http://www.gnu.org/licenses/gpl-3.0.txt * @package Heurist academic knowledge management system * @todo -->*/ require_once dirname(__FILE__) . '/../common/connect/applyCredentials.php'; require_once dirname(__FILE__) . '/../common/php/dbMySqlWrappers.php'; require_once dirname(__FILE__) . '/parseQueryToSQL.php'; require_once dirname(__FILE__) . '/../common/php/getRecordInfoLibrary.php'; mysql_connection_select(DATABASE); $searchType = BOTH; $args = array(); $publicOnly = false; $query = REQUEST_to_query("select rec_RecTypeID, count(*) ", $searchType, $args, null, $publicOnly); $query = substr($query, 0, strpos($query, "order by")); $query .= " group by rec_RecTypeID"; // style="width:640px;height:480px;" $rtStructs = getAllRectypeStructures(); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Database Summary</title> <link rel="stylesheet" type="text/css" href="../common/css/global.css"> <script type="text/javascript"> function onrowclick(rt_ID){