function search_by_usage($search, $house = 0)
{
    $data = array();
    $SEARCHENGINE = new SEARCHENGINE($search);
    $data['pagetitle'] = $SEARCHENGINE->query_description_short();
    $SEARCHENGINE = new SEARCHENGINE($search . ' groupby:speech');
    $count = $SEARCHENGINE->run_count(0, 5000, 'date');
    if ($count <= 0) {
        $data['error'] = 'No results';
        return $data;
    }
    $SEARCHENGINE->run_search(0, 5000, 'date');
    $gids = $SEARCHENGINE->get_gids();
    if (count($gids) <= 0) {
        $data['error'] = 'No results';
        return $data;
    }
    if (count($gids) == 5000) {
        $data['limit_reached'] = true;
    }
    # Fetch all the speakers of the results, count them up and get min/max date usage
    $speaker_count = array();
    $gids = join('","', $gids);
    $db = new ParlDB();
    $q = $db->query('SELECT gid,person_id,hdate FROM hansard WHERE gid IN ("' . $gids . '")');
    for ($n = 0; $n < $q->rows(); $n++) {
        $gid = $q->field($n, 'gid');
        $person_id = $q->field($n, 'person_id');
        $hdate = $q->field($n, 'hdate');
        if (!isset($speaker_count[$person_id])) {
            $speaker_count[$person_id] = 0;
            $maxdate[$person_id] = '1001-01-01';
            $mindate[$person_id] = '9999-12-31';
        }
        $speaker_count[$person_id]++;
        if ($hdate < $mindate[$person_id]) {
            $mindate[$person_id] = $hdate;
        }
        if ($hdate > $maxdate[$person_id]) {
            $maxdate[$person_id] = $hdate;
        }
    }
    # Fetch details of all the speakers
    $speakers = array();
    $pids = array();
    if (count($speaker_count)) {
        $person_ids = join(',', array_keys($speaker_count));
        $q = $db->query('SELECT member_id, member.person_id, title, given_name, family_name, lordofname,
                                constituency, house, party,
                                moffice_id, dept, position, from_date, to_date, left_house
                            FROM member LEFT JOIN moffice ON member.person_id = moffice.person
                                JOIN person_names pn ON member.person_id = pn.person_id AND pn.type="name" AND pn.start_date <= left_house AND left_house <= pn.end_date
                            WHERE member.person_id IN (' . $person_ids . ')
                            ' . ($house ? " AND house={$house}" : '') . '
                            ORDER BY left_house DESC');
        for ($n = 0; $n < $q->rows(); $n++) {
            $mid = $q->field($n, 'member_id');
            if (!isset($pids[$mid])) {
                $title = $q->field($n, 'title');
                $first = $q->field($n, 'given_name');
                $last = $q->field($n, 'family_name');
                $lordofname = $q->field($n, 'lordofname');
                $house = $q->field($n, 'house');
                $party = $q->field($n, 'party');
                $full_name = ucfirst(member_full_name($house, $title, $first, $last, $lordofname));
                $pid = $q->field($n, 'person_id');
                $pids[$mid] = $pid;
                $speakers[$pid]['house'] = $house;
                $speakers[$pid]['left'] = $q->field($n, 'left_house');
            }
            $dept = $q->field($n, 'dept');
            $posn = $q->field($n, 'position');
            $moffice_id = $q->field($n, 'moffice_id');
            if ($dept && $q->field($n, 'to_date') == '9999-12-31') {
                $speakers[$pid]['office'][$moffice_id] = prettify_office($posn, $dept);
            }
            if (!isset($speakers[$pid]['name'])) {
                $speakers[$pid]['name'] = $full_name . ($house == 1 ? ' MP' : '');
                $speakers[$pid]['party'] = $party;
            }
        }
    }
    if (isset($speaker_count[0])) {
        $speakers[0] = array('party' => '', 'name' => 'Headings, procedural text, etc.', 'house' => 0, 'count' => 0);
    }
    $party_count = array();
    $ok = 0;
    foreach ($speakers as $pid => &$speaker) {
        $speaker['count'] = $speaker_count[$pid];
        $speaker['pmaxdate'] = $maxdate[$pid];
        $speaker['pmindate'] = $mindate[$pid];
        $ok = 1;
        if (!isset($party_count[$speaker['party']])) {
            $party_count[$speaker['party']] = 0;
        }
        $party_count[$speaker['party']] += $count;
    }
    function sort_by_count($a, $b)
    {
        if ($a['count'] > $b['count']) {
            return -1;
        }
        if ($a['count'] < $b['count']) {
            return 1;
        }
        return 0;
    }
    uasort($speakers, 'sort_by_count');
    arsort($party_count);
    if (!$ok) {
        $data['error'] = 'No results';
        return $data;
    }
    $data['party_count'] = $party_count;
    $data['speakers'] = $speakers;
    return $data;
}
Пример #2
0
 function _get_speaker($speaker_id, $hdate)
 {
     // Pass it the id of a speaker. If $this->speakers doesn't
     // already contain data about the speaker, it's fetched from the DB
     // and put in $this->speakers.
     // So we don't have to keep fetching the same speaker info about chatterboxes.
     if ($speaker_id != 0) {
         if (!isset($this->speakers[$speaker_id])) {
             // Speaker isn't cached, so fetch the data.
             $q = $this->db->query("SELECT title, first_name,\n\t\t\t\t\t\t\t\t\t\tlast_name,\n\t\t\t\t\t\t\t\t\t\thouse,\n\t\t\t\t\t\t\t\t\t\tconstituency,\n\t\t\t\t\t\t\t\t\t\tparty,\n                                        person_id\n\t\t\t\t\t\t\t\tFROM \tmember\n\t\t\t\t\t\t\t\tWHERE\tmember_id = '" . mysql_escape_string($speaker_id) . "'\n\t\t\t\t\t\t\t\t");
             if ($q->rows() > 0) {
                 // *SHOULD* only get one row back here...
                 $house = $q->field(0, 'house');
                 if ($house == 1) {
                     $URL = new URL('mp');
                 } elseif ($house == 2) {
                     $URL = new URL('peer');
                 } elseif ($house == 3) {
                     $URL = new URL('mla');
                 } elseif ($house == 4) {
                     $URL = new URL('msp');
                 } elseif ($house == 0) {
                     $URL = new URL('royal');
                 }
                 $URL->insert(array('m' => $speaker_id));
                 $speaker = array('member_id' => $speaker_id, 'title' => $q->field(0, 'title'), "first_name" => $q->field(0, "first_name"), "last_name" => $q->field(0, "last_name"), 'house' => $q->field(0, 'house'), "constituency" => $q->field(0, "constituency"), "party" => $q->field(0, "party"), "person_id" => $q->field(0, "person_id"), "url" => $URL->generate());
                 global $parties;
                 // Manual fix for Speakers.
                 if (isset($parties[$speaker['party']])) {
                     $speaker['party'] = $parties[$speaker['party']];
                 }
                 $q = $this->db->query("SELECT dept, position FROM moffice WHERE person={$speaker['person_id']}\n\t\t\t\t\t\t\t\tAND to_date>='{$hdate}' AND from_date<='{$hdate}'");
                 if ($q->rows() > 0) {
                     for ($row = 0; $row < $q->rows(); $row++) {
                         $dept = $q->field($row, 'dept');
                         $pos = $q->field($row, 'position');
                         if ($pos && $pos != 'Chairman') {
                             $speaker['office'][] = array('dept' => $dept, 'position' => $pos, 'pretty' => prettify_office($pos, $dept));
                         }
                     }
                 }
                 $this->speakers[$speaker_id] = $speaker;
                 return $speaker;
             } else {
                 return array();
             }
         } else {
             // Already cached, so just return that.
             return $this->speakers[$speaker_id];
         }
     } else {
         return array();
     }
 }
Пример #3
0
function person_committees_and_topics($member, $extra_info) {
	$chairmens_panel = false;
	echo '<a name="topics"></a>
<h2>Topics of interest</h2>';
	$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 "<h3>Select Committee membership</h3>";
			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="<?=$WRANSURL->generate()?>">written questions asked by <?=$member['full_name']?></a> and answered by departments)</small></p><?
	}

	# Public Bill Committees
	if (count($extra_info['pbc'])) {
		$topics_block_empty = false;
		print '<h3>Public Bill Committees <small>(sittings attended)</small></h3>';
		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 public bill committee
and has had no written questions answered for which we know the department or subject.</em></p>";
	}

	$member['chairmens_panel'] = $chairmens_panel;
}
Пример #4
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 
}
Пример #5
0
                 $dist_miles = round($dist / 1.609344, 0);
                 $out .= ' <small title="Centre to centre">(' . $dist_miles . ' miles)</small>';
                 $out .= '</li>';
             }
             $out .= '</ul>';
             $sidebars[] = array('type' => 'html', 'content' => '<div class="block"><h4>Nearby constituencies</h4><div class="blockbody">' . $out . ' </div></div>');
         }
     }
 }
 if (array_key_exists('office', $MEMBER->extra_info())) {
     $office = $MEMBER->extra_info();
     $office = $office['office'];
     $mins = '';
     foreach ($office as $row) {
         if ($row['to_date'] != '9999-12-31') {
             $mins .= '<li>' . prettify_office($row['position'], $row['dept']);
             $mins .= ' (';
             if (!($row['source'] == 'chgpages/selctee' && $row['from_date'] == '2004-05-28') && !($row['source'] == 'chgpages/privsec' && $row['from_date'] == '2004-05-13')) {
                 if ($row['source'] == 'chgpages/privsec' && $row['from_date'] == '2005-11-10') {
                     $mins .= 'before ';
                 }
                 $mins .= format_date($row['from_date'], SHORTDATEFORMAT) . ' ';
             }
             $mins .= 'to ';
             if ($row['source'] == 'chgpages/privsec' && $row['to_date'] == '2005-11-10') {
                 $mins .= 'before ';
             }
             $mins .= format_date($row['to_date'], SHORTDATEFORMAT);
             $mins .= ')</li>';
         }
     }
Пример #6
0
 /**
  * Offices
  *
  * Return an array of Office objects held (or previously held) by the member.
  *
  * @param string $include_only  Restrict the list to include only "previous" or "current" offices.
  * @param bool   $priority_only Restrict the list to include only positions in the $priority_offices list.
  *
  * @return array An array of Office objects.
  */
 public function offices($include_only = NULL, $priority_only = FALSE)
 {
     $out = array();
     if (array_key_exists('office', $this->extra_info())) {
         $office = $this->extra_info();
         $office = $office['office'];
         foreach ($office as $row) {
             $office_title = prettify_office($row['position'], $row['dept']);
             if ($officeObject = $this->getOfficeObject($include_only, $priority_only, $office_title, $row)) {
                 $out[] = $officeObject;
             }
         }
     }
     return $out;
 }
Пример #7
0
    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;
'));
sort($pw_keys);
foreach ($pw_keys as $key) {
    $value = $member->extra_info[$key];
    $key = str_replace(array('public_whip_dreammp', '_distance'), '', $key);
    if ($none) {
        $none = false;
Пример #8
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);
        }
    }
