Exemple #1
0
function _api_getMP_row($row)
{
    global $parties;
    $row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']);
    # We need 'name' to maintain backwards compatibility due to OA-476
    $row['name'] = $row['full_name'];
    if (isset($parties[$row['party']])) {
        $row['party'] = $parties[$row['party']];
    }
    list($image, $sz) = find_rep_image($row['person_id']);
    if ($image) {
        $row['image'] = $image;
    }
    # Ministerialships and Select Committees
    $db = new ParlDB();
    $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
    for ($i = 0; $i < $q->rows(); $i++) {
        $row['office'][] = $q->row($i);
    }
    foreach ($row as $k => $r) {
        if (is_string($r)) {
            $row[$k] = html_entity_decode($r);
        }
    }
    return $row;
}
function _api_getPerson_row($row, $has_party = FALSE)
{
    global $parties;
    $row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']);
    if ($row['house'] == 1) {
        $URL = new URL('mp');
        $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house']);
    }
    if ($has_party && isset($parties[$row['party']])) {
        $row['party'] = $parties[$row['party']];
    }
    list($image, $sz) = find_rep_image($row['person_id']);
    if ($image) {
        list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
        $row['image'] = $image;
        $row['image_height'] = $height;
        $row['image_width'] = $width;
    }
    if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || $row['left_house'] == '2010-04-12')) {
        # XXX
        # Ministerialships and Select Committees
        $db = new ParlDB();
        $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
        for ($i = 0; $i < $q->rows(); $i++) {
            $row['office'][] = $q->row($i);
        }
    }
    foreach ($row as $k => $r) {
        if (is_string($r)) {
            $row[$k] = html_entity_decode($r);
        }
    }
    return $row;
}
Exemple #3
0
function _api_getMSP_row($row)
{
    global $parties;
    $row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']);
    if (isset($parties[$row['party']])) {
        $row['party'] = $parties[$row['party']];
    }
    list($image, $sz) = find_rep_image($row['person_id']);
    if ($image) {
        $row['image'] = $image;
    }
    $row = array_map('html_entity_decode', $row);
    return $row;
}
Exemple #4
0
function _api_getPerson_row($row, $has_party = FALSE)
{
    global $parties;
    $row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']);
    if ($has_party && isset($parties[$row['party']])) {
        $row['party'] = $parties[$row['party']];
    }
    list($image, $sz) = find_rep_image($row['person_id']);
    if ($image) {
        $row['image'] = $image;
    }
    foreach ($row as $k => $r) {
        if (is_string($r)) {
            $row[$k] = html_entity_decode($r);
        }
    }
    return $row;
}
function render_mps_row($mp, &$style, $order, $MPURL) {
	$style = $style == '1' ? '2' : '1';
	$name = member_full_name(4, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']);
	?>
<tr>
    <td class="row">
    <?php 
    list($image, $sz) = find_rep_image($mp['person_id'], true, true);
    if ($image) {
        echo '<a href="' . $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1) . '" class="speakerimage"><img height="59" class="portrait" alt="" src="', $image, '"';
        echo '></a>';
    }
    ?>
    </td>
<td class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 4);
    ?>
"><?php 
    echo $name;
    ?>
</a></td>
<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['party'];
    ?>
</td>
<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['constituency'];
    ?>
</td>
</tr>
<?php 
}
function person_image($member) {
	$is_lord = in_array(2, $member['houses']);
	if ($is_lord) {
		list($image,$sz) = find_rep_image($member['person_id'], false, 'lord');
	} else {
		list($image,$sz) = find_rep_image($member['person_id'], false, true);		    
	}
	echo '<p class="person">';
	echo '<img class="portrait" alt="Photo of ', $member['full_name'], '" src="', $image, '"';
	if ($sz=='S') echo ' height="118"';
	echo '></p>';
}
Exemple #7
0
function display_form($errors = array()) {
    global $db; 

    $out = '';
    if ($errors) {
        $out .= '<ul id="error"><li>' . join('</li><li>', $errors) . '</li></ul>';
    }
    $out .= <<<EOF
<p>Photos are automatically added in git and committed. Because of this,
only use this interface on a development version of the site which is
in a git checkout (francis.theyworkforyou.com or similar). Then deploy
to the live site.
</p>
<form method="post" action="photos.php" enctype="multipart/form-data">
<div class="row">
<span class="label"><label for="form_pid">Person:</label></span>
<span class="formw"><select id="form_pid" name="pid"></span>
EOF;

    $query = 'SELECT house, person_id, title, first_name, last_name, constituency, party
        FROM member
        WHERE house>0 GROUP by person_id
        ORDER BY house, last_name, first_name
    ';
    $q = $db->query($query);

    $houses = array(1 => 'MP', 'Lord', 'MLA', 'MSP');

    for ($i=0; $i<$q->rows(); $i++) {
        $p_id = $q->field($i, 'person_id');
        $house = $q->field($i, 'house');
        $desc = $q->field($i, 'last_name') . ', ' . $q->field($i, 'title') . ' ' . $q->field($i, 'first_name') .
                " " . $houses[$house];
        if ($q->field($i, 'party')) $desc .= ' (' . $q->field($i, 'party') . ')';
        $desc .= ', ' . $q->field($i, 'constituency');

        list($dummy, $sz) = find_rep_image($p_id);
        if ($sz == 'L') {
            $desc .= ' [has large photo]';
        } elseif ($sz == 'S') {
            $desc .= ' [has small photo]';
        } else {
            $desc .= ' [no photo]';
        }
        $out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n";
    }

    $out .= <<<EOF
</select></span>
</div>
<div class="row">
    <span class="label"><label for="form_photo">Photo:</label></span>
    <span class="formw"><input type="file" name="photo" id="form_photo" size="50"></span>
</div>
<div class="row">
    <span class="label">&nbsp;</span>
    <span class="formw"><input type="submit" name="submit_photo" value="Upload photo"></span>
</div>
</form>

<p style="clear:both; margin-top: 3em"><a href="/images/mps/photo-status.php">List MPs without photos</a></p>
EOF;
    return $out;
}
Exemple #8
0
include_once 'min-init.php';
include_once INCLUDESPATH . 'easyparliament/member.php';
include_once '../api/api_functions.php';
$pid = $_GET['pid'];
$db = new ParlDB();
$q = $db->query("select * from member\n\twhere house=1 and person_id = '" . mysql_real_escape_string($pid) . "'\n\torder by left_house desc limit 1");
if (!$q->rows()) {
    print '<error>Unknown ID</error>';
    exit;
}
$row = $q->row(0);
$row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']);
if (isset($parties[$row['party']])) {
    $row['party'] = $parties[$row['party']];
}
list($image, $sz) = find_rep_image($row['person_id'], true);
if ($image) {
    $row['image'] = $image;
}
$q = $db->query("SELECT position,dept FROM moffice WHERE to_date='9999-12-31'\n\tand source='chgpages/selctee' and person=" . mysql_real_escape_string($pid) . ' ORDER BY from_date DESC');
for ($i = 0; $i < $q->rows(); $i++) {
    $row['selctee'][] = prettify_office($q->field($i, 'position'), $q->field($i, 'dept'));
}
/*
$q = $db->query("SELECT title,chairman from pbc_members,bills where member_id=".$row['member_id']
	. ' and bill_id=bills.id');
for ($i=0; $i<$q->rows(); $i++) {
	$member = 'Member';
	if ($q->field($i, 'chairman')) {
		$member = 'Chairman';
	}
            // Used for action links (link, source, watch etc)
            $action_links = array();
                
			if (isset($row['speaker']) && count($row['speaker']) > 0) {
			    
			  // We have a speaker to print.
				$speaker = $row['speaker'];
				$speakername = ucfirst(member_full_name($speaker['house'], $speaker['title'], $speaker['first_name'], $speaker['last_name'], $speaker['constituency']));

				//speaker photo
				$missing_photo_type = 'general';
				if($data['info']['major'] == 101){
				    $missing_photo_type = "lord";
			    }
				list($image,$sz) = find_rep_image($speaker['person_id'], true, $missing_photo_type);				

				echo '<a class="speakerimage" id="speakerimage_' . $row['epobject_id'] . '" href="', $speaker['url'], '" title="See more information about ', $speakername, '" onmouseover="showPersonLinks(' . $row['epobject_id'] . ')" >';
				echo '<span><img src="', $image, '" class="portrait" alt="Photo of ', $speakername, '"';
				/*
				if (get_http_var('partycolours')) {
					echo ' style="border: 3px solid ', party_to_colour($speaker['party']), ';"';
				}
				*/
				echo '></span></a>';

				//speaker links
				echo '<div class="personinfo" id="personinfo_' . $row['epobject_id']  . '"><ul>';
				echo '<li><a href="/alert/?only=1&pid=' . $speaker['person_id'] . '">Email me when ' . $speakername .  ' speaks</a></li>';
				if($data['info']['major'] == 101 || $data['info']['major'] == 1){
				    echo '<li><a href="' . $speaker['url'] . '#votingrecord">View voting record</a></li>';												    
Exemple #10
0
            }
            // gid_to_anchor() is in utility.php
            $id = 'g' . gid_to_anchor($row['gid']);
            $PAGE->stripe_start($style, $id);
            ?>
				<a name="<?php 
            echo $id;
            ?>
