Example #1
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 
}
Example #2
0
function _api_getPerson_row($row, $has_party = FALSE)
{
    global $parties;
    $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'], $row['family_name'], $row['lordofname']);
    if ($row['house'] != 2) {
        unset($row['lordofname']);
    }
    if ($row['house'] == 1) {
        $URL = new URL('mp');
        $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
    }
    if ($has_party && isset($parties[$row['party']])) {
        $row['party'] = $parties[$row['party']];
    }
    list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
    if ($image) {
        list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
        $row['image'] = $image;
        $row['image_height'] = $height;
        $row['image_width'] = $width;
    }
    if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || DISSOLUTION_DATE && $row['left_house'] == DISSOLUTION_DATE)) {
        # Ministerialships and Select Committees
        $db = new ParlDB();
        $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
        for ($i = 0; $i < $q->rows(); $i++) {
            $row['office'][] = $q->row($i);
        }
    }
    foreach ($row as $k => $r) {
        if (is_string($r)) {
            $row[$k] = html_entity_decode($r);
        }
    }
    return $row;
}
Example #3
0
function render_mps_row($mp, &$style, $order, $MPURL, $letter = '')
{
    $style = $style == '1' ? '2' : '1';
    ?>
<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 class="row-<?php 
    echo $style;
    ?>
"><a href="<?php 
    echo $MPURL->generate() . $mp['url'];
    ?>
"><?php 
    echo $mp['name'];
    ?>
</a></td>
    <td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['party'];
    ?>
</td>
    <td class="row-<?php 
    echo $style;
    ?>
"><?php 
    echo $mp['constituency'];
    ?>
</td>
    </tr>
<?php 
}
Example #4
0
<?php

include_once '../../../includes/easyparliament/init.php';
include_once INCLUDESPATH . "easyparliament/member.php";
$DATA->set_page_metadata($this_page, 'heading', 'MPs photo status on TheyWorkForYou');
$PAGE->page_start();
$PAGE->stripe_start();
$db = new ParlDB();
$query = 'SELECT person_id, constituency, party
    FROM member
    WHERE house=1 AND left_house = (SELECT MAX(left_house) FROM member) ';
$q = $db->query($query . "ORDER BY person_id");
$out = array('both' => '', 'small' => '', 'none' => array());
for ($i = 0; $i < $q->rows(); $i++) {
    $p_id = $q->field($i, 'person_id');
    list($dummy, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($p_id);
    if ($sz == 'L') {
        $out['both'] .= $q->field($i, 'person_id') . ', ';
    } elseif ($sz == 'S') {
        $out['small'] .= $q->field($i, 'person_id') . ', ';
    } else {
        array_push($out['none'], '<li>' . $q->field($i, 'person_id') . ' (' . $q->field($i, 'party') . ')' . ', ' . $q->field($i, 'constituency'));
    }
}
print '<h3>Missing completely (' . count($out['none']) . ')</h3> <ul>';
print join($out['none'], "\n");
print '</ul>';
print '<h3>Large and small</h3> <p>';
print $out['both'];
print '<h3>Only small photos</h3> <p>';
print $out['small'];
Example #5
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 
}
Example #6
0
function person_drop_down()
{
    global $db;
    $out = '
<div class="row">
<span class="label"><label for="form_pid">Person:</label></span>
<span class="formw"><select id="form_pid" name="pid"></span>
';
    $query = 'SELECT house, member.person_id, title, given_name, family_name, lordofname, constituency, party
        FROM member, person_names,
        (SELECT person_id, MAX(end_date) max_date FROM person_names WHERE type="name" GROUP by person_id) md
        WHERE house>0 AND member.person_id = person_names.person_id AND person_names.type = "name"
        AND md.person_id = person_names.person_id AND md.max_date = person_names.end_date
        GROUP by person_id
        ORDER BY house, family_name, lordofname, given_name
    ';
    $q = $db->query($query);
    $houses = array(1 => 'MP', 'Lord', 'MLA', 'MSP');
    for ($i = 0; $i < $q->rows(); $i++) {
        $p_id = $q->field($i, 'person_id');
        $house = $q->field($i, 'house');
        $desc = member_full_name($house, $q->field($i, 'title'), $q->field($i, 'given_name'), $q->field($i, 'family_name'), $q->field($i, 'lordofname')) . " " . $houses[$house];
        if ($q->field($i, 'party')) {
            $desc .= ' (' . $q->field($i, 'party') . ')';
        }
        if ($q->field($i, 'constituency')) {
            $desc .= ', ' . $q->field($i, 'constituency');
        }
        list($dummy, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($p_id);
        if ($sz == 'L') {
            $desc .= ' [has large photo]';
        } elseif ($sz == 'S') {
            $desc .= ' [has small photo]';
        } else {
            $desc .= ' [no photo]';
        }
        $out .= '<option value="' . $p_id . '">' . $desc . '</option>' . "\n";
    }
    $out .= ' </select></span> </div> ';
    return $out;
}
Example #7
0
            <a name="g<?php 
    echo gid_to_anchor($speech['gid']);
    ?>
"></a>

            <div class="debate-speech__speaker-and-content">

          <?php 
    if (isset($speech['speaker']) && count($speech['speaker']) > 0) {
        ?>
            <h2 class="debate-speech__speaker">
                <?php 
        $speaker = $speech['speaker'];
        $speaker_name = ucfirst($speaker['name']);
        list($image_url, $size) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($speaker['person_id'], true, $data['info']['major'] == 101 ? 'lord' : 'general');
        if (count($speaker['office'])) {
            $desc = array();
            foreach ($speaker['office'] as $off) {
                $desc[] = $off['pretty'];
            }
            $speaker_position = join(', ', $desc);
        } else {
            $speaker_position = _htmlentities($speaker['party']);
            if ($speaker['house'] == 1 && $speaker['party'] != 'Speaker' && $speaker['party'] != 'Deputy Speaker' && $speaker['constituency']) {
                $speaker_position .= ', ' . $speaker['constituency'];
            }
        }
        ?>
                <a href="<?php 
        echo $speech['speaker']['url'];