|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace MySociety\TheyWorkForYou\Homepage; |
|
4
|
|
|
|
|
5
|
|
|
class Scotland extends Base { |
|
6
|
|
|
protected $mp_house = 4; |
|
7
|
|
|
protected $cons_type = 'SPC'; |
|
8
|
|
|
protected $page = 'spoverview'; |
|
9
|
|
|
protected $houses = [7]; |
|
10
|
|
|
|
|
11
|
|
|
protected $recent_types = [ |
|
12
|
|
|
'SPLIST' => ['recent_debates', 'spdebatesfront', 'Scottish parliament debates'], |
|
13
|
|
|
'SPWRANSLIST' => ['recent_wrans', 'spwransfront', 'Written answers'], |
|
14
|
|
|
]; |
|
15
|
|
|
|
|
16
|
|
|
protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox { |
|
17
|
|
|
$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox(); |
|
18
|
|
|
$search_box->homepage_panel_class = "panel--homepage--scotland"; |
|
19
|
|
|
$search_box->homepage_subhead = "Scottish Parliament"; |
|
20
|
|
|
$search_box->homepage_desc = ""; |
|
21
|
|
|
$search_box->search_section = "scotland"; |
|
22
|
|
|
$search_box->quick_links = []; |
|
23
|
|
|
if (count($data["mp_data"])) { |
|
24
|
|
|
$regional_con = $data["regional"][0]["constituency"]; |
|
25
|
|
|
$search_box->add_quick_link('Find out more about your MSPs for ' . $data["mp_data"]["constituency"] . ' (' . $regional_con . ')', '/postcode/?pc=' . $data["mp_data"]['postcode'], 'torso'); |
|
26
|
|
|
} |
|
27
|
|
|
$search_box->add_quick_link('Create and manage email alerts', '/alert/', 'megaphone'); |
|
28
|
|
|
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail'); |
|
29
|
|
|
$search_box->add_quick_link('Donate to support our work', '/support-us/', 'heart'); |
|
30
|
|
|
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass'); |
|
31
|
|
|
return $search_box; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
protected function getEditorialContent(&$data) { |
|
35
|
|
|
$debatelist = new \SPLIST(); |
|
36
|
|
|
$item = $debatelist->display('recent_debates', ['days' => 7, 'num' => 1], 'none'); |
|
37
|
|
|
if (count($item['data'])) { |
|
38
|
|
|
$item = $item['data'][0]; |
|
39
|
|
|
$more_url = new \MySociety\TheyWorkForYou\Url('spdebatesfront'); |
|
40
|
|
|
$item['more_url'] = $more_url->generate(); |
|
41
|
|
|
$item['desc'] = 'Scottish Parliament debate'; |
|
42
|
|
|
$item['related'] = []; |
|
43
|
|
|
$item['featured'] = false; |
|
44
|
|
|
} |
|
45
|
|
|
return $item; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
protected function getRegionalList() { |
|
49
|
|
|
global $THEUSER; |
|
50
|
|
|
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) { |
|
|
|
|
|
|
51
|
|
|
return \MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, 4, 'SPE'); |
|
52
|
|
|
} |
|
53
|
|
|
return []; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|