"></a>
<?php 
            if (isset($row['speaker']) && count($row['speaker']) > 0) {
                // We have a speaker to print.
                $speaker = $row['speaker'];
                $speakername = ucfirst(member_full_name($speaker['house'], $speaker['title'], $speaker['first_name'], $speaker['last_name'], $speaker['constituency']));
                echo '<p class="speaker"><a href="', $speaker['url'], '" title="See more information about ', $speakername, '">';
                list($image, $sz) = find_rep_image($speaker['person_id'], true);
                if ($image) {
                    echo '<img src="', $image, '" class="portrait" alt="Photo of ', $speakername, '"';
                    if (get_http_var('partycolours')) {
                        echo ' style="border: 3px solid ', party_to_colour($speaker['party']), ';"';
                    }
                    echo '>';
                }
                echo '<strong>', $speakername, '</strong></a> <small>';
                $desc = '';
                if ($speaker['house'] == 1 && $speaker['party'] != 'Speaker' && $speaker['party'] != 'Deputy Speaker' && $speaker['constituency']) {
                    $desc .= $speaker['constituency'] . ', ';
                }
                if (get_http_var('wordcolours')) {
                    $desc .= '<span style="color: ' . party_to_colour($speaker['party']) . '">';
                }
Exemple #11
0
    function display_member($member, $extra_info)
    {
        global $THEUSER, $DATA, $this_page;
        #$title = ucfirst($member['full_name']);
        /*		if (isset($extra_info["public_whip_dreammp996_distance"])) {
        			$dmpscore = floatval($extra_info["public_whip_dreammp996_distance"]);
        			$strongly_foi = "voted " . score_to_strongly(1.0 - $dmpscore);
        		}
        		if ($extra_info["public_whip_dreammp996_both_voted"] == 0) {
        			$strongly_foi = "has never voted on";
        		}
        		$this->block_start(array('id'=>'black', 'title'=>"Freedom of Information and Parliament"));
        		print "<p>There is currently a Bill before Parliament which will make Parliament
        			exempt from Freedom of Information requests. This Bill will remove
        			your legal right to see some of the information on this page, notably
        			expenses, replacing it with a weaker promise that could be retracted
        			later.</p>
        
        			<p>Even if this bill is amended to exclude expenses, exemption from the
        			Freedom of Information Act may prevent TheyWorkForYou from adding
        			useful information of new sorts in the future. The Bill is not backed
        			or opposed by a specific party, and TheyWorkForYou remains strictly
        			neutral on all issues that do not affect our ability to serve the
        			public.</p>
        
        			<p><a href=\"somewhere\">Join the Campaign to keep Parliament transparent
        			(external)</a>.</p>";
        
        		print 'For your information, '.$title.' MP <a href="http://www.publicwhip.org.uk/mp.php?mpid='.$member['member_id'].'&amp;dmp=996">'.$strongly_foi.'</a> this Bill.';
        		$this->block_end();
        */
        if (isset($extra_info["is_speaker_candidate"]) && $extra_info["is_speaker_candidate"] == 1 && isset($extra_info["speaker_candidate_contacted_on"]) || isset($extra_info['speaker_candidate_response']) && $extra_info['speaker_candidate_response']) {
            $just_response = false;
            if ($extra_info['is_speaker_candidate'] == 0) {
                $just_response = true;
            }
            // days since originally contacted
            $contact_date_string = $extra_info["speaker_candidate_contacted_on"];
            $contact_date_midnight = strtotime($contact_date_string);
            $days_since_contact = floor((time() - $contact_date_midnight) / 86400);
            if ($days_since_contact == 1) {
                $days_since_string = $days_since_contact . ' day ago';
            } elseif ($days_since_contact > 1) {
                $days_since_string = $days_since_contact . ' days ago';
            } else {
                $days_since_string = 'today';
            }
            $reply_time = "*unknown*";
            if (isset($extra_info["speaker_candidate_replied_on"])) {
                $reply_date_string = $extra_info["speaker_candidate_replied_on"];
                $reply_date_midnight = strtotime($reply_date_string);
                $days_for_reply = floor(($reply_date_midnight - $contact_date_midnight) / 86400);
                if ($days_for_reply == 0) {
                    $reply_time = "in less than 24 hours";
                } elseif ($days_for_reply == 1) {
                    $reply_time = "in 1 day";
                } else {
                    $reply_time = "in {$days_for_reply} days";
                }
            }
            if ($just_response) {
                $spk_cand_title = $member['full_name'] . ' endorses our Speaker principles';
            } else {
                if (isset($extra_info["speaker_candidate_elected"]) && $extra_info["speaker_candidate_elected"] == 1) {
                    $spk_cand_title = 'LATEST: ' . $member['full_name'] . ' elected Speaker. Here\'s what he endorsed:';
                } else {
                    $spk_cand_title = 'IMPORTANT: ' . $member['full_name'] . ' was a Candidate for Speaker.';
                }
            }
            $this->block_start(array('id' => 'campaign_block', 'title' => $spk_cand_title));
            if (!isset($extra_info["speaker_candidate_response"])) {
                print "\n                You can help make sure that all the candidates understand that they\n                must be a strong, Internet-savvy proponents of a better, more\n                accountable era of democracy.";
            }
            print "</p>\n\n            <p>mySociety asked likely candidates for the post of Speaker to endorse the\n            following principles.";
            print "<p><strong>The three principles are:</strong></p>\n\n            <ol>\n\n               <li> Voters have the right to know in <strong>detail about the money</strong> that is spent to\n            support MPs and run Parliament, and in similar detail how the decisions to\n            spend that money are settled upon. </li>\n\n               <li> Bills being considered must be published online in a much better way than\n            they are now, as the <strong>Free Our Bills</strong> campaign has been suggesting for some time. </li>\n\n               <li> The Internet is not a threat to a renewal in our democracy, it is one of\n            its best hopes. Parliament should appoint a senior officer with direct working\n            experience of the <strong>power of the Internet</strong> who reports directly to the Speaker,\n            and who will help Parliament adapt to a new era of transparency and\n            effectiveness. </li>\n\n            </ol>";
            if (isset($extra_info["speaker_candidate_response"]) && $extra_info["speaker_candidate_response"]) {
                print "</p><p><strong><big>Update: " . $member['full_name'] . " MP replied {$reply_time}. " . $extra_info["speaker_candidate_response_summary"] . " Here's the reply in full: </big></strong></p>";
                print "<blockquote><div id='speaker_candidate_response'>";
                print $extra_info["speaker_candidate_response"];
                print "</div></blockquote>";
            } else {
                print "<p> We contacted " . $member['full_name'] . " MP to ask for an endorsement " . $days_since_string . ". ";
                print "They have not yet replied.</p>";
            }
            $this->block_end();
        }
        $is_lord = false;
        foreach ($member['houses'] as $house) {
            if ($house == 2) {
                $is_lord = true;
            }
            continue;
            if (!$member['current_member'][$house]) {
                $title .= ', former';
            }
            if ($house == 1) {
                $title .= ' MP';
            }
            if ($house == 3) {
                $title .= ' MLA';
            }
            if ($house == 4) {
                $title .= ' MSP';
            }
        }
        #if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
        #	$title = '<a href="' . WEBPATH . $rssurl . '"><img src="' . WEBPATH . 'images/rss.gif" alt="RSS feed" border="0" align="right"></a> ' . $title;
        #}
        print '<p class="printonly">This data was produced by TheyWorkForYou from a variety of sources.</p>';
        //get the correct image (with special case for lords)
        if ($is_lord) {
            list($image, $sz) = find_rep_image($member['person_id'], false, 'lord');
        } else {
            list($image, $sz) = find_rep_image($member['person_id'], false, true);
        }
        //show image
        echo '<p class="person">';
        echo '<img class="portrait" alt="Photo of ', $member['full_name'], '" src="', $image, '"';
        if ($sz == 'S') {
            echo ' height="118"';
        }
        echo '></p>';
        //work out person's description
        $desc = '';
        $last_item = end($member['houses']);
        foreach ($member['houses'] as $house) {
            if ($house == 0) {
                $desc .= '<li><strong>Acceded on ';
                $desc .= $member['entered_house'][0]['date_pretty'];
                $desc .= '</strong></li>';
                $desc .= '<li><strong>Coronated on 2 June 1953</strong></li>';
                continue;
            }
            $party = $member['left_house'][$house]['party'];
            if ($house == 1 && isset($member['entered_house'][2])) {
                continue;
            }
            # Same info is printed further down
            if (!$member['current_member'][$house]) {
                $desc .= 'Former ';
            }
            $party_br = '';
            if (preg_match('#^(.*?)\\s*\\((.*?)\\)$#', $party, $m)) {
                $party_br = $m[2];
                $party = $m[1];
            }
            if ($party != 'unknown') {
                $desc .= htmlentities($party);
            }
            if ($party == 'Speaker' || $party == 'Deputy Speaker') {
                $desc .= ', and ';
                # XXX: Will go horribly wrong if something odd happens
                if ($party == 'Deputy Speaker') {
                    $last = end($member['other_parties']);
                    $desc .= $last['from'] . ' ';
                }
            }
            if ($house == 1 || $house == 3 || $house == 4) {
                $desc .= ' ';
                if ($house == 1) {
                    $desc .= 'MP';
                }
                if ($house == 3) {
                    $desc .= 'MLA';
                }
                if ($house == 4) {
                    $desc .= 'MSP';
                }
                if ($party_br) {
                    $desc .= " ({$party_br})";
                }
                $desc .= ' for ' . $member['left_house'][$house]['constituency'];
            }
            if ($house == 2 && $party != 'Bishop') {
                $desc .= ' Peer';
            }
            if ($house != $last_item) {
                $desc .= ', ';
            }
        }
        //headings
        echo '<h2>' . $member['full_name'] . '</h2>';
        echo '<h3>' . $desc . '</h3>';
        //History
        echo '<ul class="hilites">';
        if ($member['other_constituencies']) {
            print "<li>Also represented " . join('; ', array_keys($member['other_constituencies']));
            print '</li>';
        }
        if ($member['other_parties'] && $member['party'] != 'Speaker' && $member['party'] != 'Deputy Speaker') {
            print "<li>Changed party ";
            foreach ($member['other_parties'] as $r) {
                $out[] = 'from ' . $r['from'] . ' on ' . format_date($r['date'], SHORTDATEFORMAT);
            }
            print join('; ', $out);
            print '</li>';
        }
        // Ministerial position
        if (array_key_exists('office', $extra_info)) {
            $mins = array();
            foreach ($extra_info['office'] as $row) {
                if ($row['to_date'] == '9999-12-31' && $row['source'] != 'chgpages/selctee') {
                    $m = prettify_office($row['position'], $row['dept']);
                    $m .= ' (since ' . format_date($row['from_date'], SHORTDATEFORMAT) . ')';
                    $mins[] = $m;
                }
            }
            if ($mins) {
                print '<li>' . join('<br>', $mins) . '</li>';
            }
        }
        echo '<br class="clear">';
        //if dummy image, show message asking for a photo
        if (!exists_rep_image($member['person_id'])) {
            // For MPs, prompt for photo
            echo '<p class="missingphoto">';
            if ($member['current_member_anywhere']) {
                echo 'Help, we\'re missing a photo of ' . $member['full_name'] . '! If you are ' . $member['full_name'] . ', or have a photo of them (that you have copyright of) <a href="mailto:team@theyworkforyou.com">please email it to us</a>.';
            } else {
                echo 'Help, we\'re missing a photo of ' . $member['full_name'] . '! If have a photo of them (that you have copyright of), or can locate a copyright free photo of them <a href="mailto:team@theyworkforyou.com">please email it to us</a>.';
            }
            echo '</p>';
        }
        if (isset($member['left_house'][1]) && isset($member['entered_house'][2])) {
            print '<li><strong>Entered the House of Lords ';
            if (strlen($member['entered_house'][2]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            print $member['entered_house'][2]['date_pretty'] . '</strong>';
            print '</strong>';
            if ($member['entered_house'][2]['reason']) {
                print ' &mdash; ' . $member['entered_house'][2]['reason'];
            }
            print '</li>';
            print '<li><strong>Previously MP for ';
            print $member['left_house'][1]['constituency'] . ' until ';
            print $member['left_house'][1]['date_pretty'] . '</strong>';
            if ($member['left_house'][1]['reason']) {
                print ' &mdash; ' . $member['left_house'][1]['reason'];
            }
            print '</li>';
        } elseif (isset($member['entered_house'][2]['date'])) {
            print '<li><strong>Became a Lord ';
            if (strlen($member['entered_house'][2]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            print $member['entered_house'][2]['date_pretty'] . '</strong>';
            if ($member['entered_house'][2]['reason']) {
                print ' &mdash; ' . $member['entered_house'][2]['reason'];
            }
            print '</li>';
        }
        if (in_array(2, $member['houses']) && !$member['current_member'][2]) {
            print '<li><strong>Left Parliament on ' . $member['left_house'][2]['date_pretty'] . '</strong>';
            if ($member['left_house'][2]['reason']) {
                print ' &mdash; ' . $member['left_house'][2]['reason'];
            }
            print '</li>';
        }
        if (isset($extra_info['lordbio'])) {
            echo '<li><strong>Positions held at time of appointment:</strong> ', $extra_info['lordbio'], ' <small>(from <a href="', $extra_info['lordbio_from'], '">Number 10 press release</a>)</small></li>';
        }
        if (isset($member['entered_house'][1]['date'])) {
            print '<li><strong>Entered Parliament on ';
            print $member['entered_house'][1]['date_pretty'] . '</strong>';
            if ($member['entered_house'][1]['reason']) {
                print ' &mdash; ' . $member['entered_house'][1]['reason'];
            }
            print '</li>';
        }
        if (in_array(1, $member['houses']) && !$member['current_member'][1] && !isset($member['entered_house'][2])) {
            print '<li><strong>Left Parliament ';
            if (strlen($member['left_house'][1]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            echo $member['left_house'][1]['date_pretty'] . '</strong>';
            if ($member['left_house'][1]['reason']) {
                print ' &mdash; ' . $member['left_house'][1]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][3]['date'])) {
            print '<li><strong>Entered the Assembly on ';
            print $member['entered_house'][3]['date_pretty'] . '</strong>';
            if ($member['entered_house'][3]['reason']) {
                print ' &mdash; ' . $member['entered_house'][3]['reason'];
            }
            print '</li>';
        }
        if (in_array(3, $member['houses']) && !$member['current_member'][3]) {
            print '<li><strong>Left the Assembly on ' . $member['left_house'][3]['date_pretty'] . '</strong>';
            if ($member['left_house'][3]['reason']) {
                print ' &mdash; ' . $member['left_house'][3]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][4]['date'])) {
            print '<li><strong>Entered the Scottish Parliament on ';
            print $member['entered_house'][4]['date_pretty'] . '</strong>';
            if ($member['entered_house'][4]['reason']) {
                print ' &mdash; ' . $member['entered_house'][4]['reason'];
            }
            print '</li>';
        }
        if (in_array(4, $member['houses']) && !$member['current_member'][4]) {
            print '<li><strong>Left the Scottish Parliament on ' . $member['left_house'][4]['date_pretty'] . '</strong>';
            if ($member['left_house'][4]['reason']) {
                print ' &mdash; ' . $member['left_house'][4]['reason'];
            }
            print '</li>';
        }
        if (isset($extra_info['majority_in_seat'])) {
            ?>
						<li><strong>Majority:</strong> 
						<?php 
            echo number_format($extra_info['majority_in_seat']);
            ?>
 votes. <?php 
            if (isset($extra_info['swing_to_lose_seat_today'])) {
                /*
                if (isset($extra_info['swing_to_lose_seat_today_quintile'])) {
                	$q = $extra_info['swing_to_lose_seat_today_quintile'];
                	if ($q == 0) {
                		print 'Very safe seat';
                	} elseif ($q == 1) {
                		print 'Safe seat';
                	} elseif ($q == 2) {
                		print '';
                	} elseif ($q == 3) {
                		print 'Unsafe seat';
                	} elseif ($q == 4) {
                		print 'Very unsafe seat';
                	} else {
                		print '[Impossible quintile!]';
                	}
                }
                */
                print ' &mdash; ' . make_ranking($extra_info['swing_to_lose_seat_today_rank']);
                ?>
 out of <?php 
                echo $extra_info['swing_to_lose_seat_today_rank_outof'];
                ?>
 MPs.
<?php 
            }
            ?>
</li>
<?php 
        }
        if ($member['party'] == 'Sinn Fein' && in_array(1, $member['houses'])) {
            print '<li>Sinn F&eacute;in MPs do not take their seats in Parliament</li>';
        }
        print "</ul>";
        print '<br class="clear"/>';
        print "<ul class=\"hilites\">";
        if ($member['the_users_mp'] == true) {
            $pc = $THEUSER->postcode();
            ?>
						<li><a href="http://www.writetothem.com/?a=WMC&amp;pc=<?php 
            echo htmlentities(urlencode($pc));
            ?>
"><strong>Send a message to <?php 
            echo $member['full_name'];
            ?>
</strong></a> (only use this for <em>your</em> MP) <small>(via WriteToThem.com)</small></li>
						<li><a href="http://www.hearfromyourmp.com/?pc=<?php 
            echo htmlentities(urlencode($pc));
            ?>
"><strong>Get messages from your MP</strong></a> <small>(via HearFromYourMP)</small></strong></a></li>
<?php 
        } elseif ($member['current_member'][1]) {
            ?>
						<li><a href="http://www.writetothem.com/"><strong>Send a message to your MP</strong></a> <small>(via WriteToThem.com)</small></li>
						<li><a href="http://www.hearfromyourmp.com/"><strong>Sign up to <em>HearFromYourMP</em></strong></a> to get messages from your MP</li>
<?php 
        } elseif ($member['current_member'][3]) {
            ?>
						<li><a href="http://www.writetothem.com/"><strong>Send a message to your MLA</strong></a> <small>(via WriteToThem.com)</small></li>
<?php 
        } elseif ($member['current_member'][4]) {
            ?>
						<li><a href="http://www.writetothem.com/"><strong>Send a message to your MSP</strong></a> <small>(via WriteToThem.com)</small></li>
<?php 
        } elseif ($member['current_member'][2]) {
            ?>
						<li><a href="http://www.writetothem.com/?person=uk.org.publicwhip/person/<?php 
            echo $member['person_id'];
            ?>
"><strong>Send a message to <?php 
            echo $member['full_name'];
            ?>
</strong></a> <small>(via WriteToThem.com)</small></li>
<?php 
        }
        # If they're currently an MLA, a Lord or a non-Sinn Fein MP
        if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || $member['current_member'][1] && $member['party'] != 'Sinn Fein' || $member['current_member'][4]) {
            print '<li><a href="' . WEBPATH . 'alert/?only=1&amp;pid=' . $member['person_id'] . '"><strong>Email me whenever ' . $member['full_name'] . ' speaks</strong></a> (no more than once per day)</li>';
        }
        # Video
        if ($member['current_member'][1] && $member['party'] != 'Sinn Fein') {
            echo '<li>Help us add video by <a href="/video/next.php?action=random&amp;pid=' . $member['person_id'] . '"><strong>matching a speech by ' . $member['full_name'] . '</strong></a>';
        }
        ?>
						</ul>
						
						
						<ul class="jumpers hilites">
<?php 
        if (in_array(1, $member['houses']) && $member['party'] != 'Sinn Fein' || in_array(2, $member['houses'])) {
            echo '<li><a href="#votingrecord">Voting record</a></li>';
            if ($member['current_member'][1]) {
                echo '<li><a href="#topics">Committees and topics of interest</a></li>';
            }
        }
        if (!in_array(1, $member['houses']) || $member['party'] != 'Sinn Fein' || in_array(3, $member['houses'])) {
            echo '<li><a href="#hansard">Most recent appearances</a></li>';
        }
        echo '<li><a href="#numbers">Numerology</a></li>';
        if (isset($extra_info['register_member_interests_html'])) {
            echo '<li><a href="#register">Register of Members&rsquo; Interests</a></li>';
        }
        if (isset($extra_info['expenses2004_col1']) || isset($extra_info['expenses2006_col1']) || isset($extra_info['expenses2007_col1']) || isset($extra_info['expenses2008_col1'])) {
            echo '<li><a href="#expenses">Expenses</a></li>';
        }
        if (isset($extra_info['edm_ais_url'])) {
            ?>
						<li><a href="<?php 
            echo $extra_info['edm_ais_url'];
            ?>
">Early Day Motions signed by this MP</a> <small>(From edmi.parliament.uk)</small></li>
<?php 
        }
        ?>
						</ul>
<?php 
        # Big don't-print for SF MPs
        $chairmens_panel = false;
        if (in_array(1, $member['houses']) && $member['party'] != 'Sinn Fein' || in_array(2, $member['houses'])) {
            // Voting Record.
            ?>
 <a name="votingrecord"></a> <?php 
            //$this->block_start(array('id'=>'votingrecord', 'title'=>'Voting record (from PublicWhip)'));
            print '<h4>Voting record (from PublicWhip)</h4>';
            $displayed_stuff = 0;
            function display_dream_comparison($extra_info, $member, $dreamid, $desc, $inverse, $search)
            {
                if (isset($extra_info["public_whip_dreammp{$dreamid}_distance"])) {
                    if ($extra_info["public_whip_dreammp{$dreamid}_both_voted"] == 0) {
                        $dmpdesc = 'Has <strong>never voted</strong> on';
                    } else {
                        $dmpscore = floatval($extra_info["public_whip_dreammp{$dreamid}_distance"]);
                        print "<!-- distance {$dreamid}: {$dmpscore} -->";
                        if ($inverse) {
                            $dmpscore = 1.0 - $dmpscore;
                        }
                        $english = score_to_strongly($dmpscore);
                        if ($extra_info["public_whip_dreammp{$dreamid}_both_voted"] == 1) {
                            $english = preg_replace('#(very )?(strongly|moderately) #', '', $english);
                        }
                        $dmpdesc = 'Voted <strong>' . $english . '</strong>';
                        // How many votes Dream MP and MP both voted (and didn't abstain) in
                        // $extra_info["public_whip_dreammp${dreamid}_both_voted"];
                    }
                    $search_link = WEBPATH . "search/?s=" . urlencode($search) . "&pid=" . $member['person_id'] . "&pop=1";
                    ?>
				<li>
				<?php 
                    echo $dmpdesc;
                    ?>
			<?php 
                    echo $desc;
                    ?>
. 
<small class="unneededprintlinks"> 
<a href="http://www.publicwhip.org.uk/mp.php?mpid=<?php 
                    echo $member['member_id'];
                    ?>
&amp;dmp=<?php 
                    echo $dreamid;
                    ?>
">votes</a>,
<a href="<?php 
                    echo $search_link;
                    ?>
">speeches</a>
</small>

				</li>
<?php 
                    return true;
                }
                return false;
            }
            if ($member['party'] == 'Speaker' || $member['party'] == 'Deputy Speaker') {
                if ($member['party'] == 'Speaker') {
                    $art = 'the';
                } else {
                    $art = 'a';
                }
                echo "<p>As {$art} {$member['party']}, {$member['full_name']} cannot vote (except to break a tie).</p>";
            }
            if (isset($extra_info["public_whip_dreammp230_distance"]) || isset($extra_info["public_whip_dreammp996_distance"])) {
                # XXX
                $displayed_stuff = 1;
                ?>


	<p id="howvoted">How <?php 
                echo $member['full_name'];
                ?>
 voted on key issues since 2001:</p>
	<ul id="dreamcomparisons">
	<?php 
                $got_dream = false;
                $got_dream |= display_dream_comparison($extra_info, $member, 996, "a <strong>transparent Parliament</strong>", false, '"freedom of information"');
                if (in_array(1, $member['houses'])) {
                    $got_dream |= display_dream_comparison($extra_info, $member, 811, "introducing a <strong>smoking ban</strong>", false, "smoking");
                }
                #$got_dream |= display_dream_comparison($extra_info, $member, 856, "the <strong>changes to parliamentary scrutiny in the <a href=\"http://en.wikipedia.org/wiki/Legislative_and_Regulatory_Reform_Bill\">Legislative and Regulatory Reform Bill</a></strong>", false, "legislative and regulatory reform bill");
                $got_dream |= display_dream_comparison($extra_info, $member, 1051, "introducing <strong>ID cards</strong>", false, "id cards");
                $got_dream |= display_dream_comparison($extra_info, $member, 363, "introducing <strong>foundation hospitals</strong>", false, "foundation hospital");
                $got_dream |= display_dream_comparison($extra_info, $member, 1052, "introducing <strong>student top-up fees</strong>", false, "top-up fees");
                if (in_array(1, $member['houses'])) {
                    $got_dream |= display_dream_comparison($extra_info, $member, 1053, "Labour's <strong>anti-terrorism laws</strong>", false, "terrorism");
                }
                $got_dream |= display_dream_comparison($extra_info, $member, 1049, "the <strong>Iraq war</strong>", false, "iraq");
                $got_dream |= display_dream_comparison($extra_info, $member, 975, "an <strong>investigation</strong> into the Iraq war", false, "iraq");
                $got_dream |= display_dream_comparison($extra_info, $member, 984, "replacing <strong>Trident</strong>", false, "trident");
                $got_dream |= display_dream_comparison($extra_info, $member, 1050, "the <strong>hunting ban</strong>", false, "hunting");
                $got_dream |= display_dream_comparison($extra_info, $member, 826, "equal <strong>gay rights</strong>", false, "gay");
                $got_dream |= display_dream_comparison($extra_info, $member, 1030, "laws to <strong>stop climate change</strong>", false, "climate change");
                if (!$got_dream) {
                    print "<li>" . $member['full_name'] . " has not voted enough in this parliament to have any scores.</li>";
                }
                print '</ul>';
                ?>
<p class="italic">
<small>Read about <a href="<?php 
                echo WEBPATH;
                ?>
help/#votingrecord">how the voting record is decided</a>.</small>
</p>

<?php 
            }
            ?>

<?php 
            // Links to full record at Guardian and Public Whip
            $record = array();
            if (isset($extra_info['guardian_howtheyvoted'])) {
                $record[] = '<a href="' . $extra_info['guardian_howtheyvoted'] . '" title="At The Guardian">well-known issues</a> <small>(from the Guardian)</small>';
            }
            if (isset($extra_info['public_whip_division_attendance']) && $extra_info['public_whip_division_attendance'] != 'n/a') {
                $record[] = '<a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '&amp;showall=yes#divisions" title="At Public Whip">their full record</a>';
            }
            if (count($record) > 0) {
                $displayed_stuff = 1;
                ?>
			<p>More on <?php 
                echo implode(' &amp; ', $record);
                ?>
</p>
<?php 
            }
            // Rebellion rate
            if (isset($extra_info['public_whip_rebellions']) && $extra_info['public_whip_rebellions'] != 'n/a') {
                $displayed_stuff = 1;
                ?>
					<ul>
							<li><a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/<?php 
                echo $member['member_id'];
                ?>
#divisions" title="See more details at Public Whip">
                        <strong><?php 
                echo htmlentities(ucfirst($extra_info['public_whip_rebel_description']));
                ?>
 rebels</strong></a> against their party<?php 
                if (isset($extra_info['public_whip_rebelrank'])) {
                    echo " in this parliament";
                    /* &#8212; ";
                    			if (isset($extra_info['public_whip_rebelrank_joint']))
                    				print 'joint ';
                    			echo make_ranking($extra_info['public_whip_rebelrank']);
                    			echo " most rebellious of ";
                    			echo $extra_info['public_whip_rebelrank_outof'];
                    			echo ($member['house']=='House of Commons') ? " MPs" : ' Lords';
                    			*/
                }
                ?>
.
			</li>
		</ul><?php 
            }
            if (!$displayed_stuff) {
                print '<p>No data to display yet.</p>';
            }
            # Topics of interest only for MPs at the moment
            if ($member['current_member'][1]) {
                # in_array(1, $member['houses'])
                ?>
	<a name="topics"></a>
    <h4>Committees and topics of interest</h4>
		<?php 
                $topics_block_empty = true;
                // Select committee membership
                if (array_key_exists('office', $extra_info)) {
                    $mins = array();
                    foreach ($extra_info['office'] as $row) {
                        if ($row['to_date'] == '9999-12-31' && $row['source'] == 'chgpages/selctee') {
                            $m = prettify_office($row['position'], $row['dept']);
                            if ($row['from_date'] != '2004-05-28') {
                                $m .= ' <small>(since ' . format_date($row['from_date'], SHORTDATEFORMAT) . ')</small>';
                            }
                            $mins[] = $m;
                            if ($row['dept'] == "Chairmen's Panel Committee") {
                                $chairmens_panel = true;
                            }
                        }
                    }
                    if ($mins) {
                        print "<h5>Select Committee membership</h5>";
                        print "<ul>";
                        foreach ($mins as $min) {
                            print '<li>' . $min . '</li>';
                        }
                        print "</ul>";
                        $topics_block_empty = false;
                    }
                }
                $wrans_dept = false;
                $wrans_dept_1 = null;
                $wrans_dept_2 = null;
                if (isset($extra_info['wrans_departments'])) {
                    $wrans_dept = true;
                    $wrans_dept_1 = "<li><strong>Departments:</strong> " . $extra_info['wrans_departments'] . "</p>";
                }
                if (isset($extra_info['wrans_subjects'])) {
                    $wrans_dept = true;
                    $wrans_dept_2 = "<li><strong>Subjects (based on headings added by Hansard):</strong> " . $extra_info['wrans_subjects'] . "</p>";
                }
                if ($wrans_dept) {
                    print "<p><strong>Asks most questions about</strong></p>";
                    print "<ul>";
                    if ($wrans_dept_1) {
                        print $wrans_dept_1;
                    }
                    if ($wrans_dept_2) {
                        print $wrans_dept_2;
                    }
                    print "</ul>";
                    $topics_block_empty = false;
                    $WRANSURL = new URL('search');
                    $WRANSURL->insert(array('pid' => $member['person_id'], 's' => 'section:wrans', 'pop' => 1));
                    ?>
							<p><small>(based on <a href="<?php 
                    echo $WRANSURL->generate();
                    ?>
">written questions asked by <?php 
                    echo $member['full_name'];
                    ?>
</a> and answered by departments)</small></p><?php 
                }
                # Public Bill Committees
                if (count($extra_info['pbc'])) {
                    $topics_block_empty = false;
                    print '<h5>Public Bill Committees <small>(sittings attended)</small></h5>';
                    if ($member['party'] == 'Scottish National Party') {
                        echo '<p><em>SNP MPs only attend sittings where the legislation pertains to Scotland.</em></p>';
                    }
                    echo '<ul>';
                    foreach ($extra_info['pbc'] as $bill_id => $arr) {
                        print '<li>';
                        if ($arr['chairman']) {
                            print 'Chairman, ';
                        }
                        print '<a href="/pbc/' . $arr['session'] . '/' . urlencode($arr['title']) . '">' . $arr['title'] . ' Committee</a> <small>(' . $arr['attending'] . ' out of ' . $arr['outof'] . ')</small>';
                    }
                    print '</ul>';
                }
                if ($topics_block_empty) {
                    print "<p><em>This MP is not currently on any select or public bill committee\nand has had no written questions answered for which we know the department or subject.</em></p>";
                }
            }
        }
        if (!in_array(1, $member['houses']) || $member['party'] != 'Sinn Fein' || in_array(3, $member['houses'])) {
            ?>
		<a name="hansard"></a> <?php 
            $title = 'Most recent appearances';
            if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
                $title = '<a href="' . WEBPATH . $rssurl . '"><img src="' . WEBPATH . 'images/rss.gif" alt="RSS feed" border="0" align="right"></a> ' . $title;
            }
            print "<h4>{$title}</h4>";
            //$this->block_start(array('id'=>'hansard', 'title'=>$title));
            // This is really far from ideal - I don't really want $PAGE to know
            // anything about HANSARDLIST / DEBATELIST / WRANSLIST.
            // But doing this any other way is going to be a lot more work for little
            // benefit unfortunately.
            twfy_debug_timestamp();
            $HANSARDLIST = new HANSARDLIST();
            $searchstring = "speaker:{$member['person_id']}";
            global $SEARCHENGINE;
            $SEARCHENGINE = new SEARCHENGINE($searchstring);
            $args = array('s' => $searchstring, 'p' => 1, 'num' => 3, 'pop' => 1, 'o' => 'd');
            $HANSARDLIST->display('search_min', $args);
            twfy_debug_timestamp();
            $MOREURL = new URL('search');
            $MOREURL->insert(array('pid' => $member['person_id'], 'pop' => 1));
            ?>
	<p id="moreappear"><a href="<?php 
            echo $MOREURL->generate();
            ?>
#n4">More of <?php 
            echo ucfirst($member['full_name']);
            ?>
's recent appearances</a></p>

<?php 
            if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
                // If we set an RSS feed for this page.
                $HELPURL = new URL('help');
                ?>
					<p class="unneededprintlinks"><a href="<?php 
                echo WEBPATH . $rssurl;
                ?>
" title="XML version of this person's recent appearances">RSS feed</a> (<a href="<?php 
                echo $HELPURL->generate();
                ?>
#rss" title="An explanation of what RSS feeds are for">?</a>)</p>
<?php 
            }
            //	$this->block_end();
        }
        # End Sinn Fein
        ?>
 <a name="numbers"></a> <?php 
        //$this->block_start(array('id'=>'numbers', 'title'=>'Numerology'));
        print "<h4>Numerology</h4>";
        $displayed_stuff = 0;
        ?>
		<p><em>Please note that numbers do not measure quality. 
		Also, representatives may do other things not currently covered
		by this site.</em> (<a href="<?php 
        echo WEBPATH;
        ?>
help/#numbers">More about this</a>)</p>
<ul>
<?php 
        $since_text = 'in the last year';
        #if ($member['entered_house'] > '2005-05-05')
        #	$since_text = 'since joining Parliament';
        $MOREURL = new URL('search');
        $section = 'section:debates section:whall section:lords section:ni';
        $MOREURL->insert(array('pid' => $member['person_id'], 's' => $section, 'pop' => 1));
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in <a href="' . $MOREURL->generate() . '">', 'debate', '</a> ' . $since_text, '', $extra_info);
            $MOREURL->insert(array('pid' => $member['person_id'], 's' => 'section:wrans', 'pop' => 1));
            // We assume that if they've answered a question, they're a minister
            $minister = 0;
            $Lminister = false;
            if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) {
                $minister = 1;
            }
            if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) {
                $Lminister = true;
            }
            if ($member['party'] == 'Speaker' || $member['party'] == 'Deputy Speaker') {
                $minister = 2;
            }
            $displayed_stuff |= display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister);
        }
        if (isset($extra_info['select_committees'])) {
            print "<li>Is a member of <strong>{$extra_info['select_committees']}</strong> select committee";
            if ($extra_info['select_committees'] != 1) {
                print "s";
            }
            if (isset($extra_info['select_committees_chair'])) {
                print " ({$extra_info['select_committees_chair']} as chair)";
            }
            print '.</li>';
        }
        $wtt_displayed = display_writetothem_numbers(2008, $extra_info);
        $displayed_stuff |= $wtt_displayed;
        if (!$wtt_displayed) {
            $wtt_displayed = display_writetothem_numbers(2007, $extra_info);
            $displayed_stuff |= $wtt_displayed;
            if (!$wtt_displayed) {
                $wtt_displayed = display_writetothem_numbers(2006, $extra_info);
                $displayed_stuff |= $wtt_displayed;
                if (!$wtt_displayed) {
                    $displayed_stuff |= display_writetothem_numbers(2005, $extra_info);
                }
            }
        }
        $after_stuff = ' <small>(From Public Whip)</small>';
        if ($member['party'] == 'Scottish National Party') {
            $after_stuff .= '<br><em>Note SNP MPs do not vote on legislation not affecting Scotland.</em>';
        } elseif ($member['party'] == 'Speaker' || $member['party'] == 'Deputy Speaker') {
            $after_stuff .= '<br><em>Speakers and deputy speakers cannot vote except to break a tie.</em>';
        }
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('public_whip_division_attendance', 'Has voted in <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '&amp;showall=yes#divisions" title="See more details at Public Whip">', 'of vote', '</a> in parliament with this affiliation', $after_stuff, $extra_info);
            if ($chairmens_panel) {
                print '<br><em>Members of the Chairmen\'s Panel act for the Speaker when chairing things such as Public Bill Committees, and as such do not vote on Bills they are involved in chairing.</em>';
            }
            $displayed_stuff |= display_stats_line('comments_on_speeches', 'People have made <a href="' . WEBPATH . 'comments/recent/?pid=' . $member['person_id'] . '">', 'annotation', "</a> on this MP&rsquo;s speeches", '', $extra_info);
            $displayed_stuff |= display_stats_line('reading_age', 'This MP\'s speeches, in Hansard, are readable by an average ', '', ' year old, going by the <a href="http://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test">Flesch-Kincaid Grade Level</a> score', '', $extra_info);
        }
        if (isset($extra_info['number_of_alerts'])) {
            $displayed_stuff = 1;
            ?>
		<li><strong><?php 
            echo htmlentities($extra_info['number_of_alerts']);
            ?>
</strong> <?php 
            echo $extra_info['number_of_alerts'] == 1 ? 'person is' : 'people are';
            ?>
 tracking whenever <?php 
            if ($member['house_disp'] == 1) {
                print 'this MP';
            } elseif ($member['house_disp'] == 2) {
                print 'this peer';
            } elseif ($member['house_disp'] == 3) {
                print 'this MLA';
            } elseif ($member['house_disp'] == 4) {
                print 'this MSP';
            } elseif ($member['house_disp'] == 0) {
                print $member['full_name'];
            }
            ?>
 speaks<?php 
            if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || $member['current_member'][1] && $member['party'] != 'Sinn Fein' || $member['current_member'][4]) {
                print ' &mdash; <a href="' . WEBPATH . 'alert/?only=1&amp;pid=' . $member['person_id'] . '">email me whenever ' . $member['full_name'] . ' speaks</a>';
            }
            print '.</li>';
        }
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="' . WEBPATH . 'help/#numbers">Why is this here?</a>)</small>', $extra_info);
            if (isset($extra_info['three_word_alliteration_content'])) {
                print "\n<!-- " . $extra_info['three_word_alliteration_content'] . " -->\n";
            }
        }
        #		$displayed_stuff |= display_stats_line('ending_with_a_preposition', "Has ended a sentence with 'with' ", 'time', ' in debates', '', $extra_info);
        #		$displayed_stuff |= display_stats_line('only_asked_why', "Has made a speech consisting solely of 'Why?' ", 'time', ' in debates', '', $extra_info);
        ?>
						</ul>
