示例#1
0
 public static function manage($email)
 {
     $db = new \ParlDB();
     $q = $db->query('SELECT * FROM alerts WHERE email = :email
         AND deleted != 1 ORDER BY created', array(':email' => $email));
     $out = '';
     for ($i = 0; $i < $q->rows(); ++$i) {
         $row = $q->row($i);
         $criteria = explode(' ', $row['criteria']);
         $ccc = array();
         $current = true;
         foreach ($criteria as $c) {
             if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
                 $MEMBER = new \MEMBER(array('person_id' => $m[1]));
                 $ccc[] = 'spoken by ' . $MEMBER->full_name();
                 if (!$MEMBER->current_member_anywhere()) {
                     $current = false;
                 }
             } else {
                 $ccc[] = $c;
             }
         }
         $criteria = join(' ', $ccc);
         $token = $row['alert_id'] . '-' . $row['registrationtoken'];
         $action = '<form action="/alert/" method="post"><input type="hidden" name="t" value="' . $token . '">';
         if (!$row['confirmed']) {
             $action .= '<input type="submit" name="action" value="Confirm">';
         } elseif ($row['deleted'] == 2) {
             $action .= '<input type="submit" name="action" value="Resume">';
         } else {
             $action .= '<input type="submit" name="action" value="Suspend"> <input type="submit" name="action" value="Delete">';
         }
         $action .= '</form>';
         $out .= '<tr><td>' . $criteria . '</td><td align="center">' . $action . '</td></tr>';
         if (!$current) {
             $out .= '<tr><td colspan="2"><small>&nbsp;&mdash; <em>not a current member of any body covered by TheyWorkForYou</em></small></td></tr>';
         }
     }
     if ($out) {
         print '<table cellpadding="3" cellspacing="0"><tr><th>Criteria</th><th>Action</th></tr>' . $out . '</table>';
     } else {
         print '<p>You currently have no email alerts set up.</p>';
     }
 }
示例#2
0
 public static function meta($e)
 {
     $private = false;
     if ($e['committee_name']) {
         $title = $e['committee_name'];
         if ($e['title'] == 'to consider the Bill') {
         } elseif ($e['title'] && $e['title'] != 'This is a private meeting.') {
             $title .= ': ' . $e['title'];
         } else {
             $private = true;
         }
     } else {
         $title = $e['title'];
         if ($pid = $e['person_id']) {
             $MEMBER = new \MEMBER(array('person_id' => $pid));
             $name = $MEMBER->full_name();
             $title .= " &#8211; <a href='/mp/?p={$pid}'>{$name}</a>";
         }
     }
     $meta = array();
     if ($d = $e['debate_type']) {
         if ($d == 'Adjournment') {
             $d = 'Adjournment debate';
         }
         $meta[] = $d;
     }
     if ($e['time_start'] || $e['location']) {
         if ($e['time_start']) {
             $time = format_time($e['time_start'], TIMEFORMAT);
             if ($e['time_end']) {
                 $time .= ' &#8211; ' . format_time($e['time_end'], TIMEFORMAT);
             }
             $meta[] = $time;
         }
         if ($e['location']) {
             $meta[] = $e['location'];
         }
     }
     if ($private) {
         $meta[] = 'Private meeting';
     }
     return array($title, $meta);
 }
