<?php /* Used on the 'All MPs' page to produce the list of MPs in CSV format. */ global $this_page; twfy_debug("TEMPLATE", "people_peers.php"); $order = $data['info']['order']; header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename=senators.csv'); print "Person ID,Name,Party,URI"; print "\n"; foreach ($data['data'] as $n => $peer) { render_peers_row($peer, $order); } function render_peers_row($peer, $order) { global $parties; $name = member_full_name(2, $peer['title'], $peer['first_name'], $peer['last_name'], $peer['constituency']); if (strstr($name, ',')) { $name = "\"{$name}\""; } print $peer['person_id'] . ',' . ucfirst($name) . ','; if (array_key_exists($peer['party'], $parties)) { print $parties[$peer['party']]; } else { print $peer['party']; } print ',' . 'http://' . DOMAIN . WEBPATH . 'senator/' . make_member_url($name, $peer['constituency']); print "\n"; }
<th>party</th> <th>Ministerialship</th> <?php if ($order == 'debates') { ?> <th>Debates spoken in the last year</th> <?php } ?> </thead> <tbody> <?php $URL = new URL(str_replace('s', '', $this_page)); $style = '2'; foreach ($data['data'] as $pid => $peer) { render_peers_row($peer, $style, $order, $URL); } ?> </tbody> </table> <?php function manymins($p, $d) { return prettify_office($p, $d); } function render_peers_row($peer, &$style, $order, $URL) { global $parties; // Stripes $style = $style == '1' ? '2' : '1';
<?php twfy_debug("TEMPLATE", "people_peers.php"); header('Content-Type: text/csv'); print "Person ID,Name,Party,URI"; print "\r\n"; foreach ($data['data'] as $n => $peer) { render_peers_row($peer); } function render_peers_row($peer) { global $parties; $name = $peer['name']; if (strstr($name, ',')) { $name = "\"{$name}\""; } print $peer['person_id'] . ',' . ucfirst($name) . ','; if (array_key_exists($peer['party'], $parties)) { print $parties[$peer['party']]; } else { print $peer['party']; } print ',' . 'http://www.theyworkforyou.com/peer/' . $peer['url']; print "\r\n"; }