<?php 
        if (!$displayed_stuff) {
            print '<p>No data to display yet.</p>';
        }
        //$this->block_end();
        if (isset($extra_info['register_member_interests_html'])) {
            ?>
				
<a name="register"></a>
<?php 
            print "<h4>Register of Members' Interests</h4>";
            if ($extra_info['register_member_interests_html'] != '') {
                echo $extra_info['register_member_interests_html'];
            } else {
                echo "\t\t\t\t<p>Nil</p>\n";
            }
            echo '<p class="italic">';
            if (isset($extra_info['register_member_interests_date'])) {
                echo 'Register last updated: ';
                echo format_date($extra_info['register_member_interests_date'], SHORTDATEFORMAT);
                echo '. ';
            }
            echo '<a href="http://www.publications.parliament.uk/pa/cm/cmregmem/061106/memi01.htm">More about the Register</a>';
            echo '</p>';
            print '<p><strong><a href="' . WEBPATH . 'regmem/?p=' . $member['person_id'] . '">View the history of this MP\'s entries in the Register</a></strong></p>';
        }
        if (isset($extra_info['expenses2004_col1']) || isset($extra_info['expenses2006_col1']) || isset($extra_info['expenses2007_col1']) || isset($extra_info['expenses2008_col1'])) {
            include_once INCLUDESPATH . 'easyparliament/expenses.php';
            ?>
<a name="expenses"></a>
<?php 
            $title = 'Expenses';
            print "<h4>" . $title . "</h4>";
            echo expenses_display_table($extra_info);
        }
    }