示例#3
0
function add_alert($details)
{
    global $ALERT, $PAGE, $THEUSER, $this_page;
    $extra = null;
    // Instantiate an instance of ALERT
    $ALERT = new ALERT();
    $external_auth = auth_verify_with_shared_secret($details['email'], OPTION_AUTH_SHARED_SECRET, get_http_var('sign'));
    if ($external_auth) {
        $site = get_http_var('site');
        $extra = 'from_' . $site . '=1';
        $confirm = false;
    } elseif ($THEUSER->loggedin()) {
        $confirm = false;
    } else {
        $confirm = true;
    }
    // If this goes well, the alert will be added to the database and a confirmation email
    // will be sent to them.
    $success = $ALERT->add($details, $confirm);
    // Display results message on blank page for both success and failure
    $this_page = 'alertwelcome';
    $URL = new URL('alertwelcome');
    $backlink = $URL->generate();
    $PAGE->page_start();
    $PAGE->stripe_start();
    $advert = false;
    if ($success > 0 && !$confirm) {
        if ($details['pid']) {
            $MEMBER = new MEMBER(array('person_id' => $details['pid']));
            $criteria = $MEMBER->full_name();
            if ($details['keyword']) {
                $criteria .= ' mentions \'' . $details['keyword'] . '\'';
            } else {
                $criteria .= ' contributes';
            }
        } elseif ($details['keyword']) {
            $criteria = '\'' . $details['keyword'] . '\' is mentioned';
        }
        $message = array('title' => 'Your alert has been added', 'text' => 'You will now receive email alerts on any day when ' . $criteria . ' in parliament.');
        $advert = true;
    } elseif ($success > 0) {
        $message = array('title' => "We're nearly done...", 'text' => "You should receive an email shortly which will contain a link. You will need to follow that link to confirm your email address to receive the alert. Thanks.");
    } elseif ($success == -2) {
        $message = array('title' => 'You already have this alert', 'text' => 'You already appear to be subscribed to this email alert, so we have not signed you up to it again.');
        $advert = true;
    } else {
        $message = array('title' => "This alert has not been accepted", 'text' => "Sorry, we were unable to create this alert. Please <a href=\"mailto:" . CONTACTEMAIL . "\">let us know</a>. Thanks.");
    }
    $PAGE->message($message);
    if ($advert) {
        $advert_shown = alert_confirmation_advert($details);
        if ($extra) {
            $extra .= "; ";
        }
        $extra .= "advert={$advert_shown}";
    }
    $PAGE->stripe_end();
    $PAGE->page_end($extra);
}
 public function SEARCHENGINE($query)
 {
     if (!defined('XAPIANDB') || !XAPIANDB) {
         return null;
     }
     global $xapiandb, $PAGE, $hansardmajors, $parties;
     if (!$xapiandb) {
         if (strstr(XAPIANDB, ":")) {
             //ini_set('display_errors', 'On');
             list($xapian_host, $xapian_port) = explode(":", XAPIANDB);
             twfy_debug("SEARCH", "Using Xapian remote backend: " . $xapian_host . " port " . $xapian_port);
             $xapiandb_remote = remote_open($xapian_host, intval($xapian_port));
             $xapiandb = new XapianDatabase($xapiandb_remote);
         } else {
             $xapiandb = new XapianDatabase(XAPIANDB);
         }
     }
     $this->query = $query;
     if (!isset($this->stemmer)) {
         $this->stemmer = new XapianStem('english');
     }
     if (!isset($this->enquire)) {
         $this->enquire = new XapianEnquire($xapiandb);
     }
     if (!isset($this->queryparser)) {
         $this->queryparser = new XapianQueryParser();
         $this->datevaluerange = new XapianDateValueRangeProcessor(1);
         $this->queryparser->set_stemmer($this->stemmer);
         $this->queryparser->set_stemming_strategy(XapianQueryParser::STEM_SOME);
         $this->queryparser->set_database($xapiandb);
         $this->queryparser->set_default_op(Query_OP_AND);
         $this->queryparser->add_boolean_prefix('speaker', 'S');
         $this->queryparser->add_boolean_prefix('major', 'M');
         $this->queryparser->add_boolean_prefix('date', 'D');
         $this->queryparser->add_boolean_prefix('batch', 'B');
         $this->queryparser->add_boolean_prefix('segment', 'U');
         $this->queryparser->add_boolean_prefix('department', 'G');
         $this->queryparser->add_boolean_prefix('party', 'P');
         $this->queryparser->add_boolean_prefix('column', 'C');
         $this->queryparser->add_boolean_prefix('gid', 'Q');
         $this->queryparser->add_valuerangeprocessor($this->datevaluerange);
     }
     # Force words to lower case
     $this->query = preg_replace('#(department|party):.+?\\b#ie', 'strtolower("$0")', $this->query);
     // Any characters other than this are treated as, basically, white space
     // (apart from quotes and minuses, special case below)
     // The colon is in here for prefixes speaker:10043 and so on.
     $this->wordchars = "A-Za-z0-9,.'&:_À-ÿ";
     $this->wordcharsnodigit = "A-Za-z0-9'&_À-ÿ";
     // An array of normal words.
     $this->words = array();
     // All quoted phrases, as an (array of (arrays of words in each phrase)).
     $this->phrases = array();
     // Items prefixed with a colon (speaker:10024) as an (array of (name, value))
     $this->prefixed = array();
     // Split words up into individual words, and quoted phrases
     preg_match_all('/(' . '"|' . '(?:(?<![' . $this->wordchars . '])-)?' . '[' . $this->wordchars . ']+' . ')/', $this->query, $all_words);
     if ($all_words) {
         $all_words = $all_words[0];
     } else {
         $all_words = array();
     }
     $in_quote = false;
     $from = '';
     $to = '';
     foreach ($all_words as $word) {
         if ($word == '"') {
             $in_quote = !$in_quote;
             if ($in_quote) {
                 array_push($this->phrases, array());
             }
             if (!$in_quote && !count($this->phrases[count($this->phrases) - 1])) {
                 array_pop($this->phrases);
             }
             continue;
         }
         if ($word == '') {
             continue;
         }
         if (strpos($word, ':') !== false) {
             $items = explode(":", strtolower($word));
             $type = $items[0];
             if (substr($type, 0, 1) == '-') {
                 $type = substr($type, 1);
             }
             $value = strtolower(join(":", array_slice($items, 1)));
             if ($type == 'section') {
                 $newv = $value;
                 if ($value == 'debates' || $value == 'debate') {
                     $newv = 1;
                 } elseif ($value == 'whall' || $value == 'westminster' || $value == 'westminhall') {
                     $newv = 2;
                 } elseif ($value == 'wrans' || $value == 'wran') {
                     $newv = 3;
                 } elseif ($value == 'wms' || $value == 'statements' || $value == 'statement') {
                     $newv = 4;
                 } elseif ($value == 'lordsdebates' || $value == 'lords') {
                     $newv = 101;
                 } elseif ($value == 'ni' || $value == 'nidebates') {
                     $newv = 5;
                 } elseif ($value == 'pbc' || $value == 'standing') {
                     $newv = 6;
                 } elseif ($value == 'sp') {
                     $newv = 7;
                 } elseif ($value == 'spwrans' || $value == 'spwran') {
                     $newv = 8;
                 } elseif ($value == 'uk') {
                     $newv = array(1, 2, 3, 4, 6, 101);
                 } elseif ($value == 'scotland') {
                     $newv = array(7, 8);
                 } elseif ($value == 'future') {
                     $newv = 'F';
                 }
                 if (is_array($newv)) {
                     $newv = 'major:' . join(' major:', $newv);
                 } else {
                     $newv = "major:{$newv}";
                 }
                 $this->query = str_ireplace("{$type}:{$value}", $newv, $this->query);
             } elseif ($type == 'groupby') {
                 $newv = $value;
                 if ($value == 'debates' || $value == 'debate') {
                     $newv = 'debate';
                 }
                 if ($value == 'speech' || $value == 'speeches') {
                     $newv = 'speech';
                 }
                 $this->query = str_ireplace("{$type}:{$value}", '', $this->query);
                 array_push($this->prefixed, array($type, $newv));
             } elseif ($type == 'from') {
                 $from = $value;
             } elseif ($type == 'to') {
                 $to = $value;
             }
         } elseif (strpos($word, '-') !== false) {
         } elseif ($in_quote) {
             array_push($this->phrases[count($this->phrases) - 1], strtolower($word));
         } elseif (strpos($word, '..') !== false) {
         } elseif ($word == 'OR' || $word == 'AND' || $word == 'XOR' || $word == 'NEAR') {
         } else {
             array_push($this->words, strtolower($word));
         }
     }
     if ($from && $to) {
         $this->query = str_ireplace("from:{$from}", '', $this->query);
         $this->query = str_ireplace("to:{$to}", '', $this->query);
         $this->query .= " {$from}..{$to}";
     } elseif ($from) {
         $this->query = str_ireplace("from:{$from}", '', $this->query);
         $this->query .= " {$from}.." . date('Ymd');
     } elseif ($to) {
         $this->query = str_ireplace("to:{$to}", '', $this->query);
         $this->query .= " 19990101..{$to}";
     }
     # Merged people
     $db = new ParlDB();
     $merged = $db->query('SELECT * FROM gidredirect WHERE gid_from LIKE :gid_from', array(':gid_from' => "uk.org.publicwhip/person/%"));
     for ($n = 0; $n < $merged->rows(); $n++) {
         $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from'));
         $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to'));
         $this->query = preg_replace("#speaker:({$from_id}|{$to_id})#i", "(speaker:{$from_id} OR speaker:{$to_id})", $this->query);
     }
     twfy_debug("SEARCH", "prefixed: " . var_export($this->prefixed, true));
     twfy_debug("SEARCH", "query -- " . $this->query);
     $flags = XapianQueryParser::FLAG_BOOLEAN | XapianQueryParser::FLAG_LOVEHATE | XapianQueryParser::FLAG_WILDCARD | XapianQueryParser::FLAG_SPELLING_CORRECTION;
     $flags = $flags | XapianQueryParser::FLAG_PHRASE;
     try {
         $query = $this->queryparser->parse_query($this->query, $flags);
     } catch (Exception $e) {
         # Nothing we can really do with a bad query
         $this->error = _htmlspecialchars($e->getMessage());
         return null;
     }
     $this->enquire->set_query($query);
     # Now parse the parsed query back into a query string, yummy
     $qd = $query->get_description();
     twfy_debug("SEARCH", "queryparser original description -- " . $qd);
     $qd = substr($qd, 14, -1);
     # Strip Xapian::Query()
     $qd = preg_replace('#:\\(.*?\\)#', '', $qd);
     # Don't need pos or weight
     # Date range
     $qd = preg_replace('#VALUE_RANGE 1 (\\d+) (\\d+)#e', 'preg_replace("#(\\d{4})(\\d\\d)(\\d\\d)#", "\\$3/\\$2/\\$1", $1)
         . ".." . preg_replace("#(\\d{4})(\\d\\d)(\\d\\d)#", "\\$3/\\$2/\\$1", $2)', $qd);
     # Replace phrases with the phrase in quotes
     preg_match_all('#\\(([^(]*? PHRASE [^(]*?)\\)#', $qd, $m);
     foreach ($m[1] as $phrase) {
         $phrase_new = preg_replace('# PHRASE \\d+#', '', $phrase);
         #$this->phrases[] = preg_split('#\s+#', $phrase_new);
         $qd = str_replace("({$phrase})", '"' . $phrase_new . '"', $qd);
     }
     preg_match_all('#\\(([^(]*? NEAR [^(]*?)\\)#', $qd, $m);
     foreach ($m[1] as $mm) {
         $mmn = preg_replace('# NEAR \\d+ #', ' NEAR ', $mm);
         $qd = str_replace("({$mm})", "({$mmn})", $qd);
     }
     # Awesome regexes to get rid of superfluous matching brackets
     $qd = preg_replace('/( \\( ( (?: (?>[^ ()]+) | (?1) ) (?: [ ](?:AND|OR|XOR|FILTER|NEAR[ ]\\d+|PHRASE[ ]\\d+)[ ] (?: (?>[^ ()]+) | (?1) ) )*  ) \\) ) [ ] (FILTER|AND_NOT)/x', '$2 $3', $qd);
     $qd = preg_replace('/(?:FILTER | 0 [ ] \\* ) [ ] ( \\( ( (?: (?>[^ ()]+) | (?1) ) (?: [ ](?:AND|OR|XOR)[ ] (?: (?>[^ ()]+) | (?1) ) )*  ) \\) )/x', '$2', $qd);
     $qd = preg_replace('/(?:FILTER | 0 [ ] \\* ) [ ] ( [^()] )/x', '$1', $qd);
     $qd = str_replace('AND ', '', $qd);
     # AND is the default
     $qd = preg_replace('/^ ( \\( ( (?: (?>[^()]+) | (?1) )* ) \\) ) $/x', '$2', $qd);
     # Other prefixes
     $qd = preg_replace('#\\bU(\\d+)\\b#', 'segment:$1', $qd);
     $qd = preg_replace('#\\bC(\\d+)\\b#', 'column:$1', $qd);
     $qd = preg_replace('#\\bQ(.*?)\\b#', 'gid:$1', $qd);
     $qd = preg_replace('#\\bP(.*?)\\b#e', '"party:" . (isset($parties[ucfirst("$1")]) ? $parties[ucfirst("$1")] : "$1")', $qd);
     $qd = preg_replace('#\\bD(.*?)\\b#', 'date:$1', $qd);
     $qd = preg_replace('#\\bG(.*?)\\b#', 'department:$1', $qd);
     # XXX Lookup to show proper name of dept
     if (strstr($qd, 'M1 OR M2 OR M3 OR M4 OR M6 OR M101')) {
         $qd = str_replace('M1 OR M2 OR M3 OR M4 OR M6 OR M101', 'section:uk', $qd);
     } elseif (strstr($qd, 'M7 OR M8')) {
         $qd = str_replace('M7 OR M8', 'section:scotland', $qd);
     }
     $qd = preg_replace('#\\bM(\\d+)\\b#e', '"in the \'" . (isset($hansardmajors[$1]["title"]) ? $hansardmajors[$1]["title"] . "\'" : "$1")', $qd);
     $qd = preg_replace('#\\bMF\\b#', 'in Future Business', $qd);
     # Replace stemmed things with their unstemmed terms from the query
     $used = array();
     preg_match_all('#Z[^\\s()]+#', $qd, $m);
     foreach ($m[0] as $mm) {
         $iter = $this->queryparser->unstem_begin($mm);
         $end = $this->queryparser->unstem_end($mm);
         while (!$iter->equals($end)) {
             $tt = $iter->get_term();
             if (!in_array($tt, $used)) {
                 break;
             }
             $iter->next();
         }
         $used[] = $tt;
         $qd = preg_replace('#' . preg_quote($mm, '#') . '#', $tt, $qd, 1);
     }
     # Speakers
     for ($n = 0; $n < $merged->rows(); $n++) {
         $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from'));
         $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to'));
         $qd = str_replace("(S{$from_id} OR S{$to_id})", "S{$to_id}", $qd);
         $qd = str_replace("S{$from_id} OR S{$to_id}", "S{$to_id}", $qd);
     }
     preg_match_all('#S(\\d+)#', $qd, $m);
     foreach ($m[1] as $mm) {
         $member = new MEMBER(array('person_id' => $mm));
         $name = iconv('iso-8859-1', 'utf-8//TRANSLIT', $member->full_name());
         # Names are currently in ISO-8859-1
         $qd = str_replace("S{$mm}", "speaker:{$name}", $qd);
     }
     # Simplify display of excluded words
     $qd = preg_replace('#AND_NOT ([a-z0-9"]+)#', '-$1', $qd);
     preg_match_all('#AND_NOT \\((.*?)\\)#', $qd, $m);
     foreach ($m[1] as $mm) {
         $mmn = '-' . join(' -', explode(' OR ', $mm));
         $qd = str_replace("AND_NOT ({$mm})", $mmn, $qd);
     }
     foreach ($this->prefixed as $items) {
         if ($items[0] == 'groupby') {
             if ($items[1] == 'debate') {
                 $qd .= ' grouped by debate';
             } elseif ($items[1] == 'speech') {
                 $qd .= ' showing all speeches';
             } else {
                 $PAGE->error_message("Unknown group by '{$items['1']}' ignored");
             }
         }
     }
     $qd = iconv('utf-8', 'iso-8859-1//TRANSLIT', $qd);
     # Xapian is UTF-8, site is ISO8859-1
     $this->query_desc = trim($qd);
     #print 'DEBUG: ' . $query->get_description();
     twfy_debug("SEARCH", "words: " . var_export($this->words, true));
     twfy_debug("SEARCH", "phrases: " . var_export($this->phrases, true));
     twfy_debug("SEARCH", "queryparser description -- " . $this->query_desc);
     $this->valid = true;
 }
示例#5
0
文件: index.php 项目: leowmjw/twfy
function display_form($details = array(), $errors = array())
{
    global $this_page, $ALERT, $PAGE, $THEUSER;
    $ACTIONURL = new URL($this_page);
    $ACTIONURL->reset();
    ?>

<p>This page allows you to request an email alert from OpenAustralia.org.</p>

<?php 
    if (!get_http_var('only')) {
        ?>
<ul>
<li>To receive an alert <strong>every time a particular person appears</strong>,
select their name from the drop-down list and
leave the word/phrase box blank.</li>

<li>To receive an alert <strong>every time a particular keyword or phrase appears</strong>,
select "Any Representative or Senator" from the drop-down list, and enter your search term in
the box underneath.  The results are selected using the same rules as for a
normal search (see the box to the right for help on setting your criteria).</li>

<li>You can also <strong>combine</strong> both types of criteria to be alerted
<strong>only</strong> when a particular person uses the keywords you have defined.
To do this, select the person from the drop-down list <em>and</em> enter the keyword(s) as
above.</li>
</ul>

<p>Please note that you should only enter one topic per alert - if you wish to receive alerts on more than one topic, or for more than one person, simply fill in this form as many times as you need.</p>
<?php 
    }
    ?>

	<form method="post" action="<?php 
    echo $ACTIONURL->generate();
    ?>
">
	
	<?php 
    if (!$THEUSER->loggedin()) {
        if (isset($errors["email"]) && (get_http_var('submitted') || get_http_var('only'))) {
            $PAGE->error_message($errors["email"]);
        }
        ?>
				<div class="row">
				<span class="label"><label for="email">Your email address:</label></span>
				<span class="formw"><input type="text" name="email" id="email" value="<?php 
        if (isset($details["email"])) {
            echo htmlentities($details["email"]);
        }
        ?>
" maxlength="255" size="30" class="form"></span>
				</div>
	<?php 
    }
    if (!get_http_var('only') || !$details['keyword']) {
        if (isset($errors['pid'])) {
            $PAGE->error_message($errors['pid']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="pid">Person you wish to receive alerts for:</label></span>
				<span class="formw"><?php 
        if (get_http_var('only') && $details['pid']) {
            $MEMBER = new MEMBER(array('person_id' => $details['pid']));
            print $MEMBER->full_name();
            print '<input type="hidden" name="pid" value="' . htmlspecialchars($details['pid']) . '">';
        } else {
            ?>
<select name="pid">
				<option value="Any">Any Representative or Senator</option>
				<?php 
            // Get a list of MPs/Lords for displaying in the form using the PEOPLE class
            $LIST = new PEOPLE();
            $args['order'] = 'last_name';
            if ($details['pid']) {
                $args['pid'] = $details['pid'];
            }
            $LIST->listoptions($args);
            ?>
				</select>
			<?php 
        }
        ?>
				</span>
				</div>
	<?php 
    }
    if (!get_http_var('only') || !$details['pid']) {
        if (isset($errors["keyword"])) {
            $PAGE->error_message($errors["keyword"]);
        }
        ?>
				<div class="row"> 
				<span class="label"><label for="keyword">Word or phrase you wish to receive alerts for:</label></span>
				<span class="formw"><input type="text" name="keyword" id="keyword" value="<?php 
        if ($details['keyword']) {
            echo htmlentities($details['keyword']);
        }
        ?>
" maxlength="255" size="30" class="form"></span>
				</div>
	<?php 
    }
    $submittext = "Request Email Alert";
    ?>
						
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="submit" class="submit" value="<?php 
    echo $submittext;
    ?>
"><!-- this space makes the submit button appear on Mac IE 5! --> </span>
				</div>
	<?php 
    if (!$THEUSER->loggedin()) {
        ?>
				<div class="row">
				If you join or log in, you won't need to confirm your email address for every alert you set.
				</div>
	<?php 
    }
    if (get_http_var('sign')) {
        echo '<input type="hidden" name="sign" value="' . htmlspecialchars(get_http_var('sign')) . '">';
    }
    if (get_http_var('site')) {
        echo '<input type="hidden" name="site" value="' . htmlspecialchars(get_http_var('site')) . '">';
    }
    // MJ OA-437 Recommendations
    if (get_http_var('r')) {
        echo '<input type="hidden" name="r" value="' . htmlspecialchars(get_http_var('r')) . '">';
    }
    echo '<input type="hidden" name="submitted" value="true"> </form>';
}
示例#6
0
文件: mprss.php 项目: palfrey/twfy
            }
            $date = $hdate . 'T' . $htime . '+00:00';
            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
            $entries .= "<item rdf:about=\"{$link}\">\n\t<title>{$title}</title>\n\t<link>{$link}</link>\n\t<description>{$description}</description>\n\t<content:encoded><![CDATA[{$contentencoded}]]></content:encoded>\n\t<dc:date>{$date}</dc:date>\n</item>\n";
        }
    }
    // Prepare the whole text of the RSS file.
    $rsstext = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
		
