function wikipedize($source) { $was_array = false; if (is_array($source)) { $source = join('|||', $source); $was_array = true; } # Set up various variables $capsword = "[A-Z][a-zA-Z'0-9]*"; # not starting with number, as catches too much $fillerwords = "of|and|in|on|under|the"; $middlewordre = "(?:{$capsword}|{$fillerwords})\\s*"; $endwordre = "(?:{$capsword})\\s*"; # and, of etc. can't appear at ends # Match either "Two Endwords" or "Endword and Some Middle Words" $greedyproperre = "/\\b{$endwordre}(?:{$middlewordre})*{$endwordre}\\b/ms"; # Match without filler words (so if you have a phrase like # "Amnesty International and Human Rights Watch" you also get both parts # separately "Amnesty International" and "Human Rights Watch") $frugalproperre = "/\\b(?:{$endwordre}){2,}\\b/ms"; # And do a greedy without the first word of a sentence $greedynotfirst = "/\\.\\s+\\S+\\s+({$endwordre}(?:{$middlewordre})*{$endwordre})\\b/ms"; preg_match_all($greedyproperre, $source, $propernounphrases1); preg_match_all($frugalproperre, $source, $propernounphrases2); preg_match_all($greedynotfirst, $source, $propernounphrases3); # Three Letter Acronyms preg_match_all("/\\b[A-Z]{2,}/ms", $source, $acronyms); # We don't want no steenking duplicates $phrases = array_unique(array_merge($propernounphrases1[0], $propernounphrases2[0], $propernounphrases3[1], $acronyms[0])); # Sort into order, largest first usort($phrases, "lensort"); foreach ($phrases as $i => $phrase) { $phrases[$i] = mysql_real_escape_string(str_replace(' ', '_', trim($phrase))); } # Open up a db connection, and whittle our list down even further, against # the real titles. $matched = array(); $db = new ParlDB(); $source = explode('|||', $source); $q = $db->query("SELECT title FROM titles WHERE title IN ('" . join("','", $phrases) . "')"); for ($i = 0; $i < $q->rows(); $i++) { $wikistring = $q->field($i, 'title'); $phrase = str_replace('_', ' ', $wikistring); # See if already matched a string this one is contained within foreach ($matched as $got) { if (strstr($got, $phrase)) { continue 2; } } # Go ahead twfy_debug("WIKIPEDIA", "Matched '{$phrase}'"); # 1 means only replace one match for phrase per paragraph $source = preg_replace("/{$phrase}/", "<a href=\"http://en.wikipedia.org/wiki/{$wikistring}\">{$phrase}</a>", $source, 1); array_push($matched, $phrase); } if (!$was_array) { $source = join('|||', $source); } return $source; }
'trackback_id' => '37', 'gid' => '2003-02-28.475.3', 'url' => 'http://www.gyford.com/weblog/my_entry.html', 'blog_name' => "Phil's weblog", 'title' => 'Interesting speech', 'excerpt' => 'My MP has posted an interesting speech, etc', 'posted' => '2003-12-31 23:00:00' ), array ( [as above] ), etc. ); */ global $PAGE, $this_page, $DATA; twfy_debug("TEMPLATE", "trackbacks.php"); $info = $data['info']; $data = $data['data']; if (count($data) > 0) { if ($info['view'] == 'recent') { $title = $info['num'] . ' most recent trackbacks'; } else { $title = 'Some sites linking to this page'; } if (!$PAGE->within_stripe()) { $PAGE->stripe_start(); $stripe_must_be_ended = true; } else { $stripe_must_be_ended = false; } ?>
$data = array ( 'info' => array ( 'order' => 'first_name' ), 'data' => array ( 'first_name' => 'Fred', 'last_name' => 'Bloggs, 'person_id' => 23, 'constituency' => 'Here', 'party' => 'Them' ) ); */ global $this_page; twfy_debug("TEMPLATE", "people_mps.php"); $order = $data['info']['order']; $URL = new URL($this_page); if ($order == 'name') { $th_name = 'Name'; } else { $URL->insert(array('o' => 'n')); $th_name = '<a href="' . $URL->generate() . '">Name</a>'; } $URL->insert(array('o' => 'p')); $th_party = '<a href="' . $URL->generate() . '">Party</a>'; if ($order == 'party') { $th_party = 'Party'; } ?> <div class="sort">
function _get_data_by_column($args) { global $this_page; twfy_debug(get_class($this), "getting data by column"); $input = array('amount' => array('body' => true, 'comment' => true), 'where' => array('hdate=' => $args['date'], 'major=' => $this->major, 'gid LIKE ' => '%.' . $args['column'] . '.%'), 'order' => 'hpos'); $data = $this->_get_hansard_data($input); # $data = array(); # $itemdata = $this->_get_item($args); # if ($itemdata) { # $data['info']['date'] = $itemdata['hdate']; # $data['info']['text'] = $itemdata['body']; # $data['info']['major'] = $this->major; # } return $data; }
// Remember, we are currently within the HANSARDLIST class, // in the render() function. // The array $data will be packed full of luverly stuff about hansard objects. // See the bottom of hansard_gid.php for general information about its structure and contents... /* $data['info'] = array ( 'results_per_page' => 10, 'total_results' => 1240, 'first_result' => 0, 'page' => 1, 's' => 'fox+hunting' ); */ global $PAGE, $this_page, $GLOSSARY, $hansardmajors; twfy_debug("TEMPLATE", "hansard_search.php"); $info = $data['info']; $searchdescription = $data['searchdescription']; if (isset($info['total_results']) && $info['total_results'] > 0) { // If we're getting matches and no glossary entry, we can trigger them to add a definition // Obviously, only if it's a proper noun if ($info['total_results'] > 0 && $GLOSSARY['num_search_matches'] == 0) { // I'll be leaving this empty for now, pending search engine improvements... } $last_result = $info['first_result'] + $info['results_per_page'] - 1; if ($last_result > $info['total_results']) { $last_result = $info['total_results']; } print "\t\t\t\t<h3 style='font-weight:normal'>Results <strong>" . number_format($info['first_result']) . '-' . number_format($last_result) . '</strong> of ' . number_format($info['total_results']) . " for <strong>" . htmlentities($searchdescription) . "</strong></h3>\n"; } elseif ($info['total_results'] == 0) { echo '<h3 style="font-weight:normal">Your search for <strong>', htmlentities($searchdescription), '</strong> did not match anything.</h3>';
function set_postcode_cookie($pc) { // Set the user's postcode. // Doesn't change it in the DB, as it's probably mainly for // not-logged-in users. $this->postcode = $pc; if (!headers_sent()) { // if in debug mode setcookie(POSTCODE_COOKIE, $pc, time() + 7 * 86400, "/", COOKIEDOMAIN); } twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '{$pc}' for " . COOKIEDOMAIN . " domain"); }
<?php // For displaying the main Hansard content listings (by date). // Remember, we are currently within the DEBATELIST or WRANSLISTS class, // in the render() function. // The array $data will be packed full of luverly stuff about hansard objects. // See the bottom of hansard_gid for information about its structure and contents... global $PAGE, $DATA, $this_page, $hansardmajors; twfy_debug("TEMPLATE", "hansard_bill.php"); $PAGE->page_start(); $PAGE->stripe_start(); if (isset($data['rows'])) { $prevlevel = ''; print "\t\t\t\t<ul id=\"hansard-day\" class=\"hansard-day\">\n"; // Cycle through each row... foreach ($data['rows'] as $row) { // Start a top-level item, eg a section. if ($row['htype'] == '10') { if ($prevlevel == 'sub') { print "\t\t\t\t\t</ul>\n\t\t\t\t</li>\n"; } elseif ($prevlevel == 'top') { print "</li>\n"; } print "\t\t\t\t<li>"; // Start a sub-level item, eg a subsection. } else { if ($prevlevel == '') { print "\t\t\t\t<li>\n"; } elseif ($prevlevel == 'top') { print "\n\t\t\t\t\t<ul>\n"; }
function set_constituency_cookie($constituency) { $this->constituency = $constituency; if (!headers_sent()) { // if in debug mode setcookie(CONSTITUENCY_COOKIE, $constituency, time() + 7 * 86400, "/", COOKIEDOMAIN); } twfy_debug('USER', "Set the cookie named '" . CONSTITUENCY_COOKIE . " to '{$constituency}' for " . COOKIEDOMAIN . " domain"); }
<?php // For displaying the main Hansard content listings (by gid), // and individual Hansard items (the comments are handled separately // by COMMENTLIST and the comments.php template). // Remember, we are currently within the DEBATELIST or WRANSLISTS class, // in the render() function. // The array $data will be packed full of luverly stuff about hansard objects. // See the bottom of this document for information about its structure and contents... global $PAGE, $this_page, $GLOSSARY, $hansardmajors, $DATA; include_once INCLUDESPATH . "easyparliament/searchengine.php"; include_once INCLUDESPATH . "easyparliament/member.php"; twfy_debug("TEMPLATE", "hansard_gid.php"); // Will set the page headings and start the page HTML if it hasn't // already been started. if (!isset($data['info'])) { // No data! We'll be exiting here! but send a 404 so that spiders stop indexing the page. header("HTTP/1.0 404 Not Found"); # Bots have some fiddled with wrans, so we get errors here sometimes that don't # signify a real problem. #trigger_error("Not enough data to display anything.", E_USER_ERROR); exit; } $PAGE->page_start(); $PAGE->supress_heading = true; /* $PAGE->stripe_start('head-1', ''); $sidebar = $hansardmajors[$data['info']['major']]['sidebar_short']; $PAGE->stripe_end(array(
function run_search($first_result, $results_per_page, $sort_order = 'relevance') { $start = getmicrotime(); // NOTE: this is to do sort by date switch ($sort_order) { case 'date': $this->enquire->set_sort_by_value_then_relevance(0, true); break; case 'created': $this->enquire->set_sort_by_value_then_relevance(6, true); default: //do nothing, default ordering is by relevance break; } $matches = $this->enquire->get_mset($first_result, $results_per_page); $this->gids = array(); $this->created = array(); $this->relevances = array(); $iter = $matches->begin(); $end = $matches->end(); while (!$iter->equals($end)) { $relevancy = $iter->get_percent(); $weight = $iter->get_weight(); $doc = $iter->get_document(); $gid = $doc->get_data(); if ($sort_order == 'created') { array_push($this->created, $doc->get_value(6)); } twfy_debug("SEARCH", "gid: {$gid} relevancy: {$relevancy}% weight: {$weight}"); array_push($this->gids, "uk.org.publicwhip/" . $gid); array_push($this->relevances, $relevancy); $iter->next(); } $duration = getmicrotime() - $start; twfy_debug("SEARCH", "Run search took {$duration} seconds."); }
function page_footer($extra = null) { global $DATA, $this_page; // This makes the tracker appear on all sections, but only actually on openaustralia.org //if ($DATA->page_metadata($this_page, 'track') ) { if (substr(DOMAIN, -18) == "openaustralia.org" && substr(DOMAIN, 0, 7) != "staging") { // We want to track this page. // Kind of fake URLs needed for the tracker. $url = urlencode('http://' . DOMAIN . '/' . $this_page); ?> <script type="text/javascript"><!-- an=navigator.appName;sr='http://x3.extreme-dm.com/';srw="na";srb="na";d=document;r=41;function pr(n) { d.write("<div><img alt=\"\" src=\""+sr+"n\/?tag=fawkes&p=<?php echo $url; ?> &j=y&srw="+srw+"&srb="+srb+"&l="+escape(d.referrer)+"&rs="+r+"\" height=\"1\" width=\"1\"></"+"div>");} s=screen;srw=s.width;an!="Netscape"?srb=s.colorDepth:srb=s.pixelDepth pr()//--> </script><noscript><div><img alt="" src="http://x3.extreme-dm.com/z/?tag=fawkes&p=<?php echo $url; ?> &j=n" height="1" width="1"></div></noscript> <?php if (get_http_var('c4') || get_http_var('c4x')) { ?> <script type="text/javascript" src="http://www.channel4.com/media/scripts/statstag.js"></script> <!--//end WEB STATS --> <noscript><div style="display:none"><img width="1" height="1" src="http://stats.channel4.com/njs.gif?dcsuri=/nojavascript&WT.js=No" alt=""></div></noscript> <?php } // mySociety tracking, not on staging if (defined('OPTION_TRACKING') && OPTION_TRACKING) { track_event($extra); } } // DAMN, this really shouldn't be in PAGE. $db = new ParlDB(); $db->display_total_duration(); $duration = getmicrotime() - STARTTIME; twfy_debug("TIME", "Total time for page: {$duration} seconds."); if (!isset($_SERVER['WINDIR'])) { $rusage = getrusage(); $duration = $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec'] - STARTTIMEU; twfy_debug('TIME', "Total user time: {$duration} microseconds."); $duration = $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec'] - STARTTIMES; twfy_debug('TIME', "Total system time: {$duration} microseconds."); } ?> </div> <!-- end #container --> </body> </html> <?php ob_end_flush(); }
function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false) { // Use this rather than PHP's mail() direct, so we can make alterations // easily to all the emails we send out from the site. // eg, we might want to add a .sig to everything here... if (!$from) { $from = CONTACTEMAIL; } $headers = "From: TheyWorkForYou <{$from}>\r\n" . "Content-Type: text/plain; charset=iso-8859-1\r\n" . "MIME-Version: 1.0\r\n" . "Content-Transfer-Encoding: 8bit\r\n" . ($bulk ? "Precedence: bulk\r\n" : "") . "X-Mailer: PHP/" . phpversion(); twfy_debug('EMAIL', "Sending email to {$to} with subject of '{$subject}'"); if ($want_bounces) { $envelope_sender = twfy_verp_envelope_sender($to); $success = mail($to, $subject, $message, $headers, '-f ' . $envelope_sender); } else { $success = mail($to, $subject, $message, $headers); } return $success; }
# vim:sw=4:ts=4:et:nowrap include_once "../../includes/easyparliament/init.php"; include_once INCLUDESPATH."easyparliament/member.php"; include_once INCLUDESPATH."easyparliament/glossary.php"; // From http://cvs.sourceforge.net/viewcvs.py/publicwhip/publicwhip/website/ include_once INCLUDESPATH."postcode.inc"; if (get_http_var('pid') == 16407) { header('Location: /search/?pid=10133'); exit; } $searchstring = construct_search_string(); twfy_debug('SEARCH', $searchstring); $this_page = 'search'; $warning = ''; if (preg_match('#^\s*[^\s]+\.\.[^\s]+\s*$#', $searchstring)) { $warning = 'You cannot search for just a date range, please select some other criteria as well.'; } if (preg_match('#\.\..*?\.\.#', $searchstring)) { $warning = 'You cannot search for more than one date range.'; } if (get_http_var('adv') || $warning) { $PAGE->page_start(); $PAGE->stripe_start(); if ($warning) echo "<p id='warning'>$warning</p>";
function send_email($to, $subject, $message, $bulk = false) { // Use this rather than PHP's mail() direct, so we can make alterations // easily to all the emails we send out from the site. // eg, we might want to add a .sig to everything here... // Everything is not BCC'd to REPORTLIST (unless it's already going to the list!). $headers = "From: OpenAustralia.org <" . CONTACTEMAIL . ">\n" . "Reply-To: OpenAustralia.org <" . CONTACTEMAIL . ">\n" . "Content-Type: text/plain; charset=iso-8859-1\n" . "Content-Transfer-Encoding: 8bit\n" . ($bulk ? "Precedence: bulk\n" : "") . "X-Mailer: PHP/" . phpversion(); /* if ($to != REPORTLIST) { $headers .= "\r\nBcc: " . BCCADDRESS; } */ twfy_debug('EMAIL', "Sending email to {$to} with subject of '{$subject}'"); $success = mail($to, $subject, $message, $headers); return $success; }
<?php // For displaying the main Hansard content listings (by date). // Remember, we are currently within the DEBATELIST or WRANSLISTS class, // in the render() function. // The array $data will be packed full of luverly stuff about hansard objects. // See the bottom of hansard_gid for information about its structure and contents... global $PAGE, $DATA, $this_page, $hansardmajors; twfy_debug("TEMPLATE", "hansard_column.php"); $PAGE->page_start(); $PAGE->stripe_start(); print_r($data); if (isset($data)) { $prevlevel = ''; print "\t\t\t\t<ul id=\"hansard-day\" class=\"hansard-day\">\n"; // Cycle through each row... for ($i = 0; $i < count($data); $i++) { $row = $data[$i]; // Start a top-level item, eg a section. if ($row['htype'] == '10') { if ($prevlevel == 'sub') { print "\t\t\t\t\t</ul>\n\t\t\t\t</li>\n"; } elseif ($prevlevel == 'top') { print "</li>\n"; } print "\t\t\t\t<li>"; // Start a sub-level item, eg a subsection. } else { if ($prevlevel == '') { print "\t\t\t\t<li>\n"; } elseif ($prevlevel == 'top') {
</div> </div> </div> </div> <?php // DAMN, this really shouldn't be in PAGE. $db = new ParlDB(); $db->display_total_duration(); $duration = getmicrotime() - STARTTIME; twfy_debug("TIME", "Total time for page: {$duration} seconds."); if (!isset($_SERVER['WINDIR'])) { $rusage = getrusage(); $duration = $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec'] - STARTTIMEU; twfy_debug('TIME', "Total user time: {$duration} microseconds."); $duration = $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec'] - STARTTIMES; twfy_debug('TIME', "Total system time: {$duration} microseconds."); } ?> </div> <!-- end #footer --> </div> <!-- end #container --> <script src="/js/foundation/foundation.js"></script> <script src="/js/foundation/foundation.magellan.js"></script> <script src="/js/foundation/foundation.reveal.js"></script> <script src="/js/riveted.min.js"></script> <script src="/js/jquery.scrolldepth.min.js"></script> <script> $( document ).ready(function() {
<?php // For displaying most highly-voted on recent speeches. // Used on the home page. // Remember, we are currently within the DEBATELIST or WRANSLISTS class, // in the render() function. // The array $data will be packed full of luverly stuff about hansard objects. // See the bottom of hansard_gid for information about its structure and contents... global $PAGE; twfy_debug("TEMPLATE", "hansard_recentvotes.php"); if (isset($data['rows']) && count($data['rows']) > 0) { $PAGE->block_start(array('title' => 'Most interesting speeches from past ' . $data['info']['days'] . ' days')); ?> <ol> <?php foreach ($data['rows'] as $n => $row) { // While we're linking to individual speeches, // the text is the body of the parent, ie (sub)section. $title = $row['parent']['body']; if (isset($row['listurl'])) { $title = "<a href=\"" . $row['listurl'] . "\">{$title}</a>"; } if (isset($row['speaker']) && isset($row['speaker']['member_id'])) { $URL = new URL('member'); $URL->insert(array('id' => $row['speaker']['member_id'])); $member = '<a href="' . $URL->generate() . '">' . $row['speaker']['first_name'] . ' ' . $row['speaker']['last_name'] . '</a>: '; } else { $member = ''; } ?> <li><p><strong><?php
// Stripe end $PAGE->stripe_end(array( array ( 'noplatypus' => true, 'type' => 'nextprev' ) )); $titles_displayed = true; } // NOW, depending on the contents of this row, we do something different... if ($row['htype'] == '10') { $section['title'] = $row['body']; $section['hpos'] = $row['hpos']; twfy_debug("DATAMODEL" , "epobjectid " . htmlentities($row['epobject_id'])); } elseif ($row['htype'] == '11') { $subsection_title = $row['body']; $section['hpos'] = $row['hpos']; } elseif ($row['htype'] == '13') { // DEBATE PROCEDURAL. $stripecount++; $style = $stripecount % 2 == 0 ? '1' : '2'; if (!isset($section['first_gid'])) $section['first_gid'] = $row['gid']; $video_content = ''; if ($first_video_displayed == 0 && $row['video_status']&4 && !($row['video_status']&8)) { $video_content = video_sidebar($row, $section, $speeches, $data['info']['major']); $first_video_displayed = true;
<?php // For displaying the main Hansard content listings (by date). // Remember, we are currently within the DEBATELIST or WRANSLISTS class, // in the render() function. // The array $data will be packed full of luverly stuff about hansard objects. // See the bottom of hansard_gid for information about its structure and contents... global $PAGE, $DATA, $this_page, $hansardmajors; twfy_debug("TEMPLATE", "hansard_date.php"); $PAGE->page_start(); $PAGE->stripe_start(); if (isset($data['info']) && isset($data['info']['date']) && $data['info']['date'] == date('Y-m-d')) { ?> <div style="padding: 4px; margin: 1em; color: #000000; background-color: #ffeeee; border: solid 2px #ff0000;"> Warning: Showing data from the current day is <strong>experimental</strong> and may not work correctly. </div> <?php } if (isset($data['rows'])) { $prevlevel = ''; print "\t\t\t\t<ul id=\"hansard-day\">\n"; // Cycle through each row... for ($i = 0; $i < count($data['rows']); $i++) { $row = $data['rows'][$i]; // Start a top-level item, eg a section. if ($row['htype'] == '10') { if ($prevlevel == 'sub') { print "\t\t\t\t\t</ul>\n\t\t\t\t</li>\n"; } elseif ($prevlevel == 'top') { print "</li>\n"; }
function _get_data_by_search($args) { // $args should contain 'num', indicating how many to get. twfy_debug(get_class($this), "getting data by search"); // What we return. $data = array(); if (isset($args['num']) && is_numeric($args['num'])) { $num = $args['num']; } else { $num = 10; } if (isset($args['page']) && is_numeric($args['page'])) { $page = $args['page']; } else { $page = 1; } $limit = $num * ($page - 1) . ',' . $num; $input = array('amount' => array('user' => true), 'where' => array('comments.body LIKE' => "%{$args['s']}%"), 'order' => 'posted DESC', 'limit' => $limit); $commentsdata = $this->_get_comment_data($input); $data['comments'] = $commentsdata; $data['search'] = $args['s']; # $data['results_per_page'] = $num; # $data['page'] = $page; # $q = $this->db->query('SELECT COUNT(*) AS count FROM comments WHERE visible=1'); # $data['total_results'] = $q->field(0, 'count'); return $data; }
function set_skin($skin) { if (isset($skin) && isset($this->skins[$skin])) { $this->skin = $skin; } else { $this->skin = "default"; } twfy_debug("SKIN", "Skin set to '" . $this->skin . "'"); }
function display_total_duration() { global $mysqltotalduration; twfy_debug("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds."); }
array ( 'contentcount' => 128, 'body' => 'My big bill', 'hdate' => '2004-03-24', 'list_url' => '/debates/?id=2004-03-24.342.234', 'totalcomments' => 2, 'parent' => array ( 'body' => 'My new clause 23' ) ), etc. ) ); The 'parent' element is optional. */ twfy_debug("TEMPLATE", "hansard_biggest_debates.php"); if (array_key_exists('data', $data) && is_array($data['data'])) { ?> <dl class="big-debates"> <?php $count = 0; foreach ($data['data'] as $debate) { $count++; $extrainfo = array(); $plural = $debate['contentcount'] == 1 ? 'speech' : 'speeches'; $extrainfo[] = $debate['contentcount'] . ' ' . $plural; if ($debate['totalcomments'] > 0) { $plural = $debate['totalcomments'] == 1 ? 'annotation' : 'annotations'; $extrainfo[] = $debate['totalcomments'] . ' ' . $plural; } $debateline = '<strong><a href="' . $debate['list_url'] . '">' . $debate['body'] . '</a></strong> <small>(' . implode(', ', $extrainfo) . ')</small>';
twfy_debug('MP', 'Displaying MP by name'); } elseif ($name) { $MEMBER = new MEMBER(array('name' => $name)); if (($MEMBER->house_disp == 1 || $MEMBER->house_disp == 2 && $this_page != 'peer') && ($MEMBER->valid || !is_array($MEMBER->person_id())) || $redirect) { member_redirect($MEMBER); } } elseif ($cconstituency) { if ($cconstituency == 'your & my society') { header('Location: /mp/stom%20teinberg'); exit; } $MEMBER = new MEMBER(array('constituency' => $cconstituency)); member_redirect($MEMBER); } else { // No postcode, member_id or person_id to use. twfy_debug('MP', "We don't have any way of telling what MP to display"); } ///////////////////////////////////////////////////////// // DISPLAY A REPRESENTATIVE if (isset($MEMBER) && is_array($MEMBER->person_id())) { $PAGE->page_start_mobile(); $PAGE->stripe_start(); print '<p>That name is not unique. Please select from the following:</p><ul>'; $cs = $MEMBER->constituency(); $c = 0; foreach ($MEMBER->person_id() as $id) { print '<li><a href="' . WEBPATH . 'mp/?pid=' . $id . '">' . ucwords(strtolower($name)) . ', ' . $cs[$c++] . '</a></li>'; } print '</ul>'; $MPSURL = new URL('mps'); $sidebar = array('type' => 'html', 'content' => '<div class="block">
public function run_search($first_result, $results_per_page, $sort_order = 'relevance') { $start = getmicrotime(); #$matches = $this->enquire->get_mset($first_result, $results_per_page); $matches = $this->matches; $this->gids = array(); $this->created = array(); $this->collapsed = array(); $this->relevances = array(); $iter = $matches->begin(); $end = $matches->end(); while (!$iter->equals($end)) { $relevancy = $iter->get_percent(); $weight = $iter->get_weight(); $collapsed = $iter->get_collapse_count(); $doc = $iter->get_document(); $gid = $doc->get_data(); if ($sort_order == 'created') { array_push($this->created, join('', unpack('N', $doc->get_value(2)))); # XXX Needs fixing } twfy_debug("SEARCH", "gid: {$gid} relevancy: {$relevancy}% weight: {$weight}"); array_push($this->gids, "uk.org.publicwhip/" . $gid); array_push($this->collapsed, $collapsed); array_push($this->relevances, $relevancy); $iter->next(); } $duration = getmicrotime() - $start; twfy_debug("SEARCH", "Run search took {$duration} seconds."); }
$MEMBER = new MEMBER(array('constituency' => $constituencies['WMC'])); if ($MEMBER->person_id()) { $THEUSER->set_postcode_cookie($pc); } list($out, $sidebars) = pick_multiple($pc, $constituencies, 'NIE', 'MLA'); } else { # Just have an MP, redirect instantly to the canonical page $MEMBER = new MEMBER(array('constituency' => $constituencies['WMC'])); if ($MEMBER->person_id()) { $THEUSER->set_postcode_cookie($pc); } member_redirect($MEMBER); } } else { $errors['pc'] = "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."); } $PAGE->page_start(); $PAGE->stripe_start(); if (isset($errors['pc'])) { $PAGE->error_message($errors['pc']); $PAGE->postcode_form(); } echo $out; $PAGE->stripe_end($sidebars); $PAGE->page_end(); # --- function pick_multiple($pc, $areas, $area_type, $rep_type) { global $PAGE; $a = array_values($areas);
'body' => 'Fisheries', 'hdate' => '2004-03-24', 'list_url' => '/wrans/?id=2004-03-24.342W.234', 'totalcomments' => 2, 'child' => array ( 'body' => '<p>To ask the Secretary of State ... </p>' ), 'parent' => array ( 'body' => 'Environment' ) ), etc. ) ); */ twfy_debug("TEMPLATE", "hansard_recent_wrans.php"); echo '<dl class="recent-wrans">'; $count = 0; foreach ($data['data'] as $wran) { $count++; $extrainfo = array(); if ($wran['totalcomments'] > 0) { $plural = make_plural('annotation', $wran['totalcomments']); $totalcomments = '; ' . $wran['totalcomments'] . ' ' . $plural; } else { $totalcomments = ''; } $speaker = $wran['child']['speaker']; echo '<dt><a name="w', $count, '"></a><strong><a href="', $wran['list_url'], '">'; if ($wran['parent']['body']) { echo $wran['parent']['body'], ': ';
<?php /* Used on the 'All MPs' page to produce the list of MPs in CSV format. */ global $this_page; twfy_debug("TEMPLATE", "people_peers.php"); $order = $data['info']['order']; header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename=senators.csv'); print "Person ID,Name,Party,URI"; print "\n"; foreach ($data['data'] as $n => $peer) { render_peers_row($peer, $order); } function render_peers_row($peer, $order) { global $parties; $name = member_full_name(2, $peer['title'], $peer['first_name'], $peer['last_name'], $peer['constituency']); if (strstr($name, ',')) { $name = "\"{$name}\""; } print $peer['person_id'] . ',' . ucfirst($name) . ','; if (array_key_exists($peer['party'], $parties)) { print $parties[$peer['party']]; } else { print $peer['party']; } print ',' . 'http://' . DOMAIN . WEBPATH . 'senator/' . make_member_url($name, $peer['constituency']); print "\n"; }
function set_users_mp() { // Is this MP THEUSER's MP? global $THEUSER; if (is_object($THEUSER) && $THEUSER->constituency_is_set() && $this->current_member(1)) { twfy_debug('MP', "set_users_mp converting postcode to person"); $constituency = $THEUSER->constituency(); if ($constituency == $this->constituency()) { $this->the_users_mp = true; } } }
function _set_metadata($args) { if (isset($args["section"])) { $type = "section"; $item = $args["section"]; } else { $type = "page"; $item = $args["page"]; } $key = $args["key"]; $value = $args["value"]; twfy_debug("DATA", "Setting: " . $type . "[" . $item . "][" . $key . "] = '" . print_r($value, true) . "'"); $dataarray =& $this->{$type}; $dataarray[$item][$key] = $value; }