Пример #1
0
to go back to WriteToThem.
</big></strong></p>
<?php 
        }
        ?>
<p>Please note that this search is only for the exact word/phrase entered.
For example, putting in 'autism' won't return results for 'autistic spectrum disorder',
you will have to search for it separately.</p>
<table><tr><th>Number of occurences</th><th><?php 
        if ($wtt) {
            print 'Speaker';
        } else {
            $URL = new URL($this_page);
            $url_l = $URL->generate('html', array('house' => 2));
            $url_c = $URL->generate('html', array('house' => 1));
            $URL->remove(array('house'));
            $url_b = $URL->generate();
            if ($q_house == 1) {
                print 'Representatives | <a href="' . $url_l . '">Senators</a> | <a href="' . $url_b . '">Both</a>';
            } elseif ($q_house == 2) {
                print '<a href="' . $url_c . '">Representatives</a> | Senators | <a href="' . $url_b . '">Both</a>';
            } else {
                print '<a href="' . $url_c . '">Representatives</a> | <a href="' . $url_l . '">Senators</a> | Both';
            }
        }
        ?>
</th><th>Date range</th></tr>
<?php 
        foreach ($data['speakers'] as $pid => $speaker) {
            print '<tr><td align="center">';
            print $speaker['count'] . '</td><td>';
Пример #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 page_links($pagedata)
    {
        // The next/prev and page links for the search page.
        global $this_page;
        // $pagedata has...
        $total_results = $pagedata['total_results'];
        $results_per_page = $pagedata['results_per_page'];
        $page = $pagedata['page'];
        if ($total_results > $results_per_page) {
            $numpages = ceil($total_results / $results_per_page);
            $pagelinks = array();
            // How many links are we going to display on the page - don't want to
            // display all of them if we have 100s...
            if ($page < 10) {
                $firstpage = 1;
                $lastpage = 10;
            } else {
                $firstpage = $page - 10;
                $lastpage = $page + 9;
            }
            if ($firstpage < 1) {
                $firstpage = 1;
            }
            if ($lastpage > $numpages) {
                $lastpage = $numpages;
            }
            // Generate all the page links.
            $URL = new URL($this_page);
            $URL->insert(array('wtt' => get_http_var('wtt')));
            for ($n = $firstpage; $n <= $lastpage; $n++) {
                if ($n > 1) {
                    $URL->insert(array('p' => $n));
                } else {
                    // No page number for the first page.
                    $URL->remove(array('p'));
                }
                if (isset($pagedata['pid'])) {
                    $URL->insert(array('pid' => $pagedata['pid']));
                }
                if ($n != $page) {
                    $pagelinks[] = '<a href="' . $URL->generate() . '">' . $n . '</a>';
                } else {
                    $pagelinks[] = "<strong>{$n}</strong>";
                }
            }
            // Display everything.
            ?>
				<div class="pagelinks">
					Result page: 
<?php 
            if ($page != 1) {
                $prevpage = $page - 1;
                $URL->insert(array('p' => $prevpage));
                ?>
					<big><strong><a href="<?php 
                echo $URL->generate();
                ?>
"><big>&laquo;</big> Previous</a></strong></big>
<?php 
            }
            echo "\t\t\t\t" . implode(' ', $pagelinks);
            if ($page != $numpages) {
                $nextpage = $page + 1;
                $URL->insert(array('p' => $nextpage));
                ?>

					<big><strong><a href="<?php 
                echo $URL->generate();
                ?>
">Next <big>&raquo;</big></a></strong></big> <?php 
            }
            ?>

				</div>
<?php 
        }
    }
Пример #4
0
            
            <tr>
                <td class="code"><code>$url->args()</code></td>
                <td rowspan="2"><?php 
print_r($url->args());
?>
</td>
            </tr>
            <tr>
                <td class="note">get args</td>                
            </tr>
            
            <tr>
                <td class="code"><code>$url->remove('z')</code></td>
                <td rowspan="2"><?php 
echo $url->remove('z');
?>
</td>
            </tr>
            <tr>
                <td class="note">remove z</td>                
            </tr>
            
            <tr>
                <td class="code"><code>$url->remove()</code></td>
                <td rowspan="2"><?php 
echo $url->remove();
?>
</td>
            </tr>
            <tr>
Пример #5
0
<?php 
        }
        ?>