<channel rdf:about="http://' . DOMAIN . $mpurl . '">
<title>' . entities_to_numbers($MEMBER->full_name()) . '\'s recent appearances (TheyWorkForYou)</title>
<link>http://' . DOMAIN . $mpurl . '</link>
<description></description>
<dc:language>en-gb</dc:language>
<dc:creator>TheyWorkForYou.com, mprss.php script</dc:creator>
<dc:date>' . $datenow . '</dc:date>

<items>
<rdf:Seq>
' . $items . '</rdf:Seq>
</items>

</channel>

' . $entries . '
示例#7
0
 public function criteria_pretty($html = false)
 {
     $criteria = explode(' ', $this->criteria);
     $words = array();
     $spokenby = '';
     foreach ($criteria as $c) {
         if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
             $MEMBER = new MEMBER(array('person_id' => $m[1]));
             $spokenby = $MEMBER->full_name();
         } else {
             $words[] = $c;
         }
     }
     $criteria = '';
     if (count($words)) {
         $criteria .= ($html ? '<li>' : '* ') . 'Mentions of [' . join(' ', $words) . ']' . ($html ? '</li>' : '') . "\n";
     }
     if ($spokenby) {
         $criteria .= ($html ? '<li>' : '* ') . "Things by {$spokenby}" . ($html ? '</li>' : '') . "\n";
     }
     return $criteria;
 }
