Exemple #1
0
 protected function generate_votes($votes, $id, $gid)
 {
     /*
     Returns HTML for the 'Does this answer the question?' links (wrans) in the sidebar.
     $votes = => array (
         'user'    => array ( 'yes' => '21', 'no' => '3' ),
         'anon'    => array ( 'yes' => '132', 'no' => '30' )
     )
     */
     global $this_page;
     # If there's a "q" we assume it's a question and ignore it
     if (strstr($gid, 'q')) {
         return;
     }
     $data = array();
     if ($this->votelinks_so_far > 0 || strstr($gid, 'r')) {
         $yesvotes = $votes['user']['yes'] + $votes['anon']['yes'];
         $novotes = $votes['user']['no'] + $votes['anon']['no'];
         $yesplural = $yesvotes == 1 ? 'person thinks' : 'people think';
         $noplural = $novotes == 1 ? 'person thinks' : 'people think';
         $URL = new \URL($this_page);
         $returl = $URL->generate();
         $VOTEURL = new \URL('epvote');
         $VOTEURL->insert(array('v' => '1', 'id' => $id, 'ret' => $returl));
         $yes_vote_url = $VOTEURL->generate();
         $VOTEURL->insert(array('v' => '0'));
         $no_vote_url = $VOTEURL->generate();
         $data = array('yesvotes' => $yesvotes, 'yesplural' => $yesplural, 'yesvoteurl' => $yes_vote_url, 'novoteurl' => $no_vote_url, 'novotes' => $novotes, 'noplural' => $noplural);
     }
     $this->votelinks_so_far++;
     return $data;
 }
function get_listurl($q) {
	global $hansardmajors;
	$id_data = array(
		'gid' => fix_gid_from_db($q->field(0, 'gid')),
		'major' => $q->field(0, 'major'),
		'htype' => $q->field(0, 'htype'),
		'subsection_id' => $q->field(0, 'subsection_id'),
	);
	$db = new ParlDB;
	$LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']);
	$fragment = '';
	if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
		$LISTURL->insert( array( 'id' => $id_data['gid'] ) );
	} else {
		$parent_epobject_id = $id_data['subsection_id'];
		$parent_gid = '';
		$r = $db->query("SELECT gid
				FROM 	hansard
				WHERE	epobject_id = '" . mysql_real_escape_string($parent_epobject_id) . "'
				");
		if ($r->rows() > 0) {
			$parent_gid = fix_gid_from_db( $r->field(0, 'gid') );
		}
		if ($parent_gid != '') {
			$LISTURL->insert( array( 'id' => $parent_gid ) );
			$fragment = '#g' . gid_to_anchor($id_data['gid']);
		}
	}
	return $LISTURL->generate('none') . $fragment;
}
Exemple #3
0
function generate_rows($q)
{
    global $db;
    $rows = array();
    $USERURL = new URL('userview');
    for ($row = 0; $row < $q->rows(); $row++) {
        $email = $q->field($row, 'email');
        $criteria = $q->field($row, 'criteria');
        $SEARCHENGINE = new SEARCHENGINE($criteria);
        $r = $db->query("SELECT user_id,firstname,lastname FROM users WHERE email = '" . mysql_escape_string($email) . "'");
        if ($r->rows() > 0) {
            $user_id = $r->field(0, 'user_id');
            $USERURL->insert(array('u' => $user_id));
            $name = '<a href="' . $USERURL->generate() . '">' . $r->field(0, 'firstname') . ' ' . $r->field(0, 'lastname') . '</a>';
        } else {
            $name = $email;
        }
        $created = $q->field($row, 'created');
        if ($created == '0000-00-00 00:00:00') {
            $created = '&nbsp;';
        }
        $rows[] = array($name, $SEARCHENGINE->query_description_long(), $created);
    }
    return $rows;
}
Exemple #4
0
 public function get_values()
 {
     global $this_page;
     $data = array();
     // TODO: think about not hard coding these
     $current_question = 3;
     $always_ask = 1;
     $data['survey_site'] = "twfy-mini-{$current_question}";
     $show_survey_qn = 0;
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $has_answered_question = get_http_var('answered_survey');
     $hide_question = get_http_var('hide_survey');
     $data['show'] = false;
     if ($hide_question) {
         $always_ask = 0;
         $show_survey_qn = $current_question;
         setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/');
     } elseif ($has_answered_question == $current_question && !$always_ask) {
         $show_survey_qn = $current_question;
         setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/');
     } elseif (isset($_COOKIE['survey'])) {
         $show_survey_qn = $_COOKIE['survey'];
     }
     if ($show_survey_qn < $current_question && !$has_answered_question) {
         $data['show'] = true;
         $page_url = '';
         $hide_url = '';
         if (in_array($this_page, array('mp', 'peer', 'msp', 'mla', 'royal'))) {
             global $MEMBER;
             if ($MEMBER) {
                 $page_url = $MEMBER->url() . "?answered_survey={$current_question}";
                 $hide_url = $MEMBER->url() . "?hide_survey={$current_question}";
             }
         } else {
             $URL = new \URL($this_page);
             $URL->insert(array('answered_survey' => $current_question));
             $page_url = 'http://' . DOMAIN . $URL->generate();
             $URL = new \URL($this_page);
             $URL->insert(array('hide_survey' => $current_question));
             $hide_url = 'http://' . DOMAIN . $URL->generate();
         }
         $data['page_url'] = $page_url;
         $data['hide_url'] = $hide_url;
         $data['user_code'] = bin2hex(urandom_bytes(16));
         $data['auth_signature'] = auth_sign_with_shared_secret($data['user_code'], OPTION_SURVEY_SECRET);
         $data['datetime'] = time();
     }
     $data['current_q'] = $current_question;
     $data['answered'] = $has_answered_question;
     return $data;
 }
Exemple #5
0
function gid_to_url($gid)
{
    if (!$gid) {
        return '';
    }
    global $hansardmajors;
    global $db;
    $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
    $url_gid = fix_gid_from_db($gid);
    $url = new \URL($hansardmajors[$q->field(0, 'major')]['page']);
    $url->insert(array('id' => $url_gid));
    $url = 'http://' . DOMAIN . $url->generate();
    return $url;
}
Exemple #6
0
 protected function display_front_ni()
 {
     global $this_page;
     $this_page = "nioverview";
     $data = array();
     $urls = array();
     $data['popular_searches'] = NULL;
     $search = new \URL('search');
     $urls['search'] = $search->generate();
     $alert = new \URL('alert');
     $urls['alert'] = $alert->generate();
     $data['urls'] = $urls;
     $DEBATELIST = new \NILIST();
     $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none');
     $MOREURL = new \URL('nidebatesfront');
     $MOREURL->insert(array('more' => 1));
     // this makes sure that we don't repeat this debate in the list below
     $random_debate = NULL;
     if (isset($debates['data']) && count($debates['data'])) {
         $random_debate = $debates['data'][0];
     }
     $recent = array();
     if (isset($debates['data']) && count($debates['data'])) {
         for ($i = 1; $i < 6; $i++) {
             $debate = $debates['data'][$i];
             $debate['desc'] = "Northern Ireland Assembly debates";
             $debate['more_url'] = $MOREURL->generate();
             $recent[] = $debate;
         }
     }
     $featured = array();
     if ($random_debate) {
         $featured = $random_debate;
         $featured['more_url'] = $MOREURL->generate();
         $featured['desc'] = 'Northern Ireland Assembly debate';
         $featured['related'] = array();
         $featured['featured'] = false;
     }
     $data['featured'] = $featured;
     $data['debates'] = array('recent' => $recent);
     $data['regional'] = $this->getMLAList();
     \MySociety\TheyWorkForYou\Renderer::output('ni/index', $data);
 }
