示例#1
0
文件: index.php 项目: leowmjw/twfy
function your_mp_bullet_point()
{
    global $THEUSER, $MPURL;
    print "<li>";
    $pc_form = true;
    if ($THEUSER->constituency_is_set()) {
        // (We don't allow the user to search for a postcode if they
        // already have one set in their prefs.)
        $MEMBER = new MEMBER(array('constituency' => $THEUSER->constituency()));
        if ($MEMBER->valid) {
            $pc_form = false;
            $CHANGEURL = new URL('userchangepc');
            $mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
            $former = "";
            $left_house = $MEMBER->left_house();
            if ($left_house[1]['date'] != '9999-12-31') {
                $former = 'former';
            }
            ?>
	<p><a href="<?php 
            echo $MPURL->generate();
            ?>
"><strong>Find out more about <?php 
            echo $mpname;
            ?>
, your <?php 
            echo $former;
            ?>
 Representative</strong></a>
	(<a href="<?php 
            echo $CHANGEURL->generate();
            ?>
">Change</a>)</p>
<?php 
        }
    }
    if ($pc_form) {
        ?>
		<form action="<?php 
        echo $MPURL->generate();
        ?>
" method="get">
		<p><strong>Find out more about your Representative</strong><br>
		<label for="pc">Enter your Australian postcode here:</label>&nbsp; <input type="text" name="pc" id="pc" size="8" maxlength="10" class="text">&nbsp;&nbsp;<input type="submit" value=" GO " class="submit"></p>
		</form>
	<?php 
    }
    print "</li>";
}
示例#2
0
文件: mobile.php 项目: leowmjw/twfy
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>';
    }
}
示例#3
0
文件: index.php 项目: palfrey/twfy
$MPURL = new URL('yourmp');
global $THEUSER;
$pc_form = true;
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
    // User is logged in and has a postcode, or not logged in with a cookied postcode.
    // (We don't allow the user to search for a postcode if they
    // already have one set in their prefs.)
    $MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode()));
    if ($MEMBER->valid) {
        $pc_form = false;
        if ($THEUSER->isloggedin()) {
            $CHANGEURL = new URL('useredit');
        } else {
            $CHANGEURL = new URL('userchangepc');
        }
        $mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
        $former = "";
        $left_house = $MEMBER->left_house();
        if ($left_house[1]['date'] != '9999-12-31') {
            $former = 'former';
        }
        ?>
 
        	<p><a href="<?php 
        echo $MPURL->generate();
        ?>
"><strong>Find out about <?php 
        echo $mpname;
        ?>
, your <?php 
        echo $former;
示例#4
0
function your_mp_bullet_point()
{
    global $THEUSER, $MPURL;
    print "<li>";
    $pc_form = true;
    if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
        // User is logged in and has a postcode, or not logged in with a cookied postcode.
        // (We don't allow the user to search for a postcode if they
        // already have one set in their prefs.)
        $MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode()));
        if ($MEMBER->valid) {
            $pc_form = false;
            if ($THEUSER->isloggedin()) {
                $CHANGEURL = new URL('useredit');
            } else {
                $CHANGEURL = new URL('userchangepc');
            }
            $mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
            $former = "";
            $left_house = $MEMBER->left_house();
            if ($left_house[1]['date'] != '9999-12-31') {
                $former = 'former';
            }
            ?>
	<p><a href="<?php 
            echo $MPURL->generate();
            ?>
"><strong>Find out more about <?php 
            echo $mpname;
            ?>
, your <?php 
            echo $former;
            ?>
 MP</strong></a><br>
	In <?php 
            echo strtoupper(htmlentities($THEUSER->postcode()));
            ?>
 (<a href="<?php 
            echo $CHANGEURL->generate();
            ?>
">Change your postcode</a>)</p>
<?php 
        }
    }
    if ($pc_form) {
        ?>
		<form action="<?php 
        echo $MPURL->generate();
        ?>
" method="get">
		<p><strong>Find out more about your Representative</strong><br>
		<label for="pc">Enter your Australian postcode here:</label>&nbsp; <input type="text" name="pc" id="pc" size="8" maxlength="10" value="<?php 
        echo htmlentities($THEUSER->postcode());
        ?>
" class="text">&nbsp;&nbsp;<input type="submit" value=" GO " class="submit"></p>
		</form>
	<?php 
        if (!defined("POSTCODE_SEARCH_DOMAIN") || !POSTCODE_SEARCH_DOMAIN) {
            print '<p align="right"><em>Postcodes are being mapped to a random Representative</em></p>';
        }
    }
    print "</li>";
}