Skip to content

Commit

Permalink
Fixed: search map now uses Solarium
Browse files Browse the repository at this point in the history
Updates #381
  • Loading branch information
inghamn committed Jul 2, 2021
1 parent 2811352 commit bec1c31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
16 changes: 8 additions & 8 deletions crm/blocks/html/tickets/searchResultsMap.inc
Expand Up @@ -2,15 +2,15 @@
/**
* Displays a map of the search results
*
* @copyright 2013-2020 City of Bloomington, Indiana
* @copyright 2013-2021 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @param Apache_Solr_Response $this->solrObject
* @param \Solarium\QueryType\Select\Result\Result $this->result
*/
use Blossom\Classes\Block;
use Blossom\Classes\Url;

$this->_include('tickets/partials/searchResultsFormatButtons.inc');
$c = $this->solrObject->response->numFound;
$c = $this->result->getNumFound();
?>
<section class="searchResults">
<header>
Expand Down Expand Up @@ -38,18 +38,18 @@ $c = $this->solrObject->response->numFound;
}
$zoom = isset($_GET['zoom']) ? (int)$_GET['zoom'] : 12;

$solr_params = isset($this->solrObject->responseHeader->params)
? json_encode($this->solrObject->responseHeader->params)
: '{}';

$query = $this->result->getQuery()->getOptions();
$fq = [];
foreach ($query['filterquery'] as $q) { $fq[] = $q['query']; }
$params = json_encode(['query'=>$query['query'], 'fq'=>$fq ]);

echo "
<div id=\"location_map\"></div>
<script type=\"text/javascript\">
var CENTER_LATITUDE = $centerLatitude;
var CENTER_LONGITUDE = $centerLongitude;
var ZOOM = $zoom;
var SOLR_PARAMS = $solr_params;
var SOLR_PARAMS = $params;
</script>
";

Expand Down
3 changes: 1 addition & 2 deletions crm/public/js/tickets/searchResultsMap.js
Expand Up @@ -64,8 +64,7 @@ google.maps.event.addDomListener(window, 'load', function () {
},
getSolrBaseUrl = function (coordinates) {
var url = CRM.BASE_URI + '/solr?';
url += SOLR_PARAMS.q ? 'q=' + SOLR_PARAMS.q : 'q=*.*';
url += SOLR_PARAMS.sort ? '&sort=' + SOLR_PARAMS.sort : '';
url += SOLR_PARAMS.q ? 'q=' + SOLR_PARAMS.q : 'q=*:*';
url += getFqParameters() + '&fq=coordinates:' + coordinates;
url += '&wt=json&json.nl=map';
return url;
Expand Down
7 changes: 3 additions & 4 deletions crm/src/Application/Controllers/SolrController.php
Expand Up @@ -8,9 +8,8 @@
* This proxy URL provides a solution for both these problems.
* Request parameters are forwarded to the /solr/select? url
*
* @copyright 2013 City of Bloomington, Indiana
* @copyright 2013-2021 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
namespace Application\Controllers;

Expand All @@ -29,9 +28,9 @@ public function index()
}

$protocol = SOLR_SERVER_PORT==443 ? 'http://' : 'http://';
$url = $protocol.SOLR_SERVER_HOSTNAME;
$url = $protocol.SOLR_SERVER_HOST;
if (SOLR_SERVER_PORT != 80) { $url.= ':'.SOLR_SERVER_PORT; }
$url.= SOLR_SERVER_PATH.'/select?'.$_SERVER['QUERY_STRING'];
$url.= '/solr/'.SOLR_SERVER_CORE.'/select?'.$_SERVER['QUERY_STRING'];

echo Url::get($url);
exit();
Expand Down

0 comments on commit bec1c31

Please sign in to comment.