function render_mps_row($mp, &$style, $order, $MPURL)
{
    // Stripes
    $style = $style == '1' ? '2' : '1';
    $name = member_full_name(1, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']);
    #	$MPURL->insert(array('pid'=>$mp['person_id']));
    ?>
				<tr>
                <td class="row">
                <?php 
    list($image, $sz) = find_rep_image($mp['person_id'], true, true);
    if ($image) {
        echo '<a href="' . $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1) . '" class="speakerimage"><img height="59" class="portrait" alt="" src="', $image, '"';
        echo '></a>';
    }
    ?>
                </td>
				<td class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1);
    ?>
"><?php 
    echo $name;
    ?>
</a>
<?php 
    if ($mp['left_reason'] == 'general_election_not_standing') {
        print '<br><em>Standing down</em>';
    }
    ?>
</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['party'];
    ?>
</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['constituency'];
    ?>
</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    if (is_array($mp['pos'])) {
        print join('<br>', array_map('prettify_office', $mp['pos'], $mp['dept']));
    } elseif ($mp['pos'] || $mp['dept']) {
        print prettify_office($mp['pos'], $mp['dept']);
    } else {
        print '&nbsp;';
    }
    ?>
</td>
<?php 
    if ($order == 'expenses') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
">&pound;<?php 
        echo number_format($mp['data_value']);
        ?>
</td>
<?php 
    } elseif ($order == 'debates') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
"><?php 
        echo number_format($mp['data_value']);
        ?>
</td>
<?php 
    } elseif ($order == 'safety') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
"><?php 
        echo $mp['data_value'];
        ?>
</td>
<?php 
    }
    ?>
				</tr>
<?php 
}
Exemple #13
0
function exists_rep_image($pid)
{
    $image = find_rep_image($pid, false, false);
    return $image[1] !== null;
}
Exemple #14
0
    function display_member($member, $extra_info)
    {
        global $THEUSER, $DATA, $this_page;
        # If current Senator show their name as "Senator John Smith". Current Representative show their name as "John Smith MP"
        $title = $member['current_member'][2] ? 'Senator ' : '';
        $title .= ucfirst($member['full_name']);
        # Show current titles first
        foreach ($member['houses'] as $house) {
            if ($member['current_member'][$house]) {
                $title .= ' ';
                if ($house == 1) {
                    $title .= 'MP';
                }
            }
        }
        # Show former membership
        foreach ($member['houses'] as $house) {
            if (!$member['current_member'][$house]) {
                $title .= ', former ';
                if ($house == 1) {
                    $title .= 'Representative';
                }
                if ($house == 2) {
                    $title .= 'Senator';
                }
            }
        }
        /*		if (isset($extra_info["public_whip_dreammp996_distance"])) {
        			$dmpscore = floatval($extra_info["public_whip_dreammp996_distance"]);
        			$strongly_foi = "voted " . score_to_strongly(1.0 - $dmpscore);
        		}
        		if ($extra_info["public_whip_dreammp996_both_voted"] == 0) {
        			$strongly_foi = "has never voted on";
        		}
        		$this->block_start(array('id'=>'black', 'title'=>"Freedom of Information and Parliament"));
        		print "<p>There is currently a Bill before Parliament which will make Parliament
        			exempt from Freedom of Information requests. This Bill will remove
        			your legal right to see some of the information on this page, notably
        			expenses, replacing it with a weaker promise that could be retracted
        			later.</p>
        
        			<p>Even if this bill is amended to exclude expenses, exemption from the
        			Freedom of Information Act may prevent OpenAustralia from adding
        			useful information of new sorts in the future. The Bill is not backed
        			or opposed by a specific party, and OpenAustralia remains strictly
        			neutral on all issues that do not affect our ability to serve the
        			public.</p>
        
        			<p><a href=\"somewhere\">Join the Campaign to keep Parliament transparent
        			(external)</a>.</p>";
        
        		print 'For your information, '.$title.' MP <a href="http://www.publicwhip.org.uk/mp.php?mpid='.$member['member_id'].'&amp;dmp=996">'.$strongly_foi.'</a> this Bill.';
        		$this->block_end();
        */
        if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
            $title = '<a href="' . WEBPATH . $rssurl . '"><img src="' . WEBPATH . 'images/rss.gif" alt="RSS feed" border="0" align="right"></a> ' . $title;
        }
        print '<p class="printonly">This data was produced by OpenAustralia from a variety of sources.</p>';
        $this->block_start(array('id' => 'mp', 'title' => $title));
        list($image, $sz) = find_rep_image($member['person_id']);
        if ($image) {
            echo '<img class="portrait" alt="Photo of ', $member['full_name'], '" src="', $image, '"';
            if ($sz == 'S') {
                echo ' height="118"';
            }
            echo '>';
        } else {
            // Prompt for photo
            echo '<div class="textportrait"><br>We\'re missing a photo!<br><br><a href="mailto:contact@openaustralia.org">Email us one</a> <small>(that you have copyright of)</small><br><br></div>';
        }
        echo '<ul class="hilites">';
        $desc = '';
        foreach ($member['houses'] as $house) {
            $party = $member['left_house'][$house]['party'];
            $desc .= '<li><strong>';
            if (!$member['current_member'][$house]) {
                $desc .= 'Former ';
            }
            $desc .= htmlentities($party);
            if ($party == 'Speaker' || $party == 'Deputy-Speaker' || $party == 'President' || $party == 'Deputy-President') {
                $desc .= ', and ';
                # XXX: Will go horribly wrong if something odd happens
                if ($party == 'Deputy-Speaker') {
                    $last = end($member['other_parties']);
                    $desc .= $last['from'] . ' ';
                }
            }
            $desc .= ' ';
            if ($house == 1) {
                $desc .= 'Representative';
            }
            if ($house == 2) {
                $desc .= 'Senator';
            }
            if ($house == 3) {
                $desc .= 'MLA';
            }
            if ($house == 4) {
                $desc .= 'MSP';
            }
            $desc .= ' for ' . $member['left_house'][$house]['constituency'];
            $desc .= '</strong></li>';
        }
        print $desc;
        if ($member['other_parties'] && $member['party'] != 'Speaker' && $member['party'] != 'Deputy-Speaker' && $member['party'] != 'President' && $member['party'] != 'Deputy-President') {
            print "<li>Changed party ";
            foreach ($member['other_parties'] as $r) {
                $out[] = 'from ' . $r['from'] . ' on ' . format_date($r['date'], SHORTDATEFORMAT);
            }
            print join('; ', $out);
            print '</li>';
        }
        // Ministerial position
        if (array_key_exists('office', $extra_info)) {
            $mins = array();
            foreach ($extra_info['office'] as $row) {
                if ($row['to_date'] == '9999-12-31' && $row['source'] != 'chgpages/selctee') {
                    $m = prettify_office($row['position'], $row['dept']);
                    $m .= ' (since ' . format_date($row['from_date'], SHORTDATEFORMAT) . ')';
                    $mins[] = $m;
                }
            }
            if ($mins) {
                print '<li>' . join('<br>', $mins) . '</li>';
            }
        }
        if (isset($member['left_house'][1]) && isset($member['entered_house'][2])) {
            print '<li><strong>Entered the Senate ';
            if (strlen($member['entered_house'][2]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            print $member['entered_house'][2]['date_pretty'] . '</strong>';
            print '</strong>';
            if ($member['entered_house'][2]['reason']) {
                print ' &mdash; ' . $member['entered_house'][2]['reason'];
            }
            print '</li>';
            if (!$member['current_member'][1]) {
                print '<li><strong>Previously Representative for ';
                print $member['left_house'][1]['constituency'] . ' until ';
                print $member['left_house'][1]['date_pretty'] . '</strong>';
                if ($member['left_house'][1]['reason']) {
                    print ' &mdash; ' . $member['left_house'][1]['reason'];
                }
                print '</li>';
            }
        } elseif (isset($member['entered_house'][2]['date'])) {
            print '<li><strong>Became a Senator ';
            if (strlen($member['entered_house'][2]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            print $member['entered_house'][2]['date_pretty'] . '</strong>';
            if ($member['entered_house'][2]['reason']) {
                print ' &mdash; ' . $member['entered_house'][2]['reason'];
            }
            print '</li>';
        } elseif (in_array(1, $member['houses']) && !$member['current_member'][1]) {
            print '<li><strong>Left House of Representatives on ' . $member['left_house'][1]['date_pretty'] . '</strong>';
            if ($member['left_house'][1]['reason']) {
                print ' &mdash; ' . $member['left_house'][1]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][1]['date'])) {
            print '<li><strong>Entered House of Representatives on ';
            print $member['entered_house'][1]['date_pretty'] . '</strong>';
            if ($member['entered_house'][1]['reason']) {
                print ' &mdash; ' . $member['entered_house'][1]['reason'];
            }
            print '</li>';
        }
        if (isset($extra_info['lordbio'])) {
            echo '<li><strong>Positions held:</strong> ', $extra_info['lordbio'], ' <small>(from <a href="', $extra_info['lordbio_from'], '">Number 10 press release</a>)</small></li>';
        }
        if (in_array(2, $member['houses']) && !$member['current_member'][2]) {
            print '<li><strong>Left Senate on ' . $member['left_house'][2]['date_pretty'] . '</strong>';
            if ($member['left_house'][2]['reason']) {
                print ' &mdash; ' . $member['left_house'][2]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][3]['date'])) {
            print '<li><strong>Entered the Assembly on ';
            print $member['entered_house'][3]['date_pretty'] . '</strong>';
            if ($member['entered_house'][3]['reason']) {
                print ' &mdash; ' . $member['entered_house'][3]['reason'];
            }
            print '</li>';
        }
        if (in_array(3, $member['houses']) && !$member['current_member'][3]) {
            print '<li><strong>Left the Assembly on ' . $member['left_house'][3]['date_pretty'] . '</strong>';
            if ($member['left_house'][3]['reason']) {
                print ' &mdash; ' . $member['left_house'][3]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][4]['date'])) {
            print '<li><strong>Entered the Scottish Parliament on ';
            print $member['entered_house'][4]['date_pretty'] . '</strong>';
            if ($member['entered_house'][4]['reason']) {
                print ' &mdash; ' . $member['entered_house'][4]['reason'];
            }
            print '</li>';
        }
        if (in_array(4, $member['houses']) && !$member['current_member'][4]) {
            print '<li><strong>Left the Scottish Parliament on ' . $member['left_house'][4]['date_pretty'] . '</strong>';
            if ($member['left_house'][4]['reason']) {
                print ' &mdash; ' . $member['left_house'][4]['reason'];
            }
            print '</li>';
        }
        if (isset($extra_info['majority_in_seat'])) {
            ?>
						<li><strong>Majority:</strong> 
						<?php 
            echo number_format($extra_info['majority_in_seat']);
            ?>
 votes. <?php 
            if (isset($extra_info['swing_to_lose_seat_today'])) {
                /*
                if (isset($extra_info['swing_to_lose_seat_today_quintile'])) {
                	$q = $extra_info['swing_to_lose_seat_today_quintile'];
                	if ($q == 0) {
                		print 'Very safe seat';
                	} elseif ($q == 1) {
                		print 'Safe seat';
                	} elseif ($q == 2) {
                		print '';
                	} elseif ($q == 3) {
                		print 'Unsafe seat';
                	} elseif ($q == 4) {
                		print 'Very unsafe seat';
                	} else {
                		print '[Impossible quintile!]';
                	}
                }
                */
                print ' &mdash; ' . make_ranking($extra_info['swing_to_lose_seat_today_rank']);
                ?>
 out of <?php 
                echo $extra_info['swing_to_lose_seat_today_rank_outof'];
                ?>
 MPs.
<?php 
            }
            ?>
</li>
<?php 
        }
        if ($member['party'] == 'Sinn Fein' && in_array(1, $member['houses'])) {
            print '<li>Sinn F&eacute;in MPs do not take their seats in Parliament</li>';
        }
        if ($member['the_users_mp'] == true) {
        } elseif ($member['current_member'][1]) {
        } elseif ($member['current_member'][3]) {
            ?>
						<li><a href="http://www.writetothem.com/"><strong>Send a message to your MLA</strong></a> <small>(via WriteToThem.com)</small></li>
<?php 
        } elseif ($member['current_member'][2]) {
        }
        # If they're currently an MLA, a Lord or a non-Sinn Fein MP
        if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || $member['current_member'][1] && $member['party'] != 'Sinn Fein') {
            print '<li><a href="' . WEBPATH . 'alert/?only=1&amp;pid=' . $member['person_id'] . '"><strong>Email me whenever ' . $member['full_name'] . ' speaks</strong></a> (no more than once per day)</li>';
        }
        ?>
						</ul>
						
						
						<ul class="jumpers">
