Esempio n. 1
0
 private function addLoggedInLinks()
 {
     // The 'Edit details' link.
     $menudata = $this->pagedata->page_metadata('userviewself', 'menu');
     $edittext = $menudata['text'];
     $edittitle = $menudata['title'];
     $EDITURL = new \URL('userviewself');
     if ($this->page == 'userviewself' || $this->page == 'useredit') {
         $editclass = 'on';
     } else {
         $editclass = '';
     }
     // The 'Log out' link.
     $menudata = $this->pagedata->page_metadata('userlogout', 'menu');
     $logouttext = $menudata['text'];
     $logouttitle = $menudata['title'];
     $LOGOUTURL = new \URL('userlogout');
     if ($this->page != 'userlogout') {
         $LOGOUTURL->insert(array("ret" => $this->returl));
         $logoutclass = '';
     } else {
         $logoutclass = 'on';
     }
     $username = $this->user->firstname() . ' ' . $this->user->lastname();
     $this->data['user_nav_links'][] = array('href' => $LOGOUTURL->generate(), 'title' => $logouttitle, 'classes' => $logoutclass, 'text' => $logouttext);
     $this->data['user_nav_links'][] = array('href' => $EDITURL->generate(), 'title' => $edittitle, 'classes' => $editclass, 'text' => $edittext);
     $this->data['user_nav_links'][] = array('href' => $EDITURL->generate(), 'title' => $edittitle, 'classes' => $editclass, 'text' => _htmlentities($username));
 }
Esempio n. 2
0
function display_page($errors = array())
{
    global $this_page, $PAGE;
    if (isset($errors["sending"])) {
        $PAGE->error_message($errors["sending"]);
    } else {
        print "<p>If you can't remember your password we can send you a new one.</p>\n<p>If you would like a new password, enter your address below.</p>\n";
    }
    ?>

<form method="get" action="<?php 
    $URL = new URL($this_page);
    echo $URL->generate();
    ?>
">

<?php 
    if (isset($errors["email"])) {
        $PAGE->error_message($errors["email"]);
    }
    if (isset($errors["passwordchange"])) {
        $PAGE->error_message($errors["passwordchange"]);
    }
    ?>

<div class="row">
<div class="left">Email address:</div>
<div class="right"><input type="text" name="email" value="<?php 
    echo _htmlentities(get_http_var("email"));
    ?>
" maxlength="100" size="30" class="form"></div>
</div>

<div class="row">
<div class="left">&nbsp;</div>
<div class="right"><input type="submit" value="Send me a new password"></div>
</div>

<input type="hidden" name="submitted" value="true">

</form>

<?php 
}
Esempio n. 3
0
 (<?php 
    echo _htmlspecialchars($pid_member->constituency());
    ?>
)">
                      <?php 
} elseif ($keyword) {
    ?>
                        <input type="text" class="form-control" name="alertsearch" id="alertsearch" disabled="disabled" value="<?php 
    echo _htmlspecialchars($display_keyword);
    ?>
">
                      <?php 
} else {
    ?>
                        <input type="text" class="form-control" placeholder="Search term, postcode, or MP name" name="alertsearch" id="alertsearch" value="<?php 
    echo _htmlentities($search_text);
    ?>
">
                      <?php 
}
?>
                        <input type="submit" class="button" value="<?php 
echo $pid || $keyword ? 'Subscribe' : 'Search';
?>
">
                    </p>

                    <input type="hidden" name="t" value="<?php 
