Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add images to all reps on postcode page #1795

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions locale/cy_GB.UTF-8/LC_MESSAGES/TheyWorkForYou.po
Original file line number Diff line number Diff line change
Expand Up @@ -2623,8 +2623,8 @@ msgid "Image credits:"
msgstr "Credydau llun"

#: www/includes/easyparliament/templates/html/static/about.php:101
msgid "The copyright of Hansard remains under <a href=\"http://www.opsi.gov.uk/advice/parliamentary-copyright/\">Parliamentary Copyright</a>, used under licence. "
msgstr "Mae copyright Hansard yn parhau dan <a href=\"http://www.opsi.gov.uk/advice/parliamentary-copyright/\">Hawlfraint Seneddol</a>, a ddefnyddir o dan drwydded."
msgid "The copyright of Hansard remains under <a href=\"https://www.parliament.uk/site-information/copyright/\">Parliamentary Copyright</a>, used under licence. "
msgstr "Mae copyright Hansard yn parhau dan <a href=\"https://www.parliament.uk/site-information/copyright/\">Hawlfraint Seneddol</a>, a ddefnyddir o dan drwydded."

#: www/includes/easyparliament/templates/html/static/contact.php:4
msgid "Who do you want to contact?"
Expand Down
2 changes: 1 addition & 1 deletion www/docs/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function pick_multiple($pc, $areas, $area_type, $house) {
$mp = $q;
$mp['former'] = ($mp['left_house'] != '9999-12-31');
$q = $db->query("SELECT * FROM personinfo where person_id=:person_id AND data_key='standing_down_2024'", [':person_id' => $mp['person_id']]);
$mp['standing_down_2024'] = $q['data_value'];
$mp['standing_down_2024'] = $q['data_value'] ?? 0;
}

$query_base = "SELECT member.person_id, given_name, family_name, constituency, house
Expand Down
5 changes: 5 additions & 0 deletions www/docs/style/sass/pages/_mp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -785,4 +785,9 @@ a[href^="https://www.publicwhip.org"] {
.person-panels .panel ul.rep-actions {
list-style: disc;
margin-left: 1.2em;
}

.postcode-mp-image-wrapper {
display: block;
margin-top: 5px;
}
32 changes: 25 additions & 7 deletions www/includes/easyparliament/templates/html/postcode/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,28 @@
<div class="main">
<?php

function image_from_person_id(int $person_id): ?string {
// Use utility method rather than member object to avoid loading full object
// Using the same image and not using the placeholder
[$image, $size] = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($person_id, true, false);
return $size !== null ? $image : null;
}

function member_image_box(string $person_id, string $person_url, string $person_name): void {
// Render a small image box for a person with a link to the person page
// If image_url is null, render nothing
$image_url = image_from_person_id($person_id);
if ($image_url) {
echo '<div class="postcode-mp-image-wrapper">';
echo '<a href="' . $person_url . '"><img src="' . $image_url . '" height=80 width=60 alt="' . $person_name .'"></a>';
echo '</div>';
}
}

include "ge2024.php";

# The below is normally the main column, but for now let us make it the sidebar...

list ($image_url, $size) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($mp['person_id'], true);

?>

Expand All @@ -21,9 +38,6 @@
<h2><?= gettext('Your representatives') ?></h2>
<ul>
<li>
<?php if ($image_url) { ?>
<img src="<?= $image_url ?>" alt="" align="right">
<?php } ?>
<?php if ($mp['former']) {
printf(gettext('Your former <strong>MP</strong> (Member of Parliament) is <a href="%s">%s</a>, %s'), '/mp/?p=' . $mp['person_id'], $mp['name'], gettext($mp['constituency']));
} else {
Expand All @@ -32,6 +46,7 @@
<?php if ($mp['standing_down_2024']) {
echo 'They are standing down at the general election.';
} ?>
<?php member_image_box($mp["person_id"], '/mp/?p=' . $mp['person_id'], $mp['name']) ?>
</li>

<?php
Expand All @@ -57,6 +72,7 @@
printf(gettext('Your <strong>constituency MS</strong> (Member of the Senedd) was <a href="%s">%s</a>, %s'), $url, $name, $cons);
}
}
member_image_box($mcon["person_id"], $url, $name);
echo '</li>';
}
if (isset($mreg)) {
Expand All @@ -79,9 +95,11 @@
}
echo '<ul>';
foreach ($mreg as $reg) {
echo '<li><a href="' . $urlp . $reg['person_id'] . '">';
echo $reg['given_name'] . ' ' . $reg['family_name'];
echo '</a>';
$url = $urlp . $reg['person_id'];
$name = $reg['given_name'] . ' ' . $reg['family_name'];
echo '<li><a href="' . $url . '">' . $name . '</a>';
member_image_box($reg["person_id"], $url, $name );
echo '</li>';
}
echo '</ul>';
}
Expand Down
Loading