Exemple #7
0
# Stop infinite loop
# And cope with Unicode URL
if (preg_match("#^ynys môn#i", $cconstituency)) {
    $cconstituency = "ynys m&ocirc;n";
}
// Redirect for MP recent appearanecs
if (get_http_var('recent')) {
    if ($THEUSER->constituency_is_set() && !$pid) {
        $MEMBER = new MEMBER(array('constituency' => $THEUSER->constituency()));
        if ($MEMBER->person_id()) {
            $pid = $MEMBER->person_id();
        }
    }
    if ($pid) {
        $URL = new URL('search');
        $URL->insert(array('pid' => $pid, 'pop' => 1));
        header('Location: http://' . DOMAIN . $URL->generate('none'));
        exit;
    }
}
/////////////////////////////////////////////////////////
// CHECK SUBMITTED MEMBER (term of office) ID.
if (get_http_var('c4')) {
    $this_page = 'c4_mp';
} elseif (get_http_var('c4x')) {
    $this_page = 'c4x_mp';
} elseif (get_http_var('peer')) {
    $this_page = 'peer';
} elseif (get_http_var('royal')) {
    $this_page = 'royal';
} elseif (get_http_var('mla')) {
Exemple #8
0
 function confirm($token)
 {
     // The user has clicked the link in their confirmation email
     // and the confirm page has passed the token from the URL to here.
     // If all goes well they'll be confirmed and then logged in.
     // Split the token into its parts.
     $arg = '';
     if (strstr($token, '::')) {
         $arg = '::';
     }
     if (strstr($token, '-')) {
         $arg = '-';
     }
     list($user_id, $registrationtoken) = explode($arg, $token);
     if (!is_numeric($user_id) || $registrationtoken == '') {
         return false;
     }
     $q = $this->db->query("SELECT email, password, postcode\n\t\t\t\t\t\tFROM\tusers\n\t\t\t\t\t\tWHERE\tuser_id = '" . mysql_escape_string($user_id) . "'\n\t\t\t\t\t\tAND\t\tregistrationtoken = '" . mysql_escape_string($registrationtoken) . "'\n\t\t\t\t\t\t");
     if ($q->rows() == 1) {
         // We'll need these to be set before logging the user in.
         $this->user_id = $user_id;
         $this->email = $q->field(0, 'email');
         $this->password = $q->field(0, 'password');
         // Set that they're confirmed in the DB.
         $r = $this->db->query("UPDATE users\n\t\t\t\t\t\t\tSET\t\tconfirmed = '1'\n\t\t\t\t\t\t\tWHERE\tuser_id = '" . mysql_escape_string($user_id) . "'\n\t\t\t\t\t\t\t");
         if ($q->field(0, 'postcode')) {
             $MEMBER = new MEMBER(array('postcode' => $q->field(0, 'postcode')));
             $pid = $MEMBER->person_id();
             # This should probably be in the ALERT class
             $this->db->query('update alerts set confirmed=1 where email="' . mysql_escape_string($this->email) . '" and criteria="speaker:' . mysql_escape_string($pid) . '"');
         }
         if ($r->success()) {
             $this->confirmed = true;
             // Log the user in, redirecting them to the confirm page
             // where they should get a nice welcome message.
             $URL = new URL('userconfirmed');
             $URL->insert(array('welcome' => 't'));
             $redirecturl = $URL->generate();
             $this->login($redirecturl, 'session');
         } else {
             // Couldn't set them as confirmed in the DB.
             return false;
         }
     } else {
         // Couldn't find this user in the DB. Maybe the token was
         // wrong or incomplete?
         return false;
     }
 }
		'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 == 'first_name') {
    $th_first_name = 'First Name |';
} else {
    $URL->insert(array('o' => 'f'));
    $th_first_name = '<a href="' . $URL->generate() . '">First name</a> |';
}
if ($order == 'last_name') {
    $th_last_name = 'Last name |';
} else {
    $URL->insert(array('o' => 'l'));
    $th_last_name = '<a href="' . $URL->generate() . '">Last name</a> |';
}
$URL->insert(array('o' => 'p'));
$th_party = '<a href="' . $URL->generate() . '">Party</a>';
$URL->insert(array('o' => 'c'));
$th_constituency = '<a href="' . $URL->generate() . '">Constituency</a>';
if ($order == 'party') {
    $th_party = 'Party';
} elseif ($order == 'constituency') {
Exemple #10
0
 function _set_url()
 {
     global $hansardmajors;
     // Creates and sets the URL for the comment.
     if ($this->url == '') {
         $q = $this->db->query("SELECT major,\n\t\t\t\t\t\t\t\t\tgid\n\t\t\t\t\t\t\tFROM\thansard\n\t\t\t\t\t\t\tWHERE\tepobject_id = '" . addslashes($this->epobject_id) . "'\n\t\t\t\t\t\t\t");
         if ($q->rows() > 0) {
             // If you change stuff here, you might have to change it in
             // $COMMENTLIST->_get_comment_data() too...
             $gid = fix_gid_from_db($q->field(0, 'gid'));
             // In includes/utility.php
             $major = $q->field(0, 'major');
             $page = $hansardmajors[$major]['page'];
             $gidvar = $hansardmajors[$major]['gidvar'];
             $URL = new URL($page);
             $URL->insert(array($gidvar => $gid));
             $this->url = $URL->generate() . '#c' . $this->comment_id;
         }
     }
 }
Exemple #11
0
    // Get the total comments posted for this user.
    $r = $db->query("SELECT COUNT(*) AS totalcount\n                    FROM\tcomments\n                    WHERE\tuser_id = '" . $user_id . "'");
    $totalcomments = $r->field(0, 'totalcount');
    $percentagedeleted = $q->field($row, 'deletedcount') / $totalcomments * 100;
    // Get complaints made about this user's comments, but not upheld.
    $r = $db->query("SELECT COUNT(*) AS count\n                    FROM commentreports, comments\n                    WHERE\tcommentreports.comment_id = comments.comment_id\n                    AND\t\tcomments.user_id = '{$user_id}'\n                    AND\t\tcommentreports.resolved IS NOT NULL\n                    AND\t\tcommentreports.upheld = '0'");
    $notupheldcount = $r->field(0, 'count');
    $USERURL->insert(array('u' => $user_id));
    $rows[] = array('<a href="' . $USERURL->generate() . '">' . $q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname') . '</a>', $totalcomments, $q->field($row, 'deletedcount'), $percentagedeleted . '%', $notupheldcount);
}
$tabledata = array('header' => array('Name', 'Total comments', 'Number deleted', 'Percentage deleted', 'Reports against not upheld'), 'rows' => $rows);
$PAGE->display_table($tabledata);
///////////////////////////////////////////////////////////////
?>
<h4>Users who've made most rejected reports</h4>
<?php 
$q = $db->query("SELECT COUNT(*) AS rejectedcount,\n                        cr.user_id,\n                        u.firstname,\n                        u.lastname\n                FROM\tcommentreports cr, users u\n                WHERE\tcr.resolved IS NOT NULL\n                AND\t\tcr.upheld = '0'\n                AND\t\tcr.user_id = u.user_id\n                AND\t\tcr.user_id != 0\n                GROUP BY cr.user_id\n                ORDER BY rejectedcount DESC");
$rows = array();
$USERURL = new URL('userview');
for ($row = 0; $row < $q->rows(); $row++) {
    $user_id = $q->field($row, 'user_id');
    $USERURL->insert(array('u' => $user_id));
    // Get how many valid complaints they've submitted.
    $r = $db->query("SELECT COUNT(*) AS upheldcount\n                    FROM commentreports\n                    WHERE\tuser_id = '{$user_id}'\n                    AND\t\tupheld = '1'");
    $rows[] = array('<a href="' . $USERURL->generate() . '">' . $q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname') . '</a>', $q->field($row, 'rejectedcount'), $r->field(0, 'upheldcount'));
}
$tabledata = array('header' => array('Name', 'Reports not upheld', 'Reports upheld'), 'rows' => $rows);
$PAGE->display_table($tabledata);
$menu = $PAGE->admin_menu();
$PAGE->stripe_end(array(array('type' => 'html', 'content' => $menu)));
$PAGE->page_end();
Exemple #12
0
$db = $HANSARDLIST->db;
// Get all the person ids we need feeds for...
$q = $db->query("SELECT person_id, group_concat(member_id order by member_id separator ',') as member_ids\n\t\t\tFROM member GROUP BY person_id HAVING max(left_house)='9999-12-31'");
if ($q->rows() <= 0) {
    exit;
}
$starttime = time();
for ($personrow = 0; $personrow < $q->rows(); $personrow++) {
    $person_id = $q->field($personrow, 'person_id');
    $member_ids = $q->field($personrow, 'member_ids');
    $args = array('member_ids' => $member_ids);
    $speeches = $HANSARDLIST->display('person', $args, 'none');
    // Some data about this person that we'll need for the feed.
    $MEMBER = new MEMBER(array('person_id' => $person_id));
    $MPURL = new URL('mp');
    $MPURL->insert(array('pid' => $person_id));
    $mpurl = $MPURL->generate();
    $date = gmdate('Y-m-d');
    $time = gmdate('H:i:s');
    $datenow = $date . 'T' . $time . '+00:00';
    // Prepare the meat of the RSS file.
    $items = '';
    $entries = '';
    if (isset($speeches['rows']) && count($speeches['rows']) > 0) {
        foreach ($speeches['rows'] as $n => $row) {
            // While we're linking to individual speeches,
            // the text is the body of the parent, ie (sub)section.
            $title = htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
            $link = isset($row['listurl']) ? $row['listurl'] : '';
            $link = 'http://' . DOMAIN . $link;
            $description = htmlentities(trim_characters($row['body'], 0, 200));
Exemple #13
0
    public function display()
    {
        // Print all our pending items out in a nice list or something
        // Add links later for "approve, decline, refer"
        // Just get the f****r working for now
        $URL = new URL('admin_glossary_pending');
        $URL->reset();
        $form_link = $URL->generate('url');
        ?>
<form action="<?php 
        echo $form_link;
        ?>
" method="post"><?php 
        foreach ($this->pending as $editqueue_id => $pender) {
            $URL = new URL('admin_glossary_pending');
            $URL->insert(array('approve' => $editqueue_id));
            $approve_link = $URL->generate('url');
            $URL = new URL('admin_glossary_pending');
            $URL->insert(array('modify' => $editqueue_id));
            $modify_link = $URL->generate('url');
            $URL = new URL('admin_glossary_pending');
            $URL->insert(array('decline' => $editqueue_id));
            $decline_link = $URL->generate('url');
            ?>
<div class="pending-item"><label for="<?php 
            echo $editqueue_id;
            ?>
"><input type="checkbox" name="approve[]" value="<?php 
            echo $editqueue_id;
            ?>
" id="<?php 
            echo $editqueue_id;
            ?>
"><strong><?php 
            echo $pender['title'];
            ?>
</strong></label>
            <p><?php 
            echo $pender['body'];
            ?>
<br>
            <small>
                <a href="<?php 
            echo $approve_link;
            ?>
">approve</a>
                &nbsp;|&nbsp;
                <a href="<?php 
            echo $modify_link;
            ?>
">modify</a>
                &nbsp;|&nbsp;
                <a href="<?php 
            echo $decline_link;
            ?>
">decline</a>
                <br>Submitted by: <em><?php 
            echo $pender['firstname'];
            ?>
&nbsp;<?php 
            echo $pender['lastname'];
            ?>
</em>
            </small></p></div>
        <?php 
        }
        ?>
<input type="submit" value="Approve checked items">
        </form><?php 
    }
Exemple #14
0
        // COMMENT REPORTING LINK.
        if ($this_page != 'commentreport' && $this_page != 'addcomment' && $this_page != 'admin_commentreport' && $THEUSER->is_able_to('reportcomment') && $THEUSER->user_id() != $comment['user_id'] && !$comment['modflagged']) {
            // The comment hasn't been reported and we're on a page where we want to
            // display this link.
            $URL = new URL('commentreport');
            $URL->insert(array('id' => $comment['comment_id'], 'ret' => $comment['url']));
            $reporthtml = '(<a href="' . $URL->generate() . '" title="Notify moderators that this comment should be deleted">Report this comment</a>)';
        } elseif ($comment['modflagged']) {
            $reporthtml = '(This comment has been reported to moderators)';
        } else {
            // When previewing a comment...
            $reporthtml = '';
        }
        // USERNAME AND DATE AND TIME.
        $USERURL = new URL('userview');
        $USERURL->insert(array('u' => $comment['user_id']));
        list($date, $time) = explode(' ', $comment['posted']);
        $date = format_date($date, SHORTDATEFORMAT);
        $time = format_time($time, TIMEFORMAT);
        ?>
					<p class="credit"><a href="<?php 
        echo $USERURL->generate();
        ?>
" title="See information about this user"><strong><?php 
        echo htmlentities($comment['firstname']) . ' ' . htmlentities($comment['lastname']);
        ?>
</strong></a><br>
					<small>Posted on <?php 
        echo $date;
        if (isset($comment['url'])) {
            print ' <a href="' . $comment['url'] . '" title="Link to this comment">' . $time . '</a>';
Exemple #15
0
    $up_link = $URL->generate();
    $URL->insert(array("gl" => $GLOSSARY->previous_term['glossary_id']));
    $previous_link = $URL->generate('url');
    $URL->update(array("gl" => $GLOSSARY->next_term['glossary_id']));
    $next_link = $URL->generate('url');
    $nextprev = array('next' => array('url' => $next_link, 'title' => 'Next term', 'body' => $GLOSSARY->next_term['title']), 'prev' => array('url' => $previous_link, 'title' => 'Previous term', 'body' => $GLOSSARY->previous_term['title']));
    $DATA->set_page_metadata($this_page, 'nextprev', $nextprev);
    $PAGE->glossary_display_term($GLOSSARY);
} else {
    // Display the results
    if (isset($GLOSSARY->terms)) {
        ?>
<ul class="glossary"><?php 
        $URL = new URL('glossary');
        foreach ($GLOSSARY->alphabet[$GLOSSARY->current_letter] as $glossary_id) {
            $URL->insert(array('gl' => $glossary_id));
            $term_link = $URL->generate('url');
            ?>
<li><a href="<?php 
            echo $term_link;
            ?>
"><?php 
            echo $GLOSSARY->terms[$glossary_id]['title'];
            ?>
</a></li><?php 
        }
        ?>
</ul><?php 
    }
}
$URL = new URL('glossary_addterm');
 function _comment_url($urldata)
 {
     global $hansardmajors;
     // Pass it the major and gid of the comment's epobject and the comment_id.
     // And optionally the user's id, for highlighting the comments on the destination page.
     // It returns the URL for the comment.
     $major = $urldata['major'];
     $gid = $urldata['gid'];
     $comment_id = $urldata['comment_id'];
     $user_id = isset($urldata['user_id']) ? $urldata['user_id'] : false;
     // If you change stuff here, you might have to change it in
     // $COMMENT->_set_url() too...
     // We'll generate permalinks for each comment.
     // Assuming every comment is from the same major...
     $page = $hansardmajors[$major]['page'];
     $gidvar = $hansardmajors[$major]['gidvar'];
     $URL = new URL($page);
     $gid = fix_gid_from_db($gid);
     // In includes/utility.php
     $URL->insert(array($gidvar => $gid));
     if ($user_id) {
         $URL->insert(array('u' => $user_id));
     }
     $url = $URL->generate() . '#c' . $comment_id;
     return $url;
 }
Exemple #17
0
function get_question_mentions_html($row_data) {
	if( count($row_data) == 0 ) {
		return '';
	}
	$result = '<ul class="question-mentions">';
	$nrows = count($row_data);
	$last_date = NULL;
	$first_difference_output = TRUE;
	// Keep the references until after the history that's in a timeline:
	$references = array();
	for( $i = 0; $i < $nrows; $i++ ) {
		$row = $row_data[$i];
		if( ! $row["date"] ) {
			// If this mention isn't associated with a date, the difference won't be interesting.
			$last_date = NULL;
		}
		$description = '';
		if ($last_date && ($last_date != $row["date"])) {
			// Calculate how long the gap was in days:
			$daysdiff = (integer)((strtotime($row["date"]) - strtotime($last_date)) / 86400);
			$daysstring = ($daysdiff == 1) ? "day" : "days";
			$further = "";
			if( $first_difference_output ) {
				$first_difference_output = FALSE;
			} else {
				$further = " a further";
			}
			$description = "\n<span class=\"question-mention-gap\">After$further $daysdiff $daysstring,</span> ";
		}
		$reference = FALSE;
		$inner = "BUG: Unknown mention type $row[type]";
		$date = format_date($row['date'], SHORTDATEFORMAT);
		switch ($row["type"]) {
			case 1:
				$inner = "Mentioned in <a href=\"$row[url]\">today's business on $date</a>";
				break;
			case 2:
				$inner = "Mentioned in <a href=\"$row[url]\">tabled oral questions on $date</a>";
				break;
			case 3:
				$inner = "Mentioned in <a href=\"$row[url]\">tabled written questions on $date</a>";
				break;
			case 4:
				if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['gid'],$m) ) {
					$URL = new URL("spwrans");
					$URL->insert( array('spid' => $m[1]) );
					$relative_url = $URL->generate("none");
					$inner = "Given a <a href=\"$relative_url\">written answer on $date</a>";
				}
				break;
			case 5:
				$inner = "Given a holding answer on $date";
				break;
			case 6:
				if( preg_match('/^uk.org.publicwhip\/spor\/(.*)$/',$row['mentioned_gid'],$m) ) {
					$URL = new URL("spdebates");
					$URL->insert( array('id' => $m[1]) );
					$relative_url = $URL->generate("none");
					$inner = "<a href=\"$relative_url\">Asked in parliament on $date</a>";
				}
				break;
			case 7:
				if( preg_match('/^uk.org.publicwhip\/spq\/(.*)$/',$row['mentioned_gid'],$m) ) {
					$referencing_spid = $m[1];
					$URL = new URL("spwrans");
					$URL->insert( array('spid' => $referencing_spid) );
					$relative_url = $URL->generate("none");
					$inner = "Referenced in <a href=\"$relative_url\">question $referencing_spid</a>";
					$reference = TRUE;
				}
				break;
		}
		if( $reference ) {
			$references[] = "\n<li>$inner.";
		} else {
			$result .= "\n<li>$description$inner.</span>";
			$last_date = $row["date"];
		}
	}
	foreach ($references as $reference_span) {
		$result .= $reference_span;
	}
	$result .= '</ul>';
	return $result;
} 
Exemple #18
0
<?php

$URL = new URL($this_page);
$URL->insert(array('f' => 'csv'));
$csvurl = $URL->generate();
$this->block_start(array('title' => "This data as a spreadsheet", 'url' => $csvurl, 'body' => ''));
?>
<p>
	<a href="<?php 
echo $csvurl;
?>
">Download a CSV</a> (Comma Separated Values) file that you can load into your favourite spreadsheet program or data-mashing software.
</p>
<?php 
$this->block_end();
Exemple #19
0
}
if (isset($data['rows']) && count($data['rows']) > 0) {
    echo '<dl id="searchresults">';
    for ($i = 0; $i < count($data['rows']); $i++) {
        $row = $data['rows'][$i];
        echo '<dt><a href="', $row['listurl'], '">';
        if (isset($row['parent']) && count($row['parent']) > 0) {
            echo '<strong>' . $row['parent']['body'] . '</strong>';
        }
        echo '</a> <small>(' . format_date($row['hdate'], SHORTDATEFORMAT) . ')';
        if ($row['video_status'] == 5 || $row['video_status'] == 7) {
            echo ' <em>has video</em> ';
        }
        if ($row['collapsed'] && $row['subsection_id']) {
            $URL = new URL('search');
            $URL->insert(array('s' => $info['s'] . " segment:{$row['subsection_id']}"));
            echo ' <a href="', $URL->generate(), '">See ', $row['collapsed'], ' other result', $row['collapsed'] > 1 ? 's' : '', ' from this ', $hansardmajors[$row['major']]['singular'], '</a>';
        }
        echo '</small>';
        if ($match = get_http_var('match')) {
            echo ' &ndash; <a href="/search/record.php?result=', $row['gid'], '&amp;match=', htmlspecialchars($match), '">This is the correct match</a>';
        }
        echo '</dt> <dd><p>';
        if (isset($row['speaker']) && count($row['speaker'])) {
            $sp = $row['speaker'];
            echo "<em>" . ucfirst(member_full_name($sp['house'], $sp['title'], $sp['first_name'], $sp['last_name'], $sp['constituency'])) . "</em>: ";
        }
        echo $row['body'] . "</p></dd>\n";
    }
    echo '</dl> <!-- end searchresults -->';
    $PAGE->page_links($info);
 function create($COMMENT, $reportdata)
 {
     // For when a user posts a report on a comment.
     // $reportdata is an array like:
     //	array (
     //		'body' => 'some text',
     //		'firstname'	=> 'Billy',
     //		'lastname'	=> 'Nomates',
     //		'email'		=> '*****@*****.**'
     //	)
     // But if the report was made by a logged-in user, only the
     // 'body' element should really contain anything, because
     // we use $THEUSER's id to get the rest.
     // $COMMENT is an existing COMMENT object, needed for setting
     // its modflag and comment_id.
     global $THEUSER, $PAGE;
     if (!$THEUSER->is_able_to('reportcomment')) {
         $PAGE->error_message("Sorry, you are not allowed to post reports.");
         return false;
     }
     if (is_numeric($THEUSER->user_id()) && $THEUSER->user_id() > 0) {
         // Flood check - make sure the user hasn't just posted a report recently.
         // To help prevent accidental duplicates, among other nasty things.
         // (Non-logged in users are all id == 0.)
         $flood_time_limit = 20;
         // How many seconds until a user can post again?
         $q = $this->db->query("SELECT report_id\n\t\t\t\t\t\t\tFROM\tcommentreports\n\t\t\t\t\t\t\tWHERE\tuser_id = '" . $THEUSER->user_id() . "'\n\t\t\t\t\t\t\tAND\t\treported + 0 > NOW() - {$flood_time_limit}");
         if ($q->rows() > 0) {
             $PAGE->error_message("Sorry, we limit people to posting one report per {$flood_time_limit} seconds to help prevent duplicate reports. Please go back and try again, thanks.");
             return false;
         }
     }
     // Tidy up body.
     $body = filter_user_input($reportdata['body'], 'comment');
     // In utility.php
     $time = gmdate("Y-m-d H:i:s");
     if ($THEUSER->isloggedin()) {
         $sql = "INSERT INTO commentreports\n\t\t\t\t\t\t\t\t\t(comment_id, body, reported, user_id)\n\t\t\t\t\t\t\tVALUES\t('" . mysql_real_escape_string($COMMENT->comment_id()) . "',\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($body) . "', \n\t\t\t\t\t\t\t\t\t'{$time}',\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($THEUSER->user_id()) . "'\n\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t";
     } else {
         $sql = "INSERT INTO commentreports\n\t\t\t\t\t\t\t\t\t(comment_id, body, reported, firstname, lastname, email)\n\t\t\t\t\t\t\tVALUES\t('" . mysql_real_escape_string($COMMENT->comment_id()) . "',\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($body) . "', \n\t\t\t\t\t\t\t\t\t'{$time}',\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($reportdata['firstname']) . "',\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($reportdata['lastname']) . "',\n\t\t\t\t\t\t\t\t\t'" . mysql_real_escape_string($reportdata['email']) . "'\n\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t";
     }
     $q = $this->db->query($sql);
     if ($q->success()) {
         // Inserted OK, so set up this object's variables.
         $this->report_id = $q->insert_id();
         $this->comment_id = $COMMENT->comment_id();
         $this->body = $body;
         $this->reported = $time;
         if ($THEUSER->isloggedin()) {
             $this->user_id = $THEUSER->user_id();
             $this->firstname = $THEUSER->firstname();
             $this->lastname = $THEUSER->lastname();
         } else {
             $this->email = $reportdata['email'];
             $this->firstname = $reportdata['firstname'];
             $this->lastname = $reportdata['lastname'];
         }
         // Set the comment's modflag to on.
         $COMMENT->set_modflag('on');
         // Notify those who need to know that there's a new report.
         $URL = new URL('admin_commentreport');
         $URL->insert(array('rid' => $this->report_id, 'cid' => $this->comment_id));
         $emailbody = "A new comment report has been filed by " . $this->user_name() . ".\n\n";
         $emailbody .= "COMMENT:\n" . $COMMENT->body() . "\n\n";
         $emailbody .= "REPORT:\n" . $this->body . "\n\n";
         $emailbody .= "To manage this report follow this link: http://" . DOMAIN . $URL->generate('none') . "\n";
         send_email(REPORTLIST, 'New comment report', $emailbody);
         // Send an email to the user to thank them.
         if ($THEUSER->isloggedin()) {
             $email = $THEUSER->email();
         } else {
             $email = $this->email();
         }
         $data = array('to' => $email, 'template' => 'report_acknowledge');
         $merge = array('FIRSTNAME' => $this->firstname(), 'LASTNAME' => $this->lastname(), 'COMMENTURL' => "http://" . DOMAIN . $COMMENT->url(), 'REPORTBODY' => strip_tags($this->body()));
         // send_template_email in utility.php.
         send_template_email($data, $merge);
         return true;
     } else {
         return false;
     }
 }
Exemple #21
0
            echo $comment['url'];
            ?>
" title="Link to this annotation"><?php 
            echo $time;
            ?>
</a>
<?php 
        } else {
            // There won't be a URL when we're just previewing a comment.
            echo "\t\t{$time}";
        }
        if ($this_page != 'commentreport' && $this_page != 'addcomment' && $this_page != 'admin_commentreport' && $THEUSER->is_able_to('reportcomment') && !$comment['modflagged']) {
            // The comment hasn't been reported and we're on a page where we want to
            // display this link.
            $URL = new URL('commentreport');
            $URL->insert(array('id' => $comment['comment_id'], 'ret' => $comment['url']));
            ?>
<br>
        <a href="<?php 
            echo $URL->generate();
            ?>
" title="Notify moderators that this annotation needs editing or deleting">Report this annotation</a>
<?php 
        } elseif ($comment['modflagged']) {
            ?>
<br>
        This annotation has been reported
<?php 
        }
        ?>
        </p>
$list = array(1, 1, 1, 1, 0, 0, 1);
$major = array(1, 101, 2, 0, 0, 0, 0);
# Content goes here
foreach ($data['dates'] as $date => $day_events) {
    foreach ($order as $i => $chamber) {
        if (!array_key_exists($chamber, $day_events)) {
            continue;
        }
        $events = $day_events[$chamber];
        if ($plural[$i]) {
            $chamber .= 's';
        }
        print "<h2 class='calendar'>{$chamber}";
        if (in_array($major[$i], $data['majors'])) {
            $URL = new URL($hansardmajors[$major[$i]]['page_all']);
            $URL->insert(array('d' => $date));
            print ' &nbsp; <a href="' . $URL->generate() . '">See this day &rarr;</a>';
        }
        print "</h2>\n";
        print $list[$i] ? "<ul class='calendar'>\n" : "<dl class='calendar'>\n";
        foreach ($events as $event) {
            calendar_display_entry($event);
        }
        print $list[$i] ? "</ul>\n" : "</dl>\n";
    }
}
$PAGE->stripe_end(array(array('type' => 'include', 'content' => 'calendar_box'), array('type' => 'html', 'content' => '
<div class="block">
<h4>Search upcoming business, or set up a future business email alert</h4>
<div class="blockbody">
<form action="/search/" method="get">
Exemple #23
0
function find_glossary_items($args)
{
    $searchterm = $args['s'];
    $GLOSSARY = new GLOSSARY($args);
    if (isset($GLOSSARY->num_search_matches) && $GLOSSARY->num_search_matches >= 1) {
        // Got a match(es), display....
        $URL = new URL('glossary');
        $URL->insert(array('gl' => ""));
        ?>
				<h3>Matching glossary terms:</h3> 
				<p><?php 
        $n = 1;
        foreach ($GLOSSARY->search_matches as $glossary_id => $term) {
            $URL->update(array("gl" => $glossary_id));
            ?>
<a href="<?php 
            echo $URL->generate();
            ?>
"><strong><?php 
            echo htmlentities($term['title']);
            ?>
</strong></a><?php 
            if ($n < $GLOSSARY->num_search_matches) {
                print ", ";
            }
            $n++;
        }
        ?>
</p>
<?php 
    }
}
Exemple #24
0
 /**
  * Output Page
  *
  * Assembles a completed page from template and sends it to output.
  *
  * @param string $template The name of the template file to load.
  * @param array  $data     An associative array of data to be made available to the template.
  */
 public static function output($template, $data = array())
 {
     // Include includes.
     // TODO: Wrap these in a class somewhere autoloadable.
     include_once INCLUDESPATH . 'postcode.inc';
     ////////////////////////////////////////////////////////////
     // Find the user's country. Used by header, so a safe bit to do regardless.
     if (preg_match('#^[A-Z]{2}$#i', get_http_var('country'))) {
         $data['country'] = strtoupper(get_http_var('country'));
     } else {
         $data['country'] = Gaze::get_country_by_ip($_SERVER["REMOTE_ADDR"]);
     }
     ////////////////////////////////////////////////////////////
     // Get the page data
     global $DATA, $this_page, $THEUSER;
     $header = new Renderer\Header();
     $data = array_merge($header->data, $data);
     ////////////////////////////////////////////////////////////
     // User Navigation Links
     $data['user_nav_links'] = array();
     // We may want to send the user back to this current page after they've
     // joined, logged out or logged in. So we put the URL in $returl.
     $URL = new \URL($this_page);
     $returl = $URL->generate('none');
     //user logged in
     if ($THEUSER->isloggedin()) {
         // The 'Edit details' link.
         $menudata = $DATA->page_metadata('userviewself', 'menu');
         $edittext = $menudata['text'];
         $edittitle = $menudata['title'];
         $EDITURL = new \URL('userviewself');
         if ($this_page == 'userviewself' || $this_page == 'useredit' || $header->top_highlight == 'userviewself') {
             $editclass = 'on';
         } else {
             $editclass = '';
         }
         // The 'Log out' link.
         $menudata = $DATA->page_metadata('userlogout', 'menu');
         $logouttext = $menudata['text'];
         $logouttitle = $menudata['title'];
         $LOGOUTURL = new \URL('userlogout');
         if ($this_page != 'userlogout') {
             $LOGOUTURL->insert(array("ret" => $returl));
             $logoutclass = '';
         } else {
             $logoutclass = 'on';
         }
         $username = $THEUSER->firstname() . ' ' . $THEUSER->lastname();
         $data['user_nav_links'][] = array('href' => $LOGOUTURL->generate(), 'title' => $logouttitle, 'classes' => $logoutclass, 'text' => $logouttext);
         $data['user_nav_links'][] = array('href' => $EDITURL->generate(), 'title' => $edittitle, 'classes' => $editclass, 'text' => $edittext);
         $data['user_nav_links'][] = array('href' => $EDITURL->generate(), 'title' => $edittitle, 'classes' => $editclass, 'text' => _htmlentities($username));
     } else {
         // User not logged in
         // The 'Join' link.
         $menudata = $DATA->page_metadata('userjoin', 'menu');
         $jointext = $menudata['text'];
         $jointitle = $menudata['title'];
         $JOINURL = new \URL('userjoin');
         if ($this_page != 'userjoin') {
             if ($this_page != 'userlogout' && $this_page != 'userlogin') {
                 // We don't do this on the logout page, because then the user
                 // will return straight to the logout page and be logged out
                 // immediately!
                 $JOINURL->insert(array("ret" => $returl));
             }
             $joinclass = '';
         } else {
             $joinclass = 'on';
         }
         // The 'Log in' link.
         $menudata = $DATA->page_metadata('userlogin', 'menu');
         $logintext = $menudata['text'];
         $logintitle = $menudata['title'];
         $LOGINURL = new \URL('userlogin');
         if ($this_page != 'userlogin') {
             if ($this_page != "userlogout" && $this_page != "userpassword" && $this_page != 'userjoin') {
                 // We don't do this on the logout page, because then the user
                 // will return straight to the logout page and be logged out
                 // immediately!
                 // And it's also silly if we're sent back to Change Password.
                 // And the join page.
                 $LOGINURL->insert(array("ret" => $returl));
             }
             $loginclass = '';
         } else {
             $loginclass = 'on';
         }
         $data['user_nav_links'][] = array('href' => $LOGINURL->generate(), 'title' => $logintitle, 'classes' => $loginclass, 'text' => $logintext);
         $data['user_nav_links'][] = array('href' => $JOINURL->generate(), 'title' => $jointitle, 'classes' => $joinclass, 'text' => $jointext);
     }
     // If the user's postcode is set, then we add a link to Your MP etc.
     if ($THEUSER->postcode_is_set()) {
         $items = array('yourmp');
         if (postcode_is_scottish($THEUSER->postcode())) {
             $items[] = 'yourmsp';
         } elseif (postcode_is_ni($THEUSER->postcode())) {
             $items[] = 'yourmla';
         }
         foreach ($items as $item) {
             $menudata = $DATA->page_metadata($item, 'menu');
             $logintext = $menudata['text'];
             $URL = new \URL($item);
             $data['user_nav_links'][] = array('href' => $URL->generate(), 'title' => '', 'classes' => '', 'text' => $logintext);
         }
     }
     ////////////////////////////////////////////////////////////
     // Search URL
     $SEARCH = new \URL('search');
     $SEARCH->reset();
     $data['search_url'] = $SEARCH->generate();
     ////////////////////////////////////////////////////////////
     // Search URL
     // Footer Links
     $footer = new Renderer\Footer();
     $data['footer_links'] = $footer->data;
     # banner text
     $b = new Model\Banner();
     $data['banner_text'] = $b->get_text();
     # mini survey
     // we never want to display this on the front page or any
     // other survey page we might have
     if (!in_array($this_page, array('survey', 'overview'))) {
         $mini = new MiniSurvey();
         $data['mini_survey'] = $mini->get_values();
     }
     ////////////////////////////////////////////////////////////
     // Unpack the data we've been passed so it's available for use in the templates.
     extract($data);
     ////////////////////////////////////////////////////////////
     // Require the templates and output
     header('Content-Type: text/html; charset=iso-8859-1');
     require_once INCLUDESPATH . 'easyparliament/templates/html/header.php';
     require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
     require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php';
 }
Exemple #25
0
 function _get_speaker($speaker_id, $hdate)
 {
     // Pass it the id of a speaker. If $this->speakers doesn't
     // already contain data about the speaker, it's fetched from the DB
     // and put in $this->speakers.
     // So we don't have to keep fetching the same speaker info about chatterboxes.
     if ($speaker_id != 0) {
         if (!isset($this->speakers[$speaker_id])) {
             // Speaker isn't cached, so fetch the data.
             $q = $this->db->query("SELECT title, first_name,\n\t\t\t\t\t\t\t\t\t\tlast_name,\n\t\t\t\t\t\t\t\t\t\thouse,\n\t\t\t\t\t\t\t\t\t\tconstituency,\n\t\t\t\t\t\t\t\t\t\tparty,\n                                        person_id\n\t\t\t\t\t\t\t\tFROM \tmember\n\t\t\t\t\t\t\t\tWHERE\tmember_id = '" . mysql_escape_string($speaker_id) . "'\n\t\t\t\t\t\t\t\t");
             if ($q->rows() > 0) {
                 // *SHOULD* only get one row back here...
                 $house = $q->field(0, 'house');
                 if ($house == 1) {
                     $URL = new URL('mp');
                 } elseif ($house == 2) {
                     $URL = new URL('peer');
                 } elseif ($house == 3) {
                     $URL = new URL('mla');
                 } elseif ($house == 4) {
                     $URL = new URL('msp');
                 } elseif ($house == 0) {
                     $URL = new URL('royal');
                 }
                 $URL->insert(array('m' => $speaker_id));
                 $speaker = array('member_id' => $speaker_id, 'title' => $q->field(0, 'title'), "first_name" => $q->field(0, "first_name"), "last_name" => $q->field(0, "last_name"), 'house' => $q->field(0, 'house'), "constituency" => $q->field(0, "constituency"), "party" => $q->field(0, "party"), "person_id" => $q->field(0, "person_id"), "url" => $URL->generate());
                 global $parties;
                 // Manual fix for Speakers.
                 if (isset($parties[$speaker['party']])) {
                     $speaker['party'] = $parties[$speaker['party']];
                 }
                 $q = $this->db->query("SELECT dept, position FROM moffice WHERE person={$speaker['person_id']}\n\t\t\t\t\t\t\t\tAND to_date>='{$hdate}' AND from_date<='{$hdate}'");
                 if ($q->rows() > 0) {
                     for ($row = 0; $row < $q->rows(); $row++) {
                         $dept = $q->field($row, 'dept');
                         $pos = $q->field($row, 'position');
                         if ($pos && $pos != 'Chairman') {
                             $speaker['office'][] = array('dept' => $dept, 'position' => $pos, 'pretty' => prettify_office($pos, $dept));
                         }
                     }
                 }
                 $this->speakers[$speaker_id] = $speaker;
                 return $speaker;
             } else {
                 return array();
             }
         } else {
             // Already cached, so just return that.
             return $this->speakers[$speaker_id];
         }
     } else {
         return array();
     }
 }
Exemple #26
0
function person_numerology($member, $extra_info) {
	echo '<a name="numbers"></a>';
	//$this->block_start(array('id'=>'numbers', 'title'=>'Numerology'));
	print "<h2>Numerology</h2>";
	$displayed_stuff = 0;
?>
<p><em>Please note that numbers do not measure quality. 
Also, representatives may do other things not currently covered
by this site.</em> (<a href="<?=WEBPATH ?>help/#numbers">More about this</a>)</p>
<ul>
<?php

	$since_text = 'in the last year';
	$year_ago = date('Y-m-d', strtotime('now -1 year'));

	# Find latest entered house
	$entered_house = null;
	foreach ($member['entered_house'] as $h => $eh) {
		if (!$entered_house || $eh['date'] > $entered_house) $entered_house = $eh['date'];
	}
	if ($entered_house > $year_ago)
		$since_text = 'since joining Parliament';

	$MOREURL = new URL('search');
	$section = 'section:debates section:whall section:lords section:ni';
	$MOREURL->insert(array('pid'=>$member['person_id'], 's'=>$section, 'pop'=>1));
	if ($member['party']!='Sinn Fein') {
		$displayed_stuff |= display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in <a href="' . $MOREURL->generate() . '">', 'debate', '</a> ' . $since_text, '', $extra_info);

		$MOREURL->insert(array('pid'=>$member['person_id'], 's'=>'section:wrans', 'pop'=>1));
		// We assume that if they've answered a question, they're a minister
		$minister = 0; $Lminister = false;
		if (isset($extra_info['wrans_answered_inlastyear']) && $extra_info['wrans_answered_inlastyear'] > 0 && $extra_info['wrans_asked_inlastyear'] == 0)
			$minister = 1;
		if (isset($extra_info['Lwrans_answered_inlastyear']) && $extra_info['Lwrans_answered_inlastyear'] > 0 && $extra_info['Lwrans_asked_inlastyear'] == 0)
			$Lminister = true;
		if ($member['party']=='Speaker' || $member['party']=='Deputy Speaker') {
			$minister = 2;
		}
		$displayed_stuff |= display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister);
	}

/*
	if (isset($extra_info['select_committees'])) {
		print "<li>Is a member of <strong>$extra_info[select_committees]</strong> select committee";
		if ($extra_info['select_committees'] != 1)
			print "s";
		if (isset($extra_info['select_committees_chair']))
			print " ($extra_info[select_committees_chair] as chair)";
		print '.</li>';
	}
*/

	$wtt_displayed = display_writetothem_numbers(2008, $extra_info);
	$displayed_stuff |= $wtt_displayed;
	if (!$wtt_displayed) {
		$wtt_displayed = display_writetothem_numbers(2007, $extra_info);
		$displayed_stuff |= $wtt_displayed;
		if (!$wtt_displayed) {
			$wtt_displayed = display_writetothem_numbers(2006, $extra_info);
			$displayed_stuff |= $wtt_displayed;
			if (!$wtt_displayed)
				$displayed_stuff |= display_writetothem_numbers(2005, $extra_info);
		}
	}

	$after_stuff = ' <small>(From Public Whip)</small>';
	if ($member['party'] == 'Scottish National Party') {
		$after_stuff .= '<br><em>Note SNP MPs do not vote on legislation not affecting Scotland.</em>';
	} elseif ($member['party']=='Speaker' || $member['party']=='Deputy Speaker') {
		$after_stuff .= '<br><em>Speakers and deputy speakers cannot vote except to break a tie.</em>';
	}
	if ($member['party'] != 'Sinn Fein') {
		$when = 'in this Parliament with this affiliation';
		# Lords have one record per affiliation until they leave (ignoring name changes, sigh)
		if ($member['house_disp'] == 2 ) {
			$when = 'in this House with this affiliation';
		}
		$displayed_stuff |= display_stats_line('public_whip_division_attendance', 'Has voted in <a href="http://www.publicwhip.org.uk/mp.php?id=uk.org.publicwhip/member/' . $member['member_id'] . '&amp;showall=yes#divisions" title="See more details at Public Whip">', 'of vote', '</a> ' . $when, $after_stuff, $extra_info);
		if ($member['chairmens_panel']) {
			print '<br><em>Members of the Chairmen\'s Panel act for the Speaker when chairing things such as Public Bill Committees, and as such do not vote on Bills they are involved in chairing.</em>';
		}

		$displayed_stuff |= display_stats_line('comments_on_speeches', 'People have made <a href="' . WEBPATH . 'comments/recent/?pid='.$member['person_id'].'">', 'annotation', "</a> on this MP&rsquo;s speeches", '', $extra_info);
		$displayed_stuff |= display_stats_line('reading_age', 'This MP\'s speeches, in Hansard, are readable by an average ', '', ' year old, going by the <a href="http://en.wikipedia.org/wiki/Flesch-Kincaid_Readability_Test">Flesch-Kincaid Grade Level</a> score', '', $extra_info);
	}
		
	if (isset($extra_info['number_of_alerts'])) {
		$displayed_stuff = 1;
	?>
		<li><strong><?=htmlentities($extra_info['number_of_alerts']) ?></strong> <?=($extra_info['number_of_alerts']==1?'person is':'people are') ?> tracking <?
		if ($member['house_disp']==1) print 'this MP';
		elseif ($member['house_disp']==2) print 'this peer';
		elseif ($member['house_disp']==3) print 'this MLA';
		elseif ($member['house_disp']==4) print 'this MSP';
		elseif ($member['house_disp']==0) print $member['full_name'];
		if ($member['current_member'][0] || $member['current_member'][2] || $member['current_member'][3] || ($member['current_member'][1] && $member['party'] != 'Sinn Fein') || $member['current_member'][4]) {
			print ' &mdash; <a href="' . WEBPATH . 'alert/?only=1&amp;pid='.$member['person_id'].'">email me updates on '. $member['full_name']. '&rsquo;s activity</a>';
		}
		print '.</li>';
	}

	if ($member['party']!='Sinn Fein') {
		$displayed_stuff |= display_stats_line('three_word_alliterations', 'Has used three-word alliterative phrases (e.g. "she sells seashells") ', 'time', ' in debates', ' <small>(<a href="' . WEBPATH . 'help/#numbers">Why is this here?</a>)</small>', $extra_info);
		if (isset($extra_info['three_word_alliteration_content'])) {
				print "\n<!-- " . $extra_info['three_word_alliteration_content'] . " -->\n";
		}
	}
#		$displayed_stuff |= display_stats_line('ending_with_a_preposition', "Has ended a sentence with 'with' ", 'time', ' in debates', '', $extra_info);
#		$displayed_stuff |= display_stats_line('only_asked_why', "Has made a speech consisting solely of 'Why?' ", 'time', ' in debates', '', $extra_info);

	echo '</ul>';

	if (!$displayed_stuff) {
		print '<p>No data to display yet.</p>';
	}
	//$this->block_end();
}
Exemple #27
0
    }
    $PAGE->page_start();
    $PAGE->stripe_start();
    $args = array('year' => get_http_var('y'));
    $LIST = new LORDSDEBATELIST();
    $LIST->display('calendar', $args);
    $PAGE->stripe_end(array(array('type' => 'nextprev'), array('type' => 'include', 'content' => "holdebates")));
} elseif (get_http_var('gid') != '') {
    $this_page = 'lordsdebate';
    $args = array('gid' => get_http_var('gid'));
    $LORDSDEBATELIST = new LORDSDEBATELIST();
    $result = $LORDSDEBATELIST->display('gid', $args);
    // If it is a redirect, change URL
    if (is_string($result)) {
        $URL = new URL('lordsdebate');
        $URL->insert(array('gid' => $result));
        header('Location: http://' . DOMAIN . $URL->generate('none'), true, 301);
        exit;
    }
    if ($LORDSDEBATELIST->htype() == '12' || $LORDSDEBATELIST->htype() == '13') {
        $PAGE->stripe_start('side', 'comments');
        $COMMENTLIST = new COMMENTLIST();
        $args['user_id'] = get_http_var('u');
        $args['epobject_id'] = $LORDSDEBATELIST->epobject_id();
        $COMMENTLIST->display('ep', $args);
        $PAGE->stripe_end();
        $PAGE->stripe_start('side', 'addcomment');
        $commendata = array('epobject_id' => $LORDSDEBATELIST->epobject_id(), 'gid' => get_http_var('gid'), 'return_page' => $this_page);
        $PAGE->comment_form($commendata);
        if ($THEUSER->isloggedin()) {
            $sidebar = array(array('type' => 'include', 'content' => 'comment'));
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 
        echo $title;
        ?>
</strong><br>
							<?php 
        echo $member;
        ?>
&#8220;<?php 
        echo trim_characters($row['body'], 0, 200);
        ?>
Exemple #29
0
		'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">
                    Sort by:
                    <ul>
                        <li><?php 
echo $th_name;
?>
 |</li>
Exemple #30
0
if ($type == 2) {
    // Glossary.
    $message = "Sorry, you must be logged in to add a glossary item.";
    $message2 = "You'll be able to add your glossary item straight after.";
    $URL = new URL('glossary_addterm');
    $URL->insert(array('g' => get_http_var('g')));
    $glossary_returl = $URL->generate();
    $anchor = '';
} else {
    // Comment.
    $message = "Sorry, you must be logged in to post a comment.";
    $message2 = "You'll be able to post your comment straight after.";
    $anchor = '#addcomment';
}
$URL = new URL('userjoin');
$URL->insert(array('ret' => $returl . $anchor));
$joinurl = $URL->generate();
// GET THAT PAGE STARTED!
$PAGE->page_start();
$PAGE->stripe_start();
?>

<p><strong><?php 
echo $message;
?>
</strong></p>

<p>If you're not yet a member, then <a href="<?php 
echo $joinurl;
?>
"><strong>join now</strong></a>.</p>