예제 #1
0
    $rdisplay_parliament = db_scrub($_GET["parliament"]);
}
if (!$rdisplay_parliament) {
    $rdisplay_parliament = "all";
}
# generate title and header of this webpage
if ($mpprop['house'] == 'commons') {
    $contitlefor = "for " . $mpprop['constituency'];
    $contitlecomma = ", " . $mpprop['constituency'];
} else {
    $contitlefor = "";
    $contitlecomma = "";
}
$colour_scheme = $mpprop['house'];
if ($voter2type == "dreammp") {
    update_dreammp_person_distance($db, $voter2);
    $query = "SELECT nvotessame+nvotessamestrong+nvotesdiffer+nvotesdifferstrong AS nvotes, distance_a\n                            FROM pw_cache_dreamreal_distance\n                            WHERE dream_id = {$voter2} AND person = ?";
    $pwpdo->get_single_row($query, array($mpprop['person']));
    $h1title = "<div class=\"h1mppolicy\">";
    $h1title .= "<p class=\"mp\"><a href=\"" . $voter1link . "\">" . html_scrub($mpprop['fullname']) . "</a></p>";
    $agreement_a = 1.0 - $row["distance_a"];
    $h1title .= "<p class=\"voteexpl\">";
    if ($row["nvotes"] == 0) {
        $h1title .= "has <em>never voted</em> on";
    } else {
        if ($agreement_a >= 0.8) {
            $h1title .= "voted <em>strongly for</em>";
        } else {
            if ($agreement_a >= 0.6) {
                $h1title .= "voted <em>moderately for</em>";
            } else {
예제 #2
0
 $unique_parties = array_values($parties);
 $unique_parties = array_unique($unique_parties);
 $mp_party = $parties[$mpattr['party']];
 #print "<p>MP party $mp_party standing again $standing_again<p>";
 # Go through each issue to extract data
 $distances = array();
 $distances['Comparision'] = array();
 $issuecount = 0;
 foreach ($issues as $issue) {
     $dreamid = $issue[0];
     $distances[$dreamid] = array();
     $issuecount++;
     # Find your score
     $distances[$dreamid]['You'] = 1.0 - floatval($_GET["i{$dreamid}"]);
     # Find distance from Dream MP to each party
     update_dreammp_person_distance($db, $dreamid);
     $query = "select avg(distance_a) as dist, party from \npw_cache_dreamreal_distance \nleft join pw_mp \non pw_mp.person = pw_cache_dreamreal_distance.person \n   and left_house = '2005-04-11' \nwhere dream_id = {$dreamid} group by party";
     $db->query($query);
     $party_dist = array();
     while ($row = $db->fetch_row_assoc()) {
         $dist = $row['dist'];
         if ($issue[2]) {
             $dist = 1.0 - $dist;
         }
         $canonparty = $parties[$row['party']];
         $party_dist[$canonparty] += $dist;
     }
     foreach ($unique_parties as $party) {
         $distance = $party_dist[$party];
         if ($distance == null) {
             $distance = 0.5;