function __construct($seek_search_params, $search_position) { $this->search_position = $search_position; if (is_string($seek_search_params)) { parse_str($seek_search_params, $query_params); } else { $query_params = $seek_search_params; } $search = Search::from_params($query_params); $search->maxrecs = 3; $prev_item_num = $this->search_position > 1 ? $this->search_position - 1 : null; $current_result_index = $this->search_position - 1; $search->start = array(0, max(1, $current_result_index)); $results = $search->results(); if ($this->search_position > 1) { $this->previous_item = get_item($results[0]['collection'], $results[0]['pointer']); $this->previous_item['query_string'] .= "&search_position=" . ($this->search_position - 1); } if ($this->search_position < $search->total) { $next_result_index = $this->search_position > 1 ? 2 : 1; $this->next_item = get_item($results[$next_result_index]['collection'], $results[$next_result_index]['pointer']); $this->next_item['query_string'] .= "&search_position=" . ($this->search_position + 1); } $this->total_items = $search->total; }
public static function from_param_string($param_string) { if (!preg_match('/=/', $param_string)) { $param_string = urldecode($param_string); } parse_str($param_string, $params); return Search::from_params($params); }
public function testShouldParseSimpleSearch() { $params = array('s' => 'Lansing mayor'); $search = Search::from_params($params); $this->assertEquals(13, count($search->search_alias)); $this->assertEquals('Lansing mayor', $search->search_string[0]['string']); $this->assertEquals('CISOSEARCHALL', $search->search_string[0]['field']); $this->assertEquals('any', $search->search_string[0]['mode']); }
public function testShouldOverrideGivenParams() { $params = array('CISOROOT' => '/p4006coll3', 'CISOBOX1' => 'street car', 'CISOOP1' => 'exact', 'CISOFIELD1' => 'title', 'CISOBOX2' => 'Lansing', 'CISOOP2' => 'any', 'CISOFIELD2' => 'title', 'CISOBOX3' => 'station', 'CISOOP3' => 'any', 'CISOFIELD3' => 'subjec', 'CISOSTART' => '1,21'); $search = Search::from_params($params); $fields = $search->form_fields(array('CISOROOT' => 'abracadabra')); $new_params = $params; $new_params['CISOROOT'] = 'abracadabra'; $this->assertEquals($new_params, $fields); }
<? include("config.php"); include('lib/paginator.php'); $search = Search::from_params($_GET); $collections = dmGetCollectionList(); $results = $search->results(); $search_url = $_SERVER['QUERY_STRING']; $breadcrumbs = array('Home' => SEEKING_MICHIGAN_HOST, 'Seek' => 'seek_advanced.php', 'Search Results' => ''); app()->partial('header', array('body_class' => 'seek', 'breadcrumbs' => $breadcrumbs, 'title' => 'Results : Seek — Seeking Michigan')); ?> <div id="section-header"> <h1><a href="seek_advanced.php">Seek</a></h1> </div> <div id="main-content"> <div class="wrapper"> <? $search->terms; ?> <? if(!$search->is_default_search()): ?> <h1> Search Results for: <? foreach($search->terms() as $term): ?> <a href="seek_results.php?<?php echo $search->term_search_string($term); ?> "> <?php
public function testShouldReturnFalseIfSpecificSearch() { $search = Search::from_params(array('CISOROOT' => 'all', 's' => 'smokey')); $this->assertFalse($search->is_default_search()); }
public static function from_param_string($param_string) { parse_str(urldecode($param_string), $params); return Search::from_params($params); }
public function testSholdReturnListOfFieldsSansCISOROOT() { $search = Search::from_params(array('s' => 'crumbly apple cobbler')); $results = $this->helper->search_fields_without_alias($search); $this->assertEquals(array('CISOBOX1' => 'crumbly apple cobbler', 'CISOOP1' => 'any', 'CISOFIELD1' => 'CISOSEARCHALL', 'CISOSTART' => '1,1'), $results); }