예제 #1
0
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;
}
예제 #2
0
 function _get_listurl($id_data, $url_args = array(), $encode = 'html')
 {
     global $hansardmajors;
     // Generates an item's listurl - this is the 'contextual' url
     // for an item, in the full list view with an anchor (if appropriate).
     // $id_data is like this:
     //		$id_data = array (
     //		'major' 		=> 1,
     //		'htype' 		=> 12,
     //		'gid' 			=> 2003-10-30.421.4h2,
     //		'section_id'	=> 345,
     //		'subsection_id'	=> 346
     // );
     // $url_args is an array of other key/value pairs to be appended in the GET string.
     if ($id_data['major']) {
         $LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']);
     } else {
         $LISTURL = new URL('wrans');
     }
     $fragment = '';
     if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
         if ($this->major == 6) {
             $id = preg_replace('#^.*?_.*?_#', '', $id_data['gid']);
             $fragment = $this->url . '/' . $id;
             $LISTURL->remove(array('id'));
         } else {
             $LISTURL->insert(array('id' => $id_data['gid']));
         }
     } else {
         // A debate speech or question/answer, etc.
         // We need to get the gid of the parent (sub)section for this item.
         // We use this with the gid of the item itself as an #anchor.
         $parent_epobject_id = $id_data['subsection_id'];
         // Find the gid of this item's (sub)section.
         $parent_gid = '';
         if (isset($this->epobjectid_to_gid[$parent_epobject_id])) {
             // We've previously cached the gid for this epobject_id, so use that.
             $parent_gid = $this->epobjectid_to_gid[$parent_epobject_id];
         } else {
             // We haven't cached the gid, so fetch from db.
             $r = $this->db->query("SELECT gid\n\t\t\t\t\t\t\t\tFROM \thansard\n\t\t\t\t\t\t\t\tWHERE\tepobject_id = '" . mysql_escape_string($parent_epobject_id) . "'\n\t\t\t\t\t\t\t\t");
             if ($r->rows() > 0) {
                 // Remove the "uk.org.publicwhip/blah/" from the gid:
                 // (In includes/utility.php)
                 $parent_gid = fix_gid_from_db($r->field(0, 'gid'));
                 // Cache it for if we need it again:
                 $this->epobjectid_to_gid[$parent_epobject_id] = $parent_gid;
             }
         }
         if ($parent_gid != '') {
             // We have a gid so add to the URL.
             $LISTURL->insert(array('id' => $parent_gid));
             // Use a truncated form of this item's gid for the anchor.
             $fragment = '#g' . gid_to_anchor($id_data['gid']);
         }
     }
     if (count($url_args) > 0) {
         $LISTURL->insert($url_args);
     }
     return $LISTURL->generate($encode) . $fragment;
 }