示例#8
0
function display_user($user_id = "")
{
    global $THEUSER, $PAGE, $DATA, $this_page, $who;
    // We're either going to be:
    //	Displaying the details of a user who's just been edited
    //		(their user_id will be in $user_id now).
    //	Viewing THEUSER's own data.
    //	Viewing someone else's data (their id will be in the GET string
    //		user_id variable).
    // We could do something cleverer so that if THEUSER has sufficient
    // privileges we display more data when they're viewing someone else's info
    // than what your average punter sees.
    // If $user_id is a user id, we've just edited that user's info.
    // FIRST: Work out whose info we're going to show.
    $edited = false;
    // Have we just edited someone's info?
    if (is_numeric($user_id) && $user_id == $THEUSER->user_id()) {
        // Display this user's just edited info.
        $display = "this user";
        $edited = true;
    } elseif (is_numeric($user_id)) {
        // Display someone else's just edited info.
        $display = "another user";
        $edited = true;
    } elseif (is_numeric(get_http_var("u"))) {
        // Display someone else's info.
        $user_id = get_http_var("u");
        $display = "another user";
    } elseif ($THEUSER->isloggedin()) {
        // Display this user's info.
        $display = "this user";
        $user_id = $THEUSER->user_id();
    } else {
        // Nothing to show!
        $URL = new URL('userlogin');
        $URL->insert(array('ret' => '/user/'));
        $loginurl = $URL->generate();
        header("Location: {$loginurl}");
        exit;
    }
    // SECOND: Get the data for whoever we're going to show.
    if ($display == "another user") {
        // Viewing someone else's info.
        $USER = new USER();
        $valid = $USER->init($user_id);
        if ($valid && $USER->confirmed() && !$USER->deleted()) {
            // Don't want to display unconfirmed or deleted users.
            $name = $USER->firstname() . " " . $USER->lastname();
            $url = $USER->url();
            if ($USER->emailpublic() == true) {
                $email = $USER->email();
            }
            $status = $USER->status();
            $registrationtime = $USER->registrationtime();
            // Change the page title to reflect whose info we're viewing.
            $DATA->set_page_metadata($this_page, "title", "{$name}");
        } else {
            // This user_id doesn't exist.
            $display = "none";
        }
    } elseif ($display == "this user") {
        // Display THEUSER's info.
        $name = $THEUSER->firstname() . " " . $THEUSER->lastname();
        $url = $THEUSER->url();
        if ($edited) {
            // We want to show all the info to the user.
            $email = $THEUSER->email();
            $emailpublic = $THEUSER->emailpublic() == true ? "Yes" : "No";
            $optin = $THEUSER->optin() == true ? "Yes" : "No";
            $postcode = $THEUSER->postcode();
        } else {
            // We're showing them how they're seen to other people.
            if ($THEUSER->emailpublic()) {
                $email = $THEUSER->email();
            }
            $registrationtime = $THEUSER->registrationtime();
            $status = $THEUSER->status();
        }
        // Change the page title to make it clear we're viewing THEUSER's
        // own info. Make them less worried about other people seeing some of the
        // info that shouldn't be public.
        $DATA->set_page_metadata($this_page, "title", "Your details");
    } else {
        // There's nothing to display!
    }
    // THIRD: Print out what we've got.
    $PAGE->page_start();
    if ($display != "none") {
        $PAGE->stripe_start();
        if (isset($registrationtime)) {
            // Make registration time more user-friendly.
            list($date, $time) = explode(' ', $registrationtime);
            $registrationtime = format_date($date, LONGDATEFORMAT);
        }
        if ($edited) {
            print "\t\t\t\t<p><strong>" . ucfirst($who) . " details have been updated:</strong></p>\n";
        }
        if ($this_page == 'userviewself' && !$edited) {
            $EDITURL = new URL('useredit');
            ?>
				<p><strong>This is how other people see you.</strong> <a href="<?php 
            echo $EDITURL->generate();
            ?>
">Edit your details</a>.</p>
<?php 
        }
        ?>
				<div class="row">
				<span class="label">Name</span>
				<span class="formw"><?php 
        if (substr($name, -3) == ' MP') {
            print '<a href="/mp/' . make_member_url(substr($name, 0, -3)) . '">';
        }
        echo htmlentities($name);
        if (substr($name, -3) == ' MP') {
            print '</a>';
        }
        ?>
</span>
				</div>

				<div class="row">
				<span class="label">Email</span>
				<span class="formw"><?php 
        if (isset($email)) {
            $escaped_email = str_replace('@', '&#64;', htmlentities($email));
            ?>
<a href="mailto:<?php 
            echo $escaped_email . "\">" . $escaped_email;
            ?>
</a><?php 
        } else {
            ?>
Not public<?php 
        }
        ?>
</span>
				</div>

<?php 
        if (isset($postcode)) {
            if ($postcode == '') {
                $postcode = 'none';
            }
            ?>
				<div class="row">&nbsp;<br>
				<span class="label">UK Postcode</span>
				<span class="formw"><?php 
            echo htmlentities($postcode);
            ?>
 <small>(not public)</small></span>
				</div>

<?php 
        }
        if (isset($url)) {
            if ($url == '') {
                $url = 'none';
            } else {
                $url = '<a href="' . htmlentities($url) . '">' . htmlentities($url) . '</a>';
            }
            ?>
				<div class="row">
				<span class="label">Website</span>
				<span class="formw"><?php 
            echo $url;
            ?>
</span>
				</div>

<?php 
        }
        if (isset($emailpublic)) {
            ?>
				<div class="row">&nbsp;<br>Let other people see your email address? <strong><?php 
            echo htmlentities($emailpublic);
            ?>
</strong></div>

<?php 
        }
        if (isset($optin)) {
            ?>
				<div class="row">Receive TheyWorkForYou.com emails? <strong><?php 
            echo htmlentities($optin);
            ?>
</strong></div>

<?php 
        }
        if (isset($status)) {
            ?>
				<div class="row">
				<span class="label">Status</span>
				<span class="formw"><?php 
            echo htmlentities($status);
            ?>
</span>
				</div>
<?php 
        }
        if (isset($registrationtime)) {
            ?>
				<div class="row">
				<span class="label">Joined</span>
				<span class="formw"><?php 
            echo htmlentities($registrationtime);
            ?>
</span>
				</div>
<?php 
        }
        if ($edited && $this_page == 'userviewself') {
            $EDITURL = new URL('useredit');
            $VIEWURL = new URL('userviewself');
            ?>
				<p>&nbsp;<br><a href="<?php 
            echo $EDITURL->generate();
            ?>
">Edit again</a> or <a href="<?php 
            echo $VIEWURL->generate();
            ?>
">see how others see you</a>.</p>
<?php 
        }
        $PAGE->stripe_end();
        # Email alerts
        if ($this_page == 'userviewself') {
            $PAGE->stripe_start();
            print '<h3>Your email alerts</h3>';
            $db = new ParlDB();
            $q = $db->query('SELECT * FROM alerts WHERE email = "' . mysql_escape_string($THEUSER->email()) . '" ORDER BY confirmed,deleted,alert_id');
            $out = '';
            for ($i = 0; $i < $q->rows(); ++$i) {
                $row = $q->row($i);
                $criteria = explode(' ', $row['criteria']);
                $ccc = array();
                foreach ($criteria as $c) {
                    if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
                        $MEMBER = new MEMBER(array('person_id' => $m[1]));
                        $ccc[] = 'spoken by ' . $MEMBER->full_name();
                    } else {
                        $ccc[] = $c;
                    }
                }
                $criteria = join(' ', $ccc);
                $token = $row['alert_id'] . '-' . $row['registrationtoken'];
                if (!$row['confirmed']) {
                    $action = '<a href="/A/' . $token . '">Confirm</a>';
                } elseif ($row['deleted']) {
                    $action = '<form action="/alert/undelete/" method="post"><input type="hidden" name="t" value="' . $token . '"><input type="submit" value="Undelete"></form>';
                } else {
                    $action = '<form action="/alert/delete/" method="post"><input type="hidden" name="t" value="' . $token . '"><input type="submit" value="Delete"></form>';
                }
                $out .= '<tr><td>' . $criteria . '</td><td>' . $action . '</td></tr>';
            }
            print '<p>To add a new alert, simply visit an MP or Peer\'s page or conduct a search &#8212; to be given the option of turning them into alerts automatically &#8212; or visit <a href="/alert/">the manual addition page</a>.</p>';
            if ($out) {
                print '<p>Here are your email alerts:</p>';
                print '<table cellpadding="3" cellspacing="0"><tr><th>Criteria</th><th>Action</th></tr>' . $out . '</table>';
            } else {
                print '<p>You currently have no email alerts set up.</p>';
            }
            $PAGE->stripe_end();
        }
        if (!$edited) {
            $args = array('user_id' => $user_id, 'page' => get_http_var('p'));
            $COMMENTLIST = new COMMENTLIST();
            $COMMENTLIST->display('user', $args);
        }
    } else {
        $message = array('title' => 'Sorry...', 'text' => "We don't have a user ID, so we can't show you anyone's details.");
        $PAGE->message($message);
    }
    $PAGE->page_end();
}
示例#9
0
文件: page.php 项目: archoo/twfy
    function search_form($value = '')
    {
        global $SEARCHENGINE;
        // Search box on the search page.
        // If $value is set then it will be displayed in the form.
        // Otherwise the value of 's' in the URL will be displayed.
        $wtt = get_http_var('wtt');
        $URL = new URL('search');
        $URL->reset();
        // no need to pass any query params as a form action. They are not used.
        if ($value == '') {
            $value = get_http_var('s');
        }
        echo '<div class="mainsearchbox">';
        if ($wtt < 2) {
            echo '<form action="', $URL->generate(), '" method="get">';
            if (get_http_var('o')) {
                echo '<input type="hidden" name="o" value="', htmlentities(get_http_var('o')), '">';
            }
            if (get_http_var('house')) {
                echo '<input type="hidden" name="house" value="', htmlentities(get_http_var('house')), '">';
            }
            echo '<input type="text" name="s" value="', htmlentities($value), '" size="20"> ';
            echo '<input type="submit" value=" ', $wtt ? 'Modify search' : 'Search', ' "><br>';
            if ($wtt) {
                print '<input type="hidden" name="wtt" value="1">';
            }
        } else {
            ?>
	<form action="http://www.writetothem.com/lords" method="get">
	<input type="hidden" name="pid" value="<?php 
            echo htmlentities(get_http_var('pid'));
            ?>
">
	<input type="submit" style="font-size: 150%" value=" I want to write to this Lord "><br>
<?php 
        }
        if (!$wtt) {
            echo '<div style="margin-top: 5px">';
            $orderUrl = new URL('search');
            $ordering = get_http_var('o');
            if ($ordering != 'r' && $ordering != 'd' && $ordering != 'p') {
                $ordering = 'd';
            }
            if ($ordering == 'r') {
                print '<strong>Most relevant results are first</strong>';
            } else {
                printf("<a href='%s'>Show most relevant results first</a>", $orderUrl->generate('html', array('o' => 'r')));
            }
            print "&nbsp;|&nbsp;";
            if ($ordering == 'd') {
                print '<strong>Most recent results are first</strong>';
            } else {
                printf("<a href='%s'>Show most recent results first</a>", $orderUrl->generate('html', array('o' => 'd')));
            }
            print "&nbsp;|&nbsp;";
            if ($ordering == 'p') {
                print '<strong>Use by person</strong>';
            } else {
                printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o' => 'p')));
            }
            echo '</div>';
            $person_id = get_http_var('pid');
            if ($person_id != "") {
                $member = new MEMBER(array('person_id' => $person_id));
                if ($member->valid) {
                    $name = $member->full_name();
                    ?>
                    <p>
                    <input type="radio" name="pid" value="<?php 
                    echo htmlentities($person_id);
                    ?>
" checked>Search only <?php 
                    echo htmlentities($name);
                    ?>
 
                    <input type="radio" name="pid" value="">Search all speeches
                    </p>
                <?php 
                }
            }
        }
        echo '</form> </div>';
    }