<?php 
        if (!in_array(1, $member['houses']) || $member['party'] == 'Sinn Fein') {
            ?>
						<li><a href="#hansard">Recent appearances</a></li>
<?php 
        }
        ?>
						<li><a href="#numbers">Numbers</a></li>
<?php 
        if (isset($extra_info['register_member_interests_html'])) {
            ?>
						<li><a href="#register">Register of Members' Interests</a></li>
<?php 
        }
        if (isset($extra_info['expenses2004_col1']) || isset($extra_info['expenses2006_col1']) || isset($extra_info['expenses2007_col1'])) {
            ?>
 						<li><a href="#expenses">Expenses</a></li>
<?php 
        }
        if (isset($extra_info['edm_ais_url'])) {
            ?>
						<li><a href="<?php 
            echo $extra_info['edm_ais_url'];
            ?>
">Early Day Motions signed by this MP</a> <small>(From edm.ais.co.uk)</small></li>
<?php 
        }
        ?>
						</ul>
<?php 
        $this->block_end();
        # Big don't-print for SF MPs
        if (0) {
            // Voting Record.
            ?>
 <a name="votingrecord"></a> <?php 
            $this->block_start(array('id' => 'votingrecord', 'title' => 'Voting record (from PublicWhip)'));
            $displayed_stuff = 0;
            function display_dream_comparison($extra_info, $member, $dreamid, $desc, $inverse, $search)
            {
                if (isset($extra_info["public_whip_dreammp{$dreamid}_distance"])) {
                    if ($extra_info["public_whip_dreammp{$dreamid}_both_voted"] == 0) {
                        $dmpdesc = 'Has <strong>never voted</strong> on';
                    } else {
                        $dmpscore = floatval($extra_info["public_whip_dreammp{$dreamid}_distance"]);
                        print "<!-- distance {$dreamid}: {$dmpscore} -->";
                        if ($inverse) {
                            $dmpscore = 1.0 - $dmpscore;
                        }
                        $dmpdesc = 'Voted <strong>' . score_to_strongly($dmpscore) . '</strong>';
                        // How many votes Dream MP and MP both voted (and didn't abstain) in
                        // $extra_info["public_whip_dreammp${dreamid}_both_voted"];
                    }
                    $search_link = WEBPATH . "search/?s=" . urlencode($search) . "&pid=" . $member['person_id'] . "&pop=1";
                    ?>
				<li>
				<?php 
                    echo $dmpdesc;
                    ?>
			<?php 
                    echo $desc;
                    ?>
. 
<small class="unneededprintlinks"> 
<a href="http://www.publicwhip.org.uk/mp.php?mpid=<?php 
                    echo $member['member_id'];
                    ?>
&amp;dmp=<?php 
                    echo $dreamid;
                    ?>
">votes</a>,
<a href="<?php 
                    echo $search_link;
                    ?>
">speeches</a>
</small>

				</li>
<?php 
                    return true;
                }
                return false;
            }
            if (isset($extra_info["public_whip_dreammp230_distance"]) || isset($extra_info["public_whip_dreammp996_distance"])) {
                # XXX
                $displayed_stuff = 1;
                ?>


	<p id="howvoted">How <?php 
                echo $member['full_name'];
                ?>
 voted on key issues since 2001:</p>
	<ul id="dreamcomparisons">
	<?php 
                $got_dream = false;
                $got_dream |= display_dream_comparison($extra_info, $member, 996, "a <strong>transparent Parliament</strong>", false, '"freedom of information"');
                $got_dream |= display_dream_comparison($extra_info, $member, 811, "introducing a <strong>smoking ban</strong>", false, "smoking");
                #$got_dream |= display_dream_comparison($extra_info, $member, 856, "the <strong>changes to parliamentary scrutiny in the <a href=\"http://en.wikipedia.org/wiki/Legislative_and_Regulatory_Reform_Bill\">Legislative and Regulatory Reform Bill</a></strong>", false, "legislative and regulatory reform bill");
                $got_dream |= display_dream_comparison($extra_info, $member, 230, "introducing <strong>ID cards</strong>", true, "id cards");
                $got_dream |= display_dream_comparison($extra_info, $member, 363, "introducing <strong>foundation hospitals</strong>", false, "foundation hospital");
                $got_dream |= display_dream_comparison($extra_info, $member, 367, "introducing <strong>student top-up fees</strong>", true, "top-up fees");
                $got_dream |= display_dream_comparison($extra_info, $member, 258, "Labour's <strong>anti-terrorism laws</strong>", true, "terrorism");
                $got_dream |= display_dream_comparison($extra_info, $member, 219, "the <strong>Iraq war</strong>", true, "iraq");
                $got_dream |= display_dream_comparison($extra_info, $member, 975, "investigating the <strong>Iraq war</strong>", false, "iraq");
                $got_dream |= display_dream_comparison($extra_info, $member, 984, "replacing <strong>Trident</strong>", false, "trident");
                $got_dream |= display_dream_comparison($extra_info, $member, 358, "the <strong>hunting ban</strong>", true, "hunting");
                $got_dream |= display_dream_comparison($extra_info, $member, 826, "equal <strong>gay rights</strong>", false, "gay");
                if (!$got_dream) {
                    print "<li>" . $member['full_name'] . " has not voted enough in this parliament to have any scores.</li>";
                }
                print '</ul>';
                ?>
<p class="italic">
<small>Read about <a href="<?php 
                echo WEBPATH;
                ?>
help/#votingrecord">how the voting record is decided</a>.</small>
</p>

<?php 
            }
            ?>

<?php 
            // Links to full record at Guardian and Public Whip
            $record = array();
            if (isset($extra_info['guardian_howtheyvoted'])) {
                $record[] = '<a href="' . $extra_info['guardian_howtheyvoted'] . '" title="At The Guardian">well-known issues</a> <small>(from the Guardian)</small>';
            }
            if (isset($extra_info['public_whip_division_attendance']) && $extra_info['public_whip_division_attendance'] != 'n/a') {
                $record[] = '<a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '&amp;showall=yes#divisions" title="At Public Whip">their full record</a>';
            }
            if (count($record) > 0) {
                $displayed_stuff = 1;
                ?>
			<p>More on <?php 
                echo implode(' &amp; ', $record);
                ?>
</p>
<?php 
            }
            // Rebellion rate
            if (isset($extra_info['public_whip_rebellions']) && $extra_info['public_whip_rebellions'] != 'n/a') {
                $displayed_stuff = 1;
                ?>
					<ul>
							<li><a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/<?php 
                echo $member['member_id'];
                ?>
#divisions" title="See more details at Public Whip">
                        <strong><?php 
                echo htmlentities(ucfirst($extra_info['public_whip_rebel_description']));
                ?>
 rebels</strong></a> against their party<?php 
                if (isset($extra_info['public_whip_rebelrank'])) {
                    echo " in this parliament";
                    /* &#8212; ";
                    			if (isset($extra_info['public_whip_rebelrank_joint']))
                    				print 'joint ';
                    			echo make_ranking($extra_info['public_whip_rebelrank']);
                    			echo " most rebellious of ";
                    			echo $extra_info['public_whip_rebelrank_outof'];
                    			echo ($member['house']=='House of Commons') ? " MPs" : ' Lords';
                    			*/
                }
                ?>
.
			</li>
		</ul><?php 
            }
            if (!$displayed_stuff) {
                print '<p>No data to display yet.</p>';
            }
            $this->block_end();
            # Topics of interest only for MPs at the moment
            if (in_array(1, $member['houses'])) {
                ?>
	<a name="topics"></a>
		<?php 
                $this->block_start(array('id' => 'topics', 'title' => 'Committees and topics of interest'));
                $topics_block_empty = true;
                // Select committee membership
                if (array_key_exists('office', $extra_info)) {
                    $mins = array();
                    foreach ($extra_info['office'] as $row) {
                        if ($row['to_date'] == '9999-12-31' && $row['source'] == 'chgpages/selctee') {
                            $m = prettify_office($row['position'], $row['dept']);
                            if ($row['from_date'] != '2004-05-28') {
                                $m .= ' <small>(since ' . format_date($row['from_date'], SHORTDATEFORMAT) . ')</small>';
                            }
                            $mins[] = $m;
                        }
                    }
                    if ($mins) {
                        print "<h5>Select Committee membership</h5>";
                        print "<ul>";
                        foreach ($mins as $min) {
                            print '<li>' . $min . '</li>';
                        }
                        print "</ul>";
                        $topics_block_empty = false;
                    }
                }
                $wrans_dept = false;
                $wrans_dept_1 = null;
                $wrans_dept_2 = null;
                if (isset($extra_info['wrans_departments'])) {
                    $wrans_dept = true;
                    $wrans_dept_1 = "<li><strong>Departments:</strong> " . $extra_info['wrans_departments'] . "</p>";
                }
                if (isset($extra_info['wrans_subjects'])) {
                    $wrans_dept = true;
                    $wrans_dept_2 = "<li><strong>Subjects (based on headings added by Hansard):</strong> " . $extra_info['wrans_subjects'] . "</p>";
                }
                if ($wrans_dept) {
                    print "<p><strong>Asks most questions about</strong></p>";
                    print "<ul>";
                    if ($wrans_dept_1) {
                        print $wrans_dept_1;
                    }
                    if ($wrans_dept_2) {
                        print $wrans_dept_2;
                    }
                    print "</ul>";
                    $topics_block_empty = false;
                    $WRANSURL = new URL('search');
                    $WRANSURL->insert(array('pid' => $member['person_id'], 's' => 'section:wrans', 'pop' => 1));
                    ?>
							<p><small>(based on <a href="<?php 
                    echo $WRANSURL->generate();
                    ?>
">written questions asked by <?php 
                    echo $member['full_name'];
                    ?>
</a> and answered by departments)</small></p><?php 
                }
                # Public Bill Committees
                if (count($extra_info['pbc'])) {
                    $topics_block_empty = false;
                    print '<h5>Public Bill Committees <small>(sittings attended)</small></h5> <ul>';
                    foreach ($extra_info['pbc'] as $bill_id => $arr) {
                        print '<li>';
                        if ($arr['chairman']) {
                            print 'Chairman, ';
                        }
                        print '<a href="/pbc/' . $arr['session'] . '/' . urlencode($arr['title']) . '">' . $arr['title'] . ' Committee</a> <small>(' . $arr['attending'] . ' out of ' . $arr['outof'] . ')</small>';
                    }
                    print '</ul>';
                }
                if ($topics_block_empty) {
                    print "<p><em>This MP is not currently on any select <!-- or public bill --> committee\nand has had no written questions answered for which we know the department or subject.</em></p>";
                }
                $this->block_end();
            }
        }
        if (!in_array(1, $member['houses']) || $member['party'] != 'Sinn Fein') {
            ?>
		<a name="hansard"></a> <?php 
            $title = 'Most recent appearances in parliament';
            if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
                $title = '<a href="' . WEBPATH . $rssurl . '"><img src="' . WEBPATH . 'images/rss.gif" alt="RSS feed" border="0" align="right"></a> ' . $title;
            }
            $this->block_start(array('id' => 'hansard', 'title' => $title));
            // This is really far from ideal - I don't really want $PAGE to know
            // anything about HANSARDLIST / DEBATELIST / WRANSLIST.
            // But doing this any other way is going to be a lot more work for little
            // benefit unfortunately.
            twfy_debug_timestamp();
            $HANSARDLIST = new HANSARDLIST();
            $searchstring = "speaker:{$member['person_id']}";
            global $SEARCHENGINE;
            $SEARCHENGINE = new SEARCHENGINE($searchstring);
            $args = array('s' => $searchstring, 'p' => 1, 'num' => 3, 'pop' => 1, 'o' => 'd');
            $HANSARDLIST->display('search_min', $args);
            twfy_debug_timestamp();
            $MOREURL = new URL('search');
            $MOREURL->insert(array('pid' => $member['person_id'], 'pop' => 1));
            ?>
	<p id="moreappear"><a href="<?php 
            echo $MOREURL->generate();
            ?>
#n4">More of <?php 
            echo ucfirst($member['full_name']);
            ?>
's recent appearances</a></p>

<?php 
            if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
                // If we set an RSS feed for this page.
                $HELPURL = new URL('help');
                ?>
					<p class="unneededprintlinks"><a href="<?php 
                echo WEBPATH . $rssurl;
                ?>
" title="XML version of this person's recent appearances">RSS feed</a> (<a href="<?php 
                echo $HELPURL->generate();
                ?>
#rss" title="An explanation of what RSS feeds are for">?</a>)</p>
<?php 
            }
            $this->block_end();
        }
        # End Sinn Fein
        ?>
 <a name="numbers"></a> <?php 
        $this->block_start(array('id' => 'numbers', 'title' => 'Numbers'));
        $displayed_stuff = 0;
        ?>
		<p><em>Please note that numbers do not measure quality. 
		Also, <?php 
        if ($member['house_disp'] == 1) {
            echo "Representatives";
        } else {
            echo "Senators";
        }
        ?>
 may do other things not currently covered
		by this site.</em> (<a href="<?php 
        echo WEBPATH;
        ?>
help/#numbers">More about this</a>)</p>
<ul>
<?php 
        $since_text = 'in the last year';
        #if ($member['entered_house'] > '2005-05-05')
        #	$since_text = 'since joining Parliament';
        $MOREURL = new URL('search');
        $MOREURL->insert(array('pid' => $member['person_id'], 'pop' => 1));
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in <a href="' . $MOREURL->generate() . '">', 'debate', '</a> ' . $since_text, '', $extra_info);
            $MOREURL->insert(array('pid' => $member['person_id'], 's' => 'section:wrans', 'pop' => 1));
            // We assume that if they've answered a question, they're a minister
            $minister = false;
            $Lminister = false;
            if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) {
                $minister = true;
            }
            if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) {
                $Lminister = true;
            }
            #		$displayed_stuff |= display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister);
        }
        if (isset($extra_info['select_committees'])) {
            print "<li>Is a member of <strong>{$extra_info['select_committees']}</strong> select committee";
            if ($extra_info['select_committees'] > 1) {
                print "s";
            }
            if (isset($extra_info['select_committees_chair'])) {
                print " ({$extra_info['select_committees_chair']} as chair)";
            }
            print '.</li>';
        }
        #		$wtt_displayed = display_writetothem_numbers(2006, $extra_info);
        #		$displayed_stuff |= $wtt_displayed;
        #		if (!$wtt_displayed)
        # 			$displayed_stuff |= display_writetothem_numbers(2005, $extra_info);
        $after_stuff = ' <small>(From Public Whip)</small>';
        if ($member['party'] == 'Scottish National Party') {
            $after_stuff .= '<br><em>Note SNP MPs do not vote on legislation not affecting Scotland.</em>';
        }
        if ($member['party'] != 'Sinn Fein') {
            #			$displayed_stuff |= display_stats_line('public_whip_division_attendance', 'Has voted in <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '&amp;showall=yes#divisions" title="See more details at Public Whip">', 'of vote', '</a> in parliament', $after_stuff, $extra_info);
            $displayed_stuff |= display_stats_line('comments_on_speeches', 'People have made <a href="' . WEBPATH . 'comments/recent/?pid=' . $member['person_id'] . '">', 'comment', "</a> on this Representative's speeches", '', $extra_info);
            $displayed_stuff |= display_stats_line('reading_age', 'This Representative\'s speeches are understandable to an average ', '', ' year old, going by the <a href="http://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test">Flesch-Kincaid Grade Level</a> score', '', $extra_info);
        }
        if (isset($extra_info['number_of_alerts'])) {
            $displayed_stuff = 1;
            ?>
		<li><strong><?php 
            echo htmlentities($extra_info['number_of_alerts']);
            ?>
</strong> <?php 
            echo $extra_info['number_of_alerts'] == 1 ? 'person is' : 'people are';
            ?>
 tracking whenever <?php 
            if ($member['house_disp'] == 1) {
                print 'this Representative';
            } elseif ($member['house_disp'] == 2) {
                print 'this Senator';
            } elseif ($member['house_disp'] == 3) {
                print 'this MLA';
            } elseif ($member['house_disp'] == 4) {
                print 'this MSP';
            } elseif ($member['house_disp'] == 0) {
                print $member['full_name'];
            }
            ?>
 speaks<?php 
            if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || $member['current_member'][1] && $member['party'] != 'Sinn Fein') {
                print ' &mdash; <a href="' . WEBPATH . 'alert/?only=1&amp;pid=' . $member['person_id'] . '">email me whenever ' . $member['full_name'] . ' speaks</a>';
            }
            print '.</li>';
        }
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="' . WEBPATH . 'help/#numbers">Why is this here?</a>)</small>', $extra_info);
            if (isset($extra_info['three_word_alliteration_content'])) {
                print "\n<!-- " . $extra_info['three_word_alliteration_content'] . " -->\n";
            }
        }
        #		$displayed_stuff |= display_stats_line('ending_with_a_preposition', "Has ended a sentence with 'with' ", 'time', ' in debates', '', $extra_info);
        #		$displayed_stuff |= display_stats_line('only_asked_why', "Has made a speech consisting solely of 'Why?' ", 'time', ' in debates', '', $extra_info);
        ?>
						</ul>