echo _htmlspecialchars($token);
?>
">
Esempio n. 4
0
function person_numerology($member, $has_email_alerts)
{
    $extra_info = $member->extra_info();
    $out = array();
    $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() != 'SF') {
        if (display_stats_line('debate_sectionsspoken_inlastyear', 'Has spoken in <a href="' . $MOREURL->generate() . '">', 'debate', '</a> ' . $since_text, '', $extra_info)) {
            $out[] = 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() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') {
            $minister = 2;
        }
        if (display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister)) {
            $out[] = display_stats_line('wrans_asked_inlastyear', 'Has received answers to <a href="' . $MOREURL->generate() . '">', 'written question', '</a> ' . $since_text, '', $extra_info, $minister, $Lminister);
        }
    }
    $wtt_displayed = display_writetothem_numbers(2008, $extra_info);
    if ($wtt_displayed) {
        $out[] = $wtt_displayed;
    }
    if (!$wtt_displayed) {
        $wtt_displayed = display_writetothem_numbers(2007, $extra_info);
        if ($wtt_displayed) {
            $out[] = $wtt_displayed;
        }
        if (!$wtt_displayed) {
            $wtt_displayed = display_writetothem_numbers(2006, $extra_info);
            if ($wtt_displayed) {
                $out[] = $wtt_displayed;
            }
            if (!$wtt_displayed) {
                $wtt_displayed = display_writetothem_numbers(2005, $extra_info);
                if ($wtt_displayed) {
                    $out[] = $wtt_displayed;
                }
            }
        }
    }
    $after_stuff = ' <small>(From Public Whip)</small>';
    if ($member->party() == 'SNP') {
        $after_stuff .= '<br><em>Note SNP MPs do not vote on legislation not affecting Scotland.</em>';
    } elseif ($member->party() == 'SPK' || $member->party() == 'CWM' || $member->party() == 'DCWM') {
        $after_stuff .= '<br><em>Speakers and deputy speakers cannot vote except to break a tie.</em>';
    }
    if ($member->party() != 'SF') {
        $when = 'in this Parliament with this affiliation';
        # Lords have one record per affiliation until they leave (ignoring name changes, sigh)
        if ($member->house_disp == HOUSE_TYPE_LORDS) {
            $when = 'in this House with this affiliation';
        }
        if (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)) {
            $out[] = 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&rsquo;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>';
        }
        */
        if (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)) {
            $out[] = 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);
        }
        if (display_stats_line('reading_age', 'This MP&rsquo;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)) {
            $out[] = display_stats_line('reading_age', 'This MP&rsquo;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']) && ($extra_info['number_of_alerts'] > 0 || $has_email_alerts)) {
        $line = '<strong>' . _htmlentities($extra_info['number_of_alerts']) . '</strong> ' . ($extra_info['number_of_alerts'] == 1 ? 'person is' : 'people are') . ' tracking ';
        if ($member->house_disp == HOUSE_TYPE_COMMONS) {
            $line .= 'this MP';
        } elseif ($member->house_disp == HOUSE_TYPE_LORDS) {
            $line .= 'this peer';
        } elseif ($member->house_disp == HOUSE_TYPE_NI) {
            $line .= 'this MLA';
        } elseif ($member->house_disp == HOUSE_TYPE_SCOTLAND) {
            $line .= 'this MSP';
        } elseif ($member->house_disp == HOUSE_TYPE_ROYAL) {
            $line .= $member->full_name();
        }
        if ($has_email_alerts) {
            $line .= ' &mdash; <a href="' . WEBPATH . 'alert/?pid=' . $member->person_id() . '">email me updates on ' . $member->full_name() . '&rsquo;s activity</a>';
        }
        $out[] = $line;
    }
    if ($member->party() != 'SF') {
        if (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)) {
            $line = 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'])) {
                $line .= "\n<!-- " . $extra_info['three_word_alliteration_content'] . " -->\n";
            }
            $out[] = $line;
        }
    }
    return $out;
}
Esempio n. 5
0
                 $row['speaker']['image'] = IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpeg';
             } elseif (is_file(BASEDIR . IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpg')) {
                 $row['speaker']['image'] = IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpg';
             }
             $desc = '';
             if (isset($speaker['office'])) {
                 $desc = array();
                 foreach ($speaker['office'] as $off) {
                     $desc[] = $off['pretty'];
                 }
                 $desc = join(', ', $desc) . '; ';
             }
             if ($speaker['house'] == 1 && $speaker['party'] != 'Speaker' && $speaker['party'] != 'Deputy Speaker' && $speaker['constituency']) {
                 $desc .= $speaker['constituency'] . ', ';
             }
             $desc .= _htmlentities($speaker['party']);
             if ($desc) {
                 $row['speaker']['desc'] = $desc;
             }
         }
     }
     $out[] = $row;
 }
 if (isset($data['subrows'])) {
     foreach ($data['subrows'] as $row) {
         if (isset($row['contentcount']) && $row['contentcount'] > 0) {
             $has_content = true;
         } elseif ($row['htype'] == '11' && $hansardmajors[$row['major']]['type'] == 'other') {
             $has_content = true;
         } else {
             $has_content = false;
Esempio n. 6
0
$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') {
    $th_constituency = 'Constituency';
}
global $THEUSER;
?>

<form action="/postcode/" method="get">
<p><strong>Looking for your <acronym title="Members of the (Northern Irish) Legislative Assembly">MLA</acronym>, <acronym title="Member of Parliament">MP</acronym> or
<acronym title="Members of the Scottish Parliament">MSP</acronym>?</strong><br>
<label for="pc">Enter your UK postcode here:</label>&nbsp; <input type="text" name="pc" id="pc" size="8" maxlength="10" value="<?php 
echo _htmlentities($THEUSER->postcode());
?>
" class="text">&nbsp;&nbsp;<input type="submit" value=" Go " class="submit"></p>
</form>

<div class="sort">
    Sort by:
    <ul>
        <li><?php 
echo $th_family_name;
?>
 |</li>
        <li><?php 
echo $th_given_name;
?>
 |</li>
Esempio n. 7
0
<div class="search-result search-result--glossary">
    <h3 class="search-result__title"><a href="<?php 
echo $item['url'];
?>
">&ldquo;<?php 
echo _htmlentities($item['term']);
?>
&rdquo;</a></h3>
    <p class="search-result__description"><?php 
echo $item['body'];
?>
</p>
</div>
Esempio n. 8
0
 public function glossarise($body, $tokenize = 0, $urlize = 0)
 {
     // Turn a body of text into a link-up wonderland of glossary joy
     global $this_page;
     $findwords = array();
     $replacewords = array();
     $URL = new URL("glossary");
     $URL->insert(array("gl" => ""));
     // External links shown within their own definition
     // should be the complete and linked url.
     // NB. This should only match when $body is a definition beginning with "http:"
     if (is_string($body) && preg_match("/^(http:*[^\\s])\$/i", $body)) {
         $body = "<a href=\"" . $body . "\" title=\"External link to " . $body . "\">" . $body . "</a>";
         return $body;
     }
     // otherwise, just replace everything.
     // generate links from URL when wanted
     // NB WRANS is already doing this
     if ($urlize == 1) {
         $body = preg_replace("~(http(s)?:\\/\\/[^\\s\n]*)\\b(\\/)?~i", "<a href=\"\\0\">\\0</a>", $body);
     }
     // check for any glossary terms to replace
     foreach ($this->replace_order as $glossary_id => $count) {
         if ($glossary_id == $this->glossary_id) {
             continue;
         }
         $term_body = $this->terms[$glossary_id]['body'];
         $term_title = $this->terms[$glossary_id]['title'];
         $URL->update(array("gl" => $glossary_id));
         # The regex here ensures that the phrase is only matched if it's not already within <a> tags, preventing double-linking. Kudos to http://stackoverflow.com/questions/7798829/php-regular-expression-to-match-keyword-outside-html-tag-a
         $findwords[$glossary_id] = "/\\b(" . $term_title . ")\\b(?!(?>[^<]*(?:<(?!\\/?a\\b)[^<]*)*)<\\/a>)/i";
         // catch glossary terms within their own definitions
         if ($glossary_id == $this->glossary_id) {
             $replacewords[] = "<strong>\\1</strong>";
         } else {
             if ($this_page == "admin_glossary") {
                 $link_url = "#gl" . $glossary_id;
             } else {
                 $link_url = $URL->generate('url');
             }
             $title = _htmlentities(trim_characters($term_body, 0, 80));
             $replacewords[] = "<a href=\"{$link_url}\" title=\"{$title}\" class=\"glossary\">\\1</a>";
         }
     }
     // Highlight all occurrences of another glossary term in the definition.
     $body = preg_replace($findwords, $replacewords, $body, 1);
     if (isset($this->glossary_id)) {
         $body = preg_replace("/(?<![>\\.\\'\\/])\\b(" . $this->terms[$this->glossary_id]['title'] . ")\\b(?![<\\'])/i", '<strong>\\1</strong>', $body, 1);
     }
     // Replace any phrases in wikipedia
     // TODO: Merge this code into above, so our gloss and wikipedia
     // don't clash (e.g. URLs getting doubly munged etc.)
     $body = wikipedize($body);
     return $body;
 }
Esempio n. 9
0
echo $search_section == 'spwrans' ? ' selected' : '';
?>
>Written answers</option>
                                </optgroup>
                             </select>
                        </div>
                        <div class="search-option__hint">
                            <p>Restrict results to a particular parliament or assembly that we cover (e.g. the Scottish Parliament), or a particular type of data within an institution, such as Commons Written Answers.</p>
                        </div>
                    </div>

                    <h4>Column</h4>
                    <div class="search-option">
                        <div class="search-option__control">
                            <input name="column" type="text" value="<?php 
echo _htmlentities($search_column);
?>
" class="form-control">
                        </div>
                        <div class="search-option__hint">
                            <p>If you know the actual Hansard column number of the information you are interested in (perhaps you&rsquo;re looking up a paper reference), you can restrict results to that.</p>
                        </div>
                    </div>

                    <p><input type="submit" class="button" value="Search"></p>
                </div>
            </div>
        </form>

        <script type="text/javascript">
        $(function(){
Esempio n. 10
0
    $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));
            $contentencoded = $row['body'];
            $hdate = format_date($row['hdate'], 'Y-m-d');
            if ($row['htime'] != NULL) {
                $htime = format_time($row['htime'], 'H:i:s');
            } else {
                $htime = '00:00:00';
            }
            $date = $hdate . 'T' . $htime . '+00:00';
            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
            $entries .= "<item rdf:about=\"{$link}\">\n\t<title>{$title}</title>\n\t<link>{$link}</link>\n\t<description>{$description}</description>\n\t<content:encoded><![CDATA[{$contentencoded}]]></content:encoded>\n\t<dc:date>{$date}</dc:date>\n</item>\n";
        }
    }
    // Prepare the whole text of the RSS file.
    $rsstext = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
