Permalink
Browse files

highlight single MP's vote on division result page

If the ID of an MP is passed in to the division result page their vote
will be highlighted first and then the results of all MPs.
  • Loading branch information...
struan committed Apr 18, 2017
1 parent 432ec26 commit 22f44053216444dbc49a0a8b6ae4da4295c84675
@@ -5,7 +5,11 @@
$this_page = 'divisions_vote';
if ($THEUSER->postcode_is_set()) {
$main_vote_mp = false;
if ($mp = get_http_var('p')) {
$MEMBER = new MySociety\TheyWorkForYou\Member(array('person_id' => $mp, 'house' => HOUSE_TYPE_COMMONS));
$main_vote_mp = true;
} else if ($THEUSER->postcode_is_set()) {
$MEMBER = new MySociety\TheyWorkForYou\Member(array('postcode' => $THEUSER->postcode(), 'house' => HOUSE_TYPE_COMMONS));
}
@@ -18,6 +22,8 @@
$template = 'divisions/vote';
$DATA->set_page_metadata($this_page, 'title', $data['division']['division_title']);
$data['main_vote_mp'] = $main_vote_mp;
if (isset($MEMBER)) {
$data['member'] = $MEMBER;
$mp_vote = $divisions->getDivisionResultsForMember($vote, $MEMBER->person_id());
@@ -0,0 +1,3 @@
<p>
<a href="#for"><?= $division['for'] - 2 ?> for</a>, <a href="#against"><?= $division['against'] - 2 ?> against</a>, <a href="#both"><?= $division['both'] ?> abstained</a>, <a href="#absent"><?= $division['absent'] ?> absent</a>.
</p>
@@ -42,17 +42,41 @@
<div class="full-page__unit">
<div class="debate-speech__speaker-and-content">
<div class="debate-speech__content">
<?php if ($main_vote_mp) { ?>
<?php if (isset($mp_vote)) { ?>
<p>
<span class="policy-vote__text">
<?php include('_vote_description.php'); ?>
<a href="/mp/?p=<?= $member->person_id() ?>"><?= $member->full_name() ?></a> <?= preg_replace('/(voted\s+(?:for|against|not to|to|in favour))/', '<b>\1</b>', $mp_vote['text']) ?>
</span><br>
</p>
<?php } else if (isset($before_mp)) { ?>
<p>
This vote happened before <a href="/mp/?p=<?= $member->person_id() ?>"><?= $member->full_name() ?></a> was elected.
</p>
<?php } else if (isset($after_mp)) { ?>
<p>
This vote happened after <a href="/mp/?p=<?= $member->person_id() ?>"><?= $member->full_name() ?></a> left the House of Commons.
</p>
<?php } ?>
<p>
A majority of MPs
<?php if ($division['vote'] == 'aye') { ?>
voted for.
<?php } else if ($division['vote'] == 'no') { ?>
voted against.
<?php } ?>
</p>
<?php include('_vote_summary.php'); ?>
<?php } else { ?>
<p>
<a href="#for"><?= $division['for'] - 2 ?> for</a>, <a href="#against"><?= $division['against'] - 2 ?> against</a>, <a href="#both"><?= $division['both'] ?> abstained</a>, <a href="#absent"><?= $division['absent'] ?> absent</a>.
<span class="policy-vote__text">
<?php include('_vote_description.php'); ?>
</span><br>
</p>
<?php include('_vote_summary.php'); ?>
<?php if (isset($mp_vote)) { ?>
<p>
Your MP, <a href="/mp/?p=<?= $member->person_id() ?>"><?= $member->full_name() ?></a>,
@@ -79,6 +103,7 @@
This vote happened after your MP, <a href="/mp/?p=<?= $member->person_id() ?>"><?= $member->full_name() ?></a>, left the House of Commons.
</p>
<?php } ?>
<?php } ?>
</div>
</div>

0 comments on commit 22f4405

Please sign in to comment.