예제 #3
0
function video_sidebar($row, $section, $count, $major) {
	include_once INCLUDESPATH . 'easyparliament/video.php';
	$db = new ParlDB;
	if ($major == 1) {
		$gid_type = 'debate';
	} elseif ($major == 101) {
		$gid_type = 'lords';
	}
	$vq = $db->query("select id,adate,atime from video_timestamps where gid='uk.org.publicwhip/$gid_type/$row[gid]' and (user_id!=-1 or user_id is null) and deleted=0 order by (user_id is null) limit 1");
	$ts_id = $vq->field(0, 'id'); if (!$ts_id) $ts_id='*';
	$adate = $vq->field(0, 'adate');
	$time = $vq->field(0, 'atime');
	$videodb = video_db_connect();
	if (!$videodb) return '';
	$video = video_from_timestamp($videodb, $adate, $time);
	$start = $video['offset'];
	$out = '';
	if ($count > 1) {
		$out .= '<div id="video_wrap"><div style="position:relative">';
		if ($row['gid'] != $section['first_gid']) {
			$out .= '<p style="margin:0">This video starts around ' . ($row['hpos']-$section['hpos']) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
		}
	}
	$out .= video_object($video['id'], $start, "$gid_type/$row[gid]");
	$flashvars = 'gid=' . "$gid_type/$row[gid]" . '&amp;file=' . $video['id'] . '&amp;start=' . $start;
	$out .= "<br><b>Add this video to another site:</b><br><input readonly onclick='this.focus();this.select();' type='text' name='embed' size='40' value=\"<embed src='http://www.theyworkforyou.com/video/parlvid.swf' width='320' height='230' allowfullscreen='true' allowscriptaccess='always' flashvars='$flashvars'></embed>\"><br><small>(copy and paste the above)</small>";
	$out .= "<p style='margin-bottom:0'>Is this not the right video? <a href='mailto:team&#64;theyworkforyou.com?subject=Incorrect%20video,%20id%20$row[gid];$video[id];$ts_id'>Let us know</a></p>";
	if ($count > 1) {
		$out .= '<p style="position:absolute;bottom:0;right:0;margin:0"><a href="" onclick="return showVideo();">Hide</a></p>';
		$out .= '</div></div>';
		$out .= '<div id="video_show" style="display:none;position:fixed;bottom:5px;right:5px;border:solid 1px #666666; background-color: #eeeeee; padding: 4px;">
<p style="margin:0"><a href="" onclick="return hideVideo();">Show video</a></p></div>';
	}
	return $out;
}
예제 #4
0
파일: hansard_gid.php 프로젝트: bruno/twfy
            }
            // If this item is at a new time, then print the time.
            if (substr($row['htime'], 0, 5) != $timetracker && $row['htime'] != "00:00:00") {
                $PAGE->stripe_start('time-' . $style);
                echo "\t\t\t\t<p>" . format_time($row['htime'], TIMEFORMAT) . "</p>\n";
                $PAGE->stripe_end();
                // Set the timetracker to the current time
                $timetracker = substr($row['htime'], 0, 5);
                $stripecount++;
                $style = $stripecount % 2 == 0 ? '1' : '2';
            }
            if (isset($row['speaker']) && (isset($row['speaker']['member_id']) && isset($data['info']['member_id']) && $row['speaker']['member_id'] == $data['info']['member_id'] || isset($row['speaker']['person_id']) && isset($data['info']['person_id']) && $row['speaker']['person_id'] == $data['info']['person_id'])) {
                $style .= '-on';
            }
            // gid_to_anchor() is in utility.php
            $id = 'g' . gid_to_anchor($row['gid']);
            $PAGE->stripe_start($style, $id);
            ?>
				<a name="<?php 
            echo $id;
            ?>