Esempio n. 11
0
">
                  <?php 
    } else {
        ?>
                    <input type="text" name="postcode" id="id_postcode">
                  <?php 
    }
    ?>
                </p>
                <p>
                    <label for="id_email">Your email address</label>
                  <?php 
    if (isset($data['email'])) {
        ?>
                    <input type="text" name="email" id="id_email" value="<?php 
        echo _htmlentities($data['email']);
        ?>
">
                  <?php 
    } else {
        ?>
                    <input type="text" name="email" id="id_email">
                  <?php 
    }
    ?>
                </p>
                <p>
                    <button type="submit" class="button radius">Set up alerts</button>
                </p>
            </form>
Esempio n. 12
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;
     ////////////////////////////////////////////////////////////
     // Assemble the page title
     $data['page_title'] = '';
     $sitetitle = $DATA->page_metadata($this_page, "sitetitle");
     $keywords_title = '';
     if ($this_page == 'overview') {
         $data['page_title'] = $sitetitle . ': ' . $DATA->page_metadata($this_page, "title");
     } else {
         if ($page_title = $DATA->page_metadata($this_page, "title")) {
             $data['page_title'] = $page_title;
         }
         // We'll put this in the meta keywords tag.
         $keywords_title = $data['page_title'];
         $parent_page = $DATA->page_metadata($this_page, 'parent');
         if ($parent_title = $DATA->page_metadata($parent_page, 'title')) {
             if ($data['page_title']) {
                 $data['page_title'] .= ': ';
             }
             $data['page_title'] .= $parent_title;
         }
         if ($data['page_title'] == '') {
             $data['page_title'] = $sitetitle;
         } else {
             $data['page_title'] .= ' - ' . $sitetitle;
         }
     }
     ////////////////////////////////////////////////////////////
     // Meta keywords
     if (!($data['meta_keywords'] = $DATA->page_metadata($this_page, "meta_keywords"))) {
         $data['meta_keywords'] = $keywords_title;
         if ($data['meta_keywords']) {
             $data['meta_keywords'] .= ', ';
         }
         $data['meta_keywords'] .= 'Hansard, Official Report, Parliament, government, House of Commons, House of Lords, MP, Peer, Member of Parliament, MPs, Peers, Lords, Commons, Scottish Parliament, Northern Ireland Assembly, MSP, MLA, MSPs, MLAs';
     }
     $data['meta_description'] = '';
     if ($DATA->page_metadata($this_page, "meta_description")) {
         $data['meta_description'] = $DATA->page_metadata($this_page, "meta_description");
     }
     ////////////////////////////////////////////////////////////
     // Header <link>s
     $data['header_links'] = array();
     if ($this_page != 'overview') {
         $URL = new \URL('overview');
         $data['header_links'][] = array('rel' => 'start', 'title' => 'Home', 'href' => $URL->generate());
     }
     ////////////////////////////////////////////////////////////
     // Create the next/prev/up links for navigation.
     // Their data is put in the metadata in hansardlist.php
     $nextprev = $DATA->page_metadata($this_page, "nextprev");
     if ($nextprev) {
         // Four different kinds of back/forth links we might build.
         $links = array("first", "prev", "up", "next", "last");
         foreach ($links as $type) {
             if (isset($nextprev[$type]) && isset($nextprev[$type]['url'])) {
                 if (isset($nextprev[$type]['body'])) {
                     $linktitle = _htmlentities(trim_characters($nextprev[$type]['body'], 0, 40));
                     if (isset($nextprev[$type]['speaker']) && count($nextprev[$type]['speaker']) > 0) {
                         $linktitle = $nextprev[$type]['speaker']['name'] . ': ' . $linktitle;
                     }
                 } elseif (isset($nextprev[$type]['hdate'])) {
                     $linktitle = format_date($nextprev[$type]['hdate'], SHORTDATEFORMAT);
                 }
                 $data['header_links'][] = array('rel' => $type, 'title' => $linktitle, 'href' => $nextprev[$type]['url']);
             }
         }
     }
     ////////////////////////////////////////////////////////////
     // Page RSS URL
     if ($DATA->page_metadata($this_page, 'rss')) {
         // If this page has an RSS feed set.
         $data['page_rss_url'] = 'http://' . DOMAIN . WEBPATH . $DATA->page_metadata($this_page, 'rss');
     }
     ////////////////////////////////////////////////////////////
     // Site Navigation Links
     $data['assembly_nav_links'] = array();
     $data['section_nav_links'] = array();
     // Page names mapping to those in metadata.php.
     // Links in the top menu, and the sublinks we see if
     // we're within that section.
     $nav_items = array(array('home'), array('hansard', 'mps', 'peers', 'alldebatesfront', 'wranswmsfront', 'pbc_front', 'calendar_summary'), array('sp_home', 'spoverview', 'msps', 'spdebatesfront', 'spwransfront'), array('ni_home', 'nioverview', 'mlas'), array('wales_home'));
     // We work out which of the items in the top and bottom menus
     // are highlighted - $top_highlight and $bottom_highlight respectively.
     $parent = $DATA->page_metadata($this_page, 'parent');
     if (!$parent) {
         $top_highlight = $this_page;
         $bottom_highlight = '';
         $selected_top_link = $DATA->page_metadata('hansard', 'menu');
         $url = new \URL('hansard');
         $selected_top_link['link'] = $url->generate();
     } else {
         $parents = array($parent);
         $p = $parent;
         while ($p) {
             $p = $DATA->page_metadata($p, 'parent');
             if ($p) {
                 $parents[] = $p;
             }
         }
         $top_highlight = array_pop($parents);
         if (!$parents) {
             // No grandparent - this page's parent is in the top menu.
             // We're on one of the pages linked to by the bottom menu.
             // So highlight it and its parent.
             $bottom_highlight = $this_page;
         } else {
             // This page is not in either menu. So highlight its parent
             // (in the bottom menu) and its grandparent (in the top).
             $bottom_highlight = array_pop($parents);
         }
         $selected_top_link = $DATA->page_metadata($top_highlight, 'menu');
         if (!$selected_top_link) {
             # Just in case something's gone wrong
             $selected_top_link = $DATA->page_metadata('hansard', 'menu');
         }
         $url = new \URL($top_highlight);
         $selected_top_link['link'] = $url->generate();
     }
     if ($top_highlight == 'hansard') {
         $section = 'uk';
         $selected_top_link['text'] = 'UK';
     } elseif ($top_highlight == 'ni_home') {
         $section = 'ni';
         $selected_top_link['text'] = 'NORTHERN IRELAND';
     } elseif ($top_highlight == 'sp_home') {
         $section = 'scotland';
         $selected_top_link['text'] = 'SCOTLAND';
     } else {
         $section = '';
     }
     $nav_highlights = array('top' => $top_highlight, 'bottom' => $bottom_highlight, 'top_selected' => $selected_top_link, 'section' => $section);
     //get the top and bottom links
     foreach ($nav_items as $bottompages) {
         $toppage = array_shift($bottompages);
         // Generate the links for the top menu.
         // What gets displayed for this page.
         $menudata = $DATA->page_metadata($toppage, 'menu');
         $text = $menudata['text'];
         $title = $menudata['title'];
         if (!$title) {
             continue;
         }
         //get link and description for the menu ans add it to the array
         $class = $toppage == $nav_highlights['top'] ? 'on' : '';
         $URL = new \URL($toppage);
         $top_link = array('href' => $URL->generate(), 'title' => $title, 'classes' => $class, 'text' => $text);
         array_push($data['assembly_nav_links'], $top_link);
         if ($toppage == $nav_highlights['top']) {
             // This top menu link is highlighted, so generate its bottom menu.
             foreach ($bottompages as $bottompage) {
                 $menudata = $DATA->page_metadata($bottompage, 'menu');
                 $text = $menudata['text'];
                 $title = $menudata['title'];
                 // Where we're linking to.
                 $URL = new \URL($bottompage);
                 $class = $bottompage == $nav_highlights['bottom'] ? 'on' : '';
                 $data['section_nav_links'][] = array('href' => $URL->generate(), 'title' => $title, 'classes' => $class, 'text' => $text);
             }
         }
     }
     $data['assembly_nav_current'] = $nav_highlights['top_selected']['text'];
     ////////////////////////////////////////////////////////////
     // 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' || $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
     $data['footer_links']['about'] = self::get_menu_links(array('help', 'about', 'linktous', 'houserules', 'blog', 'news', 'contact', 'privacy'));
     $data['footer_links']['assemblies'] = self::get_menu_links(array('hansard', 'sp_home', 'ni_home', 'wales_home', 'boundaries'));
     $data['footer_links']['international'] = self::get_menu_links(array('newzealand', 'australia', 'ireland', 'mzalendo'));
     $data['footer_links']['tech'] = self::get_menu_links(array('code', 'api', 'data', 'pombola', 'devmailinglist', 'irc'));
     # banner text
     $b = new Model\Banner();
     $data['banner_text'] = $b->get_text();
     # Robots header
     if (DEVSITE) {
         $data['robots'] = 'noindex,nofollow';
     } elseif ($robots = $DATA->page_metadata($this_page, 'robots')) {
         $data['robots'] = $robots;
     }
     ////////////////////////////////////////////////////////////
     // 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';
 }
