本文整理汇总了PHP中MEMBER::constituency方法的典型用法代码示例。如果您正苦于以下问题:PHP MEMBER::constituency方法的具体用法?PHP MEMBER::constituency怎么用?PHP MEMBER::constituency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEMBER
的用法示例。
在下文中一共展示了MEMBER::constituency方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
$constituency = postcode_to_constituency($pc);
} else {
$constituency = $cconstituency;
}
if ($constituency == "connection_timed_out") {
$errors['pc'] = "Sorry, we couldn't check your postcode right now, as our postcode lookup server is under quite a lot of load. Please use the 'All MPs' link above to browse all the MPs.";
} elseif ($constituency == "") {
$errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a known postcode";
twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
} elseif (is_array($constituency)) {
$PAGE->page_start_mobile();
$PAGE->stripe_start();
print '<p>There are several electoral divisions within your postcode. Please select from the following:</p><ul>';
foreach ($constituency as $c) {
$member = new MEMBER(array('constituency' => $c));
print '<li><a href="' . WEBPATH . 'mp/?pc=' . $pc . '&c=' . $c . '">' . ucwords(strtolower($member->full_name())) . ', ' . $member->constituency() . '</a></li>';
}
print '</ul>';
$MPSURL = new URL('mps');
$sidebar = array('type' => 'html', 'content' => '<div class="block">
<h4><a href="' . $MPSURL->generate() . '">Browse all MPs</a></h4>
</div>');
//$PAGE->stripe_end(array($sidebar));
} else {
// Redirect to the canonical MP page, with a person id.
$MEMBER = new MEMBER(array('constituency' => $constituency));
if ($MEMBER->person_id()) {
if ($THEUSER->isloggedin()) {
# Updates too much in the database to make one change
$details = array('firstname' => $THEUSER->firstname(), 'lastname' => $THEUSER->lastname(), 'email' => $THEUSER->email(), 'emailpublic' => $THEUSER->emailpublic(), 'postcode' => $pc, 'constituency' => $constituency, 'url' => $THEUSER->url(), 'optin' => $THEUSER->optin());
$success = $THEUSER->update_self($details);
示例2: display_search_form
function display_search_form($alert, $details = array(), $errors = array())
{
global $this_page, $PAGE;
$ACTIONURL = new URL($this_page);
$ACTIONURL->reset();
$form_start = '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . _htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="email" value="' . _htmlspecialchars(get_http_var('email')) . '">';
if (isset($details['members']) && $details['members']->rows() > 0) {
echo '<ul class="hilites">';
$q = $details['members'];
for ($n = 0; $n < $q->rows(); $n++) {
echo '<li>';
echo $form_start . '<input type="hidden" name="pid" value="' . $q->field($n, 'person_id') . '">';
echo 'Things by ';
$name = member_full_name($q->field($n, 'house'), $q->field($n, 'title'), $q->field($n, 'given_name'), $q->field($n, 'family_name'), $q->field($n, 'lordofname'));
if ($q->field($n, 'constituency')) {
echo $name . ' (' . $q->field($n, 'constituency') . ') ';
} else {
echo $name;
}
echo ' <input type="submit" value="Subscribe"></form>';
echo "</li>\n";
}
echo '</ul>';
}
if (isset($details['constituencies'])) {
echo '<ul class="hilites">';
foreach ($details['constituencies'] as $constituency) {
$MEMBER = new MEMBER(array('constituency' => $constituency, 'house' => 1));
echo "<li>";
echo $form_start . '<input type="hidden" name="pid" value="' . $MEMBER->person_id() . '">';
if ($details['valid_postcode']) {
echo '<input type="hidden" name="pc" value="' . _htmlspecialchars($details['alertsearch']) . '">';
}
echo $MEMBER->full_name();
echo ' (' . _htmlspecialchars($constituency) . ')';
echo ' <input type="submit" value="Subscribe"></form>';
echo "</li>";
}
echo '</ul>';
}
if ($details['alertsearch']) {
echo '<ul class="hilites"><li>';
echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($details['alertsearch']) . '">';
echo 'Mentions of [';
$alertsearch = $details['alertsearch'];
if (preg_match('#speaker:(\\d+)#', $alertsearch, $m)) {
$MEMBER = new MEMBER(array('person_id' => $m[1]));
$alertsearch = str_replace("speaker:{$m['1']}", "speaker:" . $MEMBER->full_name(), $alertsearch);
}
echo _htmlspecialchars($alertsearch) . '] ';
echo ' <input type="submit" value="Subscribe"></form>';
# Use original alertsearch variable here, because name replacement might introduce a comma
if (strstr($details['alertsearch'], ',') > -1) {
echo '<em class="error">You have used a comma in your search term – are you sure this is what you want?
You cannot sign up to multiple search terms using a comma – either use OR, or fill in this form multiple times.</em>';
}
if (preg_match('#([A-Z]{1,2}\\d+[A-Z]? ?\\d[A-Z]{2})#i', $alertsearch, $m) && strlen($alertsearch) > strlen($m[1]) && validate_postcode($m[1])) {
$scottish_text = '';
$mp_display_text = '';
if (postcode_is_scottish($m[1])) {
$mp_display_text = 'your MP, ';
$scottish_text = ' or MSP';
}
echo '<em class="error">You have used a postcode and something else in your search term – are you sure this is what you want?
You will only get an alert if all of these are mentioned in the same debate. Did you mean to get alerts for when your MP' . $scottish_text . ' mentions something instead? If so click subscribe below.</em></li>';
try {
$MEMBER = new MEMBER(array('postcode' => $m[1]));
// move the postcode to the front just to be tidy
$tidy_alertsearch = $m[1] . " " . trim(str_replace("{$m['1']}", "", $alertsearch));
$alertsearch_display = str_replace("{$m['1']} ", "", $tidy_alertsearch);
$alertsearch = str_replace("{$m['1']}", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
echo "<li>";
echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($alertsearch) . '">';
echo 'Mentions of [';
echo _htmlspecialchars($alertsearch_display) . '] by ' . $mp_display_text . $MEMBER->full_name();
echo ' <input type="submit" value="Subscribe"></form>';
if ($scottish_text) {
$constituencies = postcode_to_constituencies($m[1]);
if (isset($constituencies['SPC'])) {
$MEMBER = new MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4));
// move the postcode to the front just to be tidy
$alertsearch = str_replace("{$m['1']}", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
echo "</li><li>";
echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($alertsearch) . '">';
echo 'Mentions of [';
echo _htmlspecialchars($alertsearch_display) . '] by your MSP, ' . $MEMBER->full_name();
echo ' <input type="submit" value="Subscribe"></form>';
}
}
} catch (MySociety\TheyWorkForYou\MemberException $e) {
echo '<p>We had a problem looking up your representative.</p>';
}
}
echo "</li></ul>";
}
if ($details['pid']) {
$MEMBER = new MEMBER(array('person_id' => $details['pid']));
echo '<ul class="hilites"><li>';
//.........这里部分代码省略.........
示例3: MEMBER
# XXX Lots here copied from elsewhere... Damn you deadlines.
include_once 'min-init.php';
include_once INCLUDESPATH . 'easyparliament/member.php';
include_once '../api/api_functions.php';
$pid = $_GET['pid'];
if (!$pid) {
print '<error>No ID</error>';
exit;
}
$member = new MEMBER(array('person_id' => $pid));
if (!$member->valid) {
print '<error>Unknown ID</error>';
exit;
}
$member->load_extra_info();
$row = array('person_id' => $pid, 'full_name' => $member->full_name(), 'constituency' => $member->constituency(), 'party' => $member->party_text(), 'majority_in_seat' => number_format($member->extra_info['majority_in_seat']), 'swing_to_lose_seat_today' => number_format($member->extra_info['swing_to_lose_seat_today']));
list($image, $sz) = find_rep_image($pid, true);
if ($image) {
$row['image'] = $image;
}
foreach ($member->extra_info['office'] as $office) {
if ($office['to_date'] == '9999-12-31' && $office['source'] == 'chgpages/selctee') {
$row['selctee'][] = prettify_office($office['position'], $office['dept']);
}
}
$none = false;
$output = array();
$pw_keys = array_filter(array_keys($member->extra_info), create_function('$a', '
if (substr($a, 0, 11) != "public_whip") return false;
if (substr($a, -7) == "_absent") return false;
return true;
示例4: display_search_form
function display_search_form ( $alert, $details = array(), $errors = array() ) {
global $this_page, $PAGE;
$ACTIONURL = new URL($this_page);
$ACTIONURL->reset();
$form_start = '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="only" value="1">
<input type="hidden" name="email" value="' . htmlspecialchars(get_http_var('email')) . '">';
if (isset($details['members']) && $details['members']->rows() > 0) {
echo '<ul class="hilites">';
$q = $details['members'];
$last_pid = null;
for ($n=0; $n<$q->rows(); $n++) {
if ($q->field($n, 'person_id') != $last_pid) {
$last_pid = $q->field($n, 'person_id');
echo '<li>';
echo $form_start . '<input type="hidden" name="pid" value="' . $last_pid . '">';
echo 'Things by ';
$name = member_full_name($q->field($n, 'house'), $q->field($n, 'title'), $q->field($n, 'first_name'), $q->field($n, 'last_name'), $q->field($n, 'constituency') );
if ($q->field($n, 'house') != 2) {
echo $name . ' (' . $q->field($n, 'constituency') . ') ';
} else {
echo $name;
}
echo ' <input type="submit" value="Subscribe"></form>';
echo "</li>\n";
}
}
echo '</ul>';
}
if (isset($details['constituencies'])) {
echo '<ul class="hilites">';
foreach ($details['constituencies'] as $constituency) {
$MEMBER = new MEMBER(array('constituency'=>$constituency, 'house' => 1));
echo "<li>";
echo $form_start . '<input type="hidden" name="pid" value="' . $MEMBER->person_id() . '">';
if ($details['valid_postcode'])
echo '<input type="hidden" name="pc" value="' . htmlspecialchars($details['alertsearch']) . '">';
echo $MEMBER->full_name();
echo ' (' . htmlspecialchars($constituency) . ')';
echo ' <input type="submit" value="Subscribe"></form>';
echo "</li>";
}
echo '</ul>';
}
if ($details['alertsearch']) {
echo '<ul class="hilites"><li>';
echo $form_start . '<input type="hidden" name="keyword" value="' . htmlspecialchars($details['alertsearch']) . '">';
echo 'Mentions of [';
$alertsearch = $details['alertsearch'];
if (preg_match('#speaker:(\d+)#', $alertsearch, $m)) {
$MEMBER = new MEMBER(array('person_id'=>$m[1]));
$alertsearch = str_replace("speaker:$m[1]", "speaker:" . $MEMBER->full_name(), $alertsearch);
}
echo htmlspecialchars($alertsearch) . '] ';
echo ' <input type="submit" value="Subscribe"></form>';
echo "</li></ul>";
}
if ($details['pid']) {
$MEMBER = new MEMBER(array('person_id'=>$details['pid']));
echo '<ul class="hilites"><li>';
echo "Signing up for things by " . $MEMBER->full_name();
echo ' (' . htmlspecialchars($MEMBER->constituency()) . ')';
echo "</li></ul>";
}
if ($details['keyword']) {
echo '<ul class="hilites"><li>';
echo 'Signing up for results from a search for [';
$alertsearch = $details['keyword'];
if (preg_match('#speaker:(\d+)#', $alertsearch, $m)) {
$MEMBER = new MEMBER(array('person_id'=>$m[1]));
$alertsearch = str_replace("speaker:$m[1]", "speaker:" . $MEMBER->full_name(), $alertsearch);
}
echo htmlspecialchars($alertsearch) . ']';
echo "</li></ul>";
}
if (!$details['add']) {
?>
<p><label for="alertsearch">To sign up to an email alert, enter either your
<strong>postcode</strong>, the <strong>name</strong> of who you're interested
in, or the <strong>search word</strong> or <strong>words</strong> you wish to receive alerts
for.</label> To be alerted on an exact <strong>phrase</strong>, be sure to put it in quotes.
Also use quotes around a word to avoid stemming (where ‘horse’ will
also match ‘horses’),
<?
}
echo '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="submitted" value="1">';
//.........这里部分代码省略.........