Commits

Richard Chiswell  committed 9f19d63

Update Readme.txt, fix homepage link in header, remove unneeded files

  • Participants
  • Parent commits 2d10d48

Comments (0)

Files changed (4)

 product go to http://www.publicwhip.org.uk.  If you don't know what this is all
 about, have a look at the FAQ there.  
 
+The code is currently under a major rewrite at the moment and so things may change quite quickly.
+
 To learn how to use the code look at http://www.publicwhip.org.uk/project/code.php 
 or locally in webpage/project/code.php.  You should also check out the
 Parliament Parse project at http://ukparse.kforge.net/parlparse, which is the
 A description of the files and folders in this package follows.
 
 LICENSE.html - Details of open source licensing terms, under the Affero GNU GPL
-todo.txt - Things I'm thinking of doing in the short term
-ideas.txt - Zillions of ideas of things which could be done
-errata.txt - Errors in Hansard that the software has found
 
 loader    - Load XML files from ukparse into the database
 website   - Code for www.publicwhip.org.uk, PHP extracts data from database/XML

File website/election_glenrothes_2008.inc~

-<?php require_once "common.inc";
-
-# The Public Whip, Copyright (C) 2008 Francis Irving and Julian Todd
-# This is free software, and you are welcome to redistribute it under
-# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
-# For details see the file LICENSE.html in the top level of the source.
-
-
-# here is the data that will have to be loaded from the database
-
-//$constituency = "Crewe and Nantwich"; # mpc=urlencode()
-$constituency = "Glenrothes"; # mpc=urlencode()
-
-$candidatesA = array();
-
-$candidatesA[] = array("name" => "The Flying Brick", 
-                      "url"=>"http://www.omrlp.com/",
-                      "party" => "Official Monster Raving Loony", 
-                      "party_code" => "OMRL");
-
-$candidatesA[] = array("name" => "Tamsin Dunwoody",
-                      "url"=>"http://www.creweandnantwichlabour.org.uk/",
-                      "party" => "Labour", 
-                      "party_code" => "Lab", "votetype"=>"party", "matchid" => "party=Lab",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=6&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Gwyneth Dunwoody", 
-                      "url"=>"http://www.gwynethdunwoody.co.uk/",
-                      "party" => "Labour", "votetype"=>"leftoffice", "personid" => 10181,
-                      "matchid" => "mpn=Gwyneth_Dunwoody&mpc=Crewe+%26amp%3B+Nantwich");
-
-$candidatesA[] = array("name" => "Gemma Garrett",
-                       "party_code" => "BfB",
-                       "party" => "Independent");
-
-$candidatesA[] = array("name" => "Mike Nattrass",
-                      "url"=>"http://www.votenattrass.info/",
-                      "party_code" => "UKIP",
-                      "party" => "UKIP",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=60&frmType=partydetail");
-
-$candidatesA[] = array("name" => "David Roberts",
-                       "url" => "http://www.englishdemocrats.org.uk",
-                       "party_code" => "ED",
-                       "party" => "English Democrats",
-                       "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=114&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Elizabeth Shenton",
-                      "url"=>"http://www.elizabethshenton.com/",
-                      "party" => "Liberal Democrats", 
-                      "party_code" => "LDem", "votetype"=>"party", "matchid" => "party=LDem",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=26&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Robert Smith",
-                       "url" => "http://eastcheshire.greenparty.org.uk/",
-                       "party_code" => "Green",
-                       "party" => "Green Party",
-                       "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=64&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Paul Thorogood",
-                       "url"=>"http://www.cuttaxonpetrol.co.uk/",
-                       "party_code" => "Diesel",
-                       "party" => "Cut Tax on Petrol and Diesel",
-                       "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=834&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Edward Timpson", 
-                      "url"=>"http://www.creweandnantwichconservatives.com/",
-                      "party" => "Conservatives",
-                      "party_code" => "Con", "votetype"=>"party", "matchid" => "party=LDem",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=25&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Mark Walklate",
-                      "party_code" => "Walklate",
-                      "party" => "Independent",
-                      );
-
-
-# filter out list and apply the matchids to these columns
-$candidates = array();
-for ($i = 0; $i < count($candidatesA); $i++)
-{
-    $candidatesA[$i]["candidate_id"] = $i + 10; 
-    if ($candidatesA[$i]["matchid"])
-        $candidates[] = $candidatesA[$i];
-}
-
-
-# the issues to be compared against
-$issues = array();
-$issues[] = array("dream_id" => 1012,  "name" => "Post offices", 
-                    "action" => "the Government's post office modernisation programme");
-$issues[] = array("dream_id" => 963,  "name" => "Invade Iraq", 
-                    "action" => "the 2003 invasion of Iraq");
-$issues[] = array("dream_id" => 975,  "name" => "Investigate Iraq", 
-                    "action" => "investigating the Iraq war");
-$issues[] = array("dream_id" => 1037, "name" => "Income tax",
-                    "action" => "abolishing the 10% income tax bracket");
-$issues[] = array("dream_id" => 1001, "name" => "Public MPs", 
-                    "action" => "the Freedom of Information Act continuing to apply to MPs and Parliament");
-$issues[] = array("dream_id" => 1003, "name" => "Replace Trident", 
-                    "action" => "replacing the Trident submarine-launched nuclear weapons system");
-$issues[] = array("dream_id" => 1000, "name" => "Ban smoking", 
-                    "action" => "banning smoking in all public places");
-$issues[] = array("dream_id" => 981,  "name" => "Control orders", 
-                    "action" => "Control Orders for terrorist suspects");
-$issues[] = array("dream_id" => 1009, "name" => "ID Cards", 
-                    "action" => "compulsory biometric ID Cards and identity register for all citizens");
-$issues[] = array("dream_id" => 852,  "name" => "Nuclear power", 
-                    "action" => "new civil nuclear power plants");
-$issues[] = array("dream_id" => 856,  "name" => "Abolish Parliament",
-                    "action" => "giving the Government the power to summarily change any law without a vote in Parliament");
-$issues[] = array("dream_id" => 629,  "name" => "Parliament protest",
-                    "action" => "allowing protests to take place around Parliament");
-$issues[] = array("dream_id" => 1034,  "name" => "Ban fox hunting",
-                    "action" => "the total ban on fox hunting");
-$issues[] = array("dream_id" => 1035,  "name" => "University tuition fees",
-                    "action" => "that universities should be allowed to charge the students tuition fees");
-
-
-function GetPartyDistances($db, $dream_id)
-{
-    update_dreammp_person_distance($db, $dream_id);
-    $qselect = "SELECT AVG(distance_a) as distance, party";
-    $qfrom =   " FROM pw_cache_dreamreal_distance";
-    $qjoin =   " LEFT JOIN pw_mp ON pw_mp.person = pw_cache_dreamreal_distance.person";
-    $qwhere =  " WHERE house = 'commons' AND dream_id = '$dream_id'";
-    $qgroup =  " GROUP BY party";
-
-    $db->query($qselect.$qfrom.$qjoin.$qwhere.$qgroup);
-    $partydistances = array();
-    while ($row = $db->fetch_row_assoc())
-        $partydistances[$row['party']] = ($row["distance"]);
-    return $partydistances;
-}
-
-function GetIncumbentIssueDistances($db, $candidate, $dream_id)
-{
-    update_dreammp_person_distance($db, $dream_id);
-    $person_id = $candidate["personid"];
-    $qselect = "SELECT distance_a AS distance";
-    $qfrom =   " FROM pw_cache_dreamreal_distance";
-    $qwhere =  " WHERE pw_cache_dreamreal_distance.person = '$person_id' AND dream_id = '$dream_id'";
-    $row = $db->query_onez_row_assoc($qselect.$qfrom.$qwhere);
-    if (($row == null) || ($row["distance"] === null))
-        return null;
-    return strval($row["distance"] + 0.0);
-}
-
-function SetCandidateIssueDistances($db, &$candidates, $issues)
-{
-    foreach ($issues as $issue)
-        $issuepartydistances[$issue["name"]] = GetPartyDistances($db, $issue["dream_id"]);
-
-    foreach ($candidates as &$candidate)  # & required so we can set its value
-    {
-        foreach ($issues as $issue)
-        {
-            $partydistance = $issuepartydistances[$issue["name"]][$candidate["party_code"]];
-            if (($candidate["votetype"] == "incumbent") or ($candidate["votetype"] == "leftoffice"))
-                $distance = GetIncumbentIssueDistances($db, $candidate, $issue["dream_id"]);
-            else  # this is where we do the dreammp case
-                $distance = $partydistance;
-            $candidate["issuedistances"][$issue["name"]] = ($distance === null ? -1 : (float)$distance);
-        }
-    }
-}
-
-
-function WriteJavascriptElecTable($candidates, $issues)
-{
-    print "// issue user-opinion map\n";
-    print "var issues = ";
-    for ($i = 0; $i < count($issues); $i++)
-        print ($i == 0 ? "[" : ", ").$issues[$i]["dream_id"];
-    print "];\n";
-    print "var candidates = ";
-    for ($j = 0; $j < count($candidates); $j++)
-        print ($j == 0 ? "[" : ", ").$candidates[$j]["candidate_id"];
-    print "];\n\n";
-
-    print "// candidate-issue distance table\n";
-    print "var citable = [ \n";
-    foreach ($candidates as $candidate)
-    {
-        print "  [";
-        foreach ($issues as $issue)
-        {
-            $distance = $candidate["issuedistances"][$issue["name"]];
-            print "$distance, ";
-        }
-        print "],\n";
-    }
-    print "     ];\n";
-}
-
-

File website/election_glenrothes_2008issues.inc~

-<?php require_once "common.inc";
-
-# The Public Whip, Copyright (C) 2008 Francis Irving and Julian Todd
-# This is free software, and you are welcome to redistribute it under
-# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
-# For details see the file LICENSE.html in the top level of the source.
-
-
-# here is the data that will have to be loaded from the database
-
-//$constituency = "Crewe and Nantwich"; # mpc=urlencode()
-$constituency = "Glenrothes"; # mpc=urlencode()
-
-$candidatesA = array();
-
-$candidatesA[] = array("name" => "Peter Grant", 
-                      "url"=>"http://glenrothes-snp.blogspot.com/",
-                      "party" => "Scottish National Party", 
-                      "party_short" => "SNP", 
-                      "party_code" => "SNP", "votetype"=>"party", "matchid" => "party=SNP", 
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=6&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Lindsay Roy",
-                      "url"=>"http://www.lindsayroy.com/",
-                      "party" => "Labour", 
-                      "party_code" => "Lab", "votetype"=>"party", "matchid" => "party=Lab",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=6&frmType=partydetail");
-
-//$candidatesA[] = array("name" => "Gwyneth Dunwoody", 
-//                      "url"=>"http://www.gwynethdunwoody.co.uk/",
-//                      "party" => "Labour", "votetype"=>"leftoffice", "personid" => 10181,
-//                      "matchid" => "mpn=Gwyneth_Dunwoody&mpc=Crewe+%26amp%3B+Nantwich");
-
-
-$candidatesA[] = array("name" => "Kris Seunarine",
-                      "url"=>"http://www.ukip.org/content/latest-news/734-ukips-candidate-to-fight-glenrothes",
-                      "party_code" => "UKIP",
-                      "party" => "UKIP",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=60&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Harry Wills",
-                      "url"=>"http://fightingforfife.org.uk/",
-                      "party" => "Liberal Democrats", 
-                      "party_short" => "LibDems",
-                      "party_code" => "LDem", "votetype"=>"party", "matchid" => "party=LDem",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=26&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Morag Balfour",
-                       "url" => "http://www.scottishsocialistparty.org/new_stories/glenrothes/sspcandidate.html",
-                       "party_code" => "SSP",
-                       "party" => "Scottish Socialist Party",
-                       "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=64&frmType=partydetail");
-
-$candidatesA[] = array("name" => "Maurice Golden", 
-                      "url"=>"http://www.mauricegolden.com/",
-                      "party" => "Conservatives",
-                      "party_code" => "Con", "votetype"=>"party", "matchid" => "party=Con",
-                      "party_url" => "http://www.electoralcommission.org.uk/regulatory-issues/regpoliticalparties.cfm?frmGB=1&frmPartyID=25&frmType=partydetail");
-
-
-
-# filter out list and apply the matchids to these columns
-$candidates = array();
-for ($i = 0; $i < count($candidatesA); $i++)
-{
-    $candidatesA[$i]["candidate_id"] = $i + 10; 
-    if ($candidatesA[$i]["matchid"])
-        $candidates[] = $candidatesA[$i];
-}
-
-
-# the issues to be compared against
-$issues = array();
-//$issues[] = array("dream_id" => 1012,  "name" => "Post offices", 
-//                    "action" => "the Government's post office modernisation programme");
-$issues[] = array("dream_id" => 1009, "name" => "ID Cards", 
-                    "action" => "compulsory biometric <em>ID Cards</em> and identity register for all citizens");
-$issues[] = array("dream_id" => 1041, "name" => "Abortion",
-                    "action" => "limiting access to <em>legal abortion</em>");
-$issues[] = array("dream_id" => 963,  "name" => "Invade Iraq", 
-                    "action" => "the 2003 <em>invasion of Iraq</em>");
-$issues[] = array("dream_id" => 975,  "name" => "Investigate Iraq", 
-                    "action" => "investigating the <em>Iraq war</em>");
-$issues[] = array("dream_id" => 1037, "name" => "Income tax",
-                    "action" => "abolishing the 10% <em>income tax</em> bracket");
-$issues[] = array("dream_id" => 1047, "name" => "MPs' pay", 
-                    "action" => "paying <em>MPs</em> higher <em>salaries</em> and protecting their benefits");
-$issues[] = array("dream_id" => 1001, "name" => "Public MPs", 
-                    "action" => "the Freedom of Information Act continuing to apply to MPs and Parliament");
-$issues[] = array("dream_id" => 1046, "name" => "Planning reform",
-                    "action" => "fast-tracking the planning laws for national infrastructure");
-//$issues[] = array("dream_id" => 1000, "name" => "Ban smoking", 
-//                    "action" => "banning smoking in all public places");
-$issues[] = array("dream_id" => 981,  "name" => "Control orders", 
-                    "action" => "<em>Control Orders</em> for terrorist suspects");
-$issues[] = array("dream_id" => 852,  "name" => "Nuclear power", 
-                    "action" => "new civil <em>nuclear power</em> plants");
-$issues[] = array("dream_id" => 856,  "name" => "Abolish Parliament",
-                    "action" => "giving the Government the power to summarily change any law without a vote in Parliament");
-$issues[] = array("dream_id" => 629,  "name" => "Parliament protest",
-                    "action" => "allowing protests to take place around Parliament");
-$issues[] = array("dream_id" => 1003, "name" => "Replace Trident", 
-                    "action" => "replacing the Trident submarine-launched <em>nuclear weapons</em> system");
-$issues[] = array("dream_id" => 1034,  "name" => "Ban fox hunting",
-                    "action" => "the total ban on <em>fox hunting</em>");
-//$issues[] = array("dream_id" => 1035,  "name" => "University tuition fees",
-//                    "action" => "universities being allowed to charge the students tuition fees");
-
-$citablecache = array(
-"1009" => array("SNP"=>0.992676122622, "Lab"=>0.0753921308169, "LDem"=>0.981429720085, "Con"=>0.965949504775, ),
-"1041" => array("SNP"=>0.66363636472, "Lab"=>0.786710454975, "LDem"=>0.696356458645, "Con"=>0.380164559174, ),
-"963" => array("SNP"=>1, "Lab"=>0.303216849019, "LDem"=>0.995422066154, "Con"=>0.0868070685343, ),
-"975" => array("SNP"=>0.0176082058654, "Lab"=>0.929568744581, "LDem"=>0.0114043537716, "Con"=>0.0961170162272, ),
-"1037" => array("SNP"=>0.829545454545, "Lab"=>0.0996025952554, "LDem"=>0.926850124082, "Con"=>0.674021186667, ),
-"1047" => array("SNP"=>0.62106782198, "Lab"=>0.369178233672, "LDem"=>0.708264974071, "Con"=>0.653098060952, ),
-"1001" => array("SNP"=>0.5, "Lab"=>0.618027559963, "LDem"=>0.386552778587, "Con"=>0.56368838073, ),
-"1046" => array("SNP"=>0.5122850158, "Lab"=>0.0793373824623, "LDem"=>0.942335006016, "Con"=>0.924439724953, ),
-"981" => array("SNP"=>0.775793325777, "Lab"=>0.172853759074, "LDem"=>0.882223341637, "Con"=>0.846820350224, ),
-"852" => array("SNP"=>1, "Lab"=>0.0811673632309, "LDem"=>0.958622938547, "Con"=>0.487667371236, ),
-"856" => array("SNP"=>0.877934932709, "Lab"=>0.125728022937, "LDem"=>0.899168736454, "Con"=>0.866141019827, ),
-"629" => array("SNP"=>0.0872193105519, "Lab"=>0.8190671137, "LDem"=>0.181201012545, "Con"=>0.411701367165, ),
-"1003" => array("SNP"=>1, "Lab"=>0.31698480111, "LDem"=>0.936567164179, "Con"=>0.0671449597209, ),
-"1034" => array("SNP"=>0.5, "Lab"=>0.0948701027692, "LDem"=>0.373711576103, "Con"=>0.898914932337, ),
-);
-
-function GetPartyDistances($db, $dream_id)
-{
-    $partydistances = array();
-    global $citablecache; 
-
-    // hack to cache the party calculations
-    foreach ($citablecache[$dream_id] as $party => $distance)
-        $partydistances[$party] = $distance; 
-    return $partydistances;
-    // end-hack to cache the party calculations
-
-    update_dreammp_person_distance($db, $dream_id);
-    $qselect = "SELECT AVG(distance_a) as distance, party";
-    $qfrom =   " FROM pw_cache_dreamreal_distance";
-    $qjoin =   " LEFT JOIN pw_mp ON pw_mp.person = pw_cache_dreamreal_distance.person";
-    $qwhere =  " WHERE house = 'commons' AND dream_id = '$dream_id'";
-    $qgroup =  " GROUP BY party";
-
-    $db->query($qselect.$qfrom.$qjoin.$qwhere.$qgroup);
-    while ($row = $db->fetch_row_assoc())
-        $partydistances[$row['party']] = ($row["distance"]);
-    return $partydistances;
-}
-
-// this function is used to make the caching table above that avoids the big sql call for the AVG party distances
-function WritePHPelectable($candidates, $issues)
-{
-    print "/*";
-    print '$citablecache = array('."\n"; 
-    foreach ($issues as $issue)
-    {
-        print '"'.$issue["dream_id"]."\" => array("; 
-        foreach ($candidates as $candidate)
-        {
-            print '"'.$candidate["party_code"].'"=>'.$candidate["issuedistances"][$issue["name"]].', ';
-        }
-        print "),\n"; 
-    }
-    print ");\n";
-    print "*/"; 
-}
-
-function GetIncumbentIssueDistances($db, $candidate, $dream_id)
-{
-    update_dreammp_person_distance($db, $dream_id);
-    $person_id = $candidate["personid"];
-    $qselect = "SELECT distance_a AS distance";
-    $qfrom =   " FROM pw_cache_dreamreal_distance";
-    $qwhere =  " WHERE pw_cache_dreamreal_distance.person = '$person_id' AND dream_id = '$dream_id'";
-    $row = $db->query_onez_row_assoc($qselect.$qfrom.$qwhere);
-    if (($row == null) || ($row["distance"] === null))
-        return null;
-    return strval($row["distance"] + 0.0);
-}
-
-function SetCandidateIssueDistances($db, &$candidates, $issues)
-{
-    foreach ($issues as $issue)
-        $issuepartydistances[$issue["name"]] = GetPartyDistances($db, $issue["dream_id"]);
-
-    foreach ($candidates as &$candidate)  # & required so we can set its value
-    {
-        foreach ($issues as $issue)
-        {
-            $partydistance = $issuepartydistances[$issue["name"]][$candidate["party_code"]];
-            if (($candidate["votetype"] == "incumbent") or ($candidate["votetype"] == "leftoffice"))
-                $distance = GetIncumbentIssueDistances($db, $candidate, $issue["dream_id"]);
-            else  # this is where we do the dreammp case
-                $distance = $partydistance;
-            $candidate["issuedistances"][$issue["name"]] = ($distance === null ? -1 : (float)$distance);
-        }
-    }
-}
-
-
-function WriteJavascriptElecTable($candidates, $issues)
-{
-    
-    //WritePHPelectable($candidates, $issues);
-
-    print "// issue user-opinion map\n";
-    print "var issues = ";
-    for ($i = 0; $i < count($issues); $i++)
-        print ($i == 0 ? "[" : ", ").$issues[$i]["dream_id"];
-    print "];\n";
-    print "var candidates = ";
-    for ($j = 0; $j < count($candidates); $j++)
-        print ($j == 0 ? "[" : ", ").$candidates[$j]["candidate_id"];
-    print "];\n\n";
-
-    print "// candidate-issue distance table\n";
-    print "var citable = [ \n";
-    foreach ($candidates as $candidate)
-    {
-        print "  [";
-        foreach ($issues as $issue)
-        {
-            $distance = $candidate["issuedistances"][$issue["name"]];
-            print "$distance, ";
-        }
-        print "],\n";
-    }
-    print "     ];\n";
-}
-
-

File website/header.inc

 <? } ?>
 
 <div id="header" class="widewidth">
-<div class="logo"><a href="#"><img src="/images/logo.jpg" alt="the Public Whip" /></a></div>
+<div class="logo"><a href="/"><img src="/images/logo.jpg" alt="the Public Whip" /></a></div>
 <div class="search"><form class="searchtitlebarform" action="/search.php" name=pw>
 Search: <input maxLength=256 size=12 id="query_head" name="query" onblur="fadeout(this)" onfocus="fadein(this)" value="" /> <input type="submit" value="Go" name="button" />
 </form></div>