Esempio n. 13
0
 private function generate_next_prev_link($nextprev, $linktype)
 {
     $link = null;
     if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) {
         if (isset($nextprev[$linktype]['body'])) {
             $linktitle = _htmlentities(trim_characters($nextprev[$linktype]['body'], 0, 40));
             if (isset($nextprev[$linktype]['speaker']) && count($nextprev[$linktype]['speaker']) > 0) {
                 $linktitle = $nextprev[$linktype]['speaker']['name'] . ': ' . $linktitle;
             }
         } elseif (isset($nextprev[$linktype]['hdate'])) {
             $linktitle = format_date($nextprev[$linktype]['hdate'], SHORTDATEFORMAT);
         }
         $link = array('rel' => $linktype, 'title' => $linktitle, 'href' => $nextprev[$linktype]['url']);
     }
     return $link;
 }
Esempio n. 14
0
 public function _get_item($args)
 {
     global $PAGE;
     if (!isset($args['gid']) && $args['gid'] == '') {
         $PAGE->error_message("Sorry, we don't have an item gid.");
         return false;
     }
     // Get all the data just for this epobject_id.
     $input = array('amount' => array('body' => true, 'speaker' => true, 'comment' => true, 'votes' => true), 'where' => array('gid=' => $this->gidprefix . $args['gid']));
     twfy_debug(get_class($this), "looking for redirected gid");
     $gid = $this->gidprefix . $args['gid'];
     $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid));
     if ($q->rows() == 0) {
         $itemdata = $this->_get_hansard_data($input);
     } else {
         do {
             $gid = $q->field(0, 'gid_to');
             $q = $this->db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid));
         } while ($q->rows() > 0);
         twfy_debug(get_class($this), "found redirected gid {$gid}");
         $input['where'] = array('gid=' => $gid);
         $itemdata = $this->_get_hansard_data($input);
         if (count($itemdata) > 0) {
             throw new RedirectException(fix_gid_from_db($gid));
         }
     }
     if (count($itemdata) > 0) {
         $itemdata = $itemdata[0];
     }
     if (count($itemdata) == 0) {
         /* Deal with old links to some Lords pages. Somewhere. I can't remember where */
         $this->check_gid_change($args['gid'], 'a', '');
         if (substr($args['gid'], -1) == 'L') {
             $letts = array('a', 'b', 'c', 'd', 'e');
             for ($i = 0; $i < 4; $i++) {
                 $this->check_gid_change($args['gid'], $letts[$i], $letts[$i + 1]);
             }
         }
         /* A lot of written answers were moved from 10th to 11th May and 11th May to 12th May.
            Deal with the bots who have stored links to those now non-existant written answers. */
         /* 2007-05-31: And then they were moved BACK in the volume edition, ARGH */
         $this->check_gid_change($args['gid'], '2006-05-10a', '2006-05-10c');
         $this->check_gid_change($args['gid'], '2006-05-10a', '2006-05-11d');
         $this->check_gid_change($args['gid'], '2006-05-11b', '2006-05-11d');
         $this->check_gid_change($args['gid'], '2006-05-11b', '2006-05-12c');
         $this->check_gid_change($args['gid'], '2006-05-11c', '2006-05-10c');
         $this->check_gid_change($args['gid'], '2006-05-12b', '2006-05-11d');
         $this->check_gid_change($args['gid'], '2007-01-08', '2007-01-05');
         $this->check_gid_change($args['gid'], '2007-02-19', '2007-02-16');
         /* More movearounds... */
         $this->check_gid_change($args['gid'], '2005-10-10d', '2005-09-12a');
         $this->check_gid_change($args['gid'], '2005-10-14a', '2005-10-13b');
         $this->check_gid_change($args['gid'], '2005-10-18b', '2005-10-10e');
         $this->check_gid_change($args['gid'], '2005-11-17b', '2005-11-15c');
         $this->check_gid_change($args['gid'], '2007-01-08a', '2007-01-08e');
         /* Right back when Lords began, we sent out email alerts when they weren't on the site. So this was to work that. */
         #$lord_gid_like = 'uk.org.publicwhip/lords/' . $args['gid'] . '%';
         #$q = $this->db->query('SELECT source_url FROM hansard WHERE gid LIKE :lord_gid_like', array(':lord_gid_like' => $lord_gid_like));
         #$u = '';
         #if ($q->rows()) {
         #	$u = $q->field(0, 'source_url');
         #	$u = '<br><a href="'. $u . '">' . $u . '</a>';
         #}
         $PAGE->error_message("Sorry, there is no Hansard object with a gid of '" . _htmlentities($args['gid']) . "'.");
         return false;
     }
     return $itemdata;
 }