"></a>
<?php 
            if (isset($row['speaker']) && count($row['speaker']) > 0) {
                // We have a speaker to print.
                $speaker = $row['speaker'];
                $speakername = ucfirst(member_full_name($speaker['house'], $speaker['title'], $speaker['first_name'], $speaker['last_name'], $speaker['constituency']));
                echo '<p class="speaker"><a href="', $speaker['url'], '" title="See more information about ', $speakername, '">';
                list($image, $sz) = find_rep_image($speaker['person_id'], true);
                if ($image) {
                    echo '<img src="', $image, '" class="portrait" alt="Photo of ', $speakername, '"';
예제 #5
0
 public function _get_listurl($id_data, $url_args = array(), $encode = 'html')
 {
     global $hansardmajors;
     // Generates an item's listurl - this is the 'contextual' url
     // for an item, in the full list view with an anchor (if appropriate).
     // $id_data is like this:
     //		$id_data = array (
     //		'major' 		=> 1,
     //		'htype' 		=> 12,
     //		'gid' 			=> 2003-10-30.421.4h2,
     //		'section_id'	=> 345,
     //		'subsection_id'	=> 346
     // );
     // $url_args is an array of other key/value pairs to be appended in the GET string.
     if ($id_data['major']) {
         $LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']);
     } else {
         $LISTURL = new URL('wrans');
     }
     $fragment = '';
     if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
         if ($this->major == 6) {
             $id = preg_replace('#^.*?_.*?_#', '', $id_data['gid']);
             global $DATA;
             $DATA->set_page_metadata('pbc_clause', 'url', 'pbc/' . $this->url . $id);
             $LISTURL->remove(array('id'));
         } else {
             $LISTURL->insert(array('id' => $id_data['gid']));
         }
     } else {
         // A debate speech or question/answer, etc.
         // We need to get the gid of the parent (sub)section for this item.
         // We use this with the gid of the item itself as an #anchor.
         $parent_epobject_id = $id_data['subsection_id'];
         $minor = $id_data['minor'];
         // Find the gid of this item's (sub)section.
         $parent_gid = '';
         if (isset($this->epobjectid_to_gid[$parent_epobject_id])) {
             // We've previously cached the gid for this epobject_id, so use that.
             $parent_gid = $this->epobjectid_to_gid[$parent_epobject_id];
         } else {
             // We haven't cached the gid, so fetch from db.
             $r = $this->db->query("SELECT gid\n                                FROM \thansard\n                                WHERE\tepobject_id = :epobject_id", array(':epobject_id' => $parent_epobject_id));
             if ($r->rows() > 0) {
                 // Remove the "uk.org.publicwhip/blah/" from the gid:
                 // (In includes/utility.php)
                 $parent_gid = fix_gid_from_db($r->field(0, 'gid'));
                 // Cache it for if we need it again:
                 $this->epobjectid_to_gid[$parent_epobject_id] = $parent_gid;
             }
         }
         if ($parent_gid != '') {
             // We have a gid so add to the URL.
             if ($id_data['major'] == 6) {
                 if (isset($this->bill_lookup[$minor])) {
                     list($title, $session) = $this->bill_lookup[$minor];
                 } else {
                     $qq = $this->db->query('select title, session from bills where id=' . $minor);
                     $title = $qq->field(0, 'title');
                     $session = $qq->field(0, 'session');
                     $this->bill_lookup[$minor] = array($title, $session);
                 }
                 $url = "{$session}/" . urlencode(str_replace(' ', '_', $title));
                 $parent_gid = preg_replace('#^.*?_.*?_#', '', $parent_gid);
                 global $DATA;
                 $DATA->set_page_metadata('pbc_clause', 'url', "pbc/{$url}/{$parent_gid}");
                 $LISTURL->remove(array('id'));
             } else {
                 $LISTURL->insert(array('id' => $parent_gid));
             }
             // Use a truncated form of this item's gid for the anchor.
             $fragment = '#g' . gid_to_anchor($id_data['gid']);
         }
     }
     if (count($url_args) > 0) {
         $LISTURL->insert($url_args);
     }
     return $LISTURL->generate($encode) . $fragment;
 }
예제 #6
0
 private function video_sidebar($row, $heading_hpos, $count)
 {
     $db = new \ParlDB();
     $gid_type = $this->video_gid_type();
     $vq = $db->query("select id,adate,atime from video_timestamps where gid='uk.org.publicwhip/{$gid_type}/{$row['gid']}' and (user_id!=-1 or user_id is null) and deleted=0 order by (user_id is null) limit 1");
     $adate = $vq->field(0, 'adate');
     $time = $vq->field(0, 'atime');
     $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
     if (!$videodb) {
         return '';
     }
     $video = \MySociety\TheyWorkForYou\Utility\Video::fromTimestamp($videodb, $adate, $time);
     $start = $video['offset'];
     $out = '';
     if ($count > 1) {
         $out .= '<div class="debate__video" id="video_wrap"><div>';
         if ($row['gid'] != $this->first_gid) {
             $out .= '<p class="video-instructions">This video starts around ' . ($row['hpos'] - $heading_hpos) . ' speeches in (<a href="#g' . gid_to_anchor($row['gid']) . '">move there in text</a>)</p>';
         }
     }
     $out .= \MySociety\TheyWorkForYou\Utility\Video::object($video['id'], $start, "{$gid_type}/{$row['gid']}");
     $flashvars = 'gid=' . "{$gid_type}/{$row['gid']}" . '&amp;file=' . $video['id'] . '&amp;start=' . $start;
     $out .= "<strong>Embed this video</strong><p class='video-instructions'>Copy and paste this code on your website</p><input readonly onclick='this.focus();this.select();' type='text' name='embed' size='40' value=\"<embed src='http://www.theyworkforyou.com/video/parlvid.swf' width='320' height='230' allowfullscreen='true' allowscriptaccess='always' flashvars='{$flashvars}'></embed>\">";
     if ($count > 1) {
         $out .= '<p class="hide-video"><a href="" onclick="return showVideo();">Hide</a></p>';
         $out .= '</div></div>';
         $out .= '<div id="video_show" class="show-video" style="display:none;">
 <p style="margin:0"><a href="" onclick="return hideVideo();">Show video</a></p></div>';
     }
     return $out;
 }
예제 #7
0
            $source['text'] = 'Official Report source';
        } else {
            $source['text'] = 'Hansard source';
        }
    }
    ?>

    <div class="debate-speech" id="g<?php 
    echo gid_to_anchor($speech['gid']);
    ?>
">
        <div class="full-page__row">
            <div class="full-page__unit">

            <a name="g<?php 
    echo gid_to_anchor($speech['gid']);
    ?>
"></a>

            <div class="debate-speech__speaker-and-content">

          <?php 
    if (isset($speech['speaker']) && count($speech['speaker']) > 0) {
        ?>
            <h2 class="debate-speech__speaker">
                <?php 
        $speaker = $speech['speaker'];
        $speaker_name = ucfirst($speaker['name']);
        list($image_url, $size) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($speaker['person_id'], true, $data['info']['major'] == 101 ? 'lord' : 'general');
        if (count($speaker['office'])) {
            $desc = array();