Ejemplo n.º 1
0
<?php

twfy_debug("TEMPLATE", "people_mlas.php");
header('Content-Type: text/csv');
print "Person ID,Name,Party,Constituency,URI";
print "\r\n";
foreach ($data['data'] as $n => $mla) {
    render_mlas_row($mla);
}
function render_mlas_row($mla)
{
    global $parties;
    $con = $mla['constituency'];
    if (strstr($con, ',')) {
        $con = "\"{$con}\"";
    }
    $name = $mla['name'];
    if (strstr($name, ',')) {
        $name = "\"{$name}\"";
    }
    print $mla['person_id'] . ',' . ucfirst($name) . ',';
    if (array_key_exists($mla['party'], $parties)) {
        print $parties[$mla['party']];
    } else {
        print $mla['party'];
    }
    print ',' . $con . ',' . 'http://www.theyworkforyou.com/mla/' . $mla['url'];
    print "\r\n";
}
Ejemplo n.º 2
0
<?php

/*
Used on the 'All MPs' page to produce the list of MPs in CSV format.
*/
global $this_page;
twfy_debug("TEMPLATE", "people_mlas.php");
$order = $data['info']['order'];
header('Content-Type: text/csv');
print "Person ID,Name,Party,Constituency,URI";
print "\n";
foreach ($data['data'] as $n => $mla) {
    render_mlas_row($mla, $order);
}
function render_mlas_row($mla, $order)
{
    global $parties;
    $con = html_entity_decode($mla['constituency']);
    if (strstr($con, ',')) {
        $con = "\"{$con}\"";
    }
    $name = member_full_name(3, $mla['title'], $mla['first_name'], $mla['last_name'], $mla['constituency']);
    if (strstr($name, ',')) {
        $name = "\"{$name}\"";
    }
    print $mla['person_id'] . ',' . ucfirst($name) . ',';
    if (array_key_exists($mla['party'], $parties)) {
        print $parties[$mla['party']];
    } else {
        print $mla['party'];
    }