コード例 #1
0
ファイル: api_getHansard.php プロジェクト: leowmjw/twfy
function _api_getHansard_search($array)
{
    $search = isset($array['s']) ? trim($array['s']) : '';
    $pid = trim($array['pid']);
    $type = isset($array['type']) ? $array['type'] : '';
    $search = filter_user_input($search, 'strict');
    if ($pid) {
        $search .= ($search ? ' ' : '') . 'speaker:' . $pid;
    }
    if ($type) {
        $search .= " section:" . $type;
    }
    $o = get_http_var('order');
    if ($o == 'p') {
        $data = search_by_usage($search);
        $out = array();
        foreach ($data['speakers'] as $pid => $s) {
            $out[$pid] = array('house' => $s['house'], 'name' => $s['name'], 'party' => $s['party'], 'count' => $s['count'], 'mindate' => substr($s['pmindate'], 0, 7), 'maxdate' => substr($s['pmaxdate'], 0, 7));
        }
        api_output($out);
        return;
    }
    global $SEARCHENGINE;
    $SEARCHENGINE = new SEARCHENGINE($search);
    #        $query_desc_short = $SEARCHENGINE->query_description_short();
    $pagenum = get_http_var('page');
    $args = array('s' => $search, 'p' => $pagenum, 'num' => get_http_var('num'), 'pop' => 1, 'o' => $o == 'd' || $o == 'r' ? $o : 'd');
    $LIST = new HANSARDLIST();
    $LIST->display('search', $args, 'api');
}
コード例 #2
0
ファイル: ByUsage.php プロジェクト: udp12/theyworkforyou
 public function search($searchstring)
 {
     $q_house = '';
     if (ctype_digit(get_http_var('house'))) {
         $q_house = get_http_var('house');
     }
     $wtt = get_http_var('wtt');
     if ($wtt) {
         $q_house = 2;
     }
     # Fetch the results
     $data = search_by_usage($searchstring, $q_house);
     $data['house'] = $q_house;
     $data['search_type'] = 'person';
     return $data;
 }
コード例 #3
0
ファイル: mobile.php プロジェクト: leowmjw/twfy
 if ($searchmajor) {
     $searchstring .= " section:" . $searchmajor;
 }
 $searchgroupby = trim(get_http_var('groupby'));
 if ($searchgroupby) {
     $searchstring .= " groupby:" . $searchgroupby;
 }
 // We have only one of these, rather than one in HANSARDLIST also
 global $SEARCHENGINE;
 if (get_http_var('o') == 'p') {
     $q_house = '';
     if (ctype_digit(get_http_var('house'))) {
         $q_house = get_http_var('house');
     }
     # Fetch the results
     $data = search_by_usage($searchstring, $q_house);
     $wtt = get_http_var('wtt');
     if ($wtt) {
         $pagetitle = 'League table of Lords who say ' . $data['pagetitle'];
     } else {
         $pagetitle = 'Who says ' . $data['pagetitle'] . ' the most?';
     }
     $DATA->set_page_metadata($this_page, 'title', $pagetitle);
     $PAGE->page_start_mobile();
     $PAGE->stripe_start();
     $PAGE->search_form();
     if (isset($data['error'])) {
         print '<p>' . $data['error'] . '</p>';
         //$PAGE->page_end();
         $PAGE->page_end_mobile();
         return;
コード例 #4
0
function search_order_p($searchstring)
{
    global $DATA, $PAGE, $this_page;
    $q_house = '';
    if (ctype_digit(get_http_var('house'))) {
        $q_house = get_http_var('house');
    }
    # Fetch the results
    $data = search_by_usage($searchstring, $q_house);
    $wtt = get_http_var('wtt');
    if ($wtt) {
        $pagetitle = 'League table of Lords who say ' . $data['pagetitle'];
    } else {
        $pagetitle = 'Who says ' . $data['pagetitle'] . ' the most?';
    }
    $DATA->set_page_metadata($this_page, 'title', $pagetitle);
    $PAGE->page_start();
    $PAGE->stripe_start();
    $PAGE->search_form($searchstring);
    if (isset($data['error'])) {
        print '<p>' . $data['error'] . '</p>';
        return;
    }
    if (isset($data['limit_reached'])) {
        print '<p><em>This service runs on a maximum number of 5,000 results, to conserve memory</em></p>';
    }
    print "\n\n<!-- ";
    foreach ($data['party_count'] as $party => $count) {
        print "{$party}:{$count}<br>";
    }
    print " -->\n\n";
    if ($wtt) {
        ?>
<p><strong><big>Now, try reading what a couple of these Lords are saying,
to help you find someone appropriate. When you've found someone,
hit the "I want to write to this Lord" button on their results page
to go back to WriteToThem.
</big></strong></p>
<?php 
    }
    ?>
<p>Please note that this search is only for the exact word/phrase entered.
For example, putting in 'autism' won't return results for 'autistic spectrum disorder',
you will have to search for it separately.</p>
<table><tr><th>Number of occurences</th><th><?php 
    if ($wtt) {
        print 'Speaker';
    } else {
        ?>
Table includes - <?php 
        $URL = new URL($this_page);
        $url_l = $URL->generate('html', array('house' => 2));
        $url_c = $URL->generate('html', array('house' => 1));
        $URL->remove(array('house'));
        $url_b = $URL->generate();
        if ($q_house == 1) {
            print 'MPs | <a href="' . $url_l . '">Lords</a> | <a href="' . $url_b . '">Both</a>';
        } elseif ($q_house == 2) {
            print '<a href="' . $url_c . '">MPs</a> | Lords | <a href="' . $url_b . '">Both</a>';
        } else {
            print '<a href="' . $url_c . '">MPs</a> | <a href="' . $url_l . '">Lords</a> | Both';
        }
    }
    ?>
</th><th>Date range</th></tr>
<?php 
    foreach ($data['speakers'] as $pid => $speaker) {
        print '<tr><td align="center">';
        print $speaker['count'] . '</td><td>';
        if ($pid) {
            $house = $speaker['house'];
            $left = $speaker['left'];
            if ($house == 1) {
                print '<span style="color:#009900">&bull;</span> ';
            } elseif ($house == 2) {
                print '<span style="color:#990000">&bull;</span> ';
            }
            if (!$wtt || $left == '9999-12-31') {
                print '<a href="' . WEBPATH . 'search/?s=' . urlencode($searchstring) . '&amp;pid=' . $pid;
            }
            if ($wtt && $left == '9999-12-31') {
                print '&amp;wtt=2';
            }
            if (!$wtt || $left == '9999-12-31') {
                print '">';
            }
        }
        print $speaker['name'];
        if ($pid) {
            print '</a>';
        }
        if ($speaker['party']) {
            print ' (' . $speaker['party'] . ')';
        }
        if (isset($speaker['office'])) {
            print ' - ' . join('; ', $speaker['office']);
        }
        print '</td> <td>';
        $pmindate = $speaker['pmindate'];
        $pmaxdate = $speaker['pmaxdate'];
        if (format_date($pmindate, 'M Y') == format_date($pmaxdate, 'M Y')) {
            print format_date($pmindate, 'M Y');
        } else {
            print str_replace(' ', '&nbsp;', format_date($pmindate, 'M Y') . ' &ndash; ' . format_date($pmaxdate, 'M Y'));
        }
        print '</td></tr>';
    }
    print '</table>';
}