Exemple #1
0
$reccount = mysql_num_rows($res);
$uniq_id = 1;
if ($reccount > 0) {
    while ($row = mysql_fetch_row($res)) {
        //find rectitle for creator
        if ($row[8]) {
            $creator = mysql__select_array("Records", "rec_Title", "rec_ID=" . $row[8]);
            $creator = count($creator) > 0 ? $creator[0] : null;
        } else {
            $creator = null;
        }
        // grab the user tags, as a single comma-delimited string
        $kwds = mysql__select_array("usrRecTagLinks left join usrTags on tag_ID=rtl_TagID", "tag_Text", "rtl_RecID=" . $row[0] . " and tag_UGrpID=" . get_user_id() . " order by rtl_Order, rtl_ID");
        $tagString = join(",", $kwds);
        //get url for thumbnail
        $thubURL = getThumbnailURL($row[0]);
        $url = $row[1] ? htmlspecialchars($row[1]) : HEURIST_BASE_URL . "records/view/viewRecord.php?db=" . HEURIST_DBNAME . "&recID=" . $row[0];
        $uid = HEURIST_BASE_URL . "records/view/viewRecord.php?db=" . HEURIST_DBNAME . "&recID=" . $row[0];
        //HEURIST_BASE_URL."search/search.html?db=".HEURIST_DBNAME."&q=ids:".$row[0];
        //$uid = $uniq_id;
        $uniq_id++;
        //error_log(">>>>>> added=".$row[6]."    edt=".$row[5]);
        $date_published = date("r", strtotime($row[5] == null ? $row[6] : $row[5]));
        $description = $row[7] ? "<![CDATA[" . $row[7] . "]]>" : "";
        if ($isAtom) {
            ?>
<entry>
	<title><?php 
            echo htmlspecialchars($row[2]);
            ?>
</title>
/**
	* 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;
}
Exemple #3
0
<!-- posts -->
<?php 
$i = 0;
$banner1 = blog_get_banner(1);
while (have_posts()) {
    the_post();
    $i++;
    if ($i == 1) {
        $title = get_the_title(get_the_id());
        $count = count(explode(' ', $title));
        $long = '';
        $long = $count > 10 && $count < 15 ? 'long' : '';
        $long = $count >= 15 ? 'long2' : '';
        $thumb_bg = '';
        if (has_post_thumbnail()) {
            $thumb_bg = sprintf('style="background: url(%s) no-repeat; background-size: cover;"', getThumbnailURL(get_the_ID()));
        }
        ?>
	<article class="hentry featured-post full-width-post" <?php 
        echo $thumb_bg;
        ?>
>
		<div class="center-wrap">
			<div class="content">

				<h2 class="<?php 
        echo $long;
        ?>
"><a href="<?php 
        the_permalink();
        ?>
function print_result($row)
{
    global $num;
    print "\t[";
    foreach ($row as $i => $val) {
        if ($i > 0) {
            print ',';
        }
        print "'" . str_replace("\n", '\\n', str_replace("\r", '', addslashes($val))) . "'";
    }
    $thumb_url = getThumbnailURL($row[2]);
    print ",'{$thumb_url}'";
    print "]";
    ++$num;
}
function createQueryRecSet()
{
    //echo "request = ".print_r($_REQUEST,true)."\n";
    $qresult = loadSearch($_REQUEST);
    //echo "query result = ".print_r($qresult,true)."\n";
    $recSet = array('count' => 0, 'recSet' => array(), 'params' => array_intersect_key($_REQUEST, array('q' => 1, 'w' => 1, 'depth' => 1, 'f' => 1, 'limit' => 1, 'offset' => 1, 'rev' => 1, 'revexpand' => 1, 'db' => 1, 'sid' => 1, 'slb' => 1, 'rtfilters' => 1, 'relfilters' => 1, 'ptrfilters' => 1)), 'infoByDepth' => array(array('recIDs' => array(), 'rectypes' => array())));
    //echo "query reults = ".json_format($result,true);
    $rec_ids = array();
    foreach ($qresult['records'] as $record) {
        array_push($rec_ids, $record['rec_ID']);
        $recSet['recSet'][$record['rec_ID']] = array('depth' => 0, 'record' => array(null, null, $record['rec_ID'], $record['rec_URL'], $record['rec_RecTypeID'], $record['rec_Title'], $record['rec_OwnerUGrpID'], $record['rec_NonOwnerVisibility'], null, null, null, getThumbnailURL($record['rec_ID'])));
        array_push($recSet['infoByDepth'][0]['recIDs'], $record['rec_ID']);
        // add recID to it's rectype array for this depth
        if (!@$recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']]) {
            $recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']] = array($record['rec_ID']);
        } else {
            if (!in_array($record['rec_ID'], $recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']])) {
                array_push($recSet['infoByDepth'][0]['rectypes'][$record['rec_RecTypeID']], $record['rec_ID']);
            }
        }
    }
    return $recSet;
}