示例#10
0
function find_constituency($args)
{
    // We see if the user is searching for a postcode or constituency.
    global $PAGE;
    if ($args['s'] != '') {
        $searchterm = $args['s'];
    } else {
        $PAGE->error_message('No search string');
        return false;
    }
    list($constituencies, $validpostcode) = search_constituencies_by_query($searchterm);
    $constituency = "";
    if (count($constituencies) == 1) {
        $constituency = $constituencies[0];
    }
    if ($constituency != '') {
        // Got a match, display....
        $MEMBER = new MEMBER(array('constituency' => $constituency, 'house' => 1));
        $URL = new URL('mp');
        if ($MEMBER->valid) {
            $URL->insert(array('p' => $MEMBER->person_id()));
            print '<h2>';
            if (!$MEMBER->current_member(1)) {
                print 'Former ';
            }
            print 'MP for ' . preg_replace('#' . preg_quote($searchterm, '#') . '#i', '<span class="hi">$0</span>', $constituency);
            if ($validpostcode) {
                // Display the postcode the user searched for.
                print ' (' . _htmlentities(strtoupper($args['s'])) . ')';
            }
            ?>
</h2>

            <p><a href="<?php 
            echo $URL->generate();
            ?>
"><strong><?php 
            echo $MEMBER->full_name();
            ?>
</strong></a> (<?php 
            echo $MEMBER->party_text();
            ?>
)</p>
    <?php 
        }
    } elseif (count($constituencies)) {
        $out = '';
        $heading = array();
        foreach ($constituencies as $constituency) {
            $MEMBER = new MEMBER(array('constituency' => $constituency, 'house' => 1));
            if ($MEMBER->valid) {
                if ($MEMBER->current_member(1)) {
                    $heading[] = 'MPs';
                } else {
                    $heading[] = 'Former MPs';
                }
                $URL = new URL('mp');
                $URL->insert(array('p' => $MEMBER->person_id()));
                $out .= '<li><a href="' . $URL->generate() . '"><strong>' . $MEMBER->full_name() . '</strong></a> (' . preg_replace('#' . preg_quote($searchterm, '#') . '#i', '<span class="hi">$0</span>', $constituency) . ', ' . $MEMBER->party() . ')</li>';
            }
        }
        print '<h2>';
        print join(" and ", array_unique($heading));
        print " in constituencies matching &lsquo;" . _htmlentities($searchterm) . "&rsquo;</h2>";
        print "<ul>{$out}</ul>";
    }
}
示例#11
0
    if (is_numeric(get_http_var('y'))) {
        $DATA->set_page_metadata($this_page, 'title', get_http_var('y'));
    }
    $PAGE->page_start();
    $PAGE->stripe_start();
    $args = array('year' => get_http_var('y'));
    $LIST = new WRANSLIST();
    $LIST->display('calendar', $args);
    $PAGE->stripe_end(array(array('type' => 'nextprev'), array('type' => 'include', 'content' => "wrans")));
} elseif (get_http_var('pid')) {
    $this_page = "wransmp";
    $args = array('person_id' => get_http_var('pid'), 'page' => get_http_var('p'));
    $MEMBER = new MEMBER(array('person_id' => $args['person_id']));
    if ($MEMBER->valid) {
        $pagetitle = $DATA->page_metadata($this_page, 'title');
        $DATA->set_page_metadata($this_page, 'title', $pagetitle . ' ' . $MEMBER->full_name());
    }
    $LIST = new WRANSLIST();
    $LIST->display('mp', $args);
} else {
    // No date or wrans id. Show recent days with wrans on.
    $this_page = "wransfront";
    $PAGE->page_start();
    $PAGE->stripe_start();
    ?>
	<h2>Some recent written answers</h2>
<?php 
    $WRANSLIST = new WRANSLIST();
    $WRANSLIST->display('recent_wrans', array('days' => 7, 'num' => 20));
    $PAGE->stripe_end(array(array('type' => 'nextprev'), array('type' => 'include', 'content' => 'calendar_wrans'), array('type' => 'include', 'content' => "wrans")));
}
示例#12
0
    public function search_form($value = '')
    {
        global $SEARCHENGINE;
        // Search box on the search page.
        // If $value is set then it will be displayed in the form.
        // Otherwise the value of 's' in the URL will be displayed.
        $wtt = get_http_var('wtt');
        $URL = new URL('search');
        $URL->reset();
        // no need to pass any query params as a form action. They are not used.
        if ($value == '') {
            if (get_http_var('q') !== '') {
                $value = get_http_var('q');
            } else {
                $value = get_http_var('s');
            }
        }
        $person_name = '';
        if (preg_match_all('#speaker:(\\d+)#', $value, $m) == 1) {
            $person_id = $m[1][0];
            $member = new MEMBER(array('person_id' => $person_id));
            if ($member->valid) {
                $value = str_replace("speaker:{$person_id}", '', $value);
                $person_name = $member->full_name();
            }
        }
        echo '<div class="mainsearchbox">';
        if ($wtt < 2) {
            echo '<form action="', $URL->generate(), '" method="get">';
            if (get_http_var('o')) {
                echo '<input type="hidden" name="o" value="', _htmlentities(get_http_var('o')), '">';
            }
            if (get_http_var('house')) {
                echo '<input type="hidden" name="house" value="', _htmlentities(get_http_var('house')), '">';
            }
            echo '<input type="text" name="q" value="', _htmlentities($value), '" size="50"> ';
            echo '<input type="submit" value=" ', $wtt ? 'Modify search' : 'Search', ' ">';
            $URL = new URL('search');
            $URL->insert(array('adv' => 1));
            echo '&nbsp;&nbsp; <a href="' . $URL->generate() . '">More&nbsp;options</a>';
            echo '<br>';
            if ($wtt) {
                print '<input type="hidden" name="wtt" value="1">';
            }
        } else {
            ?>
    <form action="http://www.writetothem.com/lords" method="get">
    <input type="hidden" name="pid" value="<?php 
            echo _htmlentities(get_http_var('pid'));
            ?>
">
    <input type="submit" style="font-size: 150%" value=" I want to write to this Lord "><br>
<?php 
        }
        if (!$wtt && ($value || $person_name)) {
            echo '<div style="margin-top: 5px">';
            $orderUrl = new URL('search');
            $orderUrl->insert(array('s' => $value));
            # Need the parsed value
            $ordering = get_http_var('o');
            if ($ordering != 'r' && $ordering != 'd' && $ordering != 'p' && $ordering != 'o') {
                $ordering = 'd';
            }
            if ($ordering == 'r') {
                print '<strong>Sorted by relevance</strong>';
            } else {
                printf("<a href='%s'>Sort by relevance</a>", $orderUrl->generate('html', array('o' => 'r')));
            }
            print "&nbsp;|&nbsp;";
            if ($ordering == 'd') {
                print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o' => 'o')) . '">oldest</a>';
            } elseif ($ordering == 'o') {
                print '<strong>Sorted by date:</strong> <a href="' . $orderUrl->generate('html', array('o' => 'd')) . '">newest</a> / <strong>oldest</strong>';
            } else {
                printf("Sort by date: <a href='%s'>newest</a> / <a href='%s'>oldest</a>", $orderUrl->generate('html', array('o' => 'd')), $orderUrl->generate('html', array('o' => 'o')));
            }
            print "&nbsp;|&nbsp;";
            if ($ordering == 'p') {
                print '<strong>Use by person</strong>';
            } else {
                printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o' => 'p')));
            }
            echo '</div>';
            if ($person_name) {
                ?>
                    <p>
                    <input type="radio" name="pid" value="<?php 
                echo _htmlentities($person_id);
                ?>
" checked>Search only <?php 
                echo _htmlentities($person_name);
                ?>
                    <input type="radio" name="pid" value="">Search all speeches
                    </p>
                <?php 
            }
        }
        echo '</form> </div>';
    }
