Browse files

allows all cross-over pages to be reached

  • Loading branch information...
1 parent 56db5e7 commit 1448acc02166c5eb97f92323102e1b1e0947a94a goatchurch committed Oct 5, 2005
Showing with 108 additions and 77 deletions.
  1. +16 −7 website/decodeids.inc
  2. +90 −68 website/policy.php
  3. +2 −2 website/tablemake.inc
View
23 website/decodeids.inc
@@ -1,5 +1,5 @@
<?php
-# $Id: decodeids.inc,v 1.24 2005/10/05 11:47:48 frabcus Exp $
+# $Id: decodeids.inc,v 1.25 2005/10/05 17:25:17 goatchurch Exp $
# The Public Whip, Copyright (C) 2005 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
@@ -258,21 +258,30 @@ function get_mpid_attr_decode($db, $db2, $i, $voter2dream_overlap=null)
# do the attributes for a dream mp
function get_dreammpid_attr_decode($db, $i)
{
- $dreammpid = db_scrub($_GET["dmp$i"]);
+ $dreammpid = db_scrub($_GET[($i == "id" ? $i : "dmp$i")]); # so we can choose to look for id= instead of dmp=
if ($dreammpid == "")
return null;
- $query = "SELECT name, description, pw_dyn_user.user_id as userid, user_name, dream_id
- FROM pw_dyn_dreammp, pw_dyn_user
- WHERE pw_dyn_dreammp.user_id = pw_dyn_user.user_id
- AND dream_id = '$dreammpid'";
+ $qselect = "SELECT pw_dyn_dreammp.name AS name, pw_dyn_dreammp.description AS description,
+ pw_dyn_user.user_id AS user_id, user_name,
+ votes_count, edited_motions_count,
+ private";
+ $qfrom = " FROM pw_dyn_dreammp";
+ $qjoin = " LEFT JOIN pw_cache_dreaminfo ON pw_cache_dreaminfo.dream_id = pw_dyn_dreammp.dream_id";
+ $qjoin .= " LEFT JOIN pw_dyn_user ON pw_dyn_user.user_id = pw_dyn_dreammp.user_id";
+ $qwhere = " WHERE pw_dyn_dreammp.dream_id = $dreammpid";
+ $query = $qselect.$qfrom.$qjoin.$qwhere;
+
$row = $db->query_one_row_assoc($query);
$dmp_name = $row[0];
return array("dreammpid" => $dreammpid,
"name" => $row['name'],
"description" => $row['description'],
- "userid" => $row['userid'],
+ "userid" => $row['user_id'],
"user_name" => $row['user_name'],
+ "private" => $row['private'],
+ "votes_count" => $row['votes_count'],
+ "edited_count" => $row['edited_motions_count'],
"anchor" => "dmp$i=".urlencode($dreammpid));
}
View
158 website/policy.php
@@ -1,5 +1,4 @@
<?php require_once "common.inc";
- $dreamid = intval($_GET["id"]);
# $id: dreammp.php,v 1.4 2004/04/16 12:32:42 frabcus Exp $
@@ -20,58 +19,77 @@
include "dream.inc";
include "tablepeop.inc";
- update_dreammp_person_distance($db, $dreamid); # new method
-
- $qselect = "SELECT pw_dyn_dreammp.name AS name, pw_dyn_dreammp.description AS description,
- pw_dyn_user.user_id AS user_id, user_name,
- votes_count, edited_motions_count, consistency_with_mps,
- private";
- $qfrom = " FROM pw_dyn_dreammp";
- $qjoin = " LEFT JOIN pw_cache_dreaminfo ON pw_cache_dreaminfo.dream_id = pw_dyn_dreammp.dream_id";
- $qjoin .= " LEFT JOIN pw_dyn_user ON pw_dyn_user.user_id = pw_dyn_dreammp.user_id";
- $qwhere = " WHERE pw_dyn_dreammp.dream_id = $dreamid";
- $query = $qselect.$qfrom.$qjoin.$qwhere;
-
-
- if ($bdebug == 1)
- print "<h3>$query</h3>\n";
- $row = $db->query_one_row_assoc($query);
- $dmp_name = $row["name"];
- $dmp_description = $row["description"];
- $dmp_user_id = $row["user_id"];
- $dmp_user_name = $row["user_name"];
- $dmp_votes_count = $row["votes_count"];
- $dmp_edited_count = $row["edited_motions_count"];
- $dmp_private = $row["private"];
-
- $title = "Policy - " . html_scrub($dmp_name);
- include "header.inc";
+ # this replaces a lot of the work just below
+ $voter = get_dreammpid_attr_decode($db, "id"); # for pulling a dreammpid from id= rather than the more standard dmp=
+ $policyname = html_scrub($voter["name"]);
+ $dreamid = $voter["dreammpid"];
+
+ $title = "Policy - $policyname";
+
+ # constants
+ $dismodes = array();
+ $dismodes["summary"] = array("dtype" => "summary",
+ "description" => "Votes",
+ "comparisons" => "yes",
+ "divisionlist" => "selected",
+ "policybox" => "yes");
+ $dismodes["everyvote"] = array("dtype" => "everyvote",
+ "divisionlist" => "all",
+ "description" => "Every division");
+
+ # work out which display mode we are in
+ $display = $_GET["display"];
+ if (!$dismodes[$display])
+ $display = "summary"; # default
+ $dismode = $dismodes[$display];
+
+ # make list of links to other display modes
+ $second_links = array();
+ foreach ($dismodes as $ldisplay => $ldismode)
+ {
+ $leadch = " | ";
+ $dlink = "href=\"policy.php?id=".$dreamid.($ldisplay != "summary" ? "&display=$ldisplay" : "")."\"";
+ array_push($second_links, "<a $dlink class=\"".($ldisplay == $display ? "on" : "off")."\">".$ldismode["description"]."</a>");
+ }
- print "<div class=\"tabledreambox\">";
-# print '<h2><a name="compare">Compare to Your MP</a></h2>';
- print dream_box($dreamid, $dmp_name);
- print '<p>Why not <a href="#dreambox">add this to your own website?</a></p>';
- print "</div>";
+ include "header.inc";
- print "<p><b>Definition:</b> " . str_replace("\n", "<br>", html_scrub($dmp_description)). "</p>";
- if ($dmp_private)
- print "<p><b>Made by:</b> " . html_scrub($dmp_user_name) . " (this is a legacy Dream MP)";
+ if ($dismode["policybox"])
+ {
+ print "<div class=\"tabledreambox\">";
+ print dream_box($dreamid, $policyname);
+ print '<p>Why not <a href="#dreambox">add this to your own website?</a></p>';
+ print "</div>";
+ }
+
+ print "<p><b>Definition:</b> " . str_replace("\n", "<br>", html_scrub($voter["description"])). "</p>";
+ if ($voter["private"])
+ print "<p><b>Made by:</b> " . html_scrub($voter["user_name"]) . " (this is a legacy Dream MP)";
print "</p>";
print "<p><a href=\"account/editpolicy.php?id=$dreamid\">Edit definition</a>";
print ' | <a href="http://www.publicwhip.org.uk/forum/viewforum.php?f=1">Discuss</a>';
-
- print "<h2><a name=\"divisions\">Divisions Selected</a></h2>
- <p>Divisions which have been selected for this policy.";
- if ($dmp_votes_count)
- print " <b>$dmp_votes_count</b> votes, of which <b>$dmp_edited_count</b> have edited motion text.";
+ if ($dismode["divisionlist"] == "selected")
+ {
+ print "<h2><a name=\"divisions\">Selected Divisions</a></h2>
+ <p>Divisions which have been selected for this policy.";
+ if ($voter["votes_count"])
+ print " <b>".$voter["votes_count"]."</b> votes, of which <b>".$voter["edited_count"]."</b> have edited motion text.";
+ else
+ print 'None so far. Try clicking on "Every division" above to get to the full list.';
+ print "</p>\n";
+ }
+ else
+ {
+ print "<h2><a name=\"divisions\">Every Division</a></h2>\n";
+ }
print "<table class=\"divisions\">\n";
$divtabattr = array(
"voter1type" => "dreammp",
"voter1" => $dreamid,
- "showwhich" => "all1",
+ "showwhich" => ($dismode["divisionlist"] == "selected" ? "all1" : "everyvote"),
"headings" => 'columns',
"divhrefappend" => "&dmp=$dreamid", # gives link to crossover page
"motionwikistate" => "listunedited");
@@ -84,33 +102,37 @@
division you can choose how someone supporting your policy would have
voted. Only vote on divisions which are relevant to your policy."; */
- print "<h2><a name=\"comparison\">Comparison to MPs</a></h2>";
-
- print "<p>Grades MPs acording to how often they voted with the policy.
- If, in policy divisions where the MP voted, they
- always voted the same as the policy then the score is 0.0. If they always voted
- differently, the score is 1.0.";
-
- $mptabattr = array("listtype" => 'dreamdistance',
- 'dreammpid' => $dreamid);
- print "<table class=\"mps\">\n";
- print "<tr class=\"headings\"><td>Name</td><td>Constituency</td><td>Party</td><td>Distance</td></tr>\n";
- mp_table($db, $mptabattr);
- print "</table>\n";
-
-
- print '<h2><a name="dreambox">Add Policies to Your Website</a></h2>';
- print '<p>Get people thinking about your issue, by adding a policy search
- box to your website. This lets people compare their own MP to your policy,
- like this.</p>';
- print dream_box($dreamid, $dmp_name);
- print '<p>To do this copy and paste the following HTML into your website.
- Feel free to fiddle with it to fit the look of your site better. We only
- ask that you leave the link to Public Whip in.';
- print '<pre class="htmlsource">';
- print htmlspecialchars(dream_box($dreamid, $dmp_name));
- print '</pre>';
-
+ if ($dismode["comparisons"])
+ {
+ print "<h2><a name=\"comparison\">Comparison to MPs</a></h2>";
+
+ print "<p>Grades MPs acording to how often they voted with the policy.
+ If, in policy divisions where the MP voted, they
+ always voted the same as the policy then the score is 0.0. If they always voted
+ differently, the score is 1.0.";
+
+ $mptabattr = array("listtype" => 'dreamdistance',
+ 'dreammpid' => $dreamid);
+ print "<table class=\"mps\">\n";
+ print "<tr class=\"headings\"><td>Name</td><td>Constituency</td><td>Party</td><td>Distance</td></tr>\n";
+ mp_table($db, $mptabattr);
+ print "</table>\n";
+ }
+
+ if ($dismode["policybox"])
+ {
+ print '<h2><a name="dreambox">Add Policies to Your Website</a></h2>';
+ print '<p>Get people thinking about your issue, by adding a policy search
+ box to your website. This lets people compare their own MP to your policy,
+ like this.</p>';
+ print dream_box($dreamid, $policyname);
+ print '<p>To do this copy and paste the following HTML into your website.
+ Feel free to fiddle with it to fit the look of your site better. We only
+ ask that you leave the link to Public Whip in.';
+ print '<pre class="htmlsource">';
+ print htmlspecialchars(dream_box($dreamid, $policyname));
+ print '</pre>';
+ }
?>
<?php include "footer.inc" ?>
View
4 website/tablemake.inc
@@ -1,6 +1,6 @@
<?php
-# $Id: tablemake.inc,v 1.35 2005/10/05 16:02:42 goatchurch Exp $
+# $Id: tablemake.inc,v 1.36 2005/10/05 17:25:17 goatchurch Exp $
# The Public Whip, Copyright (C) 2005 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
@@ -267,7 +267,7 @@ function print_division_row($nrows, $pretrowclass, $rolecol, $voter1type, $voter
if ($voter1type != "")
{
- print "<td>$vote1</td>";
+ print "<td>".($voter1type == "dreammp" && !$vote1 ? "non-voter" : $vote1)."</td>";
if ($voter2type != "")
print "<td>$vote2</td>\n";

0 comments on commit 1448acc

Please sign in to comment.