Пример #9
0
function render_peers_row($peer, &$style, $order, $URL)
{
    global $parties;
    // Stripes
    $style = $style == '1' ? '2' : '1';
    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) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($peer['person_id'], true, 'lord');
    if ($image) {
        echo '<a href="' . $URL->generate() . $peer['url'] . '" class="speakerimage"><img height="59" alt="" src="', $image, '"';
        echo '></a>';
    }
    ?>
                </td>
                <td class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $URL->generate() . $peer['url'];
    ?>
"><?php 
    echo ucfirst($peer['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>

            </tr>
<?php 
}
Пример #10
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();
        }
    }
Пример #11
0
 private function _get_speaker_offices($speaker, $hdate)
 {
     $offices = array();
     $q = $this->db->query("SELECT dept, position, source FROM moffice\n            WHERE person=:person_id\n            AND from_date <= :hdate and :hdate <= to_date", array(':person_id' => $speaker['person_id'], ':hdate' => $hdate));
     $rows = $q->rows();
     if (!$rows) {
         return $offices;
     }
     for ($row = 0; $row < $rows; $row++) {
         $dept = $q->field($row, 'dept');
         $pos = $q->field($row, 'position');
         $source = $q->field($row, 'source');
         if ($source == 'chgpages/libdem' && $hdate > '2009-01-15') {
             continue;
         }
         if (!$pos || $pos == 'Chairman' || $pos == 'Member') {
             continue;
         }
         $offices[] = array('dept' => $dept, 'position' => $pos, 'source' => $source, 'pretty' => prettify_office($pos, $dept));
     }
     return $offices;
 }
