-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
287 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
include_once '../../includes/easyparliament/init.php'; | ||
$this_page = 'profile_message'; | ||
$db = new ParlDB; | ||
|
||
$PAGE->page_start(); | ||
$PAGE->stripe_start(); | ||
|
||
print get_http_var('submit') ? submit_message() : display_message_form(); | ||
|
||
$menu = $PAGE->admin_menu(); | ||
$PAGE->stripe_end(array( | ||
array( | ||
'type' => 'html', | ||
'content' => $menu | ||
) | ||
)); | ||
|
||
$PAGE->page_end(); | ||
|
||
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" class="autocomplete"> | ||
'; | ||
$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'); | ||
} | ||
$out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n"; | ||
} | ||
|
||
$out .= ' </select></span> </div> '; | ||
|
||
return $out; | ||
} | ||
|
||
function submit_message() { | ||
global $db; | ||
|
||
$pid = intval(get_http_var('pid')); | ||
$message = get_http_var('profile_message'); | ||
|
||
if (!$pid) { | ||
return display_message_form(array('Please pick a person')); | ||
} | ||
|
||
$query = "INSERT INTO personinfo (person_id, data_key, data_value) VALUES | ||
($pid,'profile_message',:profile_message) | ||
ON DUPLICATE KEY UPDATE data_value=VALUES(data_value)"; | ||
$q = $db->query($query, array(':profile_message' => $message)); | ||
|
||
$person = new MySociety\TheyWorkForYou\Member(array( | ||
'person_id' => $pid)); | ||
$person->load_extra_info(true, true); | ||
|
||
return "<p><em>Profile message set for $pid</em> — check how it looks <a href=\"/mp?p=$pid\">on their page</a></p>" | ||
. display_message_form(); | ||
} | ||
|
||
function display_message_form($errors = array()) { | ||
$out = ''; | ||
if ($errors) { | ||
$out .= '<ul class="error"><li>' . join('</li><li>', $errors) . '</li></ul>'; | ||
} | ||
$out .= '<form method="post">'; | ||
$out .= person_drop_down(); | ||
$out .= <<<EOF | ||
<div class="row"> | ||
<span class="label"><label for="profile_message">Profile message:</label></span> | ||
<span class="formw"><textarea name="profile_message" id="profile_message" rows="5" cols="50"></textarea></span> | ||
</div> | ||
<div class="row"> | ||
<span class="label"> </span> | ||
<span class="formw"><input type="submit" name="submit" value="Update"></span> | ||
</div> | ||
</form> | ||
EOF; | ||
return $out; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
.autocomplete__wrapper { | ||
position: relative; | ||
} | ||
|
||
.autocomplete__hint, | ||
.autocomplete__input { | ||
-webkit-appearance: none; | ||
border: 2px solid; | ||
border-radius: 0; /* Safari 10 on iOS adds implicit border rounding. */ | ||
box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
-webkit-box-sizing: border-box; | ||
margin-bottom: 0; /* BUG: Safari 10 on macOS seems to add an implicit margin. */ | ||
width: 100%; | ||
} | ||
|
||
.autocomplete__input { | ||
background-color: transparent; | ||
position: relative; | ||
} | ||
|
||
.autocomplete__hint { | ||
color: #BFC1C3; | ||
position: absolute; | ||
} | ||
|
||
.autocomplete__input--default{ | ||
padding: 4px; | ||
} | ||
|
||
.autocomplete__input--focused { | ||
outline-offset: 0; | ||
outline: 3px solid #ffbf47; | ||
} | ||
|
||
.autocomplete__input--show-all-values { | ||
padding: 4px 34px 4px 4px; | ||
cursor: pointer; | ||
} | ||
|
||
.autocomplete__dropdown-arrow-down{ | ||
z-index: -1; | ||
display: inline-block; | ||
position: absolute; | ||
right: 8px; | ||
width: 24px; | ||
height: 24px; | ||
top: 10px; | ||
} | ||
|
||
.autocomplete__menu { | ||
background-color: #fff; | ||
border: 2px solid #0B0C0C; | ||
border-top: 0; | ||
color: #34384B; | ||
margin: 0; | ||
max-height: 342px; | ||
overflow-x: hidden; | ||
padding: 0; | ||
width: 100%; | ||
width: calc(100% - 4px); | ||
} | ||
|
||
.autocomplete__menu--visible { | ||
display: block; | ||
} | ||
|
||
.autocomplete__menu--hidden { | ||
display: none; | ||
} | ||
|
||
.autocomplete__menu--overlay { | ||
box-shadow: rgba(0, 0, 0, 0.256863) 0px 2px 6px; | ||
left: 0; | ||
position: absolute; | ||
top: 100%; | ||
z-index: 100; | ||
} | ||
|
||
.autocomplete__menu--inline { | ||
position: relative; | ||
} | ||
|
||
.autocomplete__option { | ||
border-bottom: solid #BFC1C3; | ||
border-width: 1px 0; | ||
cursor: pointer; | ||
display: block; | ||
position: relative; | ||
} | ||
|
||
.autocomplete__option > * { | ||
pointer-events: none; | ||
} | ||
|
||
.autocomplete__option:first-of-type { | ||
border-top-width: 0; | ||
} | ||
|
||
.autocomplete__option:last-of-type { | ||
border-bottom-width: 0; | ||
} | ||
|
||
.autocomplete__option--odd { | ||
background-color: #FAFAFA; | ||
} | ||
|
||
.autocomplete__option--focused, | ||
.autocomplete__option:hover { | ||
background-color: #005EA5; | ||
border-color: #005EA5; | ||
color: white; | ||
outline: none; | ||
} | ||
|
||
.autocomplete__option--no-results { | ||
background-color: #FAFAFA; | ||
color: #646b6f; | ||
cursor: not-allowed; | ||
} | ||
|
||
.autocomplete__hint, | ||
.autocomplete__input, | ||
.autocomplete__option { | ||
font-size: 16px; | ||
line-height: 1.25; | ||
} | ||
|
||
.autocomplete__hint, | ||
.autocomplete__option { | ||
padding: 4px; | ||
} | ||
|
||
@media (min-width: 641px) { | ||
.autocomplete__hint, | ||
.autocomplete__input, | ||
.autocomplete__option { | ||
font-size: 19px; | ||
line-height: 1.31579; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters