Exemplo n.º 1
0
 private function spwrans_redirect($spid)
 {
     global $PAGE;
     # We have a Scottish Parliament ID, need to find the date
     $SPWRANSLIST = new \SPWRANSLIST();
     $gid = $SPWRANSLIST->get_gid_from_spid($spid);
     if ($gid) {
         if (preg_match('/uk\\.org\\.publicwhip\\/spwa\\/(\\d{4}-\\d\\d-\\d\\d\\.(.*))/', $gid, $m)) {
             $URL = new \URL('spwrans');
             $URL->reset();
             $URL->insert(array('id' => $m[1]));
             $fragment_identifier = '#g' . $m[2];
             header('Location: http://' . DOMAIN . $URL->generate('none') . $fragment_identifier, true, 303);
             exit;
         } elseif (preg_match('/uk\\.org\\.publicwhip\\/spor\\/(\\d{4}-\\d\\d-\\d\\d\\.(.*))/', $gid, $m)) {
             $URL = new \URL('spdebates');
             $URL->reset();
             $URL->insert(array('id' => $m[1]));
             $fragment_identifier = '#g' . $m[2];
             header('Location: http://' . DOMAIN . $URL->generate('none') . $fragment_identifier, true, 303);
             exit;
         } else {
             $PAGE->error_message("Strange GID ({$gid}) for that Scottish Parliament ID.");
         }
     }
     $PAGE->error_message("Couldn't match that Scottish Parliament ID to a GID.");
 }
Exemplo n.º 2
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())
 {
     global $page_errors;
     ////////////////////////////////////////////////////////////
     // 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'] = Utility\Gaze::getCountryByIp($_SERVER["REMOTE_ADDR"]);
     }
     ////////////////////////////////////////////////////////////
     // Get the page data
     global $DATA, $this_page, $THEUSER;
     $header = new Renderer\Header();
     $data = array_merge($header->data, $data);
     $user = new Renderer\User();
     $data = array_merge($user->data, $data);
     if (isset($page_errors)) {
         $data['page_errors'] = $page_errors;
     }
     ////////////////////////////////////////////////////////////
     // 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();
     $data = self::addCommonURLs($data);
     # 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';
 }
Exemplo n.º 3
0
 function _get_nextprev_dates($date)
 {
     global $hansardmajors;
     // Pass it a yyyy-mm-dd date and it'll return an array
     // containing the next/prev dates that contain items from
     // $this->major of hansard object.
     twfy_debug(get_class($this), "getting next/prev dates");
     // What we return.
     $nextprevdata = array();
     $URL = new URL($this->listpage);
     $looper = array("next", "prev");
     foreach ($looper as $n => $nextorprev) {
         $URL->reset();
         if ($nextorprev == 'next') {
             $q = $this->db->query("SELECT MIN(hdate) AS hdate\n\t\t\t\t\t\t\tFROM \thansard\n\t\t\t\t\t\t\tWHERE \tmajor = '" . $this->major . "'\n\t\t\t\t\t\t\tAND\t\thdate > '" . mysql_escape_string($date) . "'\n\t\t\t\t\t\t\t");
         } else {
             $q = $this->db->query("SELECT MAX(hdate) AS hdate\n\t\t\t\t\t\t\tFROM \thansard\n\t\t\t\t\t\t\tWHERE \tmajor = '" . $this->major . "'\n\t\t\t\t\t\t\tAND\t\thdate < '" . mysql_escape_string($date) . "'\n\t\t\t\t\t\t\t");
         }
         // The '!= NULL' bit is needed otherwise I was getting errors
         // when displaying the first day of debates.
         if ($q->rows() > 0 && $q->field(0, 'hdate') != NULL) {
             $URL->insert(array('d' => $q->field(0, 'hdate')));
             if ($nextorprev == 'next') {
                 $body = 'Next day';
             } else {
                 $body = 'Previous day';
             }
             $title = format_date($q->field(0, 'hdate'), SHORTDATEFORMAT);
             $nextprevdata[$nextorprev] = array('hdate' => $q->field(0, 'hdate'), 'url' => $URL->generate(), 'body' => $body, 'title' => $title);
         }
     }
     $year = substr($date, 0, 4);
     $URL = new URL($hansardmajors[$this->major]['page_year']);
     $thing = $hansardmajors[$this->major]['plural'];
     $URL->insert(array('y' => $year));
     $nextprevdata['up'] = array('body' => "All of {$year}'s {$thing}", 'title' => '', 'url' => $URL->generate());
     return $nextprevdata;
 }