<?php 
        if (!$displayed_stuff) {
            print '<p>No data to display yet.</p>';
        }
        $this->block_end();
        if (isset($extra_info['register_member_interests_html'])) {
            ?>
				
<a name="register"></a>
<?php 
            $this->block_start(array('id' => 'register', 'title' => "Register of Members' Interests"));
            if ($extra_info['register_member_interests_html'] != '') {
                echo $extra_info['register_member_interests_html'];
            } else {
                echo "\t\t\t\t<p>Nil</p>\n";
            }
            echo '<p class="italic">';
            if (isset($extra_info['register_member_interests_date'])) {
                echo 'Register last updated: ';
                echo format_date($extra_info['register_member_interests_date'], SHORTDATEFORMAT);
                echo '. ';
            }
            echo '<a href="http://www.publications.parliament.uk/pa/cm/cmregmem/061106/memi01.htm">More about the Register</a>';
            echo '</p>';
            print '<p><strong><a href="' . WEBPATH . 'regmem/?p=' . $member['person_id'] . '">View the history of this MP\'s entries in the Register</a></strong></p>';
            $this->block_end();
        }
        if (isset($extra_info['expenses2004_col1']) || isset($extra_info['expenses2006_col1']) || isset($extra_info['expenses2007_col1'])) {
            ?>
<a name="expenses"></a>
<?php 
            $title = 'Expenses';
            $this->block_start(array('id' => 'expenses', 'title' => $title));
            print '<p class="italic">Figures in brackets are ranks. Parliament\'s <a href="http://www.parliament.uk/site_information/allowances.cfm">explanatory notes</a>.</p>';
            print '<table class="people"><tr><th>Type</th><th>2006/07';
            if (isset($extra_info['expenses2007_col1_rank_outof'])) {
                print ' (ranking out of ' . $extra_info['expenses2007_col1_rank_outof'] . ')';
            }
            print '</th><th>2005/06';
            if (isset($extra_info['expenses2006_col1_rank_outof'])) {
                # TODO: Needs to be more complicated, because of General Election
                print ' (ranking out of ' . $extra_info['expenses2006_col1_rank_outof'] . ')';
            }
            print '</th><th>2004/05';
            if (isset($extra_info['expenses2005_col1_rank_outof'])) {
                print ' (ranking out of ' . $extra_info['expenses2005_col1_rank_outof'] . ')';
            }
            print '</th><th>2003/04';
            if (isset($extra_info['expenses2004_col1_rank_outof'])) {
                print ' (ranking out of&nbsp;' . $extra_info['expenses2004_col1_rank_outof'] . ')';
            }
            print '</th><th>2002/03';
            if (isset($extra_info['expenses2003_col1_rank_outof'])) {
                print ' (ranking out of&nbsp;' . $extra_info['expenses2003_col1_rank_outof'] . ')';
            }
            print '</th><th>2001/02';
            if (isset($extra_info['expenses2002_col1_rank_outof'])) {
                print ' (ranking out of&nbsp;' . $extra_info['expenses2002_col1_rank_outof'] . ')';
            }
            print '</th></tr>';
            print '<tr><td class="row-1">Additional Costs Allowance</td>';
            $this->expenses_printout('col1', $extra_info, 1);
            print '</tr><tr><td class="row-2">London Supplement</td>';
            $this->expenses_printout('col2', $extra_info, 2);
            print '</tr><tr><td class="row-1">Incidental Expenses Provision</td>';
            $this->expenses_printout('col3', $extra_info, 1);
            print '</tr><tr><td class="row-2">Staffing Allowance</td>';
            $this->expenses_printout('col4', $extra_info, 2);
            print '</tr><tr><td class="row-1">Members\' Travel</td>';
            $this->expenses_printout('col5', $extra_info, 1);
            print '</tr><tr><td class="row-2">Members\' Staff Travel</td>';
            $this->expenses_printout('col6', $extra_info, 2);
            print '</tr><tr><td class="row-1">Centrally Purchased Stationery</td>';
            $this->expenses_printout('col7', $extra_info, 1);
            print '</tr><tr><td class="row-2">Stationery: Associated Postage Costs</td>';
            $this->expenses_printout('col7a', $extra_info, 2);
            print '</tr><tr><td class="row-1">Centrally Provided Computer Equipment</td>';
            $this->expenses_printout('col8', $extra_info, 1);
            print '</tr><tr><td class="row-2">Other Costs</td>';
            $this->expenses_printout('col9', $extra_info, 2);
            print '</tr><tr><th style="text-align: right">Total</th>';
            $this->expenses_printout('total', $extra_info, 1);
            print '</tr></table>';
            if (isset($extra_info['expenses2007_col5a'])) {
                print '<p><a name="travel2007"></a><sup>*</sup> <small>';
                foreach (array('a' => 'Car', 'b' => '3rd party', 'c' => 'Rail', 'd' => 'Air', 'e' => 'Other', 'f' => 'European') as $let => $desc) {
                    if ($extra_info['expenses2007_col5' . $let] > 0) {
                        print $desc . ' &pound;' . number_format(str_replace(',', '', $extra_info['expenses2007_col5' . $let]));
                        if (isset($extra_info['expenses2007_col5' . $let . '_rank'])) {
                            print ' (' . make_ranking($extra_info['expenses2007_col5' . $let . '_rank']) . ')';
                        }
                        print '. ';
                    }
                }
                print '</small></p>';
            }
            $this->block_end();
        }
    }
Exemple #15
0
function render_mps_row($mp, &$style, $order, $MPURL)
{
    // Stripes
    $style = $style == '1' ? '2' : '1';
    $name = member_full_name(1, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']);
    $url = $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1);
    #	$MPURL->insert(array('pid'=>$mp['person_id']));
    list($image, $sz) = find_rep_image($mp['person_id'], true);
    ?>
				<tr>
				<td class="row">
				<?php 
    if ($image) {
        echo '<a href="', $url, '">', '<img class="portrait" alt="" src="', $image, '">', '</a>';
    }
    ?>
				</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1);
    ?>
"><?php 
    echo $name;
    ?>
</a></td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['party'];
    ?>
</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['constituency'];
    ?>
</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    if (is_array($mp['dept'])) {
        print join('<br>', array_map('manymins', $mp['pos'], $mp['dept']));
    } elseif ($mp['dept'] || $mp['pos']) {
        print prettify_office($mp['pos'], $mp['dept']);
    } else {
        print '&nbsp;';
    }
    ?>
</td>
<?php 
    if ($order == 'expenses') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
">&pound;<?php 
        echo number_format($mp['data_value']);
        ?>
</td>
<?php 
    } elseif ($order == 'debates') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
"><?php 
        echo number_format($mp['data_value']);
        ?>
</td>
<?php 
    } elseif ($order == 'safety') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
"><?php 
        echo $mp['data_value'];
        ?>
</td>
<?php 
    }
    ?>
				</tr>
<?php 
}
Exemple #16
0
<?php

include_once "../../../includes/easyparliament/init.php";
include_once "../../../includes/easyparliament/member.php";
$DATA->set_page_metadata($this_page, 'heading', 'MPs photo status on OpenAustralia');
$PAGE->page_start();
$PAGE->stripe_start();
$db = new ParlDB();
$query = 'SELECT person_id, first_name, last_name, constituency, party
	FROM member
	WHERE house=1 AND left_house = (SELECT MAX(left_house) FROM member) ';
$q = $db->query($query . "ORDER BY last_name, first_name");
$out = array('both' => '', 'small' => '', 'none' => '');
for ($i = 0; $i < $q->rows(); $i++) {
    $p_id = $q->field($i, 'person_id');
    list($dummy, $sz) = find_rep_image($p_id);
    if ($sz == 'L') {
        $out['both'] .= $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name') . ', ';
    } elseif ($sz == 'S') {
        $out['small'] .= $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name') . ', ';
    } else {
        $out['none'] .= '<li>' . $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name') . ' (' . $q->field($i, 'party') . ')' . ', ' . $q->field($i, 'constituency');
    }
}
print '<h3>Missing completely</h3> <ul>';
print $out['none'];
print '</ul>';
print '<h3>Large and small</h3> <p>';
print $out['both'];
print '<h3>Only small photos</h3> <p>';
print $out['small'];
Exemple #17
0
    function display_member($member, $extra_info)
    {
        global $THEUSER, $DATA, $this_page;
        # If current Senator show their name as "Senator John Smith". Current Representative show their name as "John Smith MP"
        $title = $member['current_member'][2] ? 'Senator ' : '';
        $title .= ucfirst($member['full_name']);
        # Show current titles first
        foreach ($member['houses'] as $house) {
            if ($member['current_member'][$house]) {
                $title .= ' ';
                if ($house == 1) {
                    $title .= 'MP';
                }
            }
        }
        # Show former membership
        foreach ($member['houses'] as $house) {
            if (!$member['current_member'][$house]) {
                $title .= ', former ';
                if ($house == 1) {
                    $title .= 'Representative';
                }
                if ($house == 2) {
                    $title .= 'Senator';
                }
            }
        }
        if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
            $title = '<a href="' . WEBPATH . $rssurl . '"><img src="' . WEBPATH . 'images/rss.gif" alt="RSS feed" border="0" align="right"></a> ' . $title;
        }
        print '<p class="printonly">This data was produced by OpenAustralia from a variety of sources.</p>';
        $this->block_start(array('id' => 'mp', 'title' => $title));
        list($image, $sz) = find_rep_image($member['person_id']);
        if ($image) {
            echo '<img class="portrait" alt="Photo of ', $member['full_name'], '" src="', $image, '"';
            if ($sz == 'S') {
                echo ' height="118"';
            }
            echo '>';
        } else {
            // Prompt for photo
            echo '<div class="textportrait"><br>We\'re missing a photo!<br><br><a href="mailto:contact@openaustralia.org">Email us one</a> <small>(that you have copyright of)</small><br><br></div>';
        }
        echo '<ul class="hilites">';
        $desc = '';
        foreach ($member['houses'] as $house) {
            $party = $member['left_house'][$house]['party'];
            $desc .= '<li><strong>';
            if (!$member['current_member'][$house]) {
                $desc .= 'Former ';
            }
            $desc .= htmlentities($party);
            if ($party == 'Speaker' || $party == 'Deputy-Speaker' || $party == 'President' || $party == 'Deputy-President') {
                $desc .= ', and ';
                # XXX: Will go horribly wrong if something odd happens
                $last = end($member['other_parties']);
                $desc .= $last['from'] . ' ';
            }
            $desc .= ' ';
            if ($house == 1) {
                $desc .= 'Representative';
            }
            if ($house == 2) {
                $desc .= 'Senator';
            }
            if ($house == 3) {
                $desc .= 'MLA';
            }
            if ($house == 4) {
                $desc .= 'MSP';
            }
            $desc .= ' for ' . $member['left_house'][$house]['constituency'];
            $desc .= '</strong></li>';
        }
        print $desc;
        if ($member['other_parties'] && $member['party'] != 'Speaker' && $member['party'] != 'Deputy-Speaker' && $member['party'] != 'President' && $member['party'] != 'Deputy-President') {
            print "<li>Changed party ";
            foreach ($member['other_parties'] as $r) {
                $out[] = 'from ' . $r['from'] . ' on ' . format_date($r['date'], SHORTDATEFORMAT);
            }
            print join('; ', $out);
            print '</li>';
        }
        // Ministerial position
        if (array_key_exists('office', $extra_info)) {
            $mins = array();
            foreach ($extra_info['office'] as $row) {
                if ($row['to_date'] == '9999-12-31' && $row['source'] != 'chgpages/selctee') {
                    $m = prettify_office($row['position'], $row['dept']);
                    $m .= ' (since ' . format_date($row['from_date'], SHORTDATEFORMAT) . ')';
                    $mins[] = $m;
                }
            }
            if ($mins) {
                print '<li>' . join('<br>', $mins) . '</li>';
            }
        }
        if (isset($member['left_house'][1]) && isset($member['entered_house'][2])) {
            print '<li><strong>Entered the Senate ';
            if (strlen($member['entered_house'][2]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            print $member['entered_house'][2]['date_pretty'] . '</strong>';
            print '</strong>';
            if ($member['entered_house'][2]['reason']) {
                print ' &mdash; ' . $member['entered_house'][2]['reason'];
            }
            print '</li>';
            if (!$member['current_member'][1]) {
                print '<li><strong>Previously Representative for ';
                print $member['left_house'][1]['constituency'] . ' until ';
                print $member['left_house'][1]['date_pretty'] . '</strong>';
                if ($member['left_house'][1]['reason']) {
                    print ' &mdash; ' . $member['left_house'][1]['reason'];
                }
                print '</li>';
            }
        } elseif (isset($member['entered_house'][2]['date'])) {
            print '<li><strong>Became a Senator ';
            if (strlen($member['entered_house'][2]['date_pretty']) == 4) {
                print 'in ';
            } else {
                print 'on ';
            }
            print $member['entered_house'][2]['date_pretty'] . '</strong>';
            if ($member['entered_house'][2]['reason']) {
                print ' &mdash; ' . $member['entered_house'][2]['reason'];
            }
            print '</li>';
        } elseif (in_array(1, $member['houses']) && !$member['current_member'][1]) {
            print '<li><strong>Left House of Representatives on ' . $member['left_house'][1]['date_pretty'] . '</strong>';
            if ($member['left_house'][1]['reason']) {
                print ' &mdash; ' . $member['left_house'][1]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][1]['date'])) {
            print '<li><strong>Entered House of Representatives on ';
            print $member['entered_house'][1]['date_pretty'] . '</strong>';
            if ($member['entered_house'][1]['reason']) {
                print ' &mdash; ' . $member['entered_house'][1]['reason'];
            }
            print '</li>';
        }
        if (isset($extra_info['lordbio'])) {
            echo '<li><strong>Positions held:</strong> ', $extra_info['lordbio'], ' <small>(from <a href="', $extra_info['lordbio_from'], '">Number 10 press release</a>)</small></li>';
        }
        if (in_array(2, $member['houses']) && !$member['current_member'][2]) {
            print '<li><strong>Left Senate on ' . $member['left_house'][2]['date_pretty'] . '</strong>';
            if ($member['left_house'][2]['reason']) {
                print ' &mdash; ' . $member['left_house'][2]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][3]['date'])) {
            print '<li><strong>Entered the Assembly on ';
            print $member['entered_house'][3]['date_pretty'] . '</strong>';
            if ($member['entered_house'][3]['reason']) {
                print ' &mdash; ' . $member['entered_house'][3]['reason'];
            }
            print '</li>';
        }
        if (in_array(3, $member['houses']) && !$member['current_member'][3]) {
            print '<li><strong>Left the Assembly on ' . $member['left_house'][3]['date_pretty'] . '</strong>';
            if ($member['left_house'][3]['reason']) {
                print ' &mdash; ' . $member['left_house'][3]['reason'];
            }
            print '</li>';
        }
        if (isset($member['entered_house'][4]['date'])) {
            print '<li><strong>Entered the Scottish Parliament on ';
            print $member['entered_house'][4]['date_pretty'] . '</strong>';
            if ($member['entered_house'][4]['reason']) {
                print ' &mdash; ' . $member['entered_house'][4]['reason'];
            }
            print '</li>';
        }
        if (in_array(4, $member['houses']) && !$member['current_member'][4]) {
            print '<li><strong>Left the Scottish Parliament on ' . $member['left_house'][4]['date_pretty'] . '</strong>';
            if ($member['left_house'][4]['reason']) {
                print ' &mdash; ' . $member['left_house'][4]['reason'];
            }
            print '</li>';
        }
        if (isset($extra_info['majority_in_seat'])) {
            ?>
						<li><strong>Majority:</strong> 
						<?php 
            echo number_format($extra_info['majority_in_seat']);
            ?>
 votes. <?php 
            if (isset($extra_info['swing_to_lose_seat_today'])) {
                /*
                if (isset($extra_info['swing_to_lose_seat_today_quintile'])) {
                	$q = $extra_info['swing_to_lose_seat_today_quintile'];
                	if ($q == 0) {
                		print 'Very safe seat';
                	} elseif ($q == 1) {
                		print 'Safe seat';
                	} elseif ($q == 2) {
                		print '';
                	} elseif ($q == 3) {
                		print 'Unsafe seat';
                	} elseif ($q == 4) {
                		print 'Very unsafe seat';
                	} else {
                		print '[Impossible quintile!]';
                	}
                }
                */
                print ' &mdash; ' . make_ranking($extra_info['swing_to_lose_seat_today_rank']);
                ?>
 out of <?php 
                echo $extra_info['swing_to_lose_seat_today_rank_outof'];
                ?>
 MPs.
<?php 
            }
            ?>
</li>
<?php 
        }
        if ($member['party'] == 'Sinn Fein' && in_array(1, $member['houses'])) {
            print '<li>Sinn F&eacute;in MPs do not take their seats in Parliament</li>';
        }
        if ($member['the_users_mp'] == true) {
        } elseif ($member['current_member'][1]) {
        } elseif ($member['current_member'][3]) {
            ?>
						<li><a href="http://www.writetothem.com/"><strong>Send a message to your MLA</strong></a> <small>(via WriteToThem.com)</small></li>
<?php 
        } elseif ($member['current_member'][2]) {
        }
        # If they're currently an MLA, a Lord or a non-Sinn Fein MP
        if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || $member['current_member'][1] && $member['party'] != 'Sinn Fein') {
            if (!isset($_SERVER['DEVICE_TYPE']) || $_SERVER['DEVICE_TYPE'] != "mobile") {
                print '<li><a href="' . WEBPATH . 'alert/?only=1&amp;pid=' . $member['person_id'] . '"><strong>Email me whenever ' . $member['full_name'] . ' speaks</strong></a> (no more than once per day)</li>';
            }
        }
        ?>
						</ul>
						
						
						<ul class="jumpers">