<p>Please note that this search is only for the exact word/phrase entered.
For example, putting in 'autism' won't return results for 'autistic spectrum disorder',
you will have to search for it separately.</p>
<table><tr><th>Number of occurences</th><th><?php 
        if ($wtt) {
            print 'Speaker';
        } else {
            ?>
Table includes - <?php 
            $URL = new URL($this_page);
            $url_l = $URL->generate('html', array('house' => 2));
            $url_c = $URL->generate('html', array('house' => 1));
            $URL->remove('house');
            $url_b = $URL->generate();
            if ($q_house == 1) {
                print 'MPs | <a href="' . $url_l . '">Lords</a> | <a href="' . $url_b . '">Both</a>';
            } elseif ($q_house == 2) {
                print '<a href="' . $url_c . '">MPs</a> | Lords | <a href="' . $url_b . '">Both</a>';
            } else {
                print '<a href="' . $url_c . '">MPs</a> | <a href="' . $url_l . '">Lords</a> | Both';
            }
        }
        ?>
</th><th>Date range</th></tr>
<?php 
        foreach ($data['speakers'] as $pid => $speaker) {
            print '<tr><td align="center">';
            print $speaker['count'] . '</td><td>';
Пример #6
0
 protected function display_section_or_speech($args = array())
 {
     global $DATA, $this_page, $THEUSER;
     # += as we *don't* want to override any already supplied argument
     $args += array('gid' => get_http_var('id'), 's' => get_http_var('s'), 'member_id' => get_http_var('m'));
     if (preg_match('/speaker:(\\d+)/', get_http_var('s'), $mmm)) {
         $args['person_id'] = $mmm[1];
     }
     try {
         $data = $this->list->display('gid', $args, 'none');
     } catch (\RedirectException $e) {
         $URL = new \URL($this->major_data['page_all']);
         if ($this->major == 6) {
             # Magically (as in I can't remember quite why), pbc_clause will
             # contain the new URL without any change...
             $URL->remove(array('id'));
         } else {
             $URL->insert(array('id' => $e->getMessage()));
         }
         # put the search term back in so highlighting works.
         # NB: as we don't see the # part of the URL we lose this :(
         if ($args['s'] !== '') {
             $URL->insert(array('s' => $args['s']));
         }
         redirect($URL->generate('none'));
     }
     $data['individual_item'] = $this->list->commentspage == $this_page;
     if ($data['individual_item']) {
         $COMMENTLIST = new \COMMENTLIST();
         $args['user_id'] = get_http_var('u');
         $args['epobject_id'] = $this->list->epobject_id();
         $data['comments']['object'] = $COMMENTLIST;
         $data['comments']['args'] = $args;
         $data['comments']['commentdata'] = array('epobject_id' => $this->list->epobject_id(), 'gid' => get_http_var('id'), 'return_page' => $this_page);
     }
     if (!isset($data['info'])) {
         header("HTTP/1.0 404 Not Found");
         exit;
         # XXX
     }
     # Okay, let's set up highlighting and glossarisation
     $SEARCHENGINE = null;
     if (isset($data['info']['searchstring']) && $data['info']['searchstring'] != '') {
         $SEARCHENGINE = new \SEARCHENGINE($data['info']['searchstring']);
     }
     // Before we print the body text we need to insert glossary links
     // and highlight search string words.
     $speeches = 0;
     $bodies = array();
     foreach ($data['rows'] as $row) {
         $htype = $row['htype'];
         if ($htype == 12 || $htype == 13) {
             $speeches++;
         }
         $body = $row['body'];
         $body = preg_replace('#<phrase class="honfriend" id="uk.org.publicwhip/member/(\\d+)" name="([^"]*?)">(.*?\\s*\\((.*?)\\))</phrase>#', '<a href="/mp/?m=$1" title="Our page on $2 - \'$3\'">$4</a>', $body);
         $body = preg_replace_callback('#<phrase class="offrep" id="(.*?)/(\\d+)-(\\d+)-(\\d+)\\.(.*?)">(.*?)</phrase>#', function ($matches) {
             return '<a href="/search/?pop=1&s=date:' . $matches[2] . $matches[3] . $matches[4] . '+column:' . $matches[5] . '+section:' . $matches[1] . '">' . str_replace("Official Report", "Hansard", $matches[6]) . '</a>';
         }, $body);
         #$body = preg_replace('#<phrase class="offrep" id="((.*?)/(\d+)-(\d+)-(\d+)\.(.*?))">(.*?)</phrase>#e', "\"<a href='/search/?pop=1&amp;s=date:$3$4$5+column:$6+section:$2&amp;match=$1'>\" . str_replace('Official Report', 'Hansard', '$7') . '</a>'", $body);
         $bodies[] = $body;
     }
     // Do all this unless the glossary is turned off in the URL
     if (get_http_var('ug') != 1) {
         // And glossary phrases
         twfy_debug_timestamp('Before glossarise');
         $args['sort'] = "regexp_replace";
         $GLOSSARY = new \GLOSSARY($args);
         $bodies = $GLOSSARY->glossarise($bodies, 1);
         twfy_debug_timestamp('After glossarise');
     }
     if ($SEARCHENGINE) {
         // We have some search terms to highlight.
         twfy_debug_timestamp('Before highlight');
         $bodies = $SEARCHENGINE->highlight($bodies);
         twfy_debug_timestamp('After highlight');
     }
     $first_speech = null;
     $data['section_title'] = '';
     $subsection_title = '';
     for ($i = 0; $i < count($data['rows']); $i++) {
         $row = $data['rows'][$i];
         $htype = $row['htype'];
         // HPOS should be defined below if it's needed; otherwise default to 0
         $heading_hpos = 0;
         if ($htype == 10) {
             $data['section_title'] = $row['body'];
             $heading_hpos = $row['hpos'];
         } elseif ($htype == 11) {
             $subsection_title = $row['body'];
             $heading_hpos = $row['hpos'];
         } elseif ($htype == 12) {
             # Splitting out highlighting results back into individual bits
             $data['rows'][$i]['body'] = $bodies[$i];
         }
         if ($htype == 12 || $htype == 13) {
             if (!$first_speech) {
                 $first_speech = $data['rows'][$i];
             }
             # Voting links
             $data['rows'][$i]['voting_data'] = '';
             if (isset($row['votes'])) {
                 $data['rows'][$i]['voting_data'] = $this->generate_votes($row['votes'], $row['epobject_id'], $row['gid']);
             }
             # Annotation link
             if ($this->is_debate_section_page()) {
                 // Build the 'Add an annotation' link.
                 if (!$THEUSER->isloggedin()) {
                     $URL = new \URL('userprompt');
                     $URL->insert(array('ret' => $row['commentsurl']));
                     $data['rows'][$i]['annotation_url'] = $URL->generate();
                 } else {
                     $data['rows'][$i]['annotation_url'] = $row['commentsurl'];
                 }
                 $data['rows'][$i]['commentteaser'] = $this->generate_commentteaser($row);
             }
             if (isset($row['mentions'])) {
                 $data['rows'][$i]['mentions'] = $this->get_question_mentions_html($row['mentions']);
             }
             if ($this->major == 1) {
                 $data['rows'][$i]['video'] = $this->get_video_html($row, $heading_hpos, $speeches);
             }
         }
     }
     if ($subsection_title) {
         $data['heading'] = $subsection_title;
     } else {
         $data['heading'] = $data['section_title'];
     }
     if ($subsection_title) {
         $data['intro'] = "{$data['section_title']}";
     } else {
         $data['intro'] = "";
     }
     $country = 'UK';
     if ($this->major == 1) {
         $data['location'] = '&ndash; in the House of Commons';
     } elseif ($this->major == 2) {
         $data['location'] = '&ndash; in Westminster Hall';
     } elseif ($this->major == 3) {
         $data['location'] = 'written question &ndash; answered';
     } elseif ($this->major == 4) {
         $data['location'] = 'written statement &ndash; made';
     } elseif ($this->major == 5) {
         $country = 'NORTHERN IRELAND';
         $data['location'] = '&ndash; in the Northern Ireland Assembly';
     } elseif ($this->major == 6) {
         $data['location'] = '&ndash; in a Public Bill Committee';
     } elseif ($this->major == 7) {
         $country = 'SCOTLAND';
         $data['location'] = '&ndash; in the Scottish Parliament';
     } elseif ($this->major == 8) {
         $country = 'SCOTLAND';
         $data['location'] = '&ndash; Scottish Parliament written question &ndash; answered';
     } elseif ($this->major == 101) {
         $data['location'] = '&ndash; in the House of Lords';
     }
     $data['current_assembly'] = "westminster--debate";
     switch ($country) {
         case "UK":
             $data['current_assembly'] = "westminster--debate";
             break;
         case "SCOTLAND":
             $data['current_assembly'] = "scotland";
             break;
         case "NORTHERN IRELAND":
             $data['current_assembly'] = "ni";
             break;
     }
     if (array_key_exists('text_heading', $data['info'])) {
         // avoid having Clause 1 etc as the alert text search string on PBC pages as it's
         // almost certainly not what the person wants
         if ($this->major == 6) {
             $data['email_alert_text'] = $data['section_title'];
         } else {
             $data['email_alert_text'] = $data['info']['text_heading'];
         }
     } else {
         // The user has requested only part of a debate, so find a suitable title
         if ($subsection_title) {
             $data['intro'] = "Part of {$data['section_title']}";
         } else {
             $data['intro'] = "Part of the debate";
         }
         foreach ($data['rows'] as $row) {
             if ($row['htype'] == 10 || $row['htype'] == 11) {
                 $data['email_alert_text'] = $row['body'];
                 $data['full_debate_url'] = $row['listurl'];
                 break;
             }
         }
     }
     // strip a couple of common characters that result in encode junk in the
     // search string
     $data['email_alert_text'] = preg_replace('/(?:[:()\\[\\]]|&#\\d+;)/', '', $data['email_alert_text']);
     $data['debate_time_human'] = format_time($first_speech['htime'], 'g:i a');
     $data['debate_day_human'] = format_date($first_speech['hdate'], 'jS F Y');
     $URL = new \URL($this->list->listpage);
     $URL->insert(array('d' => $first_speech['hdate']));
     $URL->remove(array('id'));
     $data['debate_day_link'] = $URL->generate();
     $data['nextprev'] = $DATA->page_metadata($this_page, 'nextprev');
     return $data;
 }
Пример #7
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;
 }
