-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
171 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace MySociety\TheyWorkForYou\Homepage; | ||
|
||
class NI extends Base { | ||
protected $mp_house = 3; | ||
protected $conts_type = 'NIE'; | ||
protected $page = 'nioverview'; | ||
protected $houses = [5]; | ||
protected $recent_types = [ | ||
'NILIST' => ['recent_debates', 'nidebatesfront', 'Northern Ireland Assembly debates'], | ||
]; | ||
|
||
public function display() { | ||
$data = parent::display(); | ||
$data['popular_searches'] = null; | ||
$data['template'] = 'ni/index'; | ||
return $data; | ||
} | ||
|
||
protected function getEditorialContent($data) { | ||
$featured = []; | ||
if (count($data['debates']['recent'])) { | ||
$MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront'); | ||
$MOREURL->insert([ 'more' => 1 ]); | ||
$featured = array_shift($data['debates']['recent']); | ||
$featured['more_url'] = $MOREURL->generate(); | ||
$featured['desc'] = 'Northern Ireland Assembly debate'; | ||
$featured['related'] = []; | ||
$featured['featured'] = false; | ||
} | ||
return $featured; | ||
} | ||
|
||
protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox { | ||
|
||
global $THEUSER; | ||
|
||
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) { | ||
$postcode = $THEUSER->postcode(); | ||
} else { | ||
$postcode = null; | ||
} | ||
|
||
$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox(); | ||
$search_box->homepage_panel_class = "panel--homepage--niassembly"; | ||
$search_box->homepage_subhead = "Northern Ireland Assembly"; | ||
$search_box->homepage_desc = ""; | ||
$search_box->search_section = "ni"; | ||
$search_box->quick_links = []; | ||
if (count($data["regional"])) { | ||
$constituency = $data["regional"][0]["constituency"]; | ||
$search_box->add_quick_link('Find out more about your MLAs for ' . $constituency, '/postcode/?pc=' . $postcode, 'torso'); | ||
} | ||
$search_box->add_quick_link('Create and manage email alerts', '/alert/', 'megaphone'); | ||
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail'); | ||
$search_box->add_quick_link('Donate to support our work', '/support-us/', 'heart'); | ||
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass'); | ||
return $search_box; | ||
} | ||
|
||
protected function getRegionalList() { | ||
global $THEUSER; | ||
|
||
$mreg = []; | ||
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) { | ||
return \MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, 3, 'NIE'); | ||
} | ||
|
||
return $mreg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
namespace MySociety\TheyWorkForYou\Homepage; | ||
|
||
class Wales extends Base { | ||
protected $mp_house = 5; | ||
protected $cons_type = 'WAC'; | ||
protected $page = 'seneddoverview'; | ||
|
||
# Due to language, set things here | ||
public function __construct() { | ||
if (LANGUAGE == 'cy') { | ||
$this->houses = [11]; | ||
$class = 'SENEDDCYLIST'; | ||
} | ||
} else { | ||
$this->houses = [10]; | ||
$class = 'SENEDDENLIST'; | ||
} | ||
$this->recent_types = [ | ||
$class => ['recent_debates', 'senedddebatesfront', 'Senedd'], | ||
]; | ||
parent::__construct(); | ||
} | ||
|
||
public function display() { | ||
$data = parent::display(); | ||
$data['popular_searches'] = null; | ||
$data['template'] = 'senedd/index'; | ||
return $data; | ||
} | ||
|
||
protected function getEditorialContent($data) { | ||
$featured = []; | ||
if (count($data['debates']['recent'])) { | ||
$MOREURL = new \MySociety\TheyWorkForYou\Url('senedddebatesfront'); | ||
$MOREURL->insert([ 'more' => 1 ]); | ||
$featured = array_shift($data['debates']['recent']); | ||
$featured['more_url'] = $MOREURL->generate(); | ||
$featured['desc'] = 'Senedd'; | ||
$featured['related'] = []; | ||
$featured['featured'] = false; | ||
} | ||
return $featured; | ||
} | ||
|
||
protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox { | ||
$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox(); | ||
$search_box->homepage_panel_class = "panel--homepage--senedd"; | ||
$search_box->homepage_subhead = gettext("Senedd / Welsh Parliament"); | ||
$search_box->homepage_desc = ""; | ||
$search_box->search_section = "senedd"; | ||
$search_box->quick_links = []; | ||
if (count($data["regional"])) { | ||
// get all unique constituencies | ||
$constituencies = []; | ||
foreach ($data["regional"] as $member) { | ||
$constituencies[$member["constituency"]] = 1; | ||
} | ||
$constituencies = array_keys($constituencies); | ||
$search_box->add_quick_link(sprintf(gettext('Find out more about your MSs for %s and %s'), $constituencies[0], $constituencies[1]), '/postcode/?pc=' . $data["mp_data"]['postcode'], 'torso'); | ||
} | ||
$search_box->add_quick_link(gettext('Create and manage email alerts'), '/alert/', 'megaphone'); | ||
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail'); | ||
$search_box->add_quick_link(gettext('Donate to support our work'), '/support-us/', 'heart'); | ||
$search_box->add_quick_link(gettext('Learn more about TheyWorkForYou'), '/about/', 'magnifying-glass'); | ||
return $search_box; | ||
} | ||
|
||
protected function getRegionalList() { | ||
global $THEUSER; | ||
|
||
$mreg = []; | ||
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) { | ||
return array_merge( | ||
\MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, 5, 'WAC'), | ||
\MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, 5, 'WAE') | ||
); | ||
} | ||
|
||
return $mreg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.