forked from mysociety/theyworkforyou
/
index.php
181 lines (159 loc) · 6.32 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
include_once "../includes/easyparliament/init.php";
$number_of_debates_to_show = 6;
$number_of_wrans_to_show = 5;
//set page name (selects relivant bottom menu item)
$this_page = 'overview';
//output header
$PAGE->page_start();
$PAGE->supress_heading = true;
$PAGE->stripe_start("full");
?>
<!-- Welcome -->
<!-- <div class="attention welcome">
<h2>
Welcome to TheyWorkForYou for the UK Parliament.
<br>Find out what your MP is doing in your name, read debates and sign up for email alerts.
</h2>
</div>
-->
<!-- Actions -->
<div id="welcome_uk" class="welcome_actions">
<!-- Search / alerts -->
<div id="welcome_search">
<?php
global $SEARCHURL;
global $SEARCHLOG;
$SEARCHURL = new URL('search');
$popular_searches = $SEARCHLOG->popular_recent(10);
?>
<form action="<?php echo $SEARCHURL->generate(); ?>" method="get">
<h3><label for="s">Search, create an alert or RSS feed</label></h3>
<p>
<input type="text" name="s" id="s" size="20" maxlength="100" class="text" value="<?=htmlspecialchars(get_http_var("keyword"))?>">
<input type="submit" value="Go" class="submit">
<br>
<small>e.g. <em>word</em>, <em>phrase</em>, or <em>person</em> | <a href="/search/?adv=1">More options</a></small>
</p>
<?php if (count($popular_searches) > 0) { ?>
<p>
Popular searches today:
<?php foreach ($popular_searches as $popular_search) { ?>
<a href="<?php echo $popular_search['url']?>"><?php echo $popular_search['display']?></a>
<?php } ?>
</p>
<?php } ?>
</form>
</div>
<div>
<h3>Your representative</h3>
<?php
$MPURL = new URL('yourmp');
global $THEUSER;
$pc_form = true;
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
// User is logged in and has a postcode, or not logged in with a cookied postcode.
// (We don't allow the user to search for a postcode if they
// already have one set in their prefs.)
$MEMBER = new MEMBER(array ('postcode'=>$THEUSER->postcode(), 'house'=>1));
if ($MEMBER->valid) {
$pc_form = false;
if ($THEUSER->isloggedin()) {
$CHANGEURL = new URL('useredit');
} else {
$CHANGEURL = new URL('userchangepc');
}
$mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
$former = "";
$left_house = $MEMBER->left_house();
if ($left_house[1]['date'] != '9999-12-31') {
$former = 'former';
}
?>
<p><a href="<?php echo $MPURL->generate(); ?>"><strong>Find out about <?php echo $mpname; ?>, your <?= $former ?> MP</strong></a><br>
In <?php echo strtoupper(htmlentities($THEUSER->postcode())); ?> (<a href="<?php echo $CHANGEURL->generate(); ?>">Change your postcode</a>)</p>
<?php
}
}
if ($pc_form) { ?>
<form action="/postcode/" method="get">
<p><strong>Find out about your <acronym title="Member of Parliament">MP</acronym>/
<acronym title="Members of the Scottish Parliament">MSPs</acronym>/
<acronym title="Members of the (Northern Irish) Legislative Assembly">MLAs</acronym></strong><br>
<label for="pc">Enter your UK postcode here:</label> <input type="text" name="pc" id="pc" size="8" maxlength="10" value="<?php echo htmlentities($THEUSER->postcode()); ?>" class="text"> <input type="submit" value=" Go " class="submit"></p>
</form>
<?php
if (!defined("POSTCODE_SEARCH_DOMAIN") || !POSTCODE_SEARCH_DOMAIN) {
print '<p align="right"><em>Postcodes are being mapped to a random MP</em></p>';
}
}
echo '<p>Read debates they’ve taken part in, see how they voted, sign up for an email alert, and more.</p>';
?>
</div>
<br class="clear">
</div>
<?php
$PAGE->stripe_end();
$PAGE->stripe_start("full");
?>
<!-- Campaign -->
<div class="campaign">
<p>
Become a TheyWorkForYou volunteer in your constituency <span class="chev"><span class="hide">-</span></span>
<a href="http://www.democracyclub.org.uk/">Join DemocracyClub</a>
</p>
</div>
<!-- Latest in parliament -->
<div class="latest col3">
<h3>Recently in the UK Parliament</h3>
<div>
<?php
//Latest activity (column 1)
$DEBATELIST = new DEBATELIST;
$LORDSDEBATELIST = new LORDSDEBATELIST;
$last_dates = array(); // holds the most recent data there is data for, indexed by type
$last_dates[1] = $DEBATELIST->most_recent_day();
$last_dates[101] = $LORDSDEBATELIST->most_recent_day();
//get html
$latest_html = major_summary($last_dates, false);
echo $latest_html;
?>
</div>
<div>
<?php
//Latest activity (column 2)
$WHALLLIST = new WHALLLIST;
$WMSLIST = new WMSLIST;
$last_dates = array();
$last_dates[4] = $WMSLIST->most_recent_day();
$last_dates[2] = $WHALLLIST->most_recent_day();
//get html
$latest_html = major_summary($last_dates, false);
echo $latest_html;
?>
</div>
<div>
<?php
//Latest activity (column 3)
$WRANSLIST = new WRANSLIST;
$last_dates = array();
$last_dates[3] = $WRANSLIST->most_recent_day();
/*
foreach (array_keys($hansardmajors) as $major) {
if (array_key_exists($major, $data)) {
unset($data[$major]['listurl']);
if (count($data[$major]) == 0)
unset($data[$major]);
}
}
*/
//get debates html
$latest_html = major_summary($last_dates, false);
echo $latest_html;
?>
</div>
<br class="clear">
</div>
<?php
$PAGE->stripe_end();
$PAGE->page_end();