<?php 
        if (defined('DISPLAY_VOTING_DATA') && DISPLAY_VOTING_DATA) {
            ?>
						<li><a href="#votingrecord">Voting record</a></li>
<?php 
        }
        ?>
						<li><a href="#numbers">Numbers</a></li>
<?php 
        if ($member['current_member'][1] || $member['current_member'][2]) {
            ?>
						<li><a href="#register">Register of Interests</a></li>
<?php 
        }
        if (isset($extra_info['expenses2004_col1']) || isset($extra_info['expenses2006_col1']) || isset($extra_info['expenses2007_col1'])) {
            ?>
 						<li><a href="#expenses">Expenses</a></li>
<?php 
        }
        if (isset($extra_info['edm_ais_url'])) {
            ?>
						<li><a href="<?php 
            echo $extra_info['edm_ais_url'];
            ?>
">Early Day Motions signed by this MP</a> <small>(From edm.ais.co.uk)</small></li>
<?php 
        }
        ?>
						</ul>
<?php 
        $this->block_end();
        if (defined('DISPLAY_VOTING_DATA') && DISPLAY_VOTING_DATA) {
            // Voting Record.
            ?>
 <a name="votingrecord"></a> <?php 
            $this->block_start(array('id' => 'votingrecord', 'title' => 'Voting record (from <a href="https://theyvoteforyou.org.au/">They Vote For You</a>)'));
            $displayed_stuff = 0;
            function display_dream_comparison($extra_info, $member, $dreamid, $desc, $inverse, $search)
            {
                if (isset($extra_info["public_whip_dreammp{$dreamid}_distance"])) {
                    if ($extra_info["public_whip_dreammp{$dreamid}_both_voted"] == 0) {
                        $dmpdesc = 'Has <strong>never voted</strong> on';
                    } else {
                        $dmpscore = floatval($extra_info["public_whip_dreammp{$dreamid}_distance"]);
                        print "<!-- distance {$dreamid}: {$dmpscore} -->";
                        if ($inverse) {
                            $dmpscore = 1.0 - $dmpscore;
                        }
                        $dmpdesc = 'Voted <strong>' . score_to_strongly($dmpscore) . '</strong>';
                        // How many votes Dream MP and MP both voted (and didn't abstain) in
                        // $extra_info["public_whip_dreammp${dreamid}_both_voted"];
                    }
                    $search_link = WEBPATH . "search/?s=" . urlencode($search) . "&pid=" . $member['person_id'] . "&pop=1";
                    ?>
					<li>
					<?php 
                    echo $dmpdesc;
                    ?>
				<?php 
                    echo $desc;
                    ?>
.
	<small class="unneededprintlinks">
	<a href="<?php 
                    echo PUBLICWHIP_HOST;
                    ?>
/mp.php?mpid=<?php 
                    echo $member['member_id'];
                    ?>
&amp;dmp=<?php 
                    echo $dreamid;
                    ?>
">votes</a>
	</small>

					</li>
	<?php 
                    return true;
                }
                return false;
            }
            ?>

		<p id="howvoted">How <?php 
            echo $member['full_name'];
            ?>
 voted on key issues since 2006:</p>
		<ul id="dreamcomparisons">
		<?php 
            $got_dream = false;
            $got_dream |= display_dream_comparison($extra_info, $member, 1, "same sex marriage", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 2, "tobacco plain packaging", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 3, "a carbon price", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 4, "increasing scrutiny of asylum seeker management", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 5, "government administered paid parental leave", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 6, "increasing trade unions' powers in the workplace", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 7, "the Carbon Pollution Reduction Scheme", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 8, "implementing refugee and protection conventions", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 9, "increasing competition in bulk wheat export", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 10, "recognising local government in the Constitution", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 11, "temporary protection visas", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 12, "voluntary student union fees", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 13, "increasing or removing the debt limit", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 14, "a minerals resource rent tax ", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 15, "increasing protection of Australia's fresh water", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 16, "regional processing of asylum seekers", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 17, "increasing marine conservation", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 18, "unconventional gas mining", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 19, "restricting foreign ownership", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 20, "increasing investment in renewable energy", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 21, "privatising government assets", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 22, "stem cell research", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 23, "more scrutiny of intelligence services & police", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 24, "increasing Aboriginal land rights", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 25, "increasing funding for university education", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 26, "decreasing the private health insurance rebate", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 27, "increasing the price of subsidised medicine", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 28, "increasing the age pension", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 29, "extending government benefits to same-sex couples", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 30, "increasing protection of Aboriginal heritage sites", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 31, "increasing availability of abortion drugs", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 32, "live animal exports", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 33, "carbon farming", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 34, "decreasing availability of welfare payments", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 35, "re-approving/ re-registering agvet chemicals", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 36, "the Intervention in the Northern Territory", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 37, "an emissions reduction fund", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 38, "increasing funding for road infrastructure", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 39, "increasing restrictions on gambling", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 40, "increasing beef import standards", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 41, "increasing fishing restrictions", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 42, "encouraging Australian-based industry", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 43, "uranium export", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 44, "increasing surveillance powers", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 45, "increasing consumer protections", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 46, "increasing public access to government data", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 47, "an NBN (using fibre to the premises)", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 50, "a federal inquiry into Queensland government administration", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 51, "offshore processing of asylum seekers", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 53, "increasing freedom of political communication", false, "");
            $got_dream |= display_dream_comparison($extra_info, $member, 56, "decreasing ABC and SBS funding", false, "");
            if (!$got_dream) {
                print "<li>" . $member['full_name'] . " has not voted enough in this parliament to have any scores.</li>";
            }
            print '</ul>';
            ?>
	<p class="italic">
	<small>Read about <a href="<?php 
            echo WEBPATH;
            ?>
help/#votingrecord">how the voting record is decided</a>.</small>
	</p>

	<?php 
            // Links to full record at Guardian and Public Whip
            $record = array();
            if (isset($extra_info['guardian_howtheyvoted'])) {
                $record[] = '<a href="' . $extra_info['guardian_howtheyvoted'] . '" title="At The Guardian">well-known issues</a> <small>(from the Guardian)</small>';
            }
            if (isset($extra_info['public_whip_division_attendance']) && $extra_info['public_whip_division_attendance'] != 'n/a') {
                $record[] = '<a href="' . PUBLICWHIP_HOST . '/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '" title="At They Vote For You">their full record</a>';
            }
            if (count($record) > 0) {
                $displayed_stuff = 1;
                ?>
				<p>More on <?php 
                echo implode(' &amp; ', $record);
                ?>
</p>
	<?php 
            }
            // Rebellion rate
            if (isset($extra_info['public_whip_rebellions']) && $extra_info['public_whip_rebellions'] != 'n/a') {
                $displayed_stuff = 1;
                ?>
					<ul>
								<li><a href="<?php 
                echo PUBLICWHIP_HOST;
                ?>
/mp.php?id=uk.org.publicwhip/member/<?php 
                echo $member['member_id'];
                ?>
#divisions" title="See more details at Public Whip">
	                        <strong><?php 
                echo htmlentities(ucfirst($extra_info['public_whip_rebel_description']));
                ?>
 rebels</strong></a> against their party<?php 
                if (isset($extra_info['public_whip_rebelrank'])) {
                    echo " in this parliament";
                    /* &#8212; ";
                    			if (isset($extra_info['public_whip_rebelrank_joint']))
                    				print 'joint ';
                    			echo make_ranking($extra_info['public_whip_rebelrank']);
                    			echo " most rebellious of ";
                    			echo $extra_info['public_whip_rebelrank_outof'];
                    			echo ($member['house']=='House of Commons') ? " MPs" : ' Lords';
                    			*/
                }
                ?>
.
				</li>
			</ul><?php 
            }
            if (!$displayed_stuff) {
                print '<p>No data to display yet.</p>';
            }
            $this->block_end();
        }
        // End DISPLAY_VOTING_DATA feature flag
        // Topics of interest only for MPs at the moment
        // if (in_array(1, $member['houses'])) {
        // Disable topics of interest
        if (0) {
            ?>
	<a name="topics"></a>
		<?php 
            $this->block_start(array('id' => 'topics', 'title' => 'Committees and topics of interest'));
            $topics_block_empty = true;
            // Select committee membership
            if (array_key_exists('office', $extra_info)) {
                $mins = array();
                foreach ($extra_info['office'] as $row) {
                    if ($row['to_date'] == '9999-12-31' && $row['source'] == 'chgpages/selctee') {
                        $m = prettify_office($row['position'], $row['dept']);
                        if ($row['from_date'] != '2004-05-28') {
                            $m .= ' <small>(since ' . format_date($row['from_date'], SHORTDATEFORMAT) . ')</small>';
                        }
                        $mins[] = $m;
                    }
                }
                if ($mins) {
                    print "<h5>Select Committee membership</h5>";
                    print "<ul>";
                    foreach ($mins as $min) {
                        print '<li>' . $min . '</li>';
                    }
                    print "</ul>";
                    $topics_block_empty = false;
                }
            }
            $wrans_dept = false;
            $wrans_dept_1 = null;
            $wrans_dept_2 = null;
            if (isset($extra_info['wrans_departments'])) {
                $wrans_dept = true;
                $wrans_dept_1 = "<li><strong>Departments:</strong> " . $extra_info['wrans_departments'] . "</p>";
            }
            if (isset($extra_info['wrans_subjects'])) {
                $wrans_dept = true;
                $wrans_dept_2 = "<li><strong>Subjects (based on headings added by Hansard):</strong> " . $extra_info['wrans_subjects'] . "</p>";
            }
            if ($wrans_dept) {
                print "<p><strong>Asks most questions about</strong></p>";
                print "<ul>";
                if ($wrans_dept_1) {
                    print $wrans_dept_1;
                }
                if ($wrans_dept_2) {
                    print $wrans_dept_2;
                }
                print "</ul>";
                $topics_block_empty = false;
                $WRANSURL = new URL('search');
                $WRANSURL->insert(array('pid' => $member['person_id'], 's' => 'section:wrans', 'pop' => 1));
                ?>
							<p><small>(based on <a href="<?php 
                echo $WRANSURL->generate();
                ?>
">written questions asked by <?php 
                echo $member['full_name'];
                ?>
</a> and answered by departments)</small></p><?php 
            }
            # Public Bill Committees
            if (count($extra_info['pbc'])) {
                $topics_block_empty = false;
                print '<h5>Public Bill Committees <small>(sittings attended)</small></h5> <ul>';
                foreach ($extra_info['pbc'] as $bill_id => $arr) {
                    print '<li>';
                    if ($arr['chairman']) {
                        print 'Chairman, ';
                    }
                    print '<a href="/pbc/' . $arr['session'] . '/' . urlencode($arr['title']) . '">' . $arr['title'] . ' Committee</a> <small>(' . $arr['attending'] . ' out of ' . $arr['outof'] . ')</small>';
                }
                print '</ul>';
            }
            if ($topics_block_empty) {
                print "<p><em>This MP is not currently on any select <!-- or public bill --> committee\nand has had no written questions answered for which we know the department or subject.</em></p>";
            }
            $this->block_end();
        }
        if (!in_array(1, $member['houses']) || $member['party'] != 'Sinn Fein') {
            ?>
		<a name="hansard"></a> <?php 
            $title = 'Most recent appearances in parliament';
            if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
                $title = '<a href="' . WEBPATH . $rssurl . '"><img src="' . WEBPATH . 'images/rss.gif" alt="RSS feed" border="0" align="right"></a> ' . $title;
            }
            $this->block_start(array('id' => 'hansard', 'title' => $title));
            // This is really far from ideal - I don't really want $PAGE to know
            // anything about HANSARDLIST / DEBATELIST / WRANSLIST.
            // But doing this any other way is going to be a lot more work for little
            // benefit unfortunately.
            twfy_debug_timestamp();
            $HANSARDLIST = new HANSARDLIST();
            $searchstring = "speaker:{$member['person_id']}";
            global $SEARCHENGINE;
            $SEARCHENGINE = new SEARCHENGINE($searchstring);
            $args = array('s' => $searchstring, 'p' => 1, 'num' => 3, 'pop' => 1, 'o' => 'd');
            $HANSARDLIST->display('search_min', $args);
            twfy_debug_timestamp();
            $MOREURL = new URL('search');
            $MOREURL->insert(array('pid' => $member['person_id'], 'pop' => 1));
            ?>
	<p id="moreappear"><a href="<?php 
            echo $MOREURL->generate();
            ?>