示例#13
0
$tots = array();
$name = array();
for ($i = 0; $i < $q->rows(); $i++) {
    $c = $q->field($i, 'c');
    $criteria = $q->field($i, 'criteria');
    if (!preg_match('#^speaker:(\\d+)#', $criteria, $m)) {
        continue;
    }
    $person_id = $m[1];
    $MEMBER = new MEMBER(array('person_id' => $person_id));
    if ($MEMBER->valid) {
        if (!array_key_exists($person_id, $tots)) {
            $tots[$person_id] = 0;
        }
        $tots[$person_id] += $c;
        $name[$person_id] = $MEMBER->full_name();
    }
}
$q = $db->query('select count(*) as c, criteria from alerts where criteria like "speaker:%" and not confirmed group by criteria order by c desc');
$unconfirmed = array();
for ($i = 0; $i < $q->rows(); $i++) {
    $c = $q->field($i, 'c');
    $criteria = $q->field($i, 'criteria');
    if (!preg_match('#^speaker:(\\d+)#', $criteria, $m)) {
        continue;
    }
    $person_id = $m[1];
    if (isset($name[$person_id])) {
        if (!array_key_exists($person_id, $unconfirmed)) {
            $unconfirmed[$person_id] = 0;
        }
示例#14
0
文件: mprss.php 项目: leowmjw/twfy
            }
            $date = $hdate . 'T' . $htime . '+00:00';
            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
            $entries .= "<item rdf:about=\"{$link}\">\n\t<title>{$title}</title>\n\t<link>{$link}</link>\n\t<description>{$description}</description>\n\t<content:encoded><![CDATA[{$contentencoded}]]></content:encoded>\n\t<dc:date>{$date}</dc:date>\n</item>\n";
        }
    }
    // Prepare the whole text of the RSS file.
    $rsstext = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
		
<channel rdf:about="http://' . DOMAIN . $mpurl . '">
<title>' . entities_to_numbers($MEMBER->full_name()) . '\'s recent appearances (OpenAustralia.org)</title>
<link>http://' . DOMAIN . $mpurl . '</link>
<description></description>
<dc:language>en-gb</dc:language>
<dc:creator>OpenAustralia.org, mprss.php script</dc:creator>
<dc:date>' . $datenow . '</dc:date>

<items>
<rdf:Seq>
' . $items . '</rdf:Seq>
</items>

</channel>

' . $entries . '
示例#15
0
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 &ndash; are you sure this is what you want?
You cannot sign up to multiple search terms using a comma &ndash; 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 &ndash; 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>';
        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['pid'] && !$details['keyword']) {
        ?>

<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 term</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 &lsquo;horse&rsquo; would
also match &lsquo;horses&rsquo;).

<?php 
    }
    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">';
    if (!$details['pid'] && !$details['keyword'] || isset($errors['alertsearch'])) {
        if (isset($errors["alertsearch"])) {
            $PAGE->error_message($errors["alertsearch"]);
        }
        $text = $details['alertsearch'];
        if (!$text) {
            $text = $details['keyword'];
        }
        ?>

<div class="row">
<input type="text" name="alertsearch" id="alertsearch" value="<?php 
        if ($text) {
            echo _htmlentities($text);
        }
        ?>
" maxlength="255" size="30" style="font-size:150%">
</div>

<?php 
    }
    if ($details['pid']) {
        echo '<input type="hidden" name="pid" value="' . _htmlspecialchars($details['pid']) . '">';
    }
    if ($details['keyword']) {
        echo '<input type="hidden" name="keyword" value="' . _htmlspecialchars($details['keyword']) . '">';
    }
    if (!$details['email_verified']) {
        if (isset($errors["email"]) && $details['submitted']) {
            $PAGE->error_message($errors["email"]);
        }
        ?>
        <div class="row">
            <label for="email">Your email address:</label>
            <input type="text" name="email" id="email" value="<?php 
        if (isset($details["email"])) {
            echo _htmlentities($details["email"]);
        }
        ?>
" maxlength="255" size="30" class="form">
        </div>
<?php 
    }
    ?>

    <div class="row">
        <input type="submit" class="submit" value="<?php 
    echo $details['pid'] || $details['keyword'] ? 'Subscribe' : 'Search';
    ?>
">
    </div>

    <div class="row">
<?php 
    if (!$details['email_verified']) {
        ?>
        <p>If you <a href="/user/?pg=join">join</a> or <a href="/user/login/?ret=%2Falert%2F">sign in</a>, you won't need to confirm your email
        address for every alert you set.<br><br>
<?php 
    }
    if (!$details['pid'] && !$details['keyword']) {
        ?>
        <p>Please note that you should only enter <strong>one term per alert</strong> &ndash; if
        you wish to receive alerts on more than one thing, or for more than
        one person, simply fill in this form as many times as you need, or use boolean OR.<br><br></p>
        <p>For example, if you wish to receive alerts whenever the words
        <i>horse</i> or <i>pony</i> are mentioned in Parliament, please fill in
        this form once with the word <i>horse</i> and then again with the word
        <i>pony</i> (or you can put <i>horse OR pony</i> with the OR in capitals
        as explained on the right). Do not put <i>horse, pony</i> as that will only
        sign you up for alerts where <strong>both</strong> horse and pony are mentioned.</p>
<?php 
    }
    ?>
    </div>