Esempio n. 15
0
        $date = format_date($date, SHORTDATEFORMAT);
        $time = format_time($time, TIMEFORMAT);
        ?>
        <dt><a href="<?php 
        echo _htmlentities($trackback['url']);
        ?>
"><?php 
        echo _htmlentities($trackback['title']);
        ?>
</a></dt>
        <dd><?php 
        echo _htmlentities($trackback['excerpt']);
        ?>
<br>
            <small>At <?php 
        echo _htmlentities($trackback['blog_name']);
        ?>
 on <?php 
        echo $date . ' ' . $time;
        ?>
</small>
        </dd>
<?php 
    }
    // End cycling through trackbacks.
    ?>
        </dl>
    </div> <!-- end trackbacks -->
<?php 
    if ($stripe_must_be_ended) {
        $PAGE->stripe_end();
Esempio n. 16
0
function known_names()
{
    if (!file_exists(NAME_CACHE_FILE) || (time() - filemtime(NAME_CACHE_FILE)) / 60 / 60 > RECREATE_CACHE_HOURS) {
        echo "\n<br/>updating name cache ..<br/>\n";
        ob_end_flush();
        flush();
        $dir = TMP . '/' . rand(1000, 9999);
        echo system('mkdir -p ' . $dir . '; chmod -R 777 ' . $dir);
        if (!is_dir($dir)) {
            echo "error creating {$dir}\n";
            exit;
        }
        file_put_contents($dir . '/_vimrc-fetch', wrap_vimrc(vimrc2()));
        $cmd = '
  dir=' . $dir . '
  cd $dir
  exec > log.txt
  exec 2>&1
  set -x
  export PATH=/var/run/current-system/sw/bin
  mkdir -p .vim/vim-addons
  git clone --depth 1 git://github.com/MarcWeber/vim-addon-manager.git .vim/vim-addons/vim-addon-manager
  export HOME=$dir
  yes | vim -u ~/_vimrc-fetch -U NONE -N -c "qa!" &>/dev/null
    ';
        system("{$cmd}");
        file_put_contents(NAME_CACHE_FILE, file_get_contents($dir . '/names'));
        system('rm -fr $dir');
    }
    $s = '<div class="links"> You can click on these links: </br>';
    foreach (name_cache() as $key => $v) {
        $dep = strpos(implode("\n", $v), "deprecated:") != false;
        $s .= '<a class="' . ($dep ? "hide_link" : '') . '" target="n" href="?plugin_info=' . base64_encode($key) . '" >' . _htmlentities($key) . '</a>' . ', ';
    }
    $s .= "</div>";
    return $s;
}
Esempio n. 17
0
function editWork($uid, $params)
{
    $objResponse =& new xajaxResponse();
    if ($uid == null) {
        $uid = get_uid(false);
    }
    $uid = intval($uid);
    $work_id = intval($params['id']);
    if ($uid != get_uid(false) || !get_uid(false) || $work_id < 0 || is_emp()) {
        return $objResponse;
    }
    $params = stripslashes($params);
    parse_str($params, $params);
    $params['work_descr'] = _htmlentities($params['work_descr'], 'UTF-8');
    $params['work_name'] = _htmlentities($params['work_name'], 'UTF-8');
    $params = uploader::encodeCharset($params, array('utf-8', 'cp1251'));
    $edited = portfolio::editWork($uid, $params);
    if (is_array($edited)) {
        // Вернуло ошибки
        $errors = json_encode(array_map('win2utf', $edited));
        $objResponse->script("portfolio.viewError({$errors}, 'portfolio_work_edit')");
        return $objResponse;
    }
    if ($edited) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
        $first_prof = intval($params['prof_id_first']);
        $second_prof = intval($params['work_category_db_id']);
        $objResponse->script("\$('portfolio_work_edit').getParent().dispose()");
        $stop_words = new stop_words(hasPermissions('users'));
        $profession = new professions();
        $portfolio = new portfolio();
        $user = new users();
        $user->login = $_SESSION['login'];
        $user->uid = $_SESSION['uid'];
        $user->is_pro = is_pro() ? 't' : 'f';
        $is_owner = $uid == $_SESSION['uid'];
        if ($first_prof != $second_prof) {
            $pinfo = current(portfolio::getPortfolioCategory($second_prof));
            $pinfo['mainprofname'] = $pinfo['group_name'];
            $pinfo['profname'] = $pinfo['prof_name'];
            $pinfo['gr_prevs'] = $pinfo['show_preview'];
            $pinfo = $profession->prepareCostText($pinfo, $stop_words);
            $works = $portfolio->GetPortf($uid, $second_prof, true);
            if (!empty($works)) {
                $result = portfolio::prepareDataPortfolio($works, $uid, $stop_words, true);
                extract($result);
                $work[0]['id'] = 100;
                $prof_id = $second_prof;
                ob_start();
                include $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
                $second_works = ob_get_contents();
                ob_end_clean();
            } else {
                $work[0]['id'] = null;
                $prof_id = $first_prof;
                $pp_noblocks[$prof_id] = array();
                ob_start();
                include $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
                $first_works = ob_get_contents();
                ob_end_clean();
            }
            $pinfo = current(portfolio::getPortfolioCategory($first_prof));
            $pinfo['mainprofname'] = $pinfo['group_name'];
            $pinfo['profname'] = $pinfo['prof_name'];
            $pinfo['gr_prevs'] = $pinfo['show_preview'];
            $pinfo = $profession->prepareCostText($pinfo, $stop_words);
            $works = $portfolio->GetPortf($uid, $first_prof, true);
            if (!empty($works)) {
                $result = portfolio::prepareDataPortfolio($works, $uid, $stop_words, true);
                extract($result);
                $work[0]['id'] = 100;
                $prof_id = $first_prof;
                ob_start();
                include $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
                $first_works = ob_get_contents();
                ob_end_clean();
            } else {
                $work[0]['id'] = null;
                $prof_id = $first_prof;
                $pp_noblocks[$prof_id] = array();
                ob_start();
                include $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
                $first_works = ob_get_contents();
                ob_end_clean();
            }
            if ($first_works != '') {
                $objResponse->assign("prof_works_{$first_prof}", 'innerHTML', $first_works);
            }
            if ($second_works != '') {
                $objResponse->assign("prof_works_{$second_prof}", 'innerHTML', $second_works);
            }
        } else {
            $pinfo = current(portfolio::getPortfolioCategory($second_prof));
            $pinfo['mainprofname'] = $pinfo['group_name'];
            $pinfo['profname'] = $pinfo['prof_name'];
            $pinfo['gr_prevs'] = $pinfo['show_preview'];
            $pinfo = $profession->prepareCostText($pinfo, $stop_words);
            $works = $portfolio->GetPortf($uid, $second_prof, true);
            if (!empty($works)) {
                $result = portfolio::prepareDataPortfolio($works, $uid, $stop_words, true);
                extract($result);
                $work[0]['id'] = 100;
                $prof_id = $second_prof;
                ob_start();
                include_once $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
                $sWorks = ob_get_contents();
                ob_end_clean();
            } else {
                $work[0]['id'] = null;
                $prof_id = $first_prof;
                $pp_noblocks[$prof_id] = array();
                ob_start();
                include $_SERVER['DOCUMENT_ROOT'] . '/user/tpl.portfolio.works.php';
                $first_works = ob_get_contents();
                ob_end_clean();
            }
            if ($sWorks != '') {
                $objResponse->assign("prof_works_{$second_prof}", 'innerHTML', $sWorks);
            }
        }
        $objResponse->script("JSScroll(\$('professions_works_{$second_prof}'));");
    }
    return $objResponse;
}
Esempio n. 18
0
function prepare_emails_for_not_deleting($REPORT, $COMMENT, $FORMURL)
{
    // From the view() function, the user has chosen NOT to delete the comment.
    // Now they can prepare the appropriate emails, or choose not to send them.
    global $this_page;
    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined'));
    ?>
        <p><strong>You have chosen not to delete this comment.</strong> You can now send an email to the person who made the report (uncheck the box to send no email). The report will not be resolved until you click the button below.</p>

        <form action="<?php 
    echo $FORMURL->generate();
    ?>
" method="post">
            <p>&nbsp;<br><strong><input type="checkbox" name="sendtoreporter" value="true" checked id="sendtoreporter"> <label for="sendtoreporter">Send this email to the person who reported the comment:</label></strong></p>

            <p class="email-template"><?php 
    echo $reportermail;
    ?>
</p>

            <p>Enter a reason to replace {REASON}: <input type="text" name="declinedreason" size="40"></p>

            <p><input type="submit" name="resolve" value=" Resolve this report ">
            <input type="hidden" name="deletecomment" value="false">
            <input type="hidden" name="rid" value="<?php 
    echo _htmlentities($REPORT->report_id());
    ?>
">
            <input type="hidden" name="cid" value="<?php 
    echo _htmlentities($REPORT->comment_id());
    ?>
"></p>
        </form>
<?php 
}
Esempio n. 19
0
 public function set_modflag($switch)
 {
     // $switch is either 'on' or 'off'.
     // The comment's modflag goes to on when someone reports the comment.
     // It goes to off when a commentreport has been resolved but the
     // comment HASN'T been deleted.
     global $PAGE;
     if ($switch == 'on') {
         $date = gmdate("Y-m-d H:i:s");
         $flag = "'{$date}'";
     } elseif ($switch == 'off') {
         $date = NULL;
         $flag = 'NULL';
     } else {
         $PAGE->error_message("Why are you trying to switch this comment's modflag to '" . _htmlentities($switch) . "'!");
     }
     $q = $this->db->query("UPDATE comments\n                        SET\t\tmodflagged = {$flag}\n                        WHERE \tcomment_id = '" . $this->comment_id . "'\n                        ");
     if ($q->success()) {
         $this->modflagged = $date;
         return true;
     } else {
         $message = array('title' => 'Sorry', 'text' => "We couldn't update the annotation's modflag.");
         $PAGE->error_message($message);
         return false;
     }
 }