#n4">More of <?php 
            echo ucfirst($member['full_name']);
            ?>
's recent appearances</a></p>

<?php 
            if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
                // If we set an RSS feed for this page.
                $HELPURL = new URL('help');
                ?>
					<p class="unneededprintlinks"><a href="<?php 
                echo WEBPATH . $rssurl;
                ?>
" title="XML version of this person's recent appearances">RSS feed</a> (<a href="<?php 
                echo $HELPURL->generate();
                ?>
#rss" title="An explanation of what RSS feeds are for">?</a>)</p>
<?php 
            }
            $this->block_end();
        }
        # End Sinn Fein
        ?>
 <a name="numbers"></a> <?php 
        $this->block_start(array('id' => 'numbers', 'title' => 'Numbers'));
        $displayed_stuff = 0;
        ?>
		<p><em>Please note that numbers do not measure quality. 
		Also, <?php 
        if ($member['house_disp'] == 1) {
            echo "Representatives";
        } else {
            echo "Senators";
        }
        ?>
 may do other things not currently covered
		by this site.</em> (<a href="<?php 
        echo WEBPATH;
        ?>
help/#numbers">More about this</a>)</p>
<ul>
<?php 
        $since_text = 'in the last year';
        #if ($member['entered_house'] > '2005-05-05')
        #	$since_text = 'since joining Parliament';
        $MOREURL = new URL('search');
        $MOREURL->insert(array('pid' => $member['person_id'], 'pop' => 1));
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in <a href="' . $MOREURL->generate() . '">', 'debate', '</a> ' . $since_text, '', $extra_info);
            $MOREURL->insert(array('pid' => $member['person_id'], 's' => 'section:wrans', 'pop' => 1));
            // We assume that if they've answered a question, they're a minister
            $minister = false;
            $Lminister = false;
            if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0) {
                $minister = true;
            }
            if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0) {
                $Lminister = true;
            }
            #		$displayed_stuff |= display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister);
        }
        if (isset($extra_info['select_committees'])) {
            print "<li>Is a member of <strong>{$extra_info['select_committees']}</strong> select committee";
            if ($extra_info['select_committees'] > 1) {
                print "s";
            }
            if (isset($extra_info['select_committees_chair'])) {
                print " ({$extra_info['select_committees_chair']} as chair)";
            }
            print '.</li>';
        }
        #		$wtt_displayed = display_writetothem_numbers(2006, $extra_info);
        #		$displayed_stuff |= $wtt_displayed;
        #		if (!$wtt_displayed)
        # 			$displayed_stuff |= display_writetothem_numbers(2005, $extra_info);
        $after_stuff = ' <small>(From Public Whip)</small>';
        if ($member['party'] == 'Scottish National Party') {
            $after_stuff .= '<br><em>Note SNP MPs do not vote on legislation not affecting Scotland.</em>';
        }
        if ($member['party'] != 'Sinn Fein') {
            #			$displayed_stuff |= display_stats_line('public_whip_division_attendance', 'Has voted in <a href=" . PUBLICWHIP_HOST . "/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '&amp;showall=yes#divisions" title="See more details at Public Whip">', 'of vote', '</a> in parliament', $after_stuff, $extra_info);
            $displayed_stuff |= display_stats_line('comments_on_speeches', 'People have made <a href="' . WEBPATH . 'comments/recent/?pid=' . $member['person_id'] . '">', 'comment', "</a> on this Representative's speeches", '', $extra_info);
            $displayed_stuff |= display_stats_line('reading_age', 'This Representative\'s speeches are understandable to an average ', '', ' year old, going by the <a href="http://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test">Flesch-Kincaid Grade Level</a> score', '', $extra_info);
        }
        if (isset($extra_info['number_of_alerts'])) {
            $displayed_stuff = 1;
            ?>
		<li><strong><?php 
            echo htmlentities($extra_info['number_of_alerts']);
            ?>
</strong> <?php 
            echo $extra_info['number_of_alerts'] == 1 ? 'person is' : 'people are';
            ?>
 tracking whenever <?php 
            if ($member['house_disp'] == 1) {
                print 'this Representative';
            } elseif ($member['house_disp'] == 2) {
                print 'this Senator';
            } elseif ($member['house_disp'] == 3) {
                print 'this MLA';
            } elseif ($member['house_disp'] == 4) {
                print 'this MSP';
            } elseif ($member['house_disp'] == 0) {
                print $member['full_name'];
            }
            ?>
 speaks<?php 
            if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || $member['current_member'][1] && $member['party'] != 'Sinn Fein') {
                if (!isset($_SERVER['DEVICE_TYPE']) || $_SERVER['DEVICE_TYPE'] != "mobile") {
                    print ' &mdash; <a href="' . WEBPATH . 'alert/?only=1&amp;pid=' . $member['person_id'] . '">email me whenever ' . $member['full_name'] . ' speaks</a>';
                }
            }
            print '.</li>';
        }
        if ($member['party'] != 'Sinn Fein') {
            $displayed_stuff |= display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="' . WEBPATH . 'help/#numbers">Why is this here?</a>)</small>', $extra_info);
            if (isset($extra_info['three_word_alliteration_content'])) {
                print "\n<!-- " . $extra_info['three_word_alliteration_content'] . " -->\n";
            }
        }
        #		$displayed_stuff |= display_stats_line('ending_with_a_preposition', "Has ended a sentence with 'with' ", 'time', ' in debates', '', $extra_info);
        #		$displayed_stuff |= display_stats_line('only_asked_why', "Has made a speech consisting solely of 'Why?' ", 'time', ' in debates', '', $extra_info);
        ?>
						</ul>
<?php 
        if (!$displayed_stuff) {
            print '<p>No data to display yet.</p>';
        }
        $this->block_end();
        if ($member['current_member'][1] || $member['current_member'][2]) {
            ?>
				
<a name="register"></a>
<?php 
            $this->block_start(array('id' => 'register', 'title' => 'Register of Interests <small>(<a href="' . WEBPATH . 'help/#regmem">What\'s this?</a>)</small>'));
            $regpath = REGMEMPDFPATH . 'register_interests_' . $member['person_id'] . '.pdf';
            if (isset($extra_info['aph_interests_url'])) {
                echo '<p><a href="' . $extra_info['aph_interests_url'] . '">' . $member['full_name'] . '\'s latest interest statement from Australian Parliament House<img alt="PDF" src="/images/pdficon_small.gif"></a>';
                if (isset($extra_info['aph_interests_last_updated'])) {
                    echo '<small>Last updated: ';
                    echo format_date($extra_info['aph_interests_last_updated'], SHORTDATEFORMAT);
                    echo '</small>';
                }
                echo '</p>';
            }
            if (is_file(BASEDIR . $regpath)) {
                echo '<p><a href="' . WEBPATH . $regpath . '">Our last scan of ' . $member['full_name'] . '\'s interest statement</a><img alt="PDF" src="/images/pdficon_small.gif"><small>(<a href="' . WEBPATH . 'help/#regmem-links">Possibly outdated</a>)</small></p>';
            }
            if (!isset($extra_info['aph_interests_url']) && !is_file(BASEDIR . $regpath)) {
                echo 'Scan of ' . $member['full_name'] . '\'s entry is not yet available';
            }
            if (isset($extra_info['register_member_interests_date'])) {
                echo '<p class="italic">';
                echo 'Register last updated: ';
                echo format_date($extra_info['register_member_interests_date'], SHORTDATEFORMAT);
                echo '. ';
                echo '</p>';
            }
            //print '<p><strong><a href="' . WEBPATH . 'regmem/?p='.$member['person_id'].'">View the history of this MP\'s entries in the Register</a></strong></p>';
            $this->block_end();
        }
        if (isset($extra_info['expenses2004_col1']) || isset($extra_info['expenses2006_col1']) || isset($extra_info['expenses2007_col1'])) {
            ?>
<a name="expenses"></a>
<?php 
            $title = 'Expenses';
            $this->block_start(array('id' => 'expenses', 'title' => $title));
            print '<p class="italic">Figures in brackets are ranks. Parliament\'s <a href="http://www.parliament.uk/site_information/allowances.cfm">explanatory notes</a>.</p>';
            print '<table class="people"><tr><th>Type</th><th>2006/07';
            if (isset($extra_info['expenses2007_col1_rank_outof'])) {
                print ' (ranking out of ' . $extra_info['expenses2007_col1_rank_outof'] . ')';
            }
            print '</th><th>2005/06';
            if (isset($extra_info['expenses2006_col1_rank_outof'])) {
                # TODO: Needs to be more complicated, because of General Election
                print ' (ranking out of ' . $extra_info['expenses2006_col1_rank_outof'] . ')';
            }
            print '</th><th>2004/05';
            if (isset($extra_info['expenses2005_col1_rank_outof'])) {
                print ' (ranking out of ' . $extra_info['expenses2005_col1_rank_outof'] . ')';
            }
            print '</th><th>2003/04';
            if (isset($extra_info['expenses2004_col1_rank_outof'])) {
                print ' (ranking out of&nbsp;' . $extra_info['expenses2004_col1_rank_outof'] . ')';
            }
            print '</th><th>2002/03';
            if (isset($extra_info['expenses2003_col1_rank_outof'])) {
                print ' (ranking out of&nbsp;' . $extra_info['expenses2003_col1_rank_outof'] . ')';
            }
            print '</th><th>2001/02';
            if (isset($extra_info['expenses2002_col1_rank_outof'])) {
                print ' (ranking out of&nbsp;' . $extra_info['expenses2002_col1_rank_outof'] . ')';
            }
            print '</th></tr>';
            print '<tr><td class="row-1">Additional Costs Allowance</td>';
            $this->expenses_printout('col1', $extra_info, 1);
            print '</tr><tr><td class="row-2">London Supplement</td>';
            $this->expenses_printout('col2', $extra_info, 2);
            print '</tr><tr><td class="row-1">Incidental Expenses Provision</td>';
            $this->expenses_printout('col3', $extra_info, 1);
            print '</tr><tr><td class="row-2">Staffing Allowance</td>';
            $this->expenses_printout('col4', $extra_info, 2);
            print '</tr><tr><td class="row-1">Members\' Travel</td>';
            $this->expenses_printout('col5', $extra_info, 1);
            print '</tr><tr><td class="row-2">Members\' Staff Travel</td>';
            $this->expenses_printout('col6', $extra_info, 2);
            print '</tr><tr><td class="row-1">Centrally Purchased Stationery</td>';
            $this->expenses_printout('col7', $extra_info, 1);
            print '</tr><tr><td class="row-2">Stationery: Associated Postage Costs</td>';
            $this->expenses_printout('col7a', $extra_info, 2);
            print '</tr><tr><td class="row-1">Centrally Provided Computer Equipment</td>';
            $this->expenses_printout('col8', $extra_info, 1);
            print '</tr><tr><td class="row-2">Other Costs</td>';
            $this->expenses_printout('col9', $extra_info, 2);
            print '</tr><tr><th style="text-align: right">Total</th>';
            $this->expenses_printout('total', $extra_info, 1);
            print '</tr></table>';
            if (isset($extra_info['expenses2007_col5a'])) {
                print '<p><a name="travel2007"></a><sup>*</sup> <small>';
                foreach (array('a' => 'Car', 'b' => '3rd party', 'c' => 'Rail', 'd' => 'Air', 'e' => 'Other', 'f' => 'European') as $let => $desc) {
                    if ($extra_info['expenses2007_col5' . $let] > 0) {
                        print $desc . ' &pound;' . number_format(str_replace(',', '', $extra_info['expenses2007_col5' . $let]));
                        if (isset($extra_info['expenses2007_col5' . $let . '_rank'])) {
                            print ' (' . make_ranking($extra_info['expenses2007_col5' . $let . '_rank']) . ')';
                        }
                        print '. ';
                    }
                }
                print '</small></p>';
            }
            $this->block_end();
        }
    }
Exemple #18
0
function render_peers_row($peer, &$style, $order, $URL)
{
    global $parties;
    // Stripes
    $style = $style == '1' ? '2' : '1';
    $name = member_full_name(2, $peer['title'], $peer['first_name'], $peer['last_name'], $peer['constituency']);
    if (array_key_exists($peer['party'], $parties)) {
        $party = $parties[$peer['party']];
    } else {
        $party = $peer['party'];
    }
    #	$MPURL->insert(array('pid'=>$peer['person_id']));
    ?>
			<tr>
                <td class="row">
                <?php 
    list($image, $sz) = find_rep_image($peer['person_id'], true, 'lord');
    if ($image) {
        echo '<a href="' . $URL->generate() . make_member_url($name) . '" class="speakerimage"><img height="59" class="portrait" alt="" src="', $image, '"';
        echo '></a>';
    }
    ?>
                </td>				    
				<td class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $URL->generate() . make_member_url($name, null, 2);
    ?>
"><?php 
    echo ucfirst($name);
    ?>
</a></td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $party;
    ?>
</td>
				<td class="row-<?php 
    echo $style;
    ?>
"><?php 
    if (is_array($peer['dept'])) {
        print join('<br>', array_map('manymins', $peer['pos'], $peer['dept']));
    } elseif ($peer['dept']) {
        print prettify_office($peer['pos'], $peer['dept']);
    } else {
        print '&nbsp;';
    }
    ?>
</td>

<?php 
    if ($order == 'debates') {
        ?>
				<td class="row-<?php 
        echo $style;
        ?>
"><?php 
        echo number_format($peer['data_value']);
        ?>
</td>
<?php 
    }
    ?>

			</tr>
<?php 
}
Exemple #19
0
include_once 'min-init.php';
include_once INCLUDESPATH . 'easyparliament/member.php';
include_once '../api/api_functions.php';
$pid = $_GET['pid'];
if (!$pid) {
    print '<error>No ID</error>';
    exit;
}
$member = new MEMBER(array('person_id' => $pid));
if (!$member->valid) {
    print '<error>Unknown ID</error>';
    exit;
}
$member->load_extra_info();
$row = array('person_id' => $pid, 'full_name' => $member->full_name(), 'constituency' => $member->constituency(), 'party' => $member->party_text(), 'majority_in_seat' => number_format($member->extra_info['majority_in_seat']), 'swing_to_lose_seat_today' => number_format($member->extra_info['swing_to_lose_seat_today']));
list($image, $sz) = find_rep_image($pid, true);
if ($image) {
    $row['image'] = $image;
}
foreach ($member->extra_info['office'] as $office) {
    if ($office['to_date'] == '9999-12-31' && $office['source'] == 'chgpages/selctee') {
        $row['selctee'][] = prettify_office($office['position'], $office['dept']);
    }
}
$none = false;
$output = array();
$pw_keys = array_filter(array_keys($member->extra_info), create_function('$a', '
	if (substr($a, 0, 11) != "public_whip") return false;
	if (substr($a, -7) == "_absent") return false;
	return true;
'));