Exemplo n.º 4
0
    public function display()
    {
        // Print all our pending items out in a nice list or something
        // Add links later for "approve, decline, refer"
        // Just get the f****r working for now
        $URL = new URL('admin_glossary_pending');
        $URL->reset();
        $form_link = $URL->generate('url');
        ?>
<form action="<?php 
        echo $form_link;
        ?>
" method="post"><?php 
        foreach ($this->pending as $editqueue_id => $pender) {
            $URL = new URL('admin_glossary_pending');
            $URL->insert(array('approve' => $editqueue_id));
            $approve_link = $URL->generate('url');
            $URL = new URL('admin_glossary_pending');
            $URL->insert(array('modify' => $editqueue_id));
            $modify_link = $URL->generate('url');
            $URL = new URL('admin_glossary_pending');
            $URL->insert(array('decline' => $editqueue_id));
            $decline_link = $URL->generate('url');
            ?>
<div class="pending-item"><label for="<?php 
            echo $editqueue_id;
            ?>
"><input type="checkbox" name="approve[]" value="<?php 
            echo $editqueue_id;
            ?>
" id="<?php 
            echo $editqueue_id;
            ?>
"><strong><?php 
            echo $pender['title'];
            ?>
</strong></label>
            <p><?php 
            echo $pender['body'];
            ?>
<br>
            <small>
                <a href="<?php 
            echo $approve_link;
            ?>
">approve</a>
                &nbsp;|&nbsp;
                <a href="<?php 
            echo $modify_link;
            ?>
">modify</a>
                &nbsp;|&nbsp;
                <a href="<?php 
            echo $decline_link;
            ?>
">decline</a>
                <br>Submitted by: <em><?php 
            echo $pender['firstname'];
            ?>
&nbsp;<?php 
            echo $pender['lastname'];
            ?>
</em>
            </small></p></div>
        <?php 
        }
        ?>
<input type="submit" value="Approve checked items">
        </form><?php 
    }