Esempio n. 20
0
        // skip heading count for WTT lords list
        ?>
                        <tr>
                            <td><?php 
        echo $speaker['count'];
        ?>
</td>
                            <td>
                                <?php 
        if ($pid) {
            ?>
                                    <?php 
            if (!$wtt || $speaker['left'] == '9999-12-31') {
                ?>
                                    <a href="/search/?q=<?php 
                echo _htmlentities($searchstring);
                ?>
&amp;pid=<?php 
                echo $pid;
                echo isset($wtt) && $speaker['left'] == '9999-12-31' ? '&amp;wtt=2' : '';
                ?>
">
                                    <?php 
            }
            ?>
                                    <?php 
            echo isset($speaker['name']) ? $speaker['name'] : 'N/A';
            ?>
                                    <?php 
            if (!$wtt || $speaker['left'] == '9999-12-31') {
                ?>
Esempio n. 21
0
    $stripecount = 0;
    // Used to generate stripes.
    foreach ($data['comments'] as $n => $comment) {
        $stripecount++;
        $style = $stripecount % 2 == 0 ? '1' : '2';
        $PAGE->stripe_start($style);
        $hansardtext = trim_characters($comment['hbody'], 0, 65);
        list($date, $time) = explode(' ', $comment['posted']);
        $date = format_date($date, SHORTDATEFORMAT);
        // Get the name of the member whose epobject was commented upon (if any).
        if (isset($comment['speaker']) && $comment['speaker']['name'] != '') {
            $member_name = $comment['speaker']['name'] . ': ';
        } else {
            $member_name = '';
        }
        $user_name = _htmlentities($comment['firstname'] . ' ' . $comment['lastname']);
        // We're grouping things by epobject_id, so we're going to display the number
        // of comments on this epobject.
        $plural = $comment['total_comments'] == 1 ? ' comment' : ' comments';
        echo "\t\t\t\t<p><a href=\"{$comment['url']}\">{$comment['total_comments']}{$plural}</a> to <strong>" . $member_name . $hansardtext . "</strong><br>\n";
        echo "\t\t\t\t<small>(posted on {$date})</small><br>\n";
        echo "\t\t\t\t" . prepare_comment_for_display($comment['body']) . "</p>";
        ?>

<?php 
        $PAGE->stripe_end();
    }
    $PAGE->stripe_start();
    $PAGE->page_links($data);
    $PAGE->stripe_end();
} else {
Esempio n. 22
0
function forum_check_password($forum_fid)
{
    $frame_top_target = html_get_top_frame_name();
    if (!($db_forum_check_password = db_connect())) {
        return false;
    }
    $webtag = get_webtag($webtag_search);
    if (!is_numeric($forum_fid)) {
        return false;
    }
    if ($forum_passhash = forum_get_password($forum_fid)) {
        forum_get_saved_password($password, $passhash, $sesshash);
        if ($sesshash == $forum_passhash) {
            return true;
        }
        // If we got this far then the password verification failed or
        // the user hasn't seen the password dialog before.
        $lang = load_language_file();
        html_draw_top();
        echo "<h1>{$lang['passwdprotectedforum']}</h1>\n";
        if (isset($_COOKIE["bh_{$webtag}_sesshash"]) && strlen(trim(_stripslashes($_COOKIE["bh_{$webtag}_sesshash"]))) > 0) {
            bh_setcookie("bh_{$webtag}_sesshash", "", time() - YEAR_IN_SECONDS);
            html_display_error_msg($lang['usernameorpasswdnotvalid'], '550', 'center');
        }
        echo "<br />\n";
        echo "<div align=\"center\">\n";
        echo "  <form method=\"post\" action=\"forum_password.php\" target=\"", html_get_top_frame_name(), "\">\n";
        echo "    ", form_input_hidden('webtag', _htmlentities($webtag)), "\n";
        echo "    ", form_input_hidden('final_uri', _htmlentities(get_request_uri())), "\n";
        echo "    <table cellpadding=\"0\" cellspacing=\"0\" width=\"550\">\n";
        if ($password_protected_message = forum_get_setting('password_protected_message', false)) {
            echo "      <tr>\n";
            echo "        <td align=\"left\">", fix_html($password_protected_message), "</td>\n";
            echo "      </tr>\n";
        } else {
            echo "      <tr>\n";
            echo "        <td align=\"center\">{$lang['passwdprotectedwarning']}</td>\n";
            echo "      </tr>\n";
        }
        echo "      <tr>\n";
        echo "        <td align=\"left\">&nbsp;</td>\n";
        echo "      </tr>\n";
        echo "      <tr>\n";
        echo "        <td align=\"center\">\n";
        echo "          <table class=\"box\" width=\"400\">\n";
        echo "            <tr>\n";
        echo "              <td class=\"posthead\" align=\"center\">\n";
        echo "                <table class=\"posthead\" width=\"100%\">\n";
        echo "                  <tr>\n";
        echo "                    <td align=\"left\" class=\"subhead\" colspan=\"2\">{$lang['enterpasswd']}</td>\n";
        echo "                  </tr>\n";
        echo "                </table>\n";
        echo "                <table class=\"posthead\" width=\"90%\">\n";
        echo "                  <tr>\n";
        echo "                    <td align=\"left\">{$lang['passwd']}:</td>\n";
        echo "                    <td align=\"left\">", form_input_password('forum_password', _htmlentities($password), 40, false, "autocomplete=\"off\""), form_input_hidden("forum_passhash", _htmlentities($passhash)), "</td>\n";
        echo "                  </tr>\n";
        echo "                  <tr>\n";
        echo "                    <td align=\"left\">&nbsp;</td>\n";
        echo "                    <td align=\"left\">", form_checkbox('remember_password', 'Y', $lang['rememberpassword'], strlen($password) > 0 && strlen($passhash) > 0), "</td>\n";
        echo "                  </tr>\n";
        echo "                  <tr>\n";
        echo "                    <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
        echo "                  </tr>\n";
        echo "                </table>\n";
        echo "              </td>\n";
        echo "            </tr>\n";
        echo "          </table>\n";
        echo "        </td>\n";
        echo "      </tr>\n";
        echo "      <tr>\n";
        echo "        <td align=\"left\">&nbsp;</td>\n";
        echo "      </tr>\n";
        echo "      <tr>\n";
        echo "        <td align=\"center\">", form_submit("submit", $lang['logon']), "&nbsp;", form_submit("cancel", $lang['cancel']), "</td>\n";
        echo "      </tr>\n";
        if (bh_session_check_perm(USER_PERM_ADMIN_TOOLS, 0) || bh_session_check_perm(USER_PERM_FORUM_TOOLS, 0)) {
            echo "      <tr>\n";
            echo "        <td align=\"left\">&nbsp;</td>\n";
            echo "      </tr>\n";
            echo "      <tr>\n";
            echo "        <td align=\"center\">{$lang['adminforumclosedtip']}</td>\n";
            echo "      </tr>\n";
        }
        echo "    </table>\n";
        echo "  </form>\n";
        echo "</div>\n";
        html_draw_bottom();
        exit;
    }
    return true;
}
Esempio n. 23
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';
 }
Esempio n. 24
0
<?php

include_once '../../includes/easyparliament/init.php';
include_once INCLUDESPATH . "easyparliament/member.php";
include_once INCLUDESPATH . "postcode.inc";
$pc = get_http_var('pc');
$pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
if (!$pc) {
    exit;
}
if (validate_postcode($pc)) {
    $constituency = strtolower(postcode_to_constituency($pc));
    if ($constituency == "CONNECTION_TIMED_OUT") {
        $errors['pc'] = "Sorry, we couldn't check your postcode right now. Please use the 'All Mps' link above to browse MPs";
    } elseif ($constituency == "") {
        $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a known postcode";
        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
    } else {
        $MEMBER = new MEMBER(array('constituency' => $constituency));
        if ($MEMBER->person_id()) {
            // This will cookie the postcode.
            $THEUSER->set_postcode_cookie($pc);
        }
        if ($MEMBER->person_id()) {
            header('Location: http://' . DOMAIN . '/rss/mp/' . $MEMBER->person_id() . '.rdf');
        }
    }
} else {
    $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a valid postcode";
    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
}
Esempio n. 25
0
echo preg_replace('#<[^>]*>#', '', $page_title);
?>
</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <?php 
if (isset($meta_description)) {
    ?>
    <meta name="description" content="<?php 
    echo _htmlentities($meta_description);
    ?>
">
    <?php 
}
?>
    <meta name="keywords" content="<?php 
echo _htmlentities($meta_keywords);
?>
">
    <?php 
if (!empty($robots)) {
    echo '<meta name="robots" content="' . $robots . '">';
}
?>

    <link rel="author" title="Send feedback" href="mailto:<?php 
echo str_replace('@', '&#64;', CONTACTEMAIL);
?>
">
    <link rel="home" title="Home" href="http://<?php 
echo DOMAIN;
?>
 function generate_commentteaser($row)
 {
     // Returns HTML for the one fragment of comment and link for the sidebar.
     // $totalcomments is the number of comments this item has on it.
     // $comment is an array like:
     /* $comment = array (
            'comment_id' => 23,
            'user_id'    => 34,
            'body'        => 'Blah blah...',
            'posted'    => '2004-02-24 23:45:30',
            'username'    => 'phil'
            )
        */
     // $url is the URL of the item's page, which contains comments.
     if ($row['totalcomments'] == 0) {
         return;
     }
     //Add existing annotations
     $comment = $row['comment'];
     // If the comment is longer than the speech body, we want to trim it
     // to be the same length so they fit next to each other.
     // But the comment typeface is smaller, so we scale things slightly too...
     $targetsize = round(strlen($row['body']) * 0.6);
     $linktext = '';
     if ($targetsize > strlen($comment['body'])) {
         // This comment will fit in its entirety.
         $commentbody = $comment['body'];
         if ($row['totalcomments'] > 1) {
             $morecount = $row['totalcomments'] - 1;
             $plural = $morecount == 1 ? 'annotation' : 'annotations';
             $linktext = "Read {$morecount} more {$plural}";
         }
     } else {
         // This comment needs trimming.
         $commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
         if ($row['totalcomments'] > 1) {
             $morecount = $row['totalcomments'] - 1;
             $plural = $morecount == 1 ? 'annotation' : 'annotations';
             $linktext = "Continue reading (and {$morecount} more {$plural})";
         } else {
             $linktext = 'Continue reading';
         }
     }
     return array('body' => prepare_comment_for_display($commentbody), 'username' => _htmlentities($comment['username']), 'linktext' => $linktext, 'commentsurl' => $row['commentsurl'], 'comment_id' => $comment['comment_id']);
 }
Esempio n. 27
0
            echo $comment['comment_id'];
            ?>
"></a>
<?php 
        } else {
            echo ">\n";
        }
        $USERURL = new URL('userview');
        $USERURL->insert(array('u' => $comment['user_id']));
        ?>
        <div class="comment">
            <p><a href="<?php 
        echo $USERURL->generate();
        ?>