<?php 
    if (get_http_var('sign')) {
        echo '<input type="hidden" name="sign" value="' . _htmlspecialchars(get_http_var('sign')) . '">';
    }
    if (get_http_var('site')) {
        echo '<input type="hidden" name="site" value="' . _htmlspecialchars(get_http_var('site')) . '">';
    }
    echo '</form>';
}
示例#16
0
 function query_description_internal($long)
 {
     global $PAGE, $hansardmajors;
     if (!defined('XAPIANDB') || !XAPIANDB) {
         return '';
     }
     $description = "";
     if (count($this->words) > 0) {
         if ($long and $description == "") {
             $description .= " containing";
         }
         $description .= " the " . make_plural("word", count($this->words));
         $description .= " '";
         if (count($this->words) > 2) {
             $description .= join("', '", array_slice($this->words, 0, -2));
             $description .= "', '";
             $description .= $this->words[count($this->words) - 2] . "', and '" . $this->words[count($this->words) - 1];
         } elseif (count($this->words) == 2) {
             $description .= $this->words[0] . "' and '" . $this->words[1];
         } else {
             $description .= $this->words[0];
         }
         $description .= "'";
     }
     if (count($this->phrases) > 0) {
         if ($description == "") {
             if ($long) {
                 $description .= " containing";
             }
         } else {
             $description .= " and";
         }
         $description .= " the " . make_plural("phrase", count($this->phrases)) . " ";
         $description .= join(', ', array_map(array($this, "make_phrase"), $this->phrases));
     }
     if (count($this->excluded) > 0) {
         if (count($this->words) > 0 or count($this->phrases) > 0) {
             $description .= " but not";
         } else {
             $description .= " excluding";
         }
         $description .= " the " . make_plural("word", count($this->excluded));
         $description .= " '" . join(' ', $this->excluded) . "'";
     }
     /*        if (count($this->rough) > 0) {
                 if ($description == "") {
                     if ($long) {
                         $description .= " containing ";
                     }
                 }
                 $description .= " roughly words '" . join(' ', $this->rough) . "'";
             } */
     $major = array();
     $speaker = array();
     foreach ($this->prefixed as $items) {
         if ($items[0] == 'speaker') {
             $member = new MEMBER(array('person_id' => $items[1]));
             $name = $member->full_name();
             $speaker[] = $name;
         } elseif ($items[0] == 'major') {
             if (isset($hansardmajors[$items[1]]['title'])) {
                 $major[] = $hansardmajors[$items[1]]['title'];
             } else {
                 $PAGE->error_message("Unknown major section '{$items['1']}' ignored");
             }
         } elseif ($items[0] == 'groupby') {
             if ($items[1] == 'day') {
                 $description .= ' grouped by day';
             } elseif ($items[1] == 'debate') {
                 $description .= ' grouped by debate/department';
             } elseif ($items[1] == 'speech') {
                 $description .= ' showing all speeches';
             } else {
                 $PAGE->error_message("Unknown group by '{$items['1']}' ignored");
             }
         } elseif ($items[0] == "bias") {
             list($weight, $halflife) = explode(":", $items[1]);
             $description .= " bias by {$weight} halflife {$halflife} seconds";
         } elseif ($items[0] == 'date') {
             $description .= ' spoken on ' . $items[1];
         } elseif ($items[0] == 'batch') {
             # silently ignore, as description goes in email alerts
             #$description .= ' in search batch ' . $items[1];
         } else {
             $PAGE->error_message("Unknown search prefix '{$items['0']}' ignored");
         }
     }
     if (sizeof($speaker)) {
         $description .= ' by ' . join(' or ', $speaker);
     }
     if (sizeof($major)) {
         $description .= ' in ' . join(' or ', $major);
     }
     return trim($description);
 }
示例#17
0
	function criteria_pretty($html = false) {
		$criteria = explode(' ',$this->criteria);
		$words = array(); $spokenby = '';
		foreach ($criteria as $c) {
			if (preg_match('#^speaker:(\d+)#',$c,$m)) {
				$MEMBER = new MEMBER(array('person_id'=>$m[1]));
				$spokenby = $MEMBER->full_name();
			} else {
				$words[] = $c;
			}
		}
		$criteria = '';
		if (count($words)) $criteria .= ($html?'<li>':'* ') . 'Containing the ' . make_plural('word', count($words)) . ': ' . join(' ', $words) . ($html?'</li>':'') . "\n";
		if ($spokenby) $criteria .= ($html?'<li>':'* ') . "Spoken by $spokenby" . ($html?'</li>':'') . "\n";
		return $criteria;
	}
示例#18
0
function find_constituency ($args) {
	// We see if the user is searching for a postcode or constituency.
	global $PAGE;

	if ($args['s'] != '') {
        $searchterm = $args['s'];
    } else {
        $PAGE->error_message('No search string');
        return false;
    }

    list ($constituencies, $validpostcode) = search_constituencies_by_query($searchterm);

    $constituency = "";
    if (count($constituencies)==1) {
        $constituency = $constituencies[0];
    }

	if ($constituency != '') {
		// Got a match, display....
			
		$MEMBER = new MEMBER(array('constituency'=>$constituency, 'house' => 1));
        $URL = new URL('mp');
        if ($MEMBER->valid) {
            $URL->insert(array('m'=>$MEMBER->member_id()));
            print '<h2>MP for ' . preg_replace('#' . preg_quote($searchterm, '#') . '#i', '<span class="hi">$0</span>', $constituency);
            if ($validpostcode) {
                // Display the postcode the user searched for.
                print ' (' . htmlentities(strtoupper($args['s'])) . ')';
            }
            ?></h2>
            
            <p><a href="<?php echo $URL->generate(); ?>"><strong><?php echo $MEMBER->full_name(); ?></strong></a> (<?php echo $MEMBER->party(); ?>)</p>
    <?php
        }

	} elseif (count($constituencies)) {
        print "<h2>MPs in constituencies matching '".htmlentities($searchterm)."'</h2><ul>";
        foreach ($constituencies as $constituency) {
            $MEMBER = new MEMBER(array('constituency'=>$constituency, 'house' => 1));
            $URL = new URL('mp');
            if ($MEMBER->valid) {
                $URL->insert(array('m'=>$MEMBER->member_id()));
            }
            print '<li><a href="'.$URL->generate().'"><strong>' . $MEMBER->full_name() .
                '</strong></a> (' . preg_replace('#' . preg_quote($searchterm, '#') . '#i', '<span class="hi">$0</span>', $constituency) .
                ', '.$MEMBER->party().')</li>';
        }
        print '</ul>';
    }
}
示例#19
0
文件: dat.php 项目: palfrey/twfy
# 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;
示例#20
0
文件: people.php 项目: alanl/twfy
 function listoptions($args)
 {
     global $THEUSER;
     $data = $this->_get_data_by_mps($args);
     if ($THEUSER->constituency_is_set()) {
         $MEMBER = new MEMBER(array('constituency' => $THEUSER->constituency()));
         print '<option value="' . $MEMBER->person_id() . '">Your Representative, ' . $MEMBER->full_name() . '</option>';
     }
     print '<optgroup label="Representatives">';
     $opik = array();
     foreach ($data['data'] as $row) {
         // Lembit Opik is special
         if ($row['last_name'] == '&Ouml;pik') {
             $opik = $row;
             continue;
         }
         if (count($opik) && strcmp('Opik', $row['last_name']) < 0) {
             print '<option value="' . $opik['person_id'] . '">' . $opik['first_name'] . ' ' . $opik['last_name'] . '</option>';
             $opik = array();
         }
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">' . $row['first_name'] . ' ' . $row['last_name'];
         print ', ' . $row['constituency'];
         print '</option>';
     }
     print '</optgroup> <optgroup label="Peers">';
     $data = $this->_get_data_by_peers($args);
     foreach ($data['data'] as $row) {
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">';
         print ucfirst(member_full_name(2, $row['title'], $row['first_name'], $row['last_name'], $row['constituency']));
         print '</option>';
     }
     print '</optgroup> <optgroup label="MLAs">';
     $data = $this->_get_data_by_mlas($args);
     foreach ($data['data'] as $row) {
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">';
         print ucfirst(member_full_name(3, $row['title'], $row['first_name'], $row['last_name'], $row['constituency']));
         print '</option>';
     }
     print '</optgroup>';
 }
示例#21
0
文件: mprss.php 项目: NathanaelB/twfy
            }
            $date = $hdate . 'T' . $htime . '+00:00';
            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
            $entries .= "<item rdf:about=\"{$link}\">\n\t<title>{$title}</title>\n\t<link>{$link}</link>\n\t<description>{$description}</description>\n\t<content:encoded><![CDATA[{$contentencoded}]]></content:encoded>\n\t<dc:date>{$date}</dc:date>\n</item>\n";
        }
    }
    // Prepare the whole text of the RSS file.
    $rsstext = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
		
<channel rdf:about="http://' . DOMAIN . $mpurl . '">
<title>' . str_replace('&Ouml;', 'O', $MEMBER->full_name()) . '\'s Recent Appearances (OpenAustralia.org)</title>
<link>http://' . DOMAIN . $mpurl . '</link>
<description></description>
<dc:language>en-gb</dc:language>
<dc:creator>OpenAustralia.org, mprss.php script</dc:creator>
<dc:date>' . $datenow . '</dc:date>

<items>
<rdf:Seq>
' . $items . '</rdf:Seq>
</items>

</channel>