Пример #12
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();
        }
    }
Пример #13
0
function render_mps_row($mp, &$style, $order, $MPURL, $letter = false)
{
    // Stripes
    $style = $style == '1' ? '2' : '1';
    #	$MPURL->insert(array('pid'=>$mp['person_id']));
    ?>
                <tr>
                <td class="row">
<?php 
    if ($letter) {
        echo '<a name="' . $letter . '"></a>';
    }
    list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($mp['person_id'], true, true);
    if ($image) {
        echo '<a href="' . $MPURL->generate() . $mp['url'] . '" class="speakerimage"><img height="59" alt="" src="', $image, '"';
        echo '></a>';
    }
    ?>
                </td>
                <td class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $MPURL->generate() . $mp['url'];
    ?>
"><?php 
    echo $mp['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 
}
Пример #14
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']);
    #	$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 
}
Пример #15
0
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';
	}
	$row['selctee'][] = $member . ', ' . $q->field($i, 'title');
}
*/
$q = $db->query("select data_key, data_value from personinfo\n\twhere data_key like 'public\\_whip%' and person_id = '" . mysql_real_escape_string($pid) . "'\n\torder by data_key");
# order so both_voted is always first...
$none = false;
Пример #16
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 
}
Пример #17
0
 /**
  * Offices
  *
  * Return an array of Office objects held (or previously held) by the member.
  *
  * @param string $include_only  Restrict the list to include only "previous" or "current" offices.
  * @param bool   $priority_only Restrict the list to include only positions in the $priority_offices list.
  *
  * @return array An array of Office objects.
  */
 public function offices($include_only = NULL, $priority_only = FALSE)
 {
     $out = array();
     if (array_key_exists('office', $this->extra_info())) {
         $office = $this->extra_info();
         $office = $office['office'];
         foreach ($office as $row) {
             // Reset the inclusion of this position
             $include_office = TRUE;
             // If we should only include previous offices, and the to date is in the future, suppress this office.
             if ($include_only == 'previous' and $row['to_date'] == '9999-12-31') {
                 $include_office = FALSE;
             }
             // If we should only include previous offices, and the to date is in the past, suppress this office.
             if ($include_only == 'current' and $row['to_date'] != '9999-12-31') {
                 $include_office = FALSE;
             }
             $office_title = prettify_office($row['position'], $row['dept']);
             if ($priority_only and in_array($office_title, $this->priority_offices) or !$priority_only) {
                 if ($include_office) {
                     $officeObject = new Office();
                     $officeObject->title = $office_title;
                     $officeObject->from_date = $row['from_date'];
                     $officeObject->to_date = $row['to_date'];
                     $officeObject->source = $row['source'];
                     $out[] = $officeObject;
                 }
             }
         }
     }
     return $out;
 }