" title="See information about this user"><strong><?php 
        echo _htmlentities($comment['firstname']) . ' ' . _htmlentities($comment['lastname']);
        ?>
</strong></a><br>
<?php 
        // Make URLs into links and do <br>s.
        $body = prepare_comment_for_display($comment['body']);
        // In utility.php
        echo $body;
        ?>
</p>

        </div>
        <div class="sidebar">
        <p> Posted on
<?php 
        list($date, $time) = explode(' ', $comment['posted']);
Esempio n. 28
0
 public function _display_result()
 {
     $html = "";
     if ($this->rows > 0) {
         $html .= "<table border=\"1\">\n<tr>\n";
         foreach (array_keys($this->data[0]) as $fieldname) {
             $html .= "<th>" . _htmlentities($fieldname) . "</th>";
         }
         $html .= "</tr>\n";
         foreach ($this->data as $index => $row) {
             $html .= "<tr>";
             foreach ($row as $n => $field) {
                 if ($n == "email" || $n == "password" || $n == "postcode") {
                     // Don't want to risk this data being displayed on any page.
                     $html .= "<td>**MASKED**</td>";
                 } else {
                     $html .= "<td>" . _htmlentities($field) . "</td>";
                 }
             }
             $html .= "</tr>\n";
         }
         $html .= "</table>\n";
     }
     return $html;
 }