Пример #8
0
 protected function display_section_or_speech($args = array())
 {
     global $DATA, $this_page, $THEUSER;
     # += as we *don't* want to override any already supplied argument
     $args += array('gid' => get_http_var('id'), 's' => get_http_var('s'), 'member_id' => get_http_var('m'));
     if (preg_match('/speaker:(\\d+)/', get_http_var('s'), $mmm)) {
         $args['person_id'] = $mmm[1];
     }
     try {
         $data = $this->list->display('gid', $args, 'none');
     } catch (\RedirectException $e) {
         $URL = new \URL($this->major_data['page_all']);
         if ($this->major == 6) {
             # Magically (as in I can't remember quite why), pbc_clause will
             # contain the new URL without any change...
             $URL->remove(array('id'));
         } else {
             $URL->insert(array('id' => $e->getMessage()));
         }
         # put the search term back in so highlighting works.
         # NB: as we don't see the # part of the URL we lose this :(
         if ($args['s'] !== '') {
             $URL->insert(array('s' => $args['s']));
         }
         redirect($URL->generate('none'));
     }
     $data['individual_item'] = $this->list->commentspage == $this_page;
     if ($data['individual_item']) {
         $COMMENTLIST = new \COMMENTLIST();
         $args['user_id'] = get_http_var('u');
         $args['epobject_id'] = $this->list->epobject_id();
         $data['comments']['object'] = $COMMENTLIST;
         $data['comments']['args'] = $args;
         $data['comments']['commentdata'] = array('epobject_id' => $this->list->epobject_id(), 'gid' => get_http_var('id'), 'return_page' => $this_page);
     }
     if (!isset($data['info'])) {
         header("HTTP/1.0 404 Not Found");
         $data['template'] = 'error';
         return $data;
     }
     # Okay, let's set up highlighting and glossarisation
     list($bodies, $speeches) = $this->highlightSpeeches($data);
     list($data, $first_speech, $subsection_title) = $this->annotateSpeeches($data, $bodies, $speeches);
     list($country, $location, $assembly) = $this->getCountryDetails();
     $data['location'] = $location;
     $data['current_assembly'] = $assembly;
     $data = $this->setTitleAndAlertText($data, $subsection_title);
     $data['debate_time_human'] = format_time($first_speech['htime'], 'g:i a');
     $data['debate_day_human'] = format_date($first_speech['hdate'], 'jS F Y');
     $URL = new \URL($this->list->listpage);
     $URL->insert(array('d' => $first_speech['hdate']));
     $URL->remove(array('id'));
     $data['debate_day_link'] = $URL->generate();
     $data['nextprev'] = $DATA->page_metadata($this_page, 'nextprev');
     return $data;
 }