Exemplo n.º 5
0
function display_form($details = array(), $errors = array())
{
    global $this_page, $ALERT, $PAGE, $THEUSER;
    $ACTIONURL = new URL($this_page);
    $ACTIONURL->reset();
    ?>

<p>This page allows you to request an email alert from OpenAustralia.org.</p>

<?php 
    if (!get_http_var('only')) {
        ?>
<ul>
<li>To receive an alert <strong>every time a particular person appears</strong>,
select their name from the drop-down list and
leave the word/phrase box blank.</li>

<li>To receive an alert <strong>every time a particular keyword or phrase appears</strong>,
select "Any Representative or Senator" from the drop-down list, and enter your search term in
the box underneath.  The results are selected using the same rules as for a
normal search (see the box to the right for help on setting your criteria).</li>

<li>You can also <strong>combine</strong> both types of criteria to be alerted
<strong>only</strong> when a particular person uses the keywords you have defined.
To do this, select the person from the drop-down list <em>and</em> enter the keyword(s) as
above.</li>
</ul>

<p>Please note that you should only enter one topic per alert - if you wish to receive alerts on more than one topic, or for more than one person, simply fill in this form as many times as you need.</p>
<?php 
    }
    ?>

	<form method="post" action="<?php 
    echo $ACTIONURL->generate();
    ?>
">
	
	<?php 
    if (!$THEUSER->loggedin()) {
        if (isset($errors["email"]) && (get_http_var('submitted') || get_http_var('only'))) {
            $PAGE->error_message($errors["email"]);
        }
        ?>
				<div class="row">
				<span class="label"><label for="email">Your email address:</label></span>
				<span class="formw"><input type="text" name="email" id="email" value="<?php 
        if (isset($details["email"])) {
            echo htmlentities($details["email"]);
        }
        ?>
" maxlength="255" size="30" class="form"></span>
				</div>
	<?php 
    }
    if (!get_http_var('only') || !$details['keyword']) {
        if (isset($errors['pid'])) {
            $PAGE->error_message($errors['pid']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="pid">Person you wish to receive alerts for:</label></span>
				<span class="formw"><?php 
        if (get_http_var('only') && $details['pid']) {
            $MEMBER = new MEMBER(array('person_id' => $details['pid']));
            print $MEMBER->full_name();
            print '<input type="hidden" name="pid" value="' . htmlspecialchars($details['pid']) . '">';
        } else {
            ?>
<select name="pid">
				<option value="Any">Any Representative or Senator</option>
				<?php 
            // Get a list of MPs/Lords for displaying in the form using the PEOPLE class
            $LIST = new PEOPLE();
            $args['order'] = 'last_name';
            if ($details['pid']) {
                $args['pid'] = $details['pid'];
            }
            $LIST->listoptions($args);
            ?>
				</select>
			<?php 
        }
        ?>
				</span>
				</div>
	<?php 
    }
    if (!get_http_var('only') || !$details['pid']) {
        if (isset($errors["keyword"])) {
            $PAGE->error_message($errors["keyword"]);
        }
        ?>
				<div class="row"> 
				<span class="label"><label for="keyword">Word or phrase you wish to receive alerts for:</label></span>
				<span class="formw"><input type="text" name="keyword" id="keyword" value="<?php 
        if ($details['keyword']) {
            echo htmlentities($details['keyword']);
        }
        ?>
" maxlength="255" size="30" class="form"></span>
				</div>
	<?php 
    }
    $submittext = "Request Email Alert";
    ?>
						
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="submit" class="submit" value="<?php 
    echo $submittext;
    ?>
"><!-- this space makes the submit button appear on Mac IE 5! --> </span>
				</div>
	<?php 
    if (!$THEUSER->loggedin()) {
        ?>
				<div class="row">
				If you join or log in, you won't need to confirm your email address for every alert you set.
				</div>
	<?php 
    }
    if (get_http_var('sign')) {
        echo '<input type="hidden" name="sign" value="' . htmlspecialchars(get_http_var('sign')) . '">';
    }
    if (get_http_var('site')) {
        echo '<input type="hidden" name="site" value="' . htmlspecialchars(get_http_var('site')) . '">';
    }
    // MJ OA-437 Recommendations
    if (get_http_var('r')) {
        echo '<input type="hidden" name="r" value="' . htmlspecialchars(get_http_var('r')) . '">';
    }
    echo '<input type="hidden" name="submitted" value="true"> </form>';
}
Exemplo n.º 6
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';
 }
Exemplo n.º 7
0
function display_form($details = array(), $errors = array())
{
    global $this_page, $THEUSER, $who, $PAGE;
    $PAGE->stripe_start();
    if (isset($errors["db"])) {
        $PAGE->error_message($errors["db"]);
    } else {
        $URL = new URL("userlogin");
        if (!$THEUSER->isloggedin()) {
            ?>
				<p>Already joined? <a href="<?php 
            echo $URL->generate();
            ?>
">Then log in!</a></p>
<?php 
        }
    }
    $ACTIONURL = new URL($this_page);
    $ACTIONURL->reset();
    ?>

				<form method="post" action="<?php 
    echo $ACTIONURL->generate();
    ?>
">
<?php 
    if ($this_page == "otheruseredit") {
        ?>
				<div class="row">
				<span class="label">User ID:</span>
				<span class="formw"><?php 
        echo htmlentities($details["user_id"]);
        ?>
</span>
				</div>

<?php 
    }
    if ($this_page == 'useredit' && isset($details['status'])) {
        ?>
				<div class="row">
				<span class="label">Status:</span>
				<span class="formw"><?php 
        echo htmlentities($details['status']);
        ?>
</span>
				</div>
<?php 
    }
    if (isset($errors["firstname"])) {
        $PAGE->error_message($errors["firstname"]);
    }
    ?>
				<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="<?php 
    if (isset($details["firstname"])) {
        echo htmlentities($details["firstname"]);
    }
    ?>
" maxlength="255" size="30" class="form"></span>
				</div>

<?php 
    if (isset($errors["lastname"])) {
        $PAGE->error_message($errors["lastname"]);
    }
    ?>
				<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="<?php 
    if (isset($details["lastname"])) {
        echo htmlentities($details["lastname"]);
    }
    ?>
" maxlength="255" 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="<?php 
    if (isset($details["email"])) {
        echo htmlentities($details["email"]);
    }
    ?>
" maxlength="255" size="30" class="form"></span>
				</div>

<?php 
    if ($this_page == "useredit" || $this_page == "otheruseredit") {
        // If not, the user's joining.
        ?>
				<div class="row">
				&nbsp;<br><small>To change <?php 
        echo $who;
        ?>
 password enter a new one twice below (otherwise, leave blank).</small>
				</div>
<?php 
    }
    if (isset($errors["password"])) {
        $PAGE->error_message($errors["password"]);
    }
    ?>
				<div class="row">
				<span class="label"><label for="password">Password:</label></span>
				<span class="formw"><input type="password" name="password" id="password" value="" maxlength="30" size="20" class="form"> <small>At least six characters</small></span>
				</div>

<?php 
    if (isset($errors["password2"])) {
        $PAGE->error_message($errors["password2"]);
    }
    ?>
				<div class="row">
				<span class="label"><label for="password2">Repeat password:</label></span>
				<span class="formw"><input type="password" name="password2" id="password2" value="" maxlength="30" size="20" class="form"></span>
				</div>


				<br style="clear: left;">&nbsp;<br>
<?php 
    if (isset($errors["postcode"])) {
        $PAGE->error_message($errors["postcode"]);
    }
    ?>
				<div class="row">
				<span class="label"><label for="postcode">Your Australian postcode:</label></span>
				<span class="formw"><input type="postcode" name="postcode" id="postcode" value="<?php 
    if (isset($details["postcode"])) {
        echo htmlentities($details["postcode"]);
    }
    ?>
" maxlength="10" size="10" class="form"> <small>Optional and not public</small></span>
				</div>

<?php 
    if (isset($errors["url"])) {
        $PAGE->error_message($errors["url"]);
    }
    ?>
				<div class="row">
				<span class="label"><label for="url">Your website:</label></span>
				<span class="formw"><input type="url" name="url" id="url" value="<?php 
    if (isset($details['url'])) {
        echo htmlentities($details['url']);
    }
    ?>
" maxlength="255" size="20" class="form"> <small>Optional and public</small></span>
				</div>


				
				<div class="row">
				&nbsp;<br>Let other users see <?php 
    echo $who;
    ?>
 email address?
				</div>

<?php 
    if (isset($errors["emailpublic"])) {
        $PAGE->error_message($errors["emailpublic"]);
    }
    ?>
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="radio" name="emailpublic" id="emailpublictrue" value="true"<?php 
    if (isset($details["emailpublic"]) && $details["emailpublic"] == true) {
        print " checked";
    }
    ?>
> <label for="emailpublictrue">Yes</label><br>
					<input type="radio" name="emailpublic" id="emailpublicfalse" value="false"<?php 
    if ($this_page == "userjoin" && get_http_var("submitted") != "true" || isset($details["emailpublic"]) && $details["emailpublic"] == false) {
        print " checked";
    }
    ?>
> <label for="emailpublicfalse">No</label></span>
				</div>
				
				
				
				<div class="row">
				&nbsp;<br>Do <?php 
    if ($this_page == "otheruseredit") {
        echo "they";
    } else {
        echo "you";
    }
    ?>
 wish to receive occasional update emails about TheyWorkForYou.com?
				</div>

<?php 
    if (isset($errors["optin"])) {
        $PAGE->error_message($errors["optin"]);
    }
    ?>
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="radio" name="optin" id="optintrue" value="true"<?php 
    if (isset($details["optin"]) && $details["optin"] == true) {
        print " checked";
    }
    ?>
> <label for="optintrue">Yes</label><br>
				<input type="radio" name="optin" id="optinfalse" value="false"<?php 
    if ($this_page == "userjoin" && get_http_var("submitted") != "true" || isset($details["optin"]) && $details["optin"] == false) {
        print " checked";
    }
    ?>
> <label for="optinfalse">No</label></span>
				</div>

<?php 
    if ($this_page == 'userjoin') {
        ?>
				<div class="row">
				&nbsp;<br>Would <?php 
        if ($this_page == "otheruseredit") {
            echo "they";
        } else {
            echo "you";
        }
        ?>
 like to receive an email whenever your MP does something in Parliament?
	<br /><small>&nbsp;&nbsp;(if you're already getting email alerts to your address, don't worry about this)</small>
				</div>

				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="radio" name="mp_alert" id="mp_alerttrue" value="true"<?php 
        if (isset($details["mp_alert"]) && $details["mp_alert"] == true) {
            print ' checked';
        }
        ?>
> <label for="mp_alerttrue">Yes</label><br>
				<input type="radio" name="mp_alert" id="mp_alertfalse" value="false"<?php 
        if ($this_page == "userjoin" && get_http_var("submitted") != "true" || isset($details["mp_alert"]) && $details["mp_alert"] == false) {
            print ' checked';
        }
        ?>
> <label for="mp_alertfalse">No</label></span>
				</div>
<?php 
    }
    if ($this_page == "otheruseredit") {
        if (isset($errors["status"])) {
            $PAGE->error_message($errors["status"]);
        }
        ?>
				<div class="row">
				<span class="label">Security status:</span>
				<span class="formw"><select name="status">
<?php 
        $USER = new USER();
        $statuses = $USER->possible_statuses();
        foreach ($statuses as $n => $status) {
            print "\t<option value=\"{$status}\"";
            if ($status == $details["status"]) {
                print " checked";
            }
            print ">{$status}</option>\n";
        }
        ?>
				</select></span>
				</div>

				<div class="row">
				<span class="label"><label for="confirmed">Confirmed?</label></span>
				<span class="formw"><input type="checkbox" name="confirmed[]" id="confirmed" value="true"<?php 
        if (isset($details["confirmed"]) && $details["confirmed"] == true) {
            print " checked";
        }
        ?>
></span>
				</div>
				
				<div class="row">
				<span class="label"><label for="deleted">"Deleted"?</label></span>
				<span class="formw"><input type="checkbox" name="deleted[]" id="deleted" value="true"<?php 
        if (isset($details["deleted"]) && $details["deleted"] == true) {
            print " checked";
        }
        ?>
> <small>(No data will actually be deleted.)</small></span>
				</div>

<?php 
    }
    if ($this_page == "useredit" || $this_page == "otheruseredit") {
        $submittext = "Update details";
    } else {
        $submittext = "Join TheyWorkForYou.com";
    }
    $TERMSURL = new URL('disclaimer');
    ?>
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw">&nbsp;<br><small>Read our <a href="<?php 
    echo $TERMSURL->generate();
    ?>
">Terms of Use</a>.</small></span>
				</div>

				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="submit" class="submit" value="<?php 
    echo $submittext;
    ?>
"><!-- this space makes the submit button appear on Mac IE 5! --> </span>
				</div>

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

<?php 
    if (get_http_var("ret") != "") {
        // The user was probably trying to add a writer but is joining first.
        ?>
				<input type="hidden" name="ret" value="<?php 
        echo htmlentities(get_http_var("ret"));
        ?>
">
<?php 
    }
    if (get_http_var("pg") != "") {
        // So that we get to the right page.
        ?>
				<input type="hidden" name="pg" value="<?php 
        echo htmlentities(get_http_var("pg"));
        ?>
">
<?php 
    }
    if ($this_page == "otheruseredit") {
        // Need to store the id of the user we're editing.
        ?>
				<input type="hidden" name="u" value="<?php 
        echo htmlentities($details["user_id"]);
        ?>
">
<?php 
    }
    ?>

				</form>
<?php 
    if ($this_page == 'userjoin') {
        $PAGE->stripe_end(array(array('type' => 'include', 'content' => 'userjoin')));
    } else {
        $PAGE->stripe_end();
    }
}
Exemplo n.º 8
0
Arquivo: page.php Projeto: archoo/twfy
    function login_form($errors = array())
    {
        // Used for /user/login/ and /user/prompt/
        // $errors is a hash of potential errors from a previous log in attempt.
        ?>
				<form method="post" action="<?php 
        $URL = new URL('userlogin');
        $URL->reset();
        echo $URL->generate();
        ?>
">


<?php 
        if (isset($errors["email"])) {
            $this->error_message($errors['email']);
        }
        if (isset($errors["invalidemail"])) {
            $this->error_message($errors['invalidemail']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="email">Email address:</label></span>
				<span class="formw"><input type="text" name="email" id="email" value="<?php 
        echo htmlentities(get_http_var("email"));
        ?>
" maxlength="100" size="30" class="form"></span>
				</div>

<?php 
        if (isset($errors["password"])) {
            $this->error_message($errors['password']);
        }
        if (isset($errors["invalidpassword"])) {
            $this->error_message($errors['invalidpassword']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="password">Password:</label></span>
				<span class="formw"><input type="password" name="password" id="password" maxlength="30" size="20" class="form"></span>
				</div>

				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="checkbox" name="remember" id="remember" value="true"<?php 
        $remember = get_http_var("remember");
        if (get_http_var("submitted") != "true" || $remember == "true") {
            print " checked";
        }
        ?>
> <label for="remember">Remember login details.*</label></span>
				</div>

				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="submit" value="Login" class="submit"> <small><a href="<?php 
        $URL = new URL("userpassword");
        $URL->insert(array("email" => get_http_var("email")));
        echo $URL->generate();
        ?>
">Forgotten your password?</a></small></span>
				</div>

				<div class="row">
				<small></small>
				</div>

				<input type="hidden" name="submitted" value="true">
<?php 
        // I had to havk about with this a bit to cover glossary login.
        // Glossary returl can't be properly formatted until the "add" form
        // has been submitted, so we have to do this rubbish:
        global $glossary_returl;
        if (get_http_var("ret") != "" || $glossary_returl != "") {
            // The return url for after the user has logged in.
            if (get_http_var("ret") != "") {
                $returl = get_http_var("ret");
            } else {
                $returl = $glossary_returl;
            }
            ?>
				<input type="hidden" name="ret" value="<?php 
            echo htmlentities($returl);
            ?>
">
<?php 
        }
        ?>
				</form>
<?php 
    }
Exemplo n.º 9
0
<?php

$rep = preg_replace('#S$#', 's', strtoupper($this_page));

$URL = new URL($this_page);
$URL->insert(array('f'=>'csv'));
$csvurl = $URL->generate();

$URL->reset();
$URL->insert(array('all'=>1));
$allurl = $URL->generate();

$this->block_start(array('title'=>'Relevant links'));
echo "<ul><li><a href='$csvurl'>Download a CSV file that you can load into Excel</a></li>";
if ($this_page == 'mps') {
?>
<li><a href="?date=2010-05-06">MPs at 2010 general election</a></li>
<li><a href="?date=2005-05-05">MPs at 2005 general election</a></li>
<li><a href="?date=2001-06-07">MPs at 2001 general election</a></li>
<li><a href="?date=1997-05-01">MPs at 1997 general election</a></li>
<li><a href="?date=1992-04-09">MPs at 1992 general election</a></li>
<li><a href="?date=1987-06-11">MPs at 1987 general election</a></li>
<li><a href="?date=1983-06-09">MPs at 1983 general election</a></li>
<li><a href="?date=1979-05-03">MPs at 1979 general election</a></li>
<li><a href="?date=1974-10-10">MPs at Oct 1974 general election</a></li>
<li><a href="?date=1974-02-28">MPs at Feb 1974 general election</a></li>
<li><a href="?date=1970-06-18">MPs at 1970 general election</a></li>
<li><a href="?date=1966-03-31">MPs at 1966 general election</a></li>
<li><a href="?date=1964-10-15">MPs at 1964 general election</a></li>
<li><a href="?date=1959-10-08">MPs at 1959 general election</a></li>
<li><a href="?date=1955-05-26">MPs at 1955 general election</a></li>
Exemplo n.º 10
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';
 }
Exemplo n.º 11
0
function display_search_form($alert, $details = array(), $errors = array())
{
    global $this_page, $PAGE;
    $ACTIONURL = new URL($this_page);
    $ACTIONURL->reset();
    $form_start = '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . _htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="email" value="' . _htmlspecialchars(get_http_var('email')) . '">';
    if (isset($details['members']) && $details['members']->rows() > 0) {
        echo '<ul class="hilites">';
        $q = $details['members'];
        for ($n = 0; $n < $q->rows(); $n++) {
            echo '<li>';
            echo $form_start . '<input type="hidden" name="pid" value="' . $q->field($n, 'person_id') . '">';
            echo 'Things by ';
            $name = member_full_name($q->field($n, 'house'), $q->field($n, 'title'), $q->field($n, 'given_name'), $q->field($n, 'family_name'), $q->field($n, 'lordofname'));
            if ($q->field($n, 'constituency')) {
                echo $name . ' (' . $q->field($n, 'constituency') . ') ';
            } else {
                echo $name;
            }
            echo ' <input type="submit" value="Subscribe"></form>';
            echo "</li>\n";
        }
        echo '</ul>';
    }
    if (isset($details['constituencies'])) {
        echo '<ul class="hilites">';
        foreach ($details['constituencies'] as $constituency) {
            $MEMBER = new MEMBER(array('constituency' => $constituency, 'house' => 1));
            echo "<li>";
            echo $form_start . '<input type="hidden" name="pid" value="' . $MEMBER->person_id() . '">';
            if ($details['valid_postcode']) {
                echo '<input type="hidden" name="pc" value="' . _htmlspecialchars($details['alertsearch']) . '">';
            }
            echo $MEMBER->full_name();
            echo ' (' . _htmlspecialchars($constituency) . ')';
            echo ' <input type="submit" value="Subscribe"></form>';
            echo "</li>";
        }
        echo '</ul>';
    }
    if ($details['alertsearch']) {
        echo '<ul class="hilites"><li>';
        echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($details['alertsearch']) . '">';
        echo 'Mentions of [';
        $alertsearch = $details['alertsearch'];
        if (preg_match('#speaker:(\\d+)#', $alertsearch, $m)) {
            $MEMBER = new MEMBER(array('person_id' => $m[1]));
            $alertsearch = str_replace("speaker:{$m['1']}", "speaker:" . $MEMBER->full_name(), $alertsearch);
        }
        echo _htmlspecialchars($alertsearch) . '] ';
        echo ' <input type="submit" value="Subscribe"></form>';
        # Use original alertsearch variable here, because name replacement might introduce a comma
        if (strstr($details['alertsearch'], ',') > -1) {
            echo '<em class="error">You have used a comma in your search term &ndash; are you sure this is what you want?
You cannot sign up to multiple search terms using a comma &ndash; either use OR, or fill in this form multiple times.</em>';
        }
        if (preg_match('#([A-Z]{1,2}\\d+[A-Z]? ?\\d[A-Z]{2})#i', $alertsearch, $m) && strlen($alertsearch) > strlen($m[1]) && validate_postcode($m[1])) {
            $scottish_text = '';
            $mp_display_text = '';
            if (postcode_is_scottish($m[1])) {
                $mp_display_text = 'your MP, ';
                $scottish_text = ' or MSP';
            }
            echo '<em class="error">You have used a postcode and something else in your search term &ndash; are you sure this is what you want?
                  You will only get an alert if all of these are mentioned in the same debate. Did you mean to get alerts for when your MP' . $scottish_text . ' mentions something instead? If so click subscribe below.</em></li>';
            try {
                $MEMBER = new MEMBER(array('postcode' => $m[1]));
                // move the postcode to the front just to be tidy
                $tidy_alertsearch = $m[1] . " " . trim(str_replace("{$m['1']}", "", $alertsearch));
                $alertsearch_display = str_replace("{$m['1']} ", "", $tidy_alertsearch);
                $alertsearch = str_replace("{$m['1']}", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
                echo "<li>";
                echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($alertsearch) . '">';
                echo 'Mentions of [';
                echo _htmlspecialchars($alertsearch_display) . '] by ' . $mp_display_text . $MEMBER->full_name();
                echo ' <input type="submit" value="Subscribe"></form>';
                if ($scottish_text) {
                    $constituencies = postcode_to_constituencies($m[1]);
                    if (isset($constituencies['SPC'])) {
                        $MEMBER = new MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4));
                        // move the postcode to the front just to be tidy
                        $alertsearch = str_replace("{$m['1']}", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
                        echo "</li><li>";
                        echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($alertsearch) . '">';
                        echo 'Mentions of [';
                        echo _htmlspecialchars($alertsearch_display) . '] by your MSP, ' . $MEMBER->full_name();
                        echo ' <input type="submit" value="Subscribe"></form>';
                    }
                }
            } catch (MySociety\TheyWorkForYou\MemberException $e) {
                echo '<p>We had a problem looking up your representative.</p>';
            }
        }
        echo "</li></ul>";
    }
    if ($details['pid']) {
        $MEMBER = new MEMBER(array('person_id' => $details['pid']));
        echo '<ul class="hilites"><li>';
        echo "Signing up for things by " . $MEMBER->full_name();
        echo ' (' . _htmlspecialchars($MEMBER->constituency()) . ')';
        echo "</li></ul>";
    }
    if ($details['keyword']) {
        echo '<ul class="hilites"><li>';
        echo 'Signing up for results from a search for [';
        $alertsearch = $details['keyword'];
        if (preg_match('#speaker:(\\d+)#', $alertsearch, $m)) {
            $MEMBER = new MEMBER(array('person_id' => $m[1]));
            $alertsearch = str_replace("speaker:{$m['1']}", "speaker:" . $MEMBER->full_name(), $alertsearch);
        }
        echo _htmlspecialchars($alertsearch) . ']';
        echo "</li></ul>";
    }
    if (!$details['pid'] && !$details['keyword']) {
        ?>

<p><label for="alertsearch">To sign up to an email alert, enter either your
<strong>postcode</strong>, the <strong>name</strong> of who you're interested
in, or the <strong>search term</strong> you wish to receive alerts
for.</label> To be alerted on an exact <strong>phrase</strong>, be sure to put it in quotes.
Also use quotes around a word to avoid stemming (where &lsquo;horse&rsquo; would
also match &lsquo;horses&rsquo;).

<?php 
    }
    echo '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . _htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="submitted" value="1">';
    if (!$details['pid'] && !$details['keyword'] || isset($errors['alertsearch'])) {
        if (isset($errors["alertsearch"])) {
            $PAGE->error_message($errors["alertsearch"]);
        }
        $text = $details['alertsearch'];
        if (!$text) {
            $text = $details['keyword'];
        }
        ?>

<div class="row">
<input type="text" name="alertsearch" id="alertsearch" value="<?php 
        if ($text) {
            echo _htmlentities($text);
        }
        ?>
" maxlength="255" size="30" style="font-size:150%">
</div>

<?php 
    }
    if ($details['pid']) {
        echo '<input type="hidden" name="pid" value="' . _htmlspecialchars($details['pid']) . '">';
    }
    if ($details['keyword']) {
        echo '<input type="hidden" name="keyword" value="' . _htmlspecialchars($details['keyword']) . '">';
    }
    if (!$details['email_verified']) {
        if (isset($errors["email"]) && $details['submitted']) {
            $PAGE->error_message($errors["email"]);
        }
        ?>
        <div class="row">
            <label for="email">Your email address:</label>
            <input type="text" name="email" id="email" value="<?php 
        if (isset($details["email"])) {
            echo _htmlentities($details["email"]);
        }
        ?>
" maxlength="255" size="30" class="form">
        </div>
<?php 
    }
    ?>

    <div class="row">
        <input type="submit" class="submit" value="<?php 
    echo $details['pid'] || $details['keyword'] ? 'Subscribe' : 'Search';
    ?>
">
    </div>

    <div class="row">
<?php 
    if (!$details['email_verified']) {
        ?>
        <p>If you <a href="/user/?pg=join">join</a> or <a href="/user/login/?ret=%2Falert%2F">sign in</a>, you won't need to confirm your email
        address for every alert you set.<br><br>
<?php 
    }
    if (!$details['pid'] && !$details['keyword']) {
        ?>
        <p>Please note that you should only enter <strong>one term per alert</strong> &ndash; if
        you wish to receive alerts on more than one thing, or for more than
        one person, simply fill in this form as many times as you need, or use boolean OR.<br><br></p>
        <p>For example, if you wish to receive alerts whenever the words
        <i>horse</i> or <i>pony</i> are mentioned in Parliament, please fill in
        this form once with the word <i>horse</i> and then again with the word
        <i>pony</i> (or you can put <i>horse OR pony</i> with the OR in capitals
        as explained on the right). Do not put <i>horse, pony</i> as that will only
        sign you up for alerts where <strong>both</strong> horse and pony are mentioned.</p>
<?php 
    }
    ?>
    </div>
<?php 
    if (get_http_var('sign')) {
        echo '<input type="hidden" name="sign" value="' . _htmlspecialchars(get_http_var('sign')) . '">';
    }
    if (get_http_var('site')) {
        echo '<input type="hidden" name="site" value="' . _htmlspecialchars(get_http_var('site')) . '">';
    }
    echo '</form>';
}
Exemplo n.º 12
0
 private function getBasicData()
 {
     global $this_page;
     if ($this->user->loggedin()) {
         $this->data['email'] = $this->user->email();
         $this->data['email_verified'] = true;
     } elseif ($this->data['alert']) {
         $this->data['email'] = $this->data['alert']['email'];
         $this->data['email_verified'] = true;
     } else {
         $this->data["email"] = trim(get_http_var("email"));
         $this->data['email_verified'] = false;
     }
     $this->data['keyword'] = trim(get_http_var("keyword"));
     $this->data['pid'] = trim(get_http_var("pid"));
     $this->data['alertsearch'] = trim(get_http_var("alertsearch"));
     $this->data['pc'] = get_http_var('pc');
     $this->data['submitted'] = get_http_var('submitted') || $this->data['pid'] || $this->data['keyword'];
     $this->data['token'] = get_http_var('t');
     $this->data['sign'] = get_http_var('sign');
     $this->data['site'] = get_http_var('site');
     $this->data['message'] = '';
     $ACTIONURL = new \URL($this_page);
     $ACTIONURL->reset();
     $this->data['actionurl'] = $ACTIONURL->generate();
 }
Exemplo n.º 13
0
    // If we're getting matches and no glossary entry, we can trigger them to add a definition
    // Obviously, only if it's a proper noun
    if ($info['total_results'] > 0 && $GLOSSARY['num_search_matches'] == 0) {
        // I'll be leaving this empty for now, pending search engine improvements...
    }
    $last_result = $info['first_result'] + $info['results_per_page'] - 1;
    if ($last_result > $info['total_results']) {
        $last_result = $info['total_results'];
    }
    print "\t\t\t\t<h3 style='font-weight:normal'>Results <strong>" . number_format($info['first_result']) . '-' . number_format($last_result) . '</strong> of ' . number_format($info['total_results']) . " for <strong>" . _htmlentities($searchdescription) . "</strong></h3>\n";
} elseif ($info['total_results'] == 0) {
    echo '<h3 style="font-weight:normal">Your search for <strong>', _htmlentities($searchdescription), '</strong> did not match anything.</h3>';
}
if ($info['spelling_correction']) {
    $u = new URL('search');
    $u->reset();
    $u->insert(array('s' => $info['spelling_correction']));
    echo '<p><big>Did you mean: <a href="' . $u->generate(), '">', $info['spelling_correction'] . '</a>?</big></p>';
}
if ($match = get_http_var('match')) {
    echo '<p><big>Hansard only refers to previous answers/statements by column number, so we don&rsquo;t know exactly what
was being referred to. Help us out by picking the right result and clicking &ldquo;This is the correct match&rdquo; next to it.
You&rsquo;ll be taken back to the page you came from, but hopefully then the link will go directly to the section you want.</big></p>';
}
if (isset($data['rows']) && count($data['rows']) > 0) {
    echo '<dl id="searchresults">';
    for ($i = 0; $i < count($data['rows']); $i++) {
        $row = $data['rows'][$i];
        echo '<dt><a href="', $row['listurl'], '">';
        if (isset($row['parent']) && count($row['parent']) > 0) {
            echo '<strong>' . $row['parent']['body'] . '</strong>';
Exemplo n.º 14
0
function display_search_form ( $alert, $details = array(), $errors = array() ) {
    global $this_page, $PAGE;

    $ACTIONURL = new URL($this_page);
    $ACTIONURL->reset();
    $form_start = '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="only" value="1">
<input type="hidden" name="email" value="' . htmlspecialchars(get_http_var('email')) . '">';

    if (isset($details['members']) && $details['members']->rows() > 0) {
        echo '<ul class="hilites">';
        $q = $details['members'];
        $last_pid = null;
        for ($n=0; $n<$q->rows(); $n++) {
            if ($q->field($n, 'person_id') != $last_pid) {
                $last_pid = $q->field($n, 'person_id');
                echo '<li>';
                echo $form_start . '<input type="hidden" name="pid" value="' . $last_pid . '">';
                echo 'Things by ';
                $name = member_full_name($q->field($n, 'house'), $q->field($n, 'title'), $q->field($n, 'first_name'), $q->field($n, 'last_name'), $q->field($n, 'constituency') );
                if ($q->field($n, 'house') != 2) {
                    echo $name . ' (' . $q->field($n, 'constituency') . ') ';
                } else {
                    echo $name;
                }
                echo ' <input type="submit" value="Subscribe"></form>';
                echo "</li>\n";
            }
        }
        echo '</ul>';
    }

    if (isset($details['constituencies'])) {
        echo '<ul class="hilites">';
        foreach ($details['constituencies'] as $constituency) {
            $MEMBER = new MEMBER(array('constituency'=>$constituency, 'house' => 1));
            echo "<li>";
            echo $form_start . '<input type="hidden" name="pid" value="' . $MEMBER->person_id() . '">';
            if ($details['valid_postcode'])
                echo '<input type="hidden" name="pc" value="' . htmlspecialchars($details['alertsearch']) . '">';
            echo $MEMBER->full_name();
            echo ' (' . htmlspecialchars($constituency) . ')';
            echo ' <input type="submit" value="Subscribe"></form>';
            echo "</li>";
        }
        echo '</ul>';
    }

    if ($details['alertsearch']) {
        echo '<ul class="hilites"><li>';
        echo $form_start . '<input type="hidden" name="keyword" value="' . htmlspecialchars($details['alertsearch']) . '">';
        echo 'Mentions of [';
		$alertsearch = $details['alertsearch'];
        if (preg_match('#speaker:(\d+)#', $alertsearch, $m)) {
			$MEMBER = new MEMBER(array('person_id'=>$m[1]));
		    $alertsearch = str_replace("speaker:$m[1]", "speaker:" . $MEMBER->full_name(), $alertsearch);
        }
        echo htmlspecialchars($alertsearch) . '] ';
        echo ' <input type="submit" value="Subscribe"></form>';
        echo "</li></ul>";
    }

    if ($details['pid']) {
        $MEMBER = new MEMBER(array('person_id'=>$details['pid']));
        echo '<ul class="hilites"><li>';
        echo "Signing up for things by " . $MEMBER->full_name();
        echo ' (' . htmlspecialchars($MEMBER->constituency()) . ')';
        echo "</li></ul>";
    }

    if ($details['keyword']) {
        echo '<ul class="hilites"><li>';
        echo 'Signing up for results from a search for [';
		$alertsearch = $details['keyword'];
        if (preg_match('#speaker:(\d+)#', $alertsearch, $m)) {
			$MEMBER = new MEMBER(array('person_id'=>$m[1]));
		    $alertsearch = str_replace("speaker:$m[1]", "speaker:" . $MEMBER->full_name(), $alertsearch);
        }
        echo htmlspecialchars($alertsearch) . ']';
        echo "</li></ul>";
    }

    if (!$details['add']) {
?>

<p><label for="alertsearch">To sign up to an email alert, enter either your
<strong>postcode</strong>, the <strong>name</strong> of who you're interested
in, or the <strong>search word</strong> or <strong>words</strong> you wish to receive alerts
for.</label> To be alerted on an exact <strong>phrase</strong>, be sure to put it in quotes.
Also use quotes around a word to avoid stemming (where &lsquo;horse&rsquo; will
also match &lsquo;horses&rsquo;),

<?
    }

    echo '<form action="' . $ACTIONURL->generate() . '" method="post">
<input type="hidden" name="t" value="' . htmlspecialchars(get_http_var('t')) . '">
<input type="hidden" name="submitted" value="1">';

    if (!$details['add']) {
        if (isset($errors["alertsearch"])) {
            $PAGE->error_message($errors["alertsearch"]);
        }
?>

<div class="row">
<input type="text" name="alertsearch" id="alertsearch" value="<?php if ($details['alertsearch']) { echo htmlentities($details['alertsearch']); } ?>" size="30" style="font-size:150%">
</div>

<?php
    }

    if ($details['pid'])
        echo '<input type="hidden" name="pid" value="' . htmlspecialchars($details['pid']) . '">';
    if ($details['keyword'])
        echo '<input type="hidden" name="keyword" value="' . htmlspecialchars($details['keyword']) . '">';
    if ($details['pid'] || $details['keyword'])
        echo '<input type="hidden" name="only" value="1">';

    if (!$details['email_verified']) {
        if (isset($errors["email"]) && (get_http_var('submitted') || $details['add'])) {
            $PAGE->error_message($errors["email"]);
        }
?>
        <div class="row">
            <label for="email">Your email address:</label>
            <input type="text" name="email" id="email" value="<?php if (isset($details["email"])) { echo htmlentities($details["email"]); } ?>" maxlength="255" size="30" class="form">
        </div>
<?php
    }
?>

    <div class="row">   
        <input type="submit" class="submit" value="Search">
    </div>

    <div class="row">
<?php
    if (!$details['email_verified']) {
?>
        <p>If you join or sign in, you won't need to confirm your email
        address for every alert you set.
<?php
    }
    if (!$details['add']) {
?>
        <p>Please note that you should only enter one topic per alert - if
        you wish to receive alerts on more than one topic, or for more than
        one person, simply fill in this form as many times as you need.</p>
<?php
    }
?>
    </div>
<?php
    if (get_http_var('sign'))
        echo '<input type="hidden" name="sign" value="' . htmlspecialchars(get_http_var('sign')) . '">';
    if (get_http_var('site'))
        echo '<input type="hidden" name="site" value="' . htmlspecialchars(get_http_var('site')) . '">';
    echo '</form>';
}