Exemple #1
0
 private function checkForCommonMistakes()
 {
     $mistakes = array();
     if (strstr($this->data['alertsearch'], ',') > -1) {
         $mistakes['multiple'] = 1;
     }
     if (preg_match('#([A-Z]{1,2}\\d+[A-Z]? ?\\d[A-Z]{2})#i', $this->data['alertsearch'], $m) && strlen($this->data['alertsearch']) > strlen($m[1]) && validate_postcode($m[1])) {
         $this->data['postcode'] = $m[1];
         $this->data['scottish_text'] = '';
         $this->data['mp_display_text'] = '';
         if (\MySociety\TheyWorkForYou\Utility\Postcode::postcodeIsScottish($m[1])) {
             $this->data['mp_display_text'] = 'your MP, ';
             $this->data['scottish_text'] = ' or MSP';
         }
         $mistakes['postcode_and'] = 1;
     }
     $this->data['mistakes'] = $mistakes;
 }
Exemple #2
0
function get_regional_by_user_postcode($pc, $page)
{
    global $this_page;
    $this_page = "your{$page}";
    if ($page == 'msp' && \MySociety\TheyWorkForYou\Utility\Postcode::postcodeIsScottish($pc)) {
        regional_list($pc, 'SPC', $page);
    } elseif ($page == 'mla' && \MySociety\TheyWorkForYou\Utility\Postcode::postcodeIsNi($pc)) {
        regional_list($pc, 'NIE', $page);
    } else {
        throw new MySociety\TheyWorkForYou\MemberException('Your set postcode is not in the right region.');
    }
}
Exemple #3
0
 private function addRepLinks()
 {
     if ($this->user->postcode_is_set()) {
         $items = array('yourmp');
         if (\MySociety\TheyWorkForYou\Utility\Postcode::postcodeIsScottish($this->user->postcode())) {
             $items[] = 'yourmsp';
         } elseif (\MySociety\TheyWorkForYou\Utility\Postcode::postcodeIsNi($this->user->postcode())) {
             $items[] = 'yourmla';
         }
         foreach ($items as $item) {
             $menudata = $this->pagedata->page_metadata($item, 'menu');
             $logintext = $menudata['text'];
             $URL = new \URL($item);
             $this->data['user_nav_links'][] = array('href' => $URL->generate(), 'title' => '', 'classes' => '', 'text' => $logintext);
         }
     }
 }