Пример #9
0
function display_form($COMMENT, $errors = array())
{
    global $this_page, $THEUSER, $PAGE;
    ?>
				<p>Here's the comment you're reporting. Please enter a brief reason why you think it should be deleted in the form beneath. Thanks for your help!</p>
<?php 
    // First display the comment.
    $COMMENT->display();
    // Now display the form.
    $FORMURL = new URL($this_page);
    $FORMURL->remove(array('id'));
    ?>
				<br>
				<form action="<?php 
    echo $FORMURL->generate();
    ?>
" method="post">
<?php 
    if ($THEUSER->isloggedin()) {
        ?>
				<p><br><strong>From:</strong> <?php 
        echo htmlentities($THEUSER->firstname() . ' ' . $THEUSER->lastname());
        ?>
</p>
<?php 
    } else {
        // Not-logged-in user, so we want their name and email address.
        if (isset($errors['name'])) {
            $PAGE->error_message($errors['name']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="firstname">Your first name:</label></span>
				<span class="formw"><input type="text" name="firstname" id="firstname" value="" maxlength="50" size="30" class="form"></span>
				</div>

				<div class="row">
				<span class="label"><label for="lastname">Your last name:</label></span>

				<span class="formw"><input type="text" name="lastname" id="lastname" value="" maxlength="50" size="30" class="form"></span>
				</div>
<?php 
        if (isset($errors['email'])) {
            $PAGE->error_message($errors['email']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="em">Email address:</label></span>
				<span class="formw"><input type="text" name="em" id="em" value="" maxlength="100" size="30" class="form"></span>
				</div>
<?php 
    }
    if (isset($errors['body'])) {
        $PAGE->error_message($errors['body']);
    }
    $RULESURL = new URL('houserules');
    ?>
				<p style="clear: left;"><strong>Why should this comment be deleted?</strong><br>
				<small>Check our <a href="<?php 
    echo $RULESURL->generate();
    ?>
">House Rules</a> and tell us why the comment breaks them.</small><br>
				<textarea name="body" rows="10" cols="45"><?php 
    echo htmlentities(get_http_var('body'));
    ?>
</textarea></p>
		
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="submit" value="Send report"></span>
				</div>
				
				<input type="hidden" name="submitted" value="true">
				<input type="hidden" name="id" value="<?php 
    echo htmlentities($COMMENT->comment_id());
    ?>
">
<?php 
    if (get_http_var('ret') != '') {
        // Where the user came from to get here.
        ?>
				<input type="hidden" name="ret" value="<?php 
        echo htmlentities(get_http_var('ret'));
        ?>
">
<?php 
    }
    ?>
				</form>

<?php 
}
Пример #10
0
function search_order_p($searchstring)
{
    global $DATA, $PAGE, $this_page;
    $q_house = '';
    if (ctype_digit(get_http_var('house'))) {
        $q_house = get_http_var('house');
    }
    # Fetch the results
    $data = search_by_usage($searchstring, $q_house);
    $wtt = get_http_var('wtt');
    if ($wtt) {
        $pagetitle = 'League table of Lords who say ' . $data['pagetitle'];
    } else {
        $pagetitle = 'Who says ' . $data['pagetitle'] . ' the most?';
    }
    $DATA->set_page_metadata($this_page, 'title', $pagetitle);
    $PAGE->page_start();
    $PAGE->stripe_start();
    $PAGE->search_form($searchstring);
    if (isset($data['error'])) {
        print '<p>' . $data['error'] . '</p>';
        return;
    }
    if (isset($data['limit_reached'])) {
        print '<p><em>This service runs on a maximum number of 5,000 results, to conserve memory</em></p>';
    }
    print "\n\n<!-- ";
    foreach ($data['party_count'] as $party => $count) {
        print "{$party}:{$count}<br>";
    }
    print " -->\n\n";
    if ($wtt) {
        ?>
<p><strong><big>Now, try reading what a couple of these Lords are saying,
to help you find someone appropriate. When you've found someone,
hit the "I want to write to this Lord" button on their results page
to go back to WriteToThem.
</big></strong></p>
<?php 
    }
    ?>
<p>Please note that this search is only for the exact word/phrase entered.
For example, putting in 'autism' won't return results for 'autistic spectrum disorder',
you will have to search for it separately.</p>
<table><tr><th>Number of occurences</th><th><?php 
    if ($wtt) {
        print 'Speaker';
    } else {
        ?>
Table includes - <?php 
        $URL = new URL($this_page);
        $url_l = $URL->generate('html', array('house' => 2));
        $url_c = $URL->generate('html', array('house' => 1));
        $URL->remove(array('house'));
        $url_b = $URL->generate();
        if ($q_house == 1) {
            print 'MPs | <a href="' . $url_l . '">Lords</a> | <a href="' . $url_b . '">Both</a>';
        } elseif ($q_house == 2) {
            print '<a href="' . $url_c . '">MPs</a> | Lords | <a href="' . $url_b . '">Both</a>';
        } else {
            print '<a href="' . $url_c . '">MPs</a> | <a href="' . $url_l . '">Lords</a> | Both';
        }
    }
    ?>
</th><th>Date range</th></tr>
<?php 
    foreach ($data['speakers'] as $pid => $speaker) {
        print '<tr><td align="center">';
        print $speaker['count'] . '</td><td>';
        if ($pid) {
            $house = $speaker['house'];
            $left = $speaker['left'];
            if ($house == 1) {
                print '<span style="color:#009900">&bull;</span> ';
            } elseif ($house == 2) {
                print '<span style="color:#990000">&bull;</span> ';
            }
            if (!$wtt || $left == '9999-12-31') {
                print '<a href="' . WEBPATH . 'search/?s=' . urlencode($searchstring) . '&amp;pid=' . $pid;
            }
            if ($wtt && $left == '9999-12-31') {
                print '&amp;wtt=2';
            }
            if (!$wtt || $left == '9999-12-31') {
                print '">';
            }
        }
        print $speaker['name'];
        if ($pid) {
            print '</a>';
        }
        if ($speaker['party']) {
            print ' (' . $speaker['party'] . ')';
        }
        if (isset($speaker['office'])) {
            print ' - ' . join('; ', $speaker['office']);
        }
        print '</td> <td>';
        $pmindate = $speaker['pmindate'];
        $pmaxdate = $speaker['pmaxdate'];
        if (format_date($pmindate, 'M Y') == format_date($pmaxdate, 'M Y')) {
            print format_date($pmindate, 'M Y');
        } else {
            print str_replace(' ', '&nbsp;', format_date($pmindate, 'M Y') . ' &ndash; ' . format_date($pmaxdate, 'M Y'));
        }
        print '</td></tr>';
    }
    print '</table>';
}
Пример #11
0
    $committee->display('bill', $args);
} elseif ($bill_id && $id) {
    # Display the debate for a particular clause
    $this_page = 'pbc_clause';
    $args = array('gid' => $standingprefix . $id, 's' => get_http_var('s'), 'member_id' => get_http_var('m'), 'glossarise' => 1, 'sort' => 'regexp_replace', 'bill_id' => $bill_id, 'bill_title' => $bill, 'bill_session' => $session);
    $GLOSSARY = new GLOSSARY($args);
    # Why a global?
    if (preg_match('/speaker:(\\d+)/', get_http_var('s'), $mmm)) {
        $args['person_id'] = $mmm[1];
    }
    $result = $committee->display('gid', $args);
    # If it is a redirect, change URL. Magically (as in I can't remember
    # quite why), pbc_clause will contain the new URL without any change...
    if (is_string($result)) {
        $URL = new URL('pbc_clause');
        $URL->remove(array('id'));
        header('Location: http://' . DOMAIN . $URL->generate('none'), true, 301);
        exit;
    }
    /* This section below is shared between here and everywhere else - factor it out! */
    if ($committee->htype() == '12' || $committee->htype() == '13') {
        $PAGE->stripe_start('side', 'comments');
        $COMMENTLIST = new COMMENTLIST();
        $args['user_id'] = get_http_var('u');
        $args['epobject_id'] = $committee->epobject_id();
        $COMMENTLIST->display('ep', $args);
        $PAGE->stripe_end();
        $PAGE->stripe_start('side', 'addcomment');
        $commendata = array('epobject_id' => $committee->epobject_id(), 'gid' => get_http_var('id'), 'return_page' => $this_page);
        $PAGE->comment_form($commendata);
        if ($THEUSER->isloggedin()) {
Пример #12
0
 protected function get_search_url($params = true)
 {
     global $this_page;
     $url = new \URL($this_page);
     if (isset($this->searchstring)) {
         $value = $this->searchstring;
         if (preg_match_all('#speaker:(\\d+)#', $value, $m) == 1) {
             $person_id = $m[1][0];
             $value = str_replace('speaker:' . $person_id, '', $value);
             $url->insert(array('pid' => $person_id));
         }
         $url->insert(array('q' => $value));
     }
     if ($params) {
         if (get_http_var('house')) {
             $url->insert(array('house' => get_http_var('house')));
         }
         if (get_http_var('wtt')) {
             $url->insert(array('wtt' => get_http_var('wtt')));
         }
     } else {
         $url->remove(array('o', 'house'));
     }
     return $url;
 }
Пример #13
0
 private function addUrlsToData()
 {
     global $this_page;
     $urls = array();
     $URL = new \URL($this_page);
     $urls['plain'] = $URL->generate();
     $URL->insert(array('o' => 'n'));
     $urls['by_name'] = $URL->generate();
     $URL->insert(array('o' => 'l'));
     $urls['by_last'] = $URL->generate();
     $URL->insert(array('o' => 'f'));
     $urls['by_first'] = $URL->generate();
     $URL->insert(array('o' => 'p'));
     $urls['by_party'] = $URL->generate();
     $URL->insert(array('f' => 'csv'));
     $URL->remove(array('o'));
     if ($date = get_http_var('date')) {
         $URL->insert(array('date' => $date));
     }
     $urls['by_csv'] = $URL->generate();
     return $urls;
 }