本文整理汇总了PHP中fix_gid_from_db函数的典型用法代码示例。如果您正苦于以下问题:PHP fix_gid_from_db函数的具体用法?PHP fix_gid_from_db怎么用?PHP fix_gid_from_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fix_gid_from_db函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_listurl
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;
}
开发者ID:henare,项目名称:theyworkforyou,代码行数:30,代码来源:api_convertURL.php
示例2: gid_to_url
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;
}
开发者ID:udp12,项目名称:theyworkforyou,代码行数:14,代码来源:featured.php
示例3: strtolower
if (!$dept) {
} else {
$dept = strtolower(str_replace('_',' ',$dept));
$q = $db->query('select epobject.epobject_id from hansard,epobject
where hansard.epobject_id=epobject.epobject_id and major=4 and section_id=0
and hdate>(select max(hdate) from hansard where major=4) - interval 7 day
and lower(body) = "' . mysql_real_escape_string($dept).'"');
$ids = array();
for ($i=0; $i<$q->rows(); $i++) {
$ids[] = $q->field($i, 'epobject_id');
}
print '<h2>' . ucwords($dept) . '</h2>';
print '<h3>Written Ministerial Statements from the past week</h3>';
$q = $db->query('select gid,body from hansard,epobject
where hansard.epobject_id=epobject.epobject_id and major=4 and subsection_id=0
and section_id in (' . join(',', $ids) . ')
order by body');
print '<ul>';
for ($i=0; $i<$q->rows(); $i++) {
print '<li><a href="/wms/?id=' . fix_gid_from_db($q->field($i, 'gid')). '">' . $q->field($i, 'body'). '</a>';
print '</li>';
}
print '</ul>';
}
$PAGE->stripe_end();
$PAGE->page_end();
开发者ID:henare,项目名称:theyworkforyou,代码行数:29,代码来源:statements.php
示例4: _set_url
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;
}
}
}
开发者ID:palfrey,项目名称:twfy,代码行数:20,代码来源:comment.php
示例5: _get_data_by_recent_wrans
function _get_data_by_recent_wrans($args = array())
{
global $hansardmajors;
// $args['days'] is the number of days back to look for biggest debates.
// (1 by default)
// $args['num'] is the number of links to return (1 by default).
$data = array();
// Get the most recent day on which we have wrans.
$recentday = $this->most_recent_day();
if (!count($recentday)) {
return array();
}
if (!isset($args['days']) || !is_numeric($args['days'])) {
$args['days'] = 1;
}
if (!isset($args['num']) || !is_numeric($args['num'])) {
$args['num'] = 1;
}
if ($args['num'] == 1) {
$datewhere = "h.hdate = '" . mysql_escape_string($recentday['hdate']) . "'";
} else {
$firstdate = gmdate('Y-m-d', $recentday['timestamp'] - 86400 * $args['days']);
$datewhere = "h.hdate >= '" . mysql_escape_string($firstdate) . "'\n\t\t\t\t\t\tAND\t\th.hdate <= '" . mysql_escape_string($recentday['hdate']) . "'";
}
// Get a random selection of subsections in wrans.
if ($hansardmajors[$this->major]['location'] == 'Scotland') {
$htype = 'htype = 10 and section_id = 0';
} else {
$htype = 'htype = 11 and section_id != 0';
}
$q = $this->db->query("SELECT e.body,\n\t\t\t\t\t\t\t\th.hdate,\n\t\t\t\t\t\t\t\th.htype,\n\t\t\t\t\t\t\t\th.gid,\n\t\t\t\t\t\t\t\th.subsection_id,\n\t\t\t\t\t\t\t\th.section_id,\n\t\t\t\t\t\t\t\th.epobject_id\n\t\t\t\t\t\tFROM\thansard h, epobject e\n\t\t\t\t\t\tWHERE\th.major = '" . $this->major . "'\n\t\t\t\t\t\tAND\t\t{$htype}\n\t\t\t\t\t\tAND\t\tsubsection_id = 0\n\t\t\t\t\t\tAND\t\t{$datewhere}\n\t\t\t\t\t\tAND\t\th.epobject_id = e.epobject_id\n\t\t\t\t\t\tORDER BY RAND()\n\t\t\t\t\t\tLIMIT \t" . mysql_escape_string($args['num']) . "\n\t\t\t\t\t\t");
for ($row = 0; $row < $q->rows; $row++) {
// This array just used for getting further data about this debate.
$item_data = array('major' => $this->major, 'gid' => fix_gid_from_db($q->field($row, 'gid')), 'htype' => $q->field($row, 'htype'), 'section_id' => $q->field($row, 'section_id'), 'subsection_id' => $q->field($row, 'subsection_id'), 'epobject_id' => $q->field($row, 'epobject_id'));
$list_url = $this->_get_listurl($item_data);
$totalcomments = $this->_get_comment_count_for_epobject($item_data);
$body = $q->field($row, 'body');
$hdate = $q->field($row, 'hdate');
// Get the parent section for this item.
$parentbody = '';
if ($q->field($row, 'section_id')) {
$r = $this->db->query("SELECT e.body\n\t\t\t\t\t\t\tFROM\thansard h, epobject e\n\t\t\t\t\t\t\tWHERE\th.epobject_id = e.epobject_id\n\t\t\t\t\t\t\tAND\t\th.epobject_id = '" . $q->field($row, 'section_id') . "'\n\t\t\t\t\t\t\t");
$parentbody = $r->field(0, 'body');
}
// Get the question for this item.
$r = $this->db->query("SELECT e.body,\n\t\t\t\t\t\t\t\t\th.speaker_id, h.hdate\n\t\t\t\t\t\t\tFROM\thansard h, epobject e\n\t\t\t\t\t\t\tWHERE\th.epobject_id = e.epobject_id\n\t\t\t\t\t\t\tAND \th.subsection_id = '" . $q->field($row, 'epobject_id') . "'\n\t\t\t\t\t\t\tORDER BY hpos\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t");
$childbody = $r->field(0, 'body');
$speaker = $this->_get_speaker($r->field(0, 'speaker_id'), $r->field(0, 'hdate'));
$data[] = array('body' => $body, 'hdate' => $hdate, 'list_url' => $list_url, 'totalcomments' => $totalcomments, 'child' => array('body' => $childbody, 'speaker' => $speaker), 'parent' => array('body' => $parentbody));
}
$data = array('info' => array(), 'data' => $data);
return $data;
}
开发者ID:rhaleblian,项目名称:twfy,代码行数:53,代码来源:hansardlist.php
示例6: file
<?php
include_once '../../includes/easyparliament/init.php';
include_once INCLUDESPATH . "easyparliament/glossary.php";
$this_page = "debate";
$this_page = "debates";
$dates = file('alldates');
shuffle($dates);
$date = trim($dates[0]);
$db = new ParlDB();
$q = $db->query("select gid from hansard where htype in (10,11) and major=1 and hdate='{$date}' order by rand() limit 1");
$gid = $q->field(0, 'gid');
$args = array('gid' => fix_gid_from_db($gid), 'sort' => 'regexp_replace');
$GLOSSARY = new GLOSSARY($args);
$LIST = new DEBATELIST();
$result = $LIST->display('gid', $args);
$PAGE->page_end();
开发者ID:udp12,项目名称:theyworkforyou,代码行数:17,代码来源:index.php
示例7: _comment_url
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;
}
开发者ID:bruno,项目名称:openaustralia-app,代码行数:26,代码来源:commentlist.php
示例8: get_http_var
include_once "../../includes/easyparliament/init.php";
$dept = get_http_var('dept');
$PAGE->page_start();
$PAGE->stripe_start();
$db = new ParlDB();
if (!$dept) {
} else {
$dept = strtolower(str_replace('_', ' ', $dept));
$q = $db->query('select epobject.epobject_id from hansard,epobject
where hansard.epobject_id=epobject.epobject_id and major=3 and section_id=0
and hdate>(select max(hdate) from hansard where major=3) - interval 7 day
and lower(body) = "' . mysql_escape_string($dept) . '"');
$ids = array();
for ($i = 0; $i < $q->rows(); $i++) {
$ids[] = $q->field($i, 'epobject_id');
}
print '<h2>' . ucwords($dept) . '</h2>';
print '<h3>Written Questions from the past week</h3>';
$q = $db->query('select gid,body from hansard,epobject
where hansard.epobject_id=epobject.epobject_id and major=3 and subsection_id=0
and section_id in (' . join(',', $ids) . ')
order by body');
print '<ul>';
for ($i = 0; $i < $q->rows(); $i++) {
print '<li><a href="' . WEBPATH . '/wrans/?id=' . fix_gid_from_db($q->field($i, 'gid')) . '">' . $q->field($i, 'body') . '</a>';
print '</li>';
}
print '</ul>';
}
$PAGE->stripe_end();
$PAGE->page_end();
开发者ID:NathanaelB,项目名称:twfy,代码行数:31,代码来源:questions.php
示例9: generate_member_links
function generate_member_links($member, $links)
{
// Receives its data from $MEMBER->display_links;
// This returns HTML, rather than outputting it.
// Why? Because we need this to be in the sidebar, and
// we can't call the MEMBER object from the sidebar includes
// to get the links. So we call this function from the mp
// page and pass the HTML through to stripe_end(). Better than nothing.
// Bah, can't use $this->block_start() for this, as we're returning HTML...
$html = '<div class="block">
<h4>More useful links for this person</h4>
<div class="blockbody">
<ul' . (get_http_var('c4') ? ' style="list-style-type:none;"' : '') . '>';
if (isset($links['maiden_speech'])) {
$maiden_speech = fix_gid_from_db($links['maiden_speech']);
$html .= '<li><a href="' . WEBPATH . 'debate/?id=' . $maiden_speech . '">Maiden speech</a></li>';
}
// BIOGRAPHY.
if (isset($links['mp_email'])) {
$html .= ' <li><a href="mailto:' . $links['mp_email'] . '">Email ' . $member->full_name() . '</a></li>';
} elseif (isset($links['mp_contact_form'])) {
$html .= ' <li><a href="' . $links['mp_contact_form'] . '">Contact form</a> <small>(On the Australian Parliament website)</small></li>';
}
if (isset($links['mp_twitter_url'])) {
$html .= ' <li><a href="' . $links['mp_twitter_url'] . '">' . $member->full_name() . ' on Twitter</a></li>';
}
if (isset($links['mp_facebook_url'])) {
$html .= ' <li><a href="' . $links['mp_facebook_url'] . '">' . $member->full_name() . ' on Facebook</a></li>';
}
if (isset($links['mp_website'])) {
$html .= '<li><a href="' . $links['mp_website'] . '">' . $member->full_name() . '\'s personal website</a></li>';
}
if (isset($links['sp_url'])) {
$html .= '<li><a href="' . $links['sp_url'] . '">' . $member->full_name() . '\'s page on the Scottish Parliament website</a></li>';
}
if (isset($links['aph_url'])) {
$html .= '<li><a href="' . $links['aph_url'] . '">Parliament House web page for ' . $member->full_name() . '</a></li>';
}
if (isset($links['guardian_biography'])) {
$html .= ' <li><a href="' . $links['guardian_biography'] . '">Biography</a> <small>(From The Guardian)</small></li>';
}
if (isset($links['wikipedia_url'])) {
$html .= ' <li><a href="' . $links['wikipedia_url'] . '">Biography</a> <small>(From Wikipedia)</small></li>';
}
if (isset($links['mp_biography_qanda']) && $links['mp_biography_qanda'] != "") {
$html .= ' <li><a href="' . $links['mp_biography_qanda'] . '">Biography</a> <small>(From ABC\'s Q & A)</small></li>';
}
if (isset($links['diocese_url'])) {
$html .= ' <li><a href="' . $links['diocese_url'] . '">Diocese website</a></li>';
}
if (isset($links['journa_list_link'])) {
$html .= ' <li><a href="' . $links['journa_list_link'] . '">Newspaper articles written by this MP</a> <small>(From Journa-list)</small></li>';
}
if (isset($links['guardian_parliament_history'])) {
$html .= ' <li><a href="' . $links['guardian_parliament_history'] . '">Parliamentary career</a> <small>(From The Guardian)</small></li>';
}
if (isset($links['guardian_election_results'])) {
$html .= ' <li><a href="' . $links['guardian_election_results'] . '">Election results for ' . $member->constituency() . '</a> <small>(From The Guardian)</small></li>';
}
if (isset($links['abc_election_results_2013'])) {
$html .= ' <li><a href="' . $links['abc_election_results_2013'] . '">2013 Election results for ' . $member->constituency() . '</a> <small>(From ABC)</small></li>';
}
if (isset($links['abc_election_results_2010'])) {
$html .= ' <li><a href="' . $links['abc_election_results_2010'] . '">2010 Election results for ' . $member->constituency() . '</a> <small>(From ABC)</small></li>';
}
if (isset($links['abc_election_results_2007'])) {
$html .= ' <li><a href="' . $links['abc_election_results_2007'] . '">2007 Election results for ' . $member->constituency() . '</a> <small>(From ABC)</small></li>';
}
if (isset($links['guardian_candidacies'])) {
$html .= ' <li><a href="' . $links['guardian_candidacies'] . '">Previous candidacies</a> <small>(From The Guardian)</small></li>';
}
if (isset($links['guardian_contactdetails'])) {
$html .= ' <li><a href="' . $links['guardian_contactdetails'] . '">Contact details</a> <small>(From The Guardian)</small></li>';
}
if (isset($links['bbc_profile_url'])) {
$html .= ' <li><a href="' . $links['bbc_profile_url'] . '">General information</a> <small>(From BBC News)</small></li>';
}
$bbc_name = urlencode($member->first_name()) . "%20" . urlencode($member->last_name());
if ($member->member_id() == -1) {
$bbc_name = 'Queen Elizabeth';
}
#$html .= ' <li><a href="http://catalogue.bbc.co.uk/catalogue/infax/search/' . $bbc_name . '">TV/radio appearances</a> <small>(From BBC Programme Catalogue)</small></li>';
$html .= "\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</div> <!-- end block -->\n";
return $html;
}
开发者ID:archoo,项目名称:twfy,代码行数:85,代码来源:page.php
示例10: generate_member_links
function generate_member_links($member)
{
// Receives its data from $MEMBER->display_links;
// This returns HTML, rather than outputting it.
// Why? Because we need this to be in the sidebar, and
// we can't call the MEMBER object from the sidebar includes
// to get the links. So we call this function from the mp
// page and pass the HTML through to stripe_end(). Better than nothing.
$links = $member->extra_info();
// Bah, can't use $this->block_start() for this, as we're returning HTML...
$html = '<div class="block">
<h4>More useful links for this person</h4>
<div class="blockbody">
<ul' . (get_http_var('c4') ? ' style="list-style-type:none;"' : '') . '>';
if (isset($links['maiden_speech'])) {
$maiden_speech = fix_gid_from_db($links['maiden_speech']);
$html .= '<li><a href="' . WEBPATH . 'debate/?id=' . $maiden_speech . '">Maiden speech</a></li>';
}
// BIOGRAPHY.
global $THEUSER;
if (isset($links['mp_website'])) {
$html .= '<li><a href="' . $links['mp_website'] . '">' . $member->full_name() . '\'s personal website</a>';
if ($THEUSER->is_able_to('viewadminsection')) {
$html .= ' [<a href="/admin/websites.php?editperson=' . $member->person_id() . '">Edit</a>]';
}
$html .= '</li>';
} elseif ($THEUSER->is_able_to('viewadminsection')) {
$html .= '<li>[<a href="/admin/websites.php?editperson=' . $member->person_id() . '">Add personal website</a>]</li>';
}
if (isset($links['twitter_username'])) {
$html .= '<li><a href="http://twitter.com/' . $links['twitter_username'] . '">' . $member->full_name() . '’s Twitter feed</a></li>';
}
if (isset($links['sp_url'])) {
$html .= '<li><a href="' . $links['sp_url'] . '">' . $member->full_name() . '\'s page on the Scottish Parliament website</a></li>';
}
if (isset($links['guardian_biography'])) {
$html .= ' <li><a href="' . $links['guardian_biography'] . '">Guardian profile</a></li>';
}
if (isset($links['wikipedia_url'])) {
$html .= ' <li><a href="' . $links['wikipedia_url'] . '">Wikipedia page</a></li>';
}
if (isset($links['bbc_profile_url'])) {
$html .= ' <li><a href="' . $links['bbc_profile_url'] . '">BBC News profile</a></li>';
}
if (isset($links['diocese_url'])) {
$html .= ' <li><a href="' . $links['diocese_url'] . '">Diocese website</a></li>';
}
$html .= '<li><a href="http://www.edms.org.uk/mps/' . $member->person_id() . '/">Early Day Motions signed by this MP</a> <small>(From edms.org.uk)</small></li>';
if (isset($links['journa_list_link'])) {
$html .= ' <li><a href="' . $links['journa_list_link'] . '">Newspaper articles written by this MP</a> <small>(From Journalisted)</small></li>';
}
if (isset($links['guardian_election_results'])) {
$html .= ' <li><a href="' . $links['guardian_election_results'] . '">Election results for ' . $member->constituency() . '</a> <small>(From The Guardian)</small></li>';
}
/*
# BBC Catalogue is offline
$bbc_name = urlencode($member->first_name()) . "%20" . urlencode($member->last_name());
if ($member->member_id() == -1)
$bbc_name = 'Queen Elizabeth';
$html .= ' <li><a href="http://catalogue.bbc.co.uk/catalogue/infax/search/' . $bbc_name . '">TV/radio appearances</a> <small>(From BBC Programme Catalogue)</small></li>';
*/
$html .= " </ul>\n\t\t\t\t</div>\n\t\t\t</div> <!-- end block -->\n";
return $html;
}
开发者ID:henare,项目名称:theyworkforyou,代码行数:64,代码来源:index.php
示例11: major_summary
function major_summary($data, $echo = true)
{
global $hansardmajors;
$html = '';
$db = new ParlDB();
$one_date = false;
//if no printed majors passed, default to all
if (!isset($printed_majors)) {
$printed_majors = array(1, 2, 3, 5, 101, 7);
# 8
}
// single date?
if (isset($data['date'])) {
$one_date = true;
}
// remove empty entries, so they don't produce errors
foreach (array_keys($hansardmajors) as $major) {
if (array_key_exists($major, $data)) {
if (count($data[$major]) == 0) {
unset($data[$major]);
}
}
}
//work out the date text to be displaid
$daytext = array();
if (!$one_date) {
$todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y'));
foreach ($data as $major => $array) {
if (!in_array('timestamp', $array)) {
$daytext[$major] = "The most recent ";
} elseif ($todaystime - $array['timestamp'] == 86400) {
$daytext[$major] = "Yesterday’s";
} elseif ($todaystime - $array['timestamp'] <= 6 * 86400) {
$daytext[$major] = gmdate('l', $array['timestamp']) . "’s";
} else {
$daytext[$major] = "The most recent ";
}
}
}
//build html
foreach ($printed_majors as $p_major) {
if (!array_key_exists($p_major, $data)) {
continue;
}
if ($one_date) {
$date = $data['date'];
} else {
$date = $data[$p_major]['hdate'];
}
$q = $db->query('SELECT body, gid
FROM hansard, epobject
WHERE hansard.epobject_id = epobject.epobject_id AND section_id = 0
AND hdate = "' . $date . '"
AND major = ' . $p_major . '
ORDER BY hpos');
$out = '';
$LISTURL = new URL($hansardmajors[$p_major]['page_all']);
for ($i = 0; $i < $q->rows(); $i++) {
$gid = fix_gid_from_db($q->field($i, 'gid'));
$body = $q->field($i, 'body');
//if (strstr($body, 'Chair]')) continue;
$LISTURL->insert(array('id' => $gid));
$out .= '<li><a href="' . $LISTURL->generate() . '">';
$out .= $body . '</a>';
}
if ($out) {
$html .= _major_summary_title($p_major, $data, $LISTURL, $daytext);
$html .= '<ul class="hansard-day">';
$html .= $out;
$html .= '</ul>';
}
}
if (array_key_exists(4, $data)) {
if ($one_date) {
$date = $data['date'];
} else {
$date = $data[4]['hdate'];
}
$q = $db->query('SELECT section_id, body, gid FROM hansard,epobject
WHERE hansard.epobject_id = epobject.epobject_id AND major=4 AND hdate="' . $date . '" AND subsection_id=0
ORDER BY major, hpos');
if ($q->rows()) {
$LISTURL = new URL($hansardmajors[4]['page_all']);
$html .= _major_summary_title(4, $data, $LISTURL, $daytext);
$html .= "<ul>";
$current_sid = 0;
for ($i = 0; $i < $q->rows(); $i++) {
$gid = fix_gid_from_db($q->field($i, 'gid'));
$body = $q->field($i, 'body');
$section_id = $q->field($i, 'section_id');
if (!$section_id) {
if ($current_sid++) {
$html .= '</ul>';
}
$html .= '<li>' . $body . '<ul>';
} else {
$LISTURL->insert(array('id' => $gid));
$html .= '<li><a href="' . $LISTURL->generate() . '">';
$html .= $body . '</a>';
}
//.........这里部分代码省略.........
开发者ID:palfrey,项目名称:twfy,代码行数:101,代码来源:utility.php
示例12: major_summary
function major_summary($data, $limit = "")
{
global $hansardmajors;
$db = new ParlDB();
$one_date = false;
if (isset($data['date'])) {
$one_date = true;
}
$limitsql = "";
if ($limit) {
$limitsql = " limit {$limit}";
}
$daytext = array();
if (!$one_date) {
$todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y'));
foreach ($data as $major => $array) {
if ($todaystime - $array['timestamp'] == 86400) {
$daytext[$major] = "Yesterday's";
} elseif ($todaystime - $array['timestamp'] <= 6 * 86400) {
$daytext[$major] = gmdate('l', $array['timestamp']) . "'s";
} else {
$daytext[$major] = "The most recent ";
}
}
}
$printed_majors = array(1, 2, 3, 5, 101);
print '<ul id="hansard-day">';
while (count($printed_majors)) {
if (!array_key_exists($printed_majors[0], $data)) {
unset($printed_majors[0]);
sort($printed_majors);
continue;
}
if ($one_date) {
$date = $data['date'];
} else {
$date = $data[$printed_majors[0]]['hdate'];
}
$q = $db->query('SELECT major, body, gid
FROM hansard,epobject
WHERE hansard.epobject_id = epobject.epobject_id AND section_id=0
AND hdate="' . $date . '"
AND major IN (' . join(',', $printed_majors) . ')
ORDER BY major desc, hpos' . $limitsql);
$current_major = 0;
for ($i = 0; $i < $q->rows(); $i++) {
$gid = fix_gid_from_db($q->field($i, 'gid'));
$major = $q->field($i, 'major');
$body = $q->field($i, 'body');
//if (strstr($body, 'Chair]')) continue;
if ($major != $current_major) {
if ($current_major) {
print '</ul>';
}
$LISTURL = new URL($hansardmajors[$major]['page_all']);
_major_summary_title($major, $data, $LISTURL, $daytext);
$current_major = $major;
# XXX: Surely a better way of doing this? Oh well
unset($printed_majors[array_search($major, $printed_majors)]);
sort($printed_majors);
}
$LISTURL->insert(array('id' => $gid));
print '<li><a href="' . $LISTURL->generate() . '">';
print $body . '</a>';
}
print '</ul>';
if ($one_date) {
$printed_majors = array();
}
}
if (array_key_exists(4, $data)) {
if ($one_date) {
$date = $data['date'];
} else {
$date = $data[4]['hdate'];
}
$q = $db->query('SELECT section_id, body, gid FROM hansard,epobject
WHERE hansard.epobject_id = epobject.epobject_id AND major=4 AND hdate="' . $date . '" AND subsection_id=0
ORDER BY major, hpos' . $limitsql);
if ($q->rows()) {
$LISTURL = new URL($hansardmajors[4]['page_all']);
_major_summary_title(4, $data, $LISTURL, $daytext);
$current_sid = 0;
for ($i = 0; $i < $q->rows(); $i++) {
$gid = fix_gid_from_db($q->field($i, 'gid'));
$body = $q->field($i, 'body');
$section_id = $q->field($i, 'section_id');
if (!$section_id) {
if ($current_sid++) {
print '</ul>';
}
print '<li>' . $body . '<ul>';
} else {
$LISTURL->insert(array('id' => $gid));
print '<li><a href="' . $LISTURL->generate() . '">';
print $body . '</a>';
}
}
print '</ul></ul>';
}
//.........这里部分代码省略.........
开发者ID:leowmjw,项目名称:twfy,代码行数:101,代码来源:utility.php
示例13: search
//.........这里部分代码省略.........
}
$SEARCHENGINE->run_search($first_result, $results_per_page, $sort_order);
$gids = $SEARCHENGINE->get_gids();
if ($sort_order == 'created') {
$createds = $SEARCHENGINE->get_createds();
}
$relevances = $SEARCHENGINE->get_relevances();
if (count($gids) <= 0) {
// No results.
$data['rows'] = array();
return $data;
}
#if ($sort_order=='created') { print_r($gids); }
// We'll put all the data in here before giving it to a template.
$rows = array();
// We'll cache the ids=>names of speakers here.
$speakers = array();
// We'll cache (sub)section_ids here:
$hansard_to_gid = array();
// Cycle through each result, munge the data, get more, and put it all in $data.
$gids_count = count($gids);
for ($n = 0; $n < $gids_count; $n++) {
$gid = $gids[$n];
$relevancy = $relevances[$n];
$collapsed = $SEARCHENGINE->collapsed[$n];
if ($sort_order == 'created') {
#$created = substr($createds[$n], 0, strpos($createds[$n], ':'));
if ($createds[$n] < $args['threshold']) {
$data['info']['total_results'] = $n;
break;
}
}
if (strstr($gid, 'calendar')) {
$id = fix_gid_from_db($gid);
$q = $this->db->query("SELECT *, event_date as hdate, pos as hpos\n FROM future\n LEFT JOIN future_people ON id=calendar_id AND witness=0\n WHERE id = {$id} AND deleted=0");
if ($q->rows() == 0) {
continue;
}
$itemdata = $q->row(0);
# Ignore past events in places that we cover (we'll have the data from Hansard)
if ($itemdata['event_date'] < date('Y-m-d') && in_array($itemdata['chamber'], array('Commons: Main Chamber', 'Lords: Main Chamber', 'Commons: Westminster Hall'))) {
continue;
}
list($cal_item, $cal_meta) = calendar_meta($itemdata);
$body = $this->prepare_search_result_for_display($cal_item) . '.';
if ($cal_meta) {
$body .= ' <span class="future_meta">' . join('; ', $cal_meta) . '</span>';
}
if ($itemdata['witnesses']) {
$body .= '<br><small>Witnesses: ' . $this->prepare_search_result_for_display($itemdata['witnesses']) . '</small>';
}
if ($itemdata['event_date'] >= date('Y-m-d')) {
$title = 'Upcoming Business';
} else {
$title = 'Previous Business';
}
$itemdata['gid'] = $id;
$itemdata['relevance'] = $relevances[$n];
$itemdata['parent']['body'] = $title . ' – ' . $itemdata['chamber'];
$itemdata['extract'] = $body;
$itemdata['listurl'] = '/calendar/?d=' . $itemdata['event_date'] . '#cal' . $itemdata['id'];
$itemdata['major'] = 'F';
} else {
// Get the data for the gid from the database
$q = $this->db->query("SELECT hansard.gid, hansard.hdate,\n hansard.htime, hansard.section_id, hansard.subsection_id,\n hansard.htype, hansard.major, hansard.minor,\n hansard.person_id, hansard.hpos, hansard.video_status,\n epobject.epobject_id, epobject.body\n FROM hansard, epobject\n WHERE hansard.gid = '{$gid}'\n AND hansard.epobject_id = epobject.epobject_id");
if ($q->rows() > 1) {
开发者ID:sarahs-synapse,项目名称:theyworkforyou,代码行数:67,代码来源:Hansard.php
示例14: video_front_page
//.........这里部分代码省略.........
Registration is not needed to timestamp videos, but you can <a href="/user/?pg=join&ret=/video/">register here</a> if you want.</p>
<p id="video_attract"><?
if ($totaliser[0]) {
echo '<a href="next.php?action=random">Give me a random speech that needs timestamping</a>';
} else {
echo 'Wow, everything that can currently be timestamped appears to have been, thanks!';
}
?></p>
<div id="top" style="float: left; width: 45%;">
<?
list($out_today, $rank_today) = display_league(20, 'and date(whenstamped)=current_date');
list($out_week, $rank_week) = display_league(40, 'and date(whenstamped)>current_date-interval 28 day');
list($out_overall, $rank_overall) = display_league(100);
$out_overall = '';
global $THEUSER;
if ($THEUSER->user_id() && ($rank_today || $rank_week || $rank_overall)) {
echo '<p align="center"><big>You are ';
if ($rank_today) echo make_ranking($rank_today), ' today, ';
if ($rank_week) echo make_ranking($rank_week), ' last 4 weeks, ';
if ($rank_overall) echo make_ranking($rank_overall), ' overall';
echo '</big></p>';
}
if ($out_today) echo "<h3>Top timestampers (today)</h3> <ol>$out_today</ol>";
if ($out_week) echo "<h3>Top timestampers (last 4 weeks)</h3> <ol>$out_week</ol>";
if ($out_overall) echo "<h3>Top timestampers (overall)</h3> <ol>$out_overall</ol>";
echo '</div>';
?>
<div style="float: right; width: 50%">
<img align="right" width=200 height=100 src="http://chart.apis.google.com/chart?chs=200x100&cht=gom&chd=t:<?php
echo $percentage;
?>
" alt="<?php
echo $percentage;
?>
% of speeches have been timestamped">
<h3>Totaliser</h3>
<ul><?php
echo $out;
?>
</ul>
<?
$q = $db->query('select video_status&4 as checked,count(*) as c from hansard
where major=1 and video_status>0 and video_status<8 and video_status!=2 and htype in (12,13)
and hdate=(select max(hdate) from hansard where major=1)
group by video_status&4');
$totaliser = array(0=>0, 4=>0);
for ($i=0; $i<$q->rows(); $i++) {
$status = $q->field($i, 'checked');
$count = $q->field($i, 'c');
$totaliser[$status] = $count;
}
$total_possible = $totaliser[0] + $totaliser[4];
if ($total_possible == 0) {
$percentage = 0;
$out = 'Nothing possible to timestamp on most recent day';
} else {
$percentage = round($totaliser[4] / $total_possible * 10000) / 100;
$out = "$totaliser[4] timestamped out of $total_possible ($percentage%)";
}
?>
<h3 style="padding-top:0.5em;clear:right">Totaliser for most recent day</h3>
<img align="right" width=200 height=100 src="http://chart.apis.google.com/chart?chs=200x100&cht=gom&chd=t:<?php
echo $percentage;
?>
" alt="<?php
echo $percentage;
?>
% of speeches have been timestamped">
<ul><?php
echo $out;
?>
</ul>
<h3 style="clear:both;margin-top:1em">Latest stamped</h3>
<ul>
<?
$q = $db->query('select hansard.gid, body, major from video_timestamps, hansard, epobject
where (user_id != -1 or user_id is null) and video_timestamps.deleted=0
and video_timestamps.gid = hansard.gid and hansard.subsection_id = epobject.epobject_id
order by whenstamped desc limit 20');
for ($i=0; $i<$q->rows(); $i++) {
$gid = $q->field($i, 'gid');
$body = $q->field($i, 'body');
if ($q->field($i, 'major') == 101) {
$url = '/lords/?gid=';
} else {
$url = '/debate/?id=';
}
echo '<li><a href="', $url, fix_gid_from_db($gid) . '">' . $body . '</a>';
}
echo '</ul></div>';
}
开发者ID:henare,项目名称:theyworkforyou,代码行数:101,代码来源:index.php
示例15: person_useful_links
function person_useful_links($member)
{
$links = $member->extra_info();
$out = array();
if (isset($links['maiden_speech'])) {
$maiden_speech = fix_gid_from_db($links['maiden_speech']);
$out[] = array('href' => WEBPATH . 'debate/?id=' . $maiden_speech, 'text' => 'Maiden speech');
}
// BIOGRAPHY.
global $THEUSER;
if (isset($links['mp_website'])) {
$out[] = array('href' => $links['mp_website'], 'text' => 'Personal website');
}
if (isset($links['twitter_username'])) {
$out[] = array('href' => 'http://twitter.com/' . $links['twitter_username'], 'text' => 'Twitter feed');
}
if (isset($links['sp_url'])) {
$out[] = array('href' => $links['sp_url'], 'text' => 'Page on the Scottish Parliament website');
}
if (isset($links['wikipedia_url'])) {
$out[] = array('href' => $links['wikipedia_url'], 'text' => 'Wikipedia page');
}
if (isset($links['bbc_profile_url'])) {
$out[] = array('href' => $links['bbc_profile_url'], 'text' => 'BBC News profile');
}
if (isset($links['diocese_url'])) {
$out[] = array('href' => $links['diocese_url'], 'text' => 'Diocese website');
}
if ($member->house(HOUSE_TYPE_COMMONS)) {
$out[] = array('href' => 'http://www.edms.org.uk/mps/' . $member->person_id(), 'text' => 'Early Day Motions signed by this MP');
}
if (isset($links['journa_list_link'])) {
$out[] = array('href' => $links['journa_list_link'], 'text' => 'Newspaper articles written by this MP');
}
return $out;
}
开发者ID:sarahs-synapse,项目名称:theyworkforyou,代码行数:36,代码来源:index.php
示例16: divisionUrlFromGid
private function divisionUrlFromGid($gid)
{
global $hansardmajors;
$q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array(':gid' => $gid));
$parent_gid = $q->field(0, 'gid');
if (!$parent_gid) {
return '';
}
$parent_gid = fix_gid_from_db($parent_gid);
$url = new \URL($hansardmajors[$q->field(0, 'major')]['page']);
$url->insert(array('gid' => $parent_gid));
return $url->generate();
}
开发者ID:udp12,项目名称:theyworkforyou,代码行数:13,代码来源:Divisions.php
注:本文中的fix_gid_from_db函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论