Esempio n. 29
0
<?php

global $hansardmajors;
$previous_speech_time = null;
?>

<div class="debate-header regional-header regional-header--<?php 
echo $current_assembly;
?>
">
    <div class="regional-header__overlay"></div>
    <div class="full-page__row">
        <div class="debate-header__content full-page__unit">
            <h1>Column <?php 
echo _htmlentities($column);
?>
</h1>
            <p class="lead">
                <?php 
echo $location;
?>
                on <a href="<?php 
echo $debate_day_link;
?>
"><?php 
echo $debate_day_human;
?>
</a>.
            </p>
        </div>
    </div>
Esempio n. 30
0
 public function isvalid($email, $userenteredpassword)
 {
     // Returns true if this email and plaintext password match a user in the db.
     // If false returns an array of form error messages.
     // We use this on the log in page to check if the details the user entered
     // are correct. We can then continue with logging the user in (taking into
     // account their cookie remembering settings etc) with $this->login().
     // This error string is shared between both email and password errors to
     // prevent leaking of account existence.
     $error_string = 'There is no user registered with an email of ' . _htmlentities($email) . ', or the given password is incorrect. If you are subscribed to email alerts, you are not necessarily registered on the website. If you register, you will be able to manage your email alerts, as well as leave annotations.';
     $q = $this->db->query("SELECT user_id, password, deleted, confirmed FROM users WHERE email = :email", array(':email' => $email));
     if ($q->rows() == 1) {
         // OK.
         $dbpassword = $q->field(0, "password");
         if (password_verify($userenteredpassword, $dbpassword)) {
             $this->user_id = $q->field(0, "user_id");
             $this->password = $dbpassword;
             // We'll need these when we're going to log in.
             $this->deleted = $q->field(0, "deleted") == 1 ? true : false;
             $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false;
             return true;
         } else {
             // Failed.
             return array("invalidemail" => $error_string);
         }
     } else {
         // Failed.
         return array("invalidemail" => $error_string);
     }
 }