Skip to content

Commit

Permalink
Tweaks for Prince Charles.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed May 11, 2022
1 parent 9717a86 commit bc5c83e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/_fixtures/member.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<field name="left_house">9999-12-31</field>
<field name="entered_reason">accession</field>
<field name="left_reason">still_in_office</field>
<field name="person_id">1</field>
<field name="person_id">13935</field>
<field name="lastupdate">2013-08-07 11:02:49</field>
</row>
<row>
Expand Down Expand Up @@ -361,7 +361,7 @@
<field name="family_name">the Second, by the Grace of God, of the United Kingdom of Great Britain and Northern Ireland and of Her other Realms and Territories Queen, Head of the Commonwealth, Defender of the Faith</field>
<field name="start_date">1952-02-06</field>
<field name="end_date">9999-12-31</field>
<field name="person_id">1</field>
<field name="person_id">13935</field>
<field name="title">Queen</field>
</row>
<row>
Expand Down
10 changes: 7 additions & 3 deletions www/docs/mp/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function get_person_by_postcode($pc) {
function get_person_by_name($name, $const='') {
$MEMBER = new MySociety\TheyWorkForYou\Member(array('name' => $name, 'constituency' => $const));
// Edge case, only attempt further detection if this isn't the Queen.
if ($name !== 'elizabeth the second' || $const) {
if (($name !== 'elizabeth the second' && $name !== 'prince charles') || $const) {
twfy_debug ('MP', 'Redirecting for MP found by name/constituency');
member_redirect($MEMBER);
}
Expand Down Expand Up @@ -649,8 +649,12 @@ function person_summary_description ($MEMBER) {

if (in_array(HOUSE_TYPE_ROYAL, $MEMBER->houses())) {
# Royal short-circuit
return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty']
. '<br>Coronated on 2 June 1953</strong></li>';
if (substr($entered_house[HOUSE_TYPE_ROYAL]['date_pretty'], 0, 4) == 1952) {
return '<strong>Acceded on ' . $entered_house[HOUSE_TYPE_ROYAL]['date_pretty']
. '<br>Coronated on 2 June 1953</strong></li>';
} else {
return '';
}
}
$desc = '';
foreach ($MEMBER->houses() as $house) {
Expand Down
7 changes: 7 additions & 0 deletions www/includes/easyparliament/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ public function name_to_person_id($name, $const='') {
OR (given_name=:given_name AND family_name=:middle_and_last_names)
OR (title=:given_name AND given_name=:middle_name AND family_name=:family_name)
)";
} elseif ($this_page == 'royal') {
twfy_debug ('MP', $name);
if (stripos($name, 'elizabeth') !== false) {
$q .= "AND person_id=13935";
} elseif (stripos($name, 'charles') !== false) {
$q .= "AND person_id=26065";
}
}

$q = $this->db->query($q, $params);
Expand Down
9 changes: 6 additions & 3 deletions www/includes/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,12 @@ function entities_to_numbers($string) {
function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = null) {

// Case for Elizabeth II
if ($house == HOUSE_TYPE_ROYAL)
{
return 'elizabeth_the_second';
if ($house == HOUSE_TYPE_ROYAL) {
if (stripos($name, 'elizabeth') !== false) {
return 'elizabeth_the_second';
} elseif (stripos($name, 'charles') !== false) {
return 'prince_charles';
}
}

$s = array(' ', '&amp;', '&ocirc;', '&Ouml;', '&ouml;', '&acirc;', '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
Expand Down

0 comments on commit bc5c83e

Please sign in to comment.