本文整理汇总了PHP中normalise_constituency_name函数的典型用法代码示例。如果您正苦于以下问题:PHP normalise_constituency_name函数的具体用法?PHP normalise_constituency_name怎么用?PHP normalise_constituency_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normalise_constituency_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_getBoundary_name
function api_getBoundary_name($name)
{
$name = html_entity_decode(normalise_constituency_name($name));
# XXX
if (!$name) {
api_error('Name not recognised');
return;
}
$out = array();
$areas = _api_cacheCheck('mapit_get_areas_by_type', 'WMC');
$areas_info = _api_cacheCheck('mapit_get_voting_areas_info', $areas);
$id = null;
foreach ($areas_info as $k => $v) {
if (html_entity_decode(normalise_constituency_name($v['name'])) == $name) {
$id = $k;
}
}
if (!$id) {
api_error('No data found for name');
return;
}
$out = mapit_get_voting_area_geometry($id, 'wgs84');
if (isset($out['polygon'])) {
api_output($out['polygon']);
} else {
api_error('Nothing returned from get_voting_areas_geometry');
}
}
示例2: api_getConstituency_name
function api_getConstituency_name($constituency) {
$constituency = normalise_constituency_name($constituency);
if (!$constituency) {
api_error('Could not find anything with that name');
return;
}
return _api_getConstituency_name($constituency);
}
示例3: get_person_id
function get_person_id($c) {
$db = new ParlDB;
if ($c == '') return false;
if ($c == 'Orkney ') $c = 'Orkney & Shetland';
$n = normalise_constituency_name($c); if ($n) $c = $n;
$q = $db->query("SELECT person_id FROM member
WHERE constituency = '" . mysql_real_escape_string($c) . "'
AND left_reason = 'still_in_office' AND house=1");
if ($q->rows > 0)
return $q->field(0, 'person_id');
return false;
}
示例4: _api_getGeometry_name
function _api_getGeometry_name($name) {
$geometry = _api_getGeometry();
if (!get_http_var('future')) {
$name = normalise_constituency_name($name);
}
$out = array();
foreach ($geometry['data'] as $n => $data) {
if ($n == $name)
return $data;
}
return null;
}
示例5: _api_getGeometry_name
function _api_getGeometry_name($name)
{
$geometry = _api_getGeometry();
$name = html_entity_decode(normalise_constituency_name($name));
# XXX
$out = array();
foreach ($geometry['data'] as $n => $data) {
if ($n == $name) {
return $data;
}
}
return null;
}
示例6: api_getBoundary_name
function api_getBoundary_name($name)
{
$name = normalise_constituency_name($name);
if (!$name) {
api_error('Name not recognised');
return;
}
$out = array();
$areas_info = _api_cacheCheck('areas', 'WMC');
$id = null;
foreach ($areas_info as $k => $v) {
if (normalise_constituency_name($v['name']) == $name) {
$id = $k;
}
}
if (!$id) {
api_error('No data found for name');
return;
}
header("Location: http://mapit.mysociety.org/area/4326/{$id}.kml");
exit;
}
示例7: _api_getGeometry_name
function _api_getGeometry_name($name) {
if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL)
return null;
$name = normalise_constituency_name($name);
$areas = _api_cacheCheck('mapit_get_areas_by_type', 'WMC');
$ni_geometry = _api_ni_centroids();
$areas_info = _api_cacheCheck('mapit_get_voting_areas_info', $areas);
foreach ($areas_info as $area_id => $area) {
if ($name == $area['name']) {
if (isset($ni_geometry[$area_id])) {
$out = $ni_geometry[$area_id];
} else {
$out = mapit_call('area/geometry', $area_id);
}
$out['name'] = $name;
return $out;
}
}
return null;
}
示例8: _api_getGeometry_name
function _api_getGeometry_name($name)
{
if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) {
return null;
}
$name = normalise_constituency_name($name);
# Names are currently in ISO-8859-1, but MapIt is in UTF-8
$name_utf8 = iconv('iso-8859-1', 'utf-8//TRANSLIT', $name);
$areas_info = _api_cacheCheck('areas', 'WMC');
$ni_geometry = _api_ni_centroids();
foreach ($areas_info as $area_id => $area) {
if ($name_utf8 == $area['name']) {
if (isset($ni_geometry[$area_id])) {
$out = $ni_geometry[$area_id];
} else {
$out = mapit_call('area/geometry', $area_id);
}
$out['name'] = $name;
return $out;
}
}
return null;
}
示例9: _api_getMP_constituency
function _api_getMP_constituency($constituency) {
$db = new ParlDB;
if ($constituency == '')
return false;
if ($constituency == 'Orkney ')
$constituency = 'Orkney & Shetland';
$normalised = normalise_constituency_name($constituency);
if ($normalised) $constituency = $normalised;
$q = $db->query("SELECT * FROM member
WHERE constituency = '" . mysql_real_escape_string($constituency) . "'
AND left_reason = 'still_in_office' AND house=1");
if ($q->rows > 0)
return _api_getPerson_row($q->row(0), true);
if (get_http_var('always_return')) {
$q = $db->query("SELECT * FROM member
WHERE house=1 AND constituency = '".mysql_real_escape_string($constituency)."'
ORDER BY left_house DESC LIMIT 1");
if ($q->rows > 0)
return _api_getPerson_row($q->row(0), true);
}
return false;
}
示例10: _api_getMP_constituency
function _api_getMP_constituency($constituency)
{
$db = new ParlDB();
$out = null;
if ($constituency == '') {
return false;
}
if ($constituency == 'Orkney ') {
$constituency = 'Orkney & Shetland';
}
$normalised = normalise_constituency_name($constituency);
if ($normalised) {
$constituency = $normalised;
}
$q = $db->query("SELECT member.*, p.title, p.given_name, p.family_name, p.lordofname\n FROM member, person_names p\n WHERE constituency = :constituency\n AND member.person_id = p.person_id AND p.type = 'name'\n AND p.start_date <= left_house and left_house <= p.end_date\n AND left_reason = 'still_in_office' AND house=:house", array(':house' => HOUSE_TYPE_COMMONS, ':constituency' => $constituency));
if ($q->rows > 0) {
$out = _api_getPerson_row($q->row(0), true);
}
if (!$out && get_http_var('always_return')) {
$q = $db->query("SELECT member.*, p.title, p.given_name, p.family_name, p.lordofname\n FROM member, person_names p\n WHERE house=:house AND constituency = :constituency\n AND member.person_id = p.person_id AND p.type = 'name'\n AND p.start_date <= left_house and left_house <= p.end_date\n ORDER BY left_house DESC LIMIT 1", array(':house' => HOUSE_TYPE_COMMONS, ':constituency' => $constituency));
if ($q->rows > 0) {
$out = _api_getPerson_row($q->row(0), true);
}
}
if ($out) {
api_output($out, isset($out['lastupdate']) ? strtotime($out['lastupdate']) : null);
return true;
}
return false;
}
示例11: str_replace
<link href="quiz/quiz.css" type="text/css" rel="stylesheet"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<?php
if ($_GET['submit'] and !$errors) {
# See if MP is standing again
$mpattr = $mpattr['mpprops'][0];
$constituency = str_replace("&", "&", $mpattr['constituency']);
$house = $mpattr['house'];
$standing_again = false;
if ($mpattr['leftreason'] == "general_election_standing") {
$standing_again = true;
}
# Regional parties
$consid = normalise_constituency_name(strtolower($constituency), $house, "2001");
if (!$consid) {
print "<div class=\"error\">Constituency '{$constituency}' not found, please <a href=\"team@publicwhip.org.uk\">let us know</a>.</div>";
exit;
}
if (array_key_exists($consid, $wales_constituencies)) {
$parties = array_merge($parties, $wales_parties);
}
if (array_key_exists($consid, $scotland_constituencies)) {
$parties = array_merge($parties, $scotland_parties);
}
if (array_key_exists($consid, $northern_ireland_constituencies)) {
$parties = $northern_ireland_parties;
}
if ($consid == "uk.org.publicwhip/cons/655") {
// Wyre Forest, Richard Taylor (Ind)
示例12: constituency_to_person_id
function constituency_to_person_id($constituency, $house = null)
{
global $PAGE;
if ($constituency == '') {
$PAGE->error_message("Sorry, no constituency was found.");
return false;
}
if ($constituency == 'Orkney ') {
$constituency = 'Orkney & Shetland';
}
$normalised = normalise_constituency_name($constituency);
if ($normalised) {
$constituency = $normalised;
}
$q = $this->db->query("SELECT person_id FROM member \n\t\t\t\t\tWHERE constituency = '" . mysql_real_escape_string($constituency) . "' \n\t\t\t\t\tAND left_reason = 'still_in_office'" . ($house ? ' AND house=' . mysql_real_escape_string($house) : ''));
if ($q->rows > 0) {
return $q->field(0, 'person_id');
} else {
#$q = $this->db->query("SELECT person_id FROM member WHERE constituency = '".mysql_real_escape_string($constituency) . "'"
# . ($house ? ' AND house='.mysql_real_escape_string($house) : '') . ' ORDER BY left_house DESC LIMIT 1');
#if ($q->rows > 0) {
# return $q->field(0, 'person_id');
#} else {
$PAGE->error_message("Sorry, there is no current member for the '" . htmlentities($constituency) . "' constituency.");
return false;
#}
}
}
示例13: constituency_to_person_id
public function constituency_to_person_id($constituency, $house = null)
{
if ($constituency == '') {
throw new MySociety\TheyWorkForYou\MemberException('Sorry, no constituency was found.');
}
if ($constituency == 'Orkney ') {
$constituency = 'Orkney & Shetland';
}
$normalised = normalise_constituency_name($constituency);
if ($normalised) {
$constituency = $normalised;
}
$params = array();
$left = "left_reason = 'still_in_office'";
if (DISSOLUTION_DATE) {
$left = "({$left} OR left_house = '" . DISSOLUTION_DATE . "')";
}
$query = "SELECT person_id FROM member\n WHERE constituency = :constituency\n AND {$left}";
$params[':constituency'] = $constituency;
if ($house) {
$query .= ' AND house = :house';
$params[':house'] = $house;
}
$q = $this->db->query($query, $params);
if ($q->rows > 0) {
return $q->field(0, 'person_id');
} else {
throw new MySociety\TheyWorkForYou\MemberException('Sorry, there is no current member for the "' . _htmlentities(ucwords($constituency)) . '" constituency.');
}
}
示例14: search_constituencies_by_query
function search_constituencies_by_query($searchterm)
{
$constituencies = array();
$constituency = '';
$validpostcode = false;
if (validate_postcode($searchterm)) {
// Looks like a postcode - can we find the constituency?
$constituency = postcode_to_constituency($searchterm);
if ($constituency != '') {
$validpostcode = true;
}
}
if ($constituency == '' && $searchterm) {
// No luck so far - let's see if they're searching for a constituency.
$try = strtolower($searchterm);
if (normalise_constituency_name($try)) {
$constituency = normalise_constituency_name($try);
} else {
$query = "select distinct\n (select name from constituency where cons_id = o.cons_id and main_name) as name \n from constituency AS o where name like '%" . mysql_real_escape_string($try) . "%'\n and from_date <= date(now()) and date(now()) <= to_date";
$db = new ParlDB();
$q = $db->query($query);
for ($n = 0; $n < $q->rows(); $n++) {
$constituencies[] = $q->field($n, 'name');
}
}
} else {
if ($constituency) {
$constituencies[] = $constituency;
}
}
return array($constituencies, $validpostcode);
}
示例15: find_constituency
function find_constituency($args)
{
// We see if the user is searching for a postcode or constituency.
global $PAGE, $db;
if ($args['s'] != '') {
$searchterm = $args['s'];
} else {
$PAGE->error_message('No search string');
return false;
}
$constituencies = array();
$constituency = '';
$validpostcode = false;
if (validate_postcode($searchterm)) {
// Looks like a postcode - can we find the constituency?
$constituencies = postcode_to_constituency($searchterm);
if ($constituencies == '') {
$constituencies = array();
} else {
$validpostcode = true;
}
if (!is_array($constituencies)) {
$constituencies = array($constituencies);
}
}
if ($constituencies == array() && $searchterm) {
// No luck so far - let's see if they're searching for a constituency.
$try = strtolower($searchterm);
if (normalise_constituency_name($try)) {
$constituency = normalise_constituency_name($try);
} else {
$query = "select distinct\n (select name from constituency where cons_id = o.cons_id and main_name) as name \n from constituency AS o where name like '%" . mysql_real_escape_string($try) . "%'\n and from_date <= date(now()) and date(now()) <= to_date";
$q = $db->query($query);
for ($n = 0; $n < $q->rows(); $n++) {
$constituencies[] = $q->field($n, 'name');
}
}
}
if (count($constituencies) == 1) {
$constituency = $constituencies[0];
}
if ($constituency != '') {
// Got a match, display....
$MEMBER = new MEMBER(array('constituency' => $constituency));
$URL = new URL('mp');
if ($MEMBER->valid) {
$URL->insert(array('m' => $MEMBER->member_id()));
print '<h3>MP for ' . preg_replace("#{$searchterm}#i", '<span class="hi">$0</span>', $constituency);
if ($validpostcode) {
// Display the postcode the user searched for.
print ' (' . htmlentities(strtoupper($args['s'])) . ')';
}
?>
</h3>
<p><a href="<?php
echo $URL->generate();
?>
"><strong><?php
echo htmlentities($MEMBER->first_name()) . ' ' . htmlentities($MEMBER->last_name());
?>
</strong></a> (<?php
echo $MEMBER->party();
?>
)</p>
<?php
}
} elseif (count($constituencies)) {
print "<h3>MPs in constituencies matching '" . htmlentities($searchterm) . "'</h3><ul>";
foreach ($constituencies as $constituency) {
$MEMBER = new MEMBER(array('constituency' => $constituency));
$URL = new URL('mp');
if ($MEMBER->valid) {
$URL->insert(array('m' => $MEMBER->member_id()));
}
print '<li><a href="' . $URL->generate() . '"><strong>' . htmlentities($MEMBER->first_name()) . ' ' . htmlentities($MEMBER->last_name()) . '</strong></a> (' . preg_replace("#{$searchterm}#i", '<span class="hi">$0</span>', $constituency) . ', ' . $MEMBER->party() . ')</li>';
}
print '</ul>';
}
}