' . $entries . '
示例#22
0
 function listoptions($args)
 {
     global $THEUSER;
     $data = $this->_get_data_by_mps($args);
     if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
         $MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode()));
         print '<option value="' . $MEMBER->person_id() . '">Your MP, ' . $MEMBER->full_name() . '</option>';
     }
     print '<optgroup label="MPs">';
     foreach ($data['data'] as $row) {
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">' . $row['first_name'] . ' ' . $row['last_name'];
         print ', ' . $row['constituency'];
         print '</option>';
     }
     print '</optgroup> <optgroup label="Peers">';
     $data = $this->_get_data_by_peers($args);
     foreach ($data['data'] as $row) {
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">';
         print ucfirst(member_full_name(2, $row['title'], $row['first_name'], $row['last_name'], $row['constituency']));
         print '</option>';
     }
     print '</optgroup> <optgroup label="MLAs">';
     $data = $this->_get_data_by_mlas($args);
     foreach ($data['data'] as $row) {
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">';
         print ucfirst(member_full_name(3, $row['title'], $row['first_name'], $row['last_name'], $row['constituency']));
         print '</option>';
     }
     print '</optgroup> <optgroup label="MSPs">';
     $data = $this->_get_data_by_msps($args);
     foreach ($data['data'] as $row) {
         print '<option';
         if (isset($args['pid']) && $args['pid'] == $row['person_id']) {
             print ' selected';
         }
         print ' value="' . $row['person_id'] . '">';
         print ucfirst(member_full_name(4, $row['title'], $row['first_name'], $row['last_name'], $row['constituency']));
         print '</option>';
     }
     print '</optgroup>';
 }
         $constituency = postcode_to_constituency($pc);
     } else {
         $constituency = $cconstituency;
     }
     if ($constituency == "connection_timed_out") {
         $errors['pcerr'] = "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['pcerr'] = "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)) {
         # @@JR
         # Collect the member names and email addresses
         foreach ($constituency as $c) {
             $member = new MEMBER(array('constituency' => $c));
             $member_email = $member->email();
             $members[$member_email] = $member->full_name();
         }
     } else {
         $member = new MEMBER(array('constituency' => $constituency));
         $member_email = makeMemberEmail($member);
         $members[$member_email] = $member->full_name();
     }
 } else {
     $errors['pcerr'] = "Sorry, " . htmlentities($pc) . " isn't a valid postcode";
     twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
 }
 if (sizeof($errors) > 0) {
     echo $jsonp_callback . '(' . json_encode($errors) . ')';
 } else {
     echo $jsonp_callback . '(' . json_encode($members) . ')';
 }
示例#24
0
    ?>
" size="30">
<br><label for="sendname">Your name:</label> <input type="text" id="sendname" name="sender_name" value="<?php 
    echo $sender_name;
    ?>
" size="30">
<input type="hidden" name="pid" value="<?php 
    echo $pid;
    ?>
">
<br>(<a href="/privacy/">privacy policy</a>)
<input type="submit" class="submit" value="Send"></p>
</form>
<?php 
} else {
    $rep_name = $MEMBER->full_name();
    if ($MEMBER->house_disp == 1) {
        $rep_name .= ' MP';
    } elseif ($MEMBER->house_disp == 3) {
        $rep_name .= ' MLA';
    }
    $data = array('template' => 'email_a_friend', 'to' => $recipient_email, 'subject' => 'Find out all about ' . $rep_name);
    $url = $MEMBER->url();
    $merge = array('NAME' => $sender_name, 'EMAIL' => $sender_email, 'REP_NAME' => $rep_name, 'REP_URL' => $url);
    $success = send_template_email($data, $merge);
    if ($success) {
        print "<p>Your email has been sent successfully. Thank you for using TheyWorkForYou.</p> <p><a href=\"{$url}\">Return to " . $MEMBER->full_name() . "'s page</a></p>";
    } else {
        print "<p>Sorry, something went wrong trying to send an email. Please wait a few minutes and try again.</p>";
    }
}
示例#25
0
文件: mobile.php 项目: leowmjw/twfy
            $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);
示例#26
0
function find_constituency ($args) {
	// We see if the user is searching for a postcode or constituency.
	global $PAGE;

	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?
		$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
                    (select name from constituency where cons_id = o.cons_id and main_name) as name 
                from constituency AS o where name like '%" . mysql_real_escape_string($try) . "%'
                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');
            }
        }
	}

    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('#' . preg_quote($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 $MEMBER->full_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>' . $MEMBER->full_name() .
                '</strong></a> (' . preg_replace('#' . preg_quote($searchterm, '#') . '#i', '<span class="hi">$0</span>', $constituency) .
                ', '.$MEMBER->party().')</li>';
        }
        print '</ul>';
    }
}
示例#27
0
            }
            $date = $hdate . 'T' . $htime . '+00:00';
            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
            $entries .= "<item rdf:about=\"{$link}\">\n\t<title>{$title}</title>\n\t<link>{$link}</link>\n\t<description>{$description}</description>\n\t<content:encoded><![CDATA[{$contentencoded}]]></content:encoded>\n\t<dc:date>{$date}</dc:date>\n</item>\n";
        }
    }
    // Prepare the whole text of the RSS file.
    $rsstext = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
		
<channel rdf:about="http://' . DOMAIN . $mpurl . '">
<title>' . str_replace('&Ouml;', 'O', $MEMBER->full_name()) . '\'s Recent Appearances (TheyWorkForYou.com)</title>
<link>http://' . DOMAIN . $mpurl . '</link>
<description></description>
<dc:language>en-gb</dc:language>
<dc:creator>TheyWorkForYou.com, mprss.php script</dc:creator>
<dc:date>' . $datenow . '</dc:date>

<items>
<rdf:Seq>
' . $items . '</rdf:Seq>
</items>

</channel>

' . $entries . '
示例#28
0
?>
                        <ol>

                        <li>
<?php 
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.)
    if ($THEUSER->isloggedin()) {
        $CHANGEURL = new URL('useredit');
    } else {
        $CHANGEURL = new URL('userchangepc');
    }
    $MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode(), 'house' => 1));
    $mpname = $MEMBER->full_name();
    ?>
      <p><a href="<?php 
    echo $MPURL->generate();
    ?>
"><strong>Find out more about how <?php 
    echo $mpname;
    ?>
, your ex-MP, represented you over the last parliament</strong></a><br>
                        In <?php 
    echo strtoupper(_htmlentities($THEUSER->postcode()));
    ?>
 (<a href="<?php 
    echo $CHANGEURL->generate();
    ?>
">Change your postcode</a>)</p>
示例#29
0
    function _get_committee($bill_id)
    {
        include_once INCLUDESPATH . "easyparliament/member.php";
        $q = $this->db->query('select count(*) as c from hansard where major=6 and minor=' . mysql_escape_string($bill_id) . ' and htype=10');
        $sittings = $q->field(0, 'c');
        $q = $this->db->query('select member_id,sum(attending) as attending, sum(chairman) as chairman
			from pbc_members where bill_id=' . mysql_escape_string($bill_id) . ' group by member_id');
        $comm = array('sittings' => $sittings);
        for ($i = 0; $i < $q->rows(); $i++) {
            $member_id = $q->field($i, 'member_id');
            $mp = new MEMBER(array('member_id' => $member_id));
            $attending = $q->field($i, 'attending');
            $chairman = $q->field($i, 'chairman');
            $arr = array('name' => $mp->full_name(), 'attending' => $attending);
            if ($chairman) {
                $comm['chairmen'][$member_id] = $arr;
            } else {
                $comm['members'][$member_id] = $arr;
            }
        }
        return $comm;
    }
示例#30
0
?>

<p class="footer"><small>Images produced from the Ordnance Survey <a href="http://www.election-maps.co.uk/" rel="nofollow">election-maps</a> service. Images reproduced with permission of <a href="http://www.ordnancesurvey.co.uk/" rel="nofollow">Ordnance Survey</a> and <a href="http://www.lpsni.gov.uk/" rel="nofollow">Land and Property Services</a>.</small></p>

</div>

<ul class="results">

<li>You are currently in the <strong><?php 
echo $current_disp;
?>
</strong> constituency; your MP is <a href='<?php 
echo $MEMBER->url();
?>
'><?php 
echo $MEMBER->full_name();
?>
</a>.</p>
<?
    if (isset($new) && $new_info['country']=='S') {
        print '<li>Scotland does not have any boundary changes, so you will remain in this constituency.';
    } elseif (isset($new)) {
        print '<li>At the next election, you will be in the <strong>' . $new . '</strong> constituency.';
    } else {
        print '<li>We cannot look up the constituency for the next election for some reason, sorry.';
    }

    echo '</ul>';

    if (isset($new) && $current_disp == $new && $new_info['country']!='S') {
        print '<p>The constituency may have kept the same name but altered its boundaries &ndash; do check the maps on the right.</p>';