Passed
Pull Request — master (#1700)
by Struan
04:54
created
tests/AlertsPageTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/alertspage.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/alertspage.xml');
15 15
     }
16 16
 
17 17
     private function fetch_page($vars)
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function testFetchPage()
23 23
     {
24
-        $page = $this->fetch_page( array() );
24
+        $page = $this->fetch_page(array());
25 25
         $this->assertContains('TheyWorkForYou Email Alerts', $page);
26 26
     }
27 27
 
28 28
     public function testKeywordOnly() {
29
-        $page = $this->fetch_page( array( 'alertsearch' => 'elephant') );
29
+        $page = $this->fetch_page(array('alertsearch' => 'elephant'));
30 30
         $this->assertContains('Receive alerts when [elephant] is mentioned', $page);
31 31
     }
32 32
 
33 33
     public function testPostCodeOnly() {
34
-        $page = $this->fetch_page( array( 'alertsearch' => 'SE17 3HE') );
34
+        $page = $this->fetch_page(array('alertsearch' => 'SE17 3HE'));
35 35
         $this->assertContains('when Mrs Test Current-MP', $page);
36 36
     }
37 37
 
38 38
     public function testPostCodeWithKeyWord()
39 39
     {
40
-        $page = $this->fetch_page( array( 'alertsearch' => 'SE17 3HE elephant') );
40
+        $page = $this->fetch_page(array('alertsearch' => 'SE17 3HE elephant'));
41 41
         $this->assertContains('You have used a postcode and something else', $page);
42 42
         $this->assertContains('Mentions of [elephant] by your MP, Mrs Test Current-MP', $page);
43 43
         $this->assertNotContains('by your MSP', $page);
44 44
     }
45 45
 
46 46
     public function testScottishPostcodeWithKeyword() {
47
-        $page = $this->fetch_page( array( 'alertsearch' => 'PH6 2DB elephant') );
47
+        $page = $this->fetch_page(array('alertsearch' => 'PH6 2DB elephant'));
48 48
         $this->assertContains('You have used a postcode and something else', $page);
49 49
         $this->assertContains('Mentions of [elephant] by your MP, Mr Test2 Current-MP', $page);
50 50
         $this->assertContains('Mentions of [elephant] by your MSP, Mrs Test Current-MSP', $page);
51 51
     }
52 52
 
53 53
     public function testPostcodeAndKeywordWithNoSittingMP() {
54
-        $page = $this->fetch_page( array( 'alertsearch' => 'OX1 4LF elephant') );
54
+        $page = $this->fetch_page(array('alertsearch' => 'OX1 4LF elephant'));
55 55
         $this->assertContains('You have used a postcode and something else', $page);
56 56
         $this->assertNotContains('Did you mean to get alerts for when your MP', $page);
57 57
     }
Please login to merge, or discard this patch.
tests/SectionTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function testDebatesFront() {
22 22
         foreach ($this->types as $type) {
23
-            $this->fetch_page( array( 'type' => $type ) );
23
+            $this->fetch_page(array('type' => $type));
24 24
         }
25 25
     }
26 26
 
27 27
     public function testDebatesYear() {
28 28
         foreach ($this->types as $type) {
29
-            $page = $this->fetch_page( array( 'type' => $type, 'y' => '2014' ) );
29
+            $page = $this->fetch_page(array('type' => $type, 'y' => '2014'));
30 30
             $this->assertContains('<div class="calendar">', $page);
31 31
             $this->assertContains('January', $page);
32 32
             $this->assertRegExp('/<td colspan="2">&nbsp;<\/td><td[^>]*><a href="\/' . $type . '\/\?d=2014-01-01">1<\/a><\/td><td[^>]*><span>2<\/span><\/td>/', $page);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     public function testDebatesDay() {
37 37
         foreach ($this->types as $type) {
38
-            $page = $this->fetch_page( array( 'type' => $type, 'd' => '2014-01-01' ) );
38
+            $page = $this->fetch_page(array('type' => $type, 'd' => '2014-01-01'));
39 39
             $this->assertContains('Wednesday,  1 January 2014', $page);
40 40
             $this->assertContains('HeadingA', $page);
41 41
             if ($type == 'wrans') {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                 continue;
61 61
             }
62 62
 
63
-            $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.1' ) );
63
+            $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.1'));
64 64
             if ($type == 'wrans') {
65 65
                 $this->assertRegexp("#All .*?written answers on  1 Jan 2014#i", $page);
66 66
                 $this->assertContains("QuestionA", $page);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function testDebatesSubheading() {
74 74
         foreach ($this->types as $type) {
75
-            $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.2' ) );
75
+            $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.2'));
76 76
             $this->assertContains("HeadingA", $page);
77 77
             if ($type == 'spwrans') {
78 78
                 $this->assertContains("QuestionA", $page);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
     public function testDebatesSpeech() {
103 103
         foreach ($this->types as $type) {
104
-            $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.3' ) );
104
+            $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.3'));
105 105
             if ($type == 'wrans' || $type == 'spwrans' || $type == 'wms') {
106 106
                 $this->assertRegexp("#Location: .*?/$type/\?id=2014-01-01b\.1\.2#", $page);
107 107
             } else {
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
      * @group xapian
126 126
      */
127 127
     public function testGlossaryAndSearchHighlights() {
128
-            $page = $this->fetch_page( array( 'type' => 'lords', 's' => 'constituency', 'id' => '2014-02-02b.1.3' ) );
128
+            $page = $this->fetch_page(array('type' => 'lords', 's' => 'constituency', 'id' => '2014-02-02b.1.3'));
129 129
             $this->assertContains("constituency", $page);
130 130
             $this->assertContains("<span class=\"hi\"><a href=\"/glossary/?gl=1\" title=\"In a general election, each Constituency chooses an MP to represent them....\" class=\"glossary\">constituency</a></span>", $page);
131 131
     }
132 132
 
133 133
     public function testGidRedirect() {
134
-        $page = $this->fetch_page( array( 'type' => 'wrans', 'id' => '2014-01-01a.187335.h' ) );
134
+        $page = $this->fetch_page(array('type' => 'wrans', 'id' => '2014-01-01a.187335.h'));
135 135
         $this->assertRegexp("#Location: .*?/wrans/\?id=2014-01-01b\.1\.2#", $page);
136 136
     }
137 137
 }
Please login to merge, or discard this patch.
scripts/alertmailer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@
 block discarded – undo
245 245
     $data = $DEBATELIST->_get_data_by_search($args);
246 246
     $total_results = $data['info']['total_results'];
247 247
     $queries++;
248
-    mlog(", hits " . $total_results . ", time " . (getmicrotime()-$start) . "\n");
248
+    mlog(", hits " . $total_results . ", time " . (getmicrotime() - $start) . "\n");
249 249
 
250 250
     # Divisions
251 251
     if (preg_match('#^speaker:(\d+)$#', $criteria_raw, $m)) {
Please login to merge, or discard this patch.
www/docs/postcode/index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
16 16
 if (!validate_postcode($pc)) {
17
-    twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
17
+    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
18 18
     postcode_error("Sorry, " . _htmlentities($pc) . " isn't a valid postcode");
19 19
 }
20 20
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     exit;
61 61
 }
62 62
 
63
-function fetch_mp($pc, $constituencies, $house=null) {
63
+function fetch_mp($pc, $constituencies, $house = null) {
64 64
     global $THEUSER;
65 65
     $args = array('constituency' => $constituencies['WMC']);
66 66
     if ($house) {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     }
69 69
     try {
70 70
         $MEMBER = new MEMBER($args);
71
-    } catch (MySociety\TheyWorkForYou\MemberException $e){
71
+    } catch (MySociety\TheyWorkForYou\MemberException $e) {
72 72
         postcode_error($e->getMessage());
73 73
     }
74 74
     if ($MEMBER->person_id()) {
Please login to merge, or discard this patch.
www/docs/mp/index.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     }
140 140
     if ($pid) {
141 141
         $URL = new \MySociety\TheyWorkForYou\Url('search');
142
-        $URL->insert( array('pid'=>$pid, 'pop'=>1) );
142
+        $URL->insert(array('pid'=>$pid, 'pop'=>1));
143 143
         header('Location: ' . $URL->generate('none'));
144 144
         exit;
145 145
     }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     } elseif ($THEUSER->postcode_is_set()) {
190 190
         get_mp_by_user_postcode($THEUSER->postcode());
191 191
     } else {
192
-        twfy_debug ('MP', "We don't have any way of telling what MP to display");
192
+        twfy_debug('MP', "We don't have any way of telling what MP to display");
193 193
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, but we can&rsquo;t tell which representative to display.');
194 194
     }
195 195
     if (!isset($MEMBER) || !$MEMBER->valid) {
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     if (!$MEMBER->current_member(HOUSE_TYPE_SCOTLAND)) {
262 262
         $title .= ', former';
263 263
     }
264
-    $title .= ' MSP, '.$MEMBER->constituency();
264
+    $title .= ' MSP, ' . $MEMBER->constituency();
265 265
 }
266 266
 
267 267
 // Enhance title if this is a member of Welsh Parliament
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     if (!$MEMBER->current_member(HOUSE_TYPE_WALES)) {
276 276
         $title .= ', former';
277 277
     }
278
-    $title .= ' MS, '.$MEMBER->constituency();
278
+    $title .= ' MS, ' . $MEMBER->constituency();
279 279
 }
280 280
 
281 281
 $known_for = '';
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 $data['eu_stance'] = $MEMBER->getEUStance();
346 346
 
347 347
 # People who are or were MPs and Lords potentially have voting records, except Sinn Fein MPs
348
-$data['has_voting_record'] = ( ($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS) );
348
+$data['has_voting_record'] = (($MEMBER->house(HOUSE_TYPE_COMMONS) && $MEMBER->party() != 'Sinn Féin') || $MEMBER->house(HOUSE_TYPE_LORDS));
349 349
 # Everyone who is currently somewhere has email alert signup, apart from current Sinn Fein MPs who are not MLAs
350 350
 $data['has_email_alerts'] = ($MEMBER->current_member_anywhere() && !($MEMBER->current_member(HOUSE_TYPE_COMMONS) && $MEMBER->party() == 'Sinn Féin' && !$MEMBER->current_member(HOUSE_TYPE_NI)));
351 351
 $data['has_expenses'] = $data['leave_date'] > '2004-01-01';
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER);
386 386
         $policySummaries = $divisions->getMemberDivisionDetails();
387 387
 
388
-        $policyOptions = array( 'summaries' => $policySummaries);
388
+        $policyOptions = array('summaries' => $policySummaries);
389 389
 
390 390
         // Generate voting segments
391 391
         $set_descriptions = $policiesList->getSetDescriptions();
392
-        if ( $policy_set && array_key_exists($policy_set, $set_descriptions) ) {
392
+        if ($policy_set && array_key_exists($policy_set, $set_descriptions)) {
393 393
             $sets = array($policy_set);
394 394
             $data['og_image'] = $MEMBER->url(true) . "/policy_set_png?policy_set=" . $policy_set;
395 395
             $data['page_title'] = $set_descriptions[$policy_set] . ' ' . $title . ' - TheyWorkForYou';
@@ -431,15 +431,15 @@  discard block
 block discarded – undo
431 431
 
432 432
     case 'divisions':
433 433
         $policyID = get_http_var('policy');
434
-        if ( $policyID ) {
435
-            $policiesList = new MySociety\TheyWorkForYou\Policies( $policyID );
434
+        if ($policyID) {
435
+            $policiesList = new MySociety\TheyWorkForYou\Policies($policyID);
436 436
         } else {
437 437
             $policiesList = new MySociety\TheyWorkForYou\Policies;
438 438
         }
439
-        $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER );
439
+        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
440 440
         $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER, $positions, $policiesList);
441 441
 
442
-        if ( $policyID ) {
442
+        if ($policyID) {
443 443
             $data['policydivisions'] = $divisions->getMemberDivisionsForPolicy($policyID);
444 444
         } else {
445 445
             $data['policydivisions'] = $divisions->getAllMemberDivisionsByPolicy();
@@ -515,16 +515,16 @@  discard block
 block discarded – undo
515 515
     global $THEUSER;
516 516
     $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
517 517
     if (!validate_postcode($pc)) {
518
-        twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
519
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc) .' isn&rsquo;t a valid postcode');
518
+        twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
519
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, ' . _htmlentities($pc) . ' isn&rsquo;t a valid postcode');
520 520
     }
521
-    twfy_debug ('MP', "MP lookup by postcode");
521
+    twfy_debug('MP', "MP lookup by postcode");
522 522
     $constituency = strtolower(MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency($pc));
523 523
     if ($constituency == "connection_timed_out") {
524 524
         throw new MySociety\TheyWorkForYou\MemberException('Sorry, we couldn&rsquo;t check your postcode right now, as our postcode lookup server is under quite a lot of load.');
525 525
     } elseif ($constituency == "") {
526
-        twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
527
-        throw new MySociety\TheyWorkForYou\MemberException('Sorry, '._htmlentities($pc) .' isn&rsquo;t a known postcode');
526
+        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
527
+        throw new MySociety\TheyWorkForYou\MemberException('Sorry, ' . _htmlentities($pc) . ' isn&rsquo;t a known postcode');
528 528
     } else {
529 529
         // Redirect to the canonical MP page, with a person id.
530 530
         $MEMBER = new MySociety\TheyWorkForYou\Member(array('constituency' => $constituency, 'house' => HOUSE_TYPE_COMMONS));
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
     }
537 537
 }
538 538
 
539
-function get_person_by_name($name, $const='') {
539
+function get_person_by_name($name, $const = '') {
540 540
     $MEMBER = new MySociety\TheyWorkForYou\Member(array('name' => $name, 'constituency' => $const));
541 541
     // Edge case, only attempt further detection if this isn't the Queen.
542 542
     if (($name !== 'elizabeth the second' && $name !== 'prince charles') || $const) {
543
-        twfy_debug ('MP', 'Redirecting for MP found by name/constituency');
543
+        twfy_debug('MP', 'Redirecting for MP found by name/constituency');
544 544
         member_redirect($MEMBER);
545 545
     }
546 546
     return $MEMBER;
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
  * Redirect to the canonical page for a member.
578 578
  */
579 579
 
580
-function member_redirect (&$MEMBER, $code = 301, $pagetype = NULL) {
580
+function member_redirect(&$MEMBER, $code = 301, $pagetype = NULL) {
581 581
     // We come here after creating a MEMBER object by various methods.
582 582
     // Now we redirect to the canonical MP page, with a person_id.
583 583
     if ($MEMBER->person_id()) {
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
         } else {
597 597
             $pagetype = '';
598 598
         }
599
-        header('Location: ' . $url . $pagetype, true, $code );
599
+        header('Location: ' . $url . $pagetype, true, $code);
600 600
         exit;
601 601
     }
602 602
 }
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 
625 625
 function person_error_page($message) {
626 626
     global $this_page;
627
-    switch($this_page) {
627
+    switch ($this_page) {
628 628
         case 'mla':
629 629
             $rep = 'MLA';
630 630
             $SEARCHURL = '/postcode/';
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
  * Generate the summary of this person's held positions.
663 663
  */
664 664
 
665
-function person_summary_description ($MEMBER) {
665
+function person_summary_description($MEMBER) {
666 666
     $entered_house = $MEMBER->entered_house();
667 667
     $current_member = $MEMBER->current_member();
668 668
     $left_house = $MEMBER->left_house();
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
     }
679 679
     $desc = '';
680 680
     foreach ($MEMBER->houses() as $house) {
681
-        if ($house==HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) {
681
+        if ($house == HOUSE_TYPE_COMMONS && isset($entered_house[HOUSE_TYPE_LORDS])) {
682 682
             # Same info is printed further down
683 683
             continue;
684 684
         }
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
  * @return string A HTML summary of this person's rebellion rate.
752 752
  */
753 753
 
754
-function person_rebellion_rate ($member) {
754
+function person_rebellion_rate($member) {
755 755
 
756 756
     // Rebellion string may be empty.
757 757
     $rebellion_string = '';
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
         $SEARCHENGINE = new \SEARCHENGINE($searchstring);
801 801
 
802 802
         $hansard = new MySociety\TheyWorkForYou\Hansard();
803
-        $args = array (
803
+        $args = array(
804 804
             's' => $searchstring,
805 805
             'p' => 1,
806 806
             'num' => 3,
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
     twfy_debug_timestamp();
816 816
 
817 817
     $MOREURL = new \MySociety\TheyWorkForYou\Url('search');
818
-    $MOREURL->insert( array('pid'=>$person_id, 'pop'=>1) );
818
+    $MOREURL->insert(array('pid'=>$person_id, 'pop'=>1));
819 819
 
820 820
     $out['more_href'] = $MOREURL->generate() . '#n4';
821 821
     $out['more_text'] = sprintf(gettext('More of %s’s recent appearances'), ucfirst($member->full_name()));
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
         return;
990 990
     }
991 991
 
992
-    $reg = array( 'date' => '', 'data' => '<p>Nil</p>' );
992
+    $reg = array('date' => '', 'data' => '<p>Nil</p>');
993 993
     if (isset($extra_info['register_member_interests_date'])) {
994 994
         $reg['date'] = format_date($extra_info['register_member_interests_date'], SHORTDATEFORMAT);
995 995
     }
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
         }
1080 1080
     }
1081 1081
 
1082
-    foreach($mreg as $reg) {
1083
-        $data['members'][] = array (
1082
+    foreach ($mreg as $reg) {
1083
+        $data['members'][] = array(
1084 1084
             'url' => '/' . $rep_type . '/?p=' . $reg['person_id'],
1085 1085
             'name' => $reg['given_name'] . ' ' . $reg['family_name']
1086 1086
         );
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
     # comparison which is Commons only
1150 1150
     $data['party_member_count'] = $party->getCurrentMemberCount(HOUSE_TYPE_COMMONS);
1151 1151
 
1152
-    $positions = new MySociety\TheyWorkForYou\PolicyPositions( $policiesList, $MEMBER, [
1152
+    $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER, [
1153 1153
         'summaries' => $policySummaries,
1154 1154
     ]);
1155 1155
     $policy_diffs = $MEMBER->getPartyPolicyDiffs($partyCohort, $policiesList, $positions, $only_diffs);
Please login to merge, or discard this patch.
www/includes/easyparliament/page.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public $within_stripe_sidebar = false;
20 20
 
21 21
     public function page_start() {
22
-        if ( !$this->page_started() ) {
22
+        if (!$this->page_started()) {
23 23
             $this->checkForAdmin();
24 24
             $this->displayHeader();
25 25
         }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
         $data = $h->data;
34 34
         $data = array_merge($u->data, $data);
35
-        if ( isset($page_errors) ) {
35
+        if (isset($page_errors)) {
36 36
             $data['page_errors'] = $page_errors;
37 37
         }
38 38
         $data['banner_text'] = '';
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 $THISPAGE = new \MySociety\TheyWorkForYou\Url($this_page);
53 53
 
54 54
                 $LOGINURL = new \MySociety\TheyWorkForYou\Url('userlogin');
55
-                $LOGINURL->insert(array('ret' => $THISPAGE->generate('none') ));
55
+                $LOGINURL->insert(array('ret' => $THISPAGE->generate('none')));
56 56
 
57 57
                 $text = "<a href=\"" . $LOGINURL->generate() . '">' . gettext('You’d better sign in!') . '</a>';
58 58
             } else {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     }
68 68
 
69 69
     public function page_end() {
70
-        if ( !$this->page_started() ) {
70
+        if (!$this->page_started()) {
71 71
             $this->page_start();
72 72
         }
73 73
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         }
102 102
     }
103 103
 
104
-    public function stripe_start($type='side', $id='', $extra_class = '') {
104
+    public function stripe_start($type = 'side', $id = '', $extra_class = '') {
105 105
         // $type is one of:
106 106
         //  'full' - a full width div
107 107
         //  'side' - a white stripe with a coloured sidebar.
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     }
135 135
 
136 136
 
137
-    public function stripe_end ($contents = array(), $extra = '') {
137
+    public function stripe_end($contents = array(), $extra = '') {
138 138
         // $contents is an array containing 0 or more hashes.
139 139
         // Each hash has two values, 'type' and 'content'.
140 140
         // 'Type' could be one of these:
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     public function include_sidebar_template($sidebarname) {
238 238
         global $this_page, $DATA;
239 239
 
240
-            $sidebarpath = INCLUDESPATH.'easyparliament/sidebars/'.$sidebarname.'.php';
240
+            $sidebarpath = INCLUDESPATH . 'easyparliament/sidebars/' . $sidebarname . '.php';
241 241
 
242 242
             if (file_exists($sidebarpath)) {
243 243
                 include $sidebarpath;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     }
246 246
 
247 247
 
248
-    public function block_start($data=array()) {
248
+    public function block_start($data = array()) {
249 249
         // Starts a 'block' div, used mostly on the home page,
250 250
         // on the MP page, and in the sidebars.
251 251
         // $data is a hash like this:
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
         if (is_string($message)) {
393 393
             // Sometimes we're just sending a single line to this function
394 394
             // rather like the bigger array...
395
-            $message = array (
395
+            $message = array(
396 396
                 'text' => $message
397 397
             );
398 398
         }
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
         // if the page has started then we're most likely in an old school page
401 401
         // so we should just print out the error, otherwise stick it in the error
402 402
         // global which will then be displayed by the header template
403
-        if ( $this->page_started() ) {
403
+        if ($this->page_started()) {
404 404
             $this->message($message, 'error');
405 405
         } else {
406
-            if ( !isset($page_errors) ) {
406
+            if (!isset($page_errors)) {
407 407
                 $page_errors = array();
408 408
             }
409
-            $page_errors[]  = $message;
409
+            $page_errors[] = $message;
410 410
         }
411 411
 
412 412
         if ($fatal) {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     }
424 424
 
425 425
 
426
-    public function message($message, $class='') {
426
+    public function message($message, $class = '') {
427 427
         // Generates a very simple but common page content.
428 428
         // Used for when a user logs out, or votes, or any simple thing
429 429
         // where there's a little message and probably a link elsewhere.
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
             if ($page_title != '') {
514 514
                 $page_title .= ': ';
515 515
             }
516
-            $page_title .= format_date ($info['date'], SHORTDATEFORMAT);
516
+            $page_title .= format_date($info['date'], SHORTDATEFORMAT);
517 517
         }
518 518
 
519 519
         if ($page_title != '') {
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 
569 569
         if (isset($nextprev['up'])) {
570 570
 
571
-            $uplink = '<span class="up"><a href="' .  $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>';
571
+            $uplink = '<span class="up"><a href="' . $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>';
572 572
             if (get_http_var('s')) {
573 573
                 $URL = new \MySociety\TheyWorkForYou\Url($this_page);
574 574
                 $uplink .= '<br><a href="' . $URL->generate() . '">' . gettext('Remove highlighting') . '</a>';
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             $next = $nextprev['next'];
584 584
 
585 585
             if (isset($next['url'])) {
586
-                $nextlink = '<a href="' .  $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' &raquo;</a>';
586
+                $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' &raquo;</a>';
587 587
             } else {
588 588
                 $nextlink = $next['body'] . ' &raquo;';
589 589
             }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
     }
601 601
 
602 602
 
603
-    public function search_form($value='') {
603
+    public function search_form($value = '') {
604 604
         global $SEARCHENGINE;
605 605
         // Search box on the search page.
606 606
         // If $value is set then it will be displayed in the form.
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             }
631 631
 
632 632
         echo '<div class="mainsearchbox">';
633
-        if ($wtt<2) {
633
+        if ($wtt < 2) {
634 634
                 echo '<form action="', $URL->generate(), '" method="get">';
635 635
                 if (get_http_var('o')) {
636 636
                     echo '<input type="hidden" name="o" value="', _htmlentities(get_http_var('o')), '">';
@@ -663,16 +663,16 @@  discard block
 block discarded – undo
663 663
                     $ordering = 'd';
664 664
                 }
665 665
 
666
-                if ($ordering=='r') {
666
+                if ($ordering == 'r') {
667 667
                 print '<strong>' . gettext('Sorted by relevance') . '</strong>';
668 668
                 } else {
669 669
                 printf(gettext("<a href='%s'>Sort by relevance</a>"), $orderUrl->generate('html', array('o'=>'r')));
670 670
                 }
671 671
 
672 672
                 print "&nbsp;|&nbsp;";
673
-                if ($ordering=='d') {
673
+                if ($ordering == 'd') {
674 674
                 print '<strong>' . gettext('Sorted by date:') . ' ' . gettext('newest') . '</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">' . gettext('oldest') . '</a>';
675
-                } elseif ($ordering=='o') {
675
+                } elseif ($ordering == 'o') {
676 676
                 print '<strong>' . gettext('Sorted by date:') . '</strong> <a href="' . $orderUrl->generate('html', array('o'=>'d')) . '">' . gettext('newest') . '</a> / <strong>' . gettext('oldest') . '</strong>';
677 677
                 } else {
678 678
                 print gettext("Sort by date:") . ' ';
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
                 }
686 686
 
687 687
             print "&nbsp;|&nbsp;";
688
-            if ($ordering=='p') {
688
+            if ($ordering == 'p') {
689 689
                 print '<strong>' . gettext('Use by person') . '</strong>';
690 690
             } else {
691 691
                 printf('<a href="%s">', $orderUrl->generate('html', array('o'=>'p')));
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
         echo '</form> </div>';
707 707
     }
708 708
 
709
-    public function login_form ($errors = array()) {
709
+    public function login_form($errors = array()) {
710 710
         // Used for /user/login/ and /user/prompt/
711 711
         // $errors is a hash of potential errors from a previous log in attempt.
712 712
         ?>
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     public function glossary_atoz(&$GLOSSARY) {
810 810
     // Print out a nice list of lettered links to glossary pages
811 811
 
812
-        $letters = array ();
812
+        $letters = array();
813 813
 
814 814
         foreach ($GLOSSARY->alphabet as $letter => $eps) {
815 815
             // if we're writing out the current letter (list or item)
@@ -840,14 +840,14 @@  discard block
 block discarded – undo
840 840
                     <div class="letters">
841 841
                         <ul>
842 842
     <?php
843
-        for ($n=0; $n<13; $n++) {
843
+        for ($n = 0; $n < 13; $n++) {
844 844
             print $letters[$n];
845 845
         }
846 846
         ?>
847 847
                         </ul>
848 848
                         <ul>
849 849
     <?php
850
-        for ($n=13; $n<26; $n++) {
850
+        for ($n = 13; $n < 26; $n++) {
851 851
             print $letters[$n];
852 852
         }
853 853
         ?>
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
 
867 867
         // add some extra controls for the administrators
868 868
         if ($this_page == "admin_glossary") {
869
-            print "<a id=\"gl".$term['glossary_id']."\"></a>";
869
+            print "<a id=\"gl" . $term['glossary_id'] . "\"></a>";
870 870
             print "<h3>" . $term['title'] . "</h3>";
871 871
             $URL = new \MySociety\TheyWorkForYou\Url('admin_glossary');
872 872
             $URL->insert(array("delete_confirm" => $term['glossary_id']));
873 873
             $delete_url = $URL->generate();
874
-            $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>";
874
+            $admin_links = "<br><small><a href=\"" . $delete_url . "\">delete</a></small>";
875 875
         } else {
876 876
             $admin_links = "";
877 877
         }
@@ -892,9 +892,9 @@  discard block
 block discarded – undo
892 892
             // Add a direct search link for current glossary item
893 893
             $URL = new \MySociety\TheyWorkForYou\Url('search');
894 894
             // remember to quote the term for phrase matching in search
895
-            $URL->insert(array('s' => '"'.$term['title'].'"'));
895
+            $URL->insert(array('s' => '"' . $term['title'] . '"'));
896 896
             $search_url = $URL->generate();
897
-            printf ("\t\t\t\t<p>Search hansard for \"<a href=\"%s\" title=\"View search results for this glossary item\">%s</a>\"</p>", $search_url, $term['title']);
897
+            printf("\t\t\t\t<p>Search hansard for \"<a href=\"%s\" title=\"View search results for this glossary item\">%s</a>\"</p>", $search_url, $term['title']);
898 898
         }
899 899
     }
900 900
 
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 
970 970
             // Generate all the page links.
971 971
             $URL = new \MySociety\TheyWorkForYou\Url($this_page);
972
-            $URL->insert( array('wtt' => get_http_var('wtt')) );
972
+            $URL->insert(array('wtt' => get_http_var('wtt')));
973 973
             if (isset($pagedata['s'])) {
974 974
                 # XXX: Should be taken out in *one* place, not here + search_form etc.
975 975
                 $value = $pagedata['s'];
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 
1108 1108
                 $body = trim_characters($report['body'], 0, 40);
1109 1109
 
1110
-                $tabledata['rows'][] = array (
1110
+                $tabledata['rows'][] = array(
1111 1111
                     _htmlentities($report['firstname'] . ' ' . $report['lastname']),
1112 1112
                     _htmlentities($body),
1113 1113
                     $report['reported'],
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
         // Returns HTML suitable for putting in the sidebar on Admin pages.
1190 1190
         global $this_page, $DATA;
1191 1191
 
1192
-        $pages = array ('admin_home',
1192
+        $pages = array('admin_home',
1193 1193
                 'admin_comments', 'admin_searchlogs', 'admin_popularsearches', 'admin_failedsearches',
1194 1194
                 'alert_stats', 'admin_statistics', 'admin_reportstats',
1195 1195
                 'admin_commentreports', 'admin_glossary', 'admin_glossary_pending', 'admin_badusers',
Please login to merge, or discard this patch.
www/includes/easyparliament/alert.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public $token_checked = null;
42 42
     private $alert_id = "";
43 43
     public $email = "";
44
-    public $criteria = "";		// Sets the terms that are used to produce the search results.
44
+    public $criteria = ""; // Sets the terms that are used to produce the search results.
45 45
 
46 46
     private $db;
47 47
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             $contents = array('criteria' => $row['criteria'], 'count' => $row['cnt']);
73 73
             $data[] = $contents;
74 74
         }
75
-        $data = array ('alerts' => $data);
75
+        $data = array('alerts' => $data);
76 76
         return $data;
77 77
     }
78 78
 
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
         $data = $q->fetchAll();
102 102
         $info = "Alert";
103
-        $data = array ('info' => $info, 'data' => $data);
103
+        $data = array('info' => $info, 'data' => $data);
104 104
 
105 105
         return $data;
106 106
     }
107 107
 
108
-    public function add($details, $confirmation_email=false, $instantly_confirm=true) {
108
+    public function add($details, $confirmation_email = false, $instantly_confirm = true) {
109 109
 
110 110
         // Adds a new alert's info into the database.
111 111
         // Then calls another function to send them a confirmation email.
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             // This gives a code for their email address which is then joined
171 171
             // to the timestamp so as to provide a unique ID for each alert.
172 172
 
173
-            $token = substr( password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16 );
173
+            $token = substr(password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16);
174 174
 
175 175
             // Full stops don't work well at the end of URLs in emails, so
176 176
             // replace them. And double slash would be treated as single and
@@ -244,19 +244,19 @@  discard block
 block discarded – undo
244 244
 
245 245
         $urltoken = $this->alert_id . '-' . $this->registrationtoken;
246 246
 
247
-        if ( isset($details['confirm_base']) && $details['confirm_base'] !== '' ) {
247
+        if (isset($details['confirm_base']) && $details['confirm_base'] !== '') {
248 248
             $confirmurl = $details['confirm_base'] . $urltoken;
249 249
         } else {
250 250
             $confirmurl = 'https://' . DOMAIN . '/A/' . $urltoken;
251 251
         }
252 252
 
253 253
         // Arrays we need to send a templated email.
254
-        $data = array (
254
+        $data = array(
255 255
             'to' 		=> $details['email'],
256 256
             'template' 	=> 'alert_confirmation'
257 257
         );
258 258
 
259
-        $merge = array (
259
+        $merge = array(
260 260
             'CONFIRMURL'	=> $confirmurl,
261 261
             'CRITERIA'	=> $this->criteria_pretty()
262 262
         );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     public function send_already_signedup_email($details) {
273
-        $data = array (
273
+        $data = array(
274 274
             'to' 		=> $details['email'],
275 275
             'template' 	=> 'alert_already_signedup'
276 276
         );
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
         $criteria = \MySociety\TheyWorkForYou\Utility\Alert::detailsToCriteria($details);
279 279
         $this->criteria = $criteria;
280 280
 
281
-        $merge = array (
281
+        $merge = array(
282 282
             'CRITERIA'	=> $this->criteria_pretty()
283 283
         );
284 284
 
@@ -449,20 +449,20 @@  discard block
 block discarded – undo
449 449
     public function email() { return $this->email; }
450 450
     public function criteria() { return $this->criteria; }
451 451
     public function criteria_pretty($html = false) {
452
-        $criteria = explode(' ',$this->criteria);
452
+        $criteria = explode(' ', $this->criteria);
453 453
         $spokenby = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($this->criteria));
454 454
         $words = array();
455 455
         foreach ($criteria as $c) {
456
-            if (!preg_match('#^speaker:(\d+)#',$c,$m)) {
456
+            if (!preg_match('#^speaker:(\d+)#', $c, $m)) {
457 457
                 $words[] = $c;
458 458
             }
459 459
         }
460 460
         $criteria = '';
461 461
         if (count($words)) {
462
-            $criteria .= ($html?'<li>':'* ') . sprintf(gettext('Mentions of [%s]'), implode(' ', $words)) . ($html?'</li>':'') . "\n";
462
+            $criteria .= ($html ? '<li>' : '* ') . sprintf(gettext('Mentions of [%s]'), implode(' ', $words)) . ($html ? '</li>' : '') . "\n";
463 463
         }
464 464
         if ($spokenby) {
465
-            $criteria .= ($html?'<li>':'* ') . sprintf(gettext("Things by %s"), implode(' or ', $spokenby)) . ($html?'</li>':'') . "\n";
465
+            $criteria .= ($html ? '<li>' : '* ') . sprintf(gettext("Things by %s"), implode(' or ', $spokenby)) . ($html ? '</li>' : '') . "\n";
466 466
         }
467 467
         return $criteria;
468 468
     }
Please login to merge, or discard this patch.
www/includes/easyparliament/searchengine.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public $valid = false;
38 38
     public $error;
39 39
 
40
-    public function __construct($query, $lang='') {
40
+    public function __construct($query, $lang = '') {
41 41
         if (!defined('XAPIANDB') || !XAPIANDB)
42 42
             return null;
43 43
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
         // Split words up into individual words, and quoted phrases
97 97
         preg_match_all('/(' .
98 98
             '"|' . # match either a quote, or...
99
-            '(?:(?<![' .$this->wordchars. '])-)?' . # optionally a - (exclude)
99
+            '(?:(?<![' . $this->wordchars . '])-)?' . # optionally a - (exclude)
100 100
             # if at start of word (i.e. not preceded by a word character, in
101 101
             # which case it is probably a hyphenated-word)
102
-            '['.$this->wordchars.']+' . # followed by a string of word-characters
102
+            '[' . $this->wordchars . ']+' . # followed by a string of word-characters
103 103
             ')/', $this->query, $all_words);
104 104
         if ($all_words) {
105 105
             $all_words = $all_words[0];
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
             if (strpos($word, ':') !== false) {
125 125
                 $items = explode(":", strtolower($word));
126 126
                 $type = $items[0];
127
-                if (substr($type, 0, 1)=='-') $type = substr($type, 1);
128
-                $value = strtolower(join(":", array_slice($items,1)));
127
+                if (substr($type, 0, 1) == '-') $type = substr($type, 1);
128
+                $value = strtolower(join(":", array_slice($items, 1)));
129 129
                 if ($type == 'section') {
130 130
                     $newv = $value;
131 131
                     if ($value == 'debates' || $value == 'debate') $newv = 1;
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
                     elseif ($value == 'sp') $newv = 7;
139 139
                     elseif ($value == 'spwrans' || $value == 'spwran') $newv = 8;
140 140
                     elseif ($value == 'lmqs') $newv = 9;
141
-                    elseif ($value == 'uk') $newv = array(1,2,3,4,6,101);
142
-                    elseif ($value == 'scotland') $newv = array(7,8);
141
+                    elseif ($value == 'uk') $newv = array(1, 2, 3, 4, 6, 101);
142
+                    elseif ($value == 'scotland') $newv = array(7, 8);
143 143
                     elseif ($value == 'wales') $newv = ($lang == 'cy' || LANGUAGE == 'cy') ? 11 : 10;
144 144
                     elseif ($value == 'future') $newv = 'F';
145 145
                     if (is_array($newv)) {
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             $this->query .= " $from..$to";
175 175
         } elseif ($from) {
176 176
             $this->query = str_ireplace("from:$from", '', $this->query);
177
-            $this->query .= " $from..".date('Ymd');
177
+            $this->query .= " $from.." . date('Ymd');
178 178
         } elseif ($to) {
179 179
             $this->query = str_ireplace("to:$to", '', $this->query);
180 180
             $this->query .= " 19990101..$to";
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
         twfy_debug("SEARCH", "prefixed: " . var_export($this->prefixed, true));
193 193
 
194
-        twfy_debug("SEARCH", "query -- ". $this->query);
194
+        twfy_debug("SEARCH", "query -- " . $this->query);
195 195
         $flags = XapianQueryParser::FLAG_BOOLEAN | XapianQueryParser::FLAG_LOVEHATE |
196 196
             XapianQueryParser::FLAG_WILDCARD | XapianQueryParser::FLAG_SPELLING_CORRECTION;
197 197
         $flags = $flags | XapianQueryParser::FLAG_PHRASE;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         foreach ($m[1] as $phrase) {
245 245
             $phrase_new = preg_replace('# PHRASE \d+#', '', $phrase);
246 246
             #$this->phrases[] = preg_split('#\s+#', $phrase_new);
247
-            $qd = str_replace("($phrase)", '"'.$phrase_new.'"', $qd);
247
+            $qd = str_replace("($phrase)", '"' . $phrase_new . '"', $qd);
248 248
         }
249 249
         preg_match_all('#\(([^(]*? NEAR [^(]*?)\)#', $qd, $m);
250 250
         foreach ($m[1] as $mm) {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
     }
375 375
 
376 376
     // Perform partial query to get a count of number of matches
377
-    public function run_count($first_result, $results_per_page, $sort_order='relevance') {
377
+    public function run_count($first_result, $results_per_page, $sort_order = 'relevance') {
378 378
         if (!defined('XAPIANDB') || !XAPIANDB)
379 379
             return null;
380 380
 
@@ -447,13 +447,13 @@  discard block
 block discarded – undo
447 447
         #}
448 448
 
449 449
         $duration = getmicrotime() - $start;
450
-        twfy_debug ("SEARCH", "Search count took $duration seconds.");
450
+        twfy_debug("SEARCH", "Search count took $duration seconds.");
451 451
 
452 452
         return $count;
453 453
     }
454 454
 
455 455
     // Perform the full search...
456
-    public function run_search($first_result, $results_per_page, $sort_order='relevance') {
456
+    public function run_search($first_result, $results_per_page, $sort_order = 'relevance') {
457 457
         $start = getmicrotime();
458 458
 
459 459
         #$matches = $this->enquire->get_mset($first_result, $results_per_page);
@@ -474,13 +474,13 @@  discard block
 block discarded – undo
474 474
                 array_push($this->created, join('', unpack('N', $doc->get_value(2)))); # XXX Needs fixing
475 475
             }
476 476
             twfy_debug("SEARCH", "gid: $gid relevancy: $relevancy% weight: $weight");
477
-            array_push($this->gids, "uk.org.publicwhip/".$gid);
477
+            array_push($this->gids, "uk.org.publicwhip/" . $gid);
478 478
             array_push($this->collapsed, $collapsed);
479 479
             array_push($this->relevances, $relevancy);
480 480
             $iter->next();
481 481
         }
482 482
         $duration = getmicrotime() - $start;
483
-        twfy_debug ("SEARCH", "Run search took $duration seconds.");
483
+        twfy_debug("SEARCH", "Run search took $duration seconds.");
484 484
     }
485 485
     // ... use these to get the results
486 486
     public function get_gids() {
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
         $body = str_replace($this->specialchars, $this->specialchars_upper, $body);
522 522
         $body = mb_convert_encoding($body, "UTF-8", "HTML-ENTITIES");
523 523
         $body = str_replace($this->specialchars_upper, $this->specialchars, $body);
524
-        $splitextract = preg_split('/(<[^>]*>|[0-9,.]+|['.$this->wordcharsnodigit.']+)/', $body, -1, PREG_SPLIT_DELIM_CAPTURE);
524
+        $splitextract = preg_split('/(<[^>]*>|[0-9,.]+|[' . $this->wordcharsnodigit . ']+)/', $body, -1, PREG_SPLIT_DELIM_CAPTURE);
525 525
         $hlextract = "";
526 526
         foreach ($splitextract as $extractword) {
527 527
             if (preg_match('/^<[^>]*>$/', $extractword)) {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
         */
570 570
 
571 571
         foreach ($this->phrases as $phrase) {
572
-            $phrasematch = join($phrase, '[^'.$this->wordchars.']+');
572
+            $phrasematch = join($phrase, '[^' . $this->wordchars . ']+');
573 573
             array_push($findwords, "/\b($phrasematch)\b(?!(?>[^<>]*>))/i");
574 574
             $replacewords[] = "<span class=\"hi\">\\1</span>";
575 575
         }
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
 
588 588
         // look for phrases
589 589
         foreach ($this->phrases as $phrase) {
590
-            $phrasematch = join($phrase, '[^'.$this->wordchars.']+');
591
-            if (preg_match('/([^'.$this->wordchars.']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches))
590
+            $phrasematch = join($phrase, '[^' . $this->wordchars . ']+');
591
+            if (preg_match('/([^' . $this->wordchars . ']' . $phrasematch . '[^A-Za-z0-9])/', $lcbody, $matches))
592 592
             {
593
-                $wordpos = strpos( $lcbody, $matches[0] );
593
+                $wordpos = strpos($lcbody, $matches[0]);
594 594
                 if ($wordpos) {
595
-                    if ( ($wordpos < $pos) || ($pos==-1) ) {
595
+                    if (($wordpos < $pos) || ($pos == -1)) {
596 596
                         $pos = $wordpos;
597 597
                     }
598 598
                 }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
         }
601 601
         if ($pos != -1) return $pos;
602 602
 
603
-        $splitextract = preg_split('/([0-9,.]+|['.$this->wordcharsnodigit.']+)/', $lcbody, -1, PREG_SPLIT_DELIM_CAPTURE);
603
+        $splitextract = preg_split('/([0-9,.]+|[' . $this->wordcharsnodigit . ']+)/', $lcbody, -1, PREG_SPLIT_DELIM_CAPTURE);
604 604
         $stemmed_words = array_map(array($this, 'stem'), $this->words);
605 605
         foreach ($splitextract as $extractword) {
606 606
             $extractword = preg_replace('/&$/', '', $extractword);
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
             foreach ($stemmed_words as $word) {
611 611
                 if ($word == '') continue;
612 612
                 $matchword = $this->stem($extractword);
613
-                if ($matchword == $word && ($wordpos < $pos || $pos==-1)) {
613
+                if ($matchword == $word && ($wordpos < $pos || $pos == -1)) {
614 614
                     $pos = $wordpos;
615 615
                 }
616 616
             }
@@ -619,11 +619,11 @@  discard block
 block discarded – undo
619 619
         if ($pos != -1) return $pos;
620 620
 
621 621
         foreach ($this->words as $word) {
622
-            if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')';
623
-            if (preg_match('/([^'.$this->wordchars.']' . $word . '[^'.$this->wordchars. '])/', $lcbody, $matches)) {
624
-                $wordpos = strpos( $lcbody, $matches[0] );
622
+            if (ctype_digit($word)) $word = '(?:' . $word . '|' . number_format($word) . ')';
623
+            if (preg_match('/([^' . $this->wordchars . ']' . $word . '[^' . $this->wordchars . '])/', $lcbody, $matches)) {
624
+                $wordpos = strpos($lcbody, $matches[0]);
625 625
                 if ($wordpos) {
626
-                    if ( ($wordpos < $pos) || ($pos==-1) ) {
626
+                    if (($wordpos < $pos) || ($pos == -1)) {
627 627
                         $pos = $wordpos;
628 628
                     }
629 629
                 }
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
         if ($pos != -1) return $pos;
634 634
 
635 635
         foreach ($this->words as $word) {
636
-            if (ctype_digit($word)) $word = '(?:'.$word.'|'.number_format($word).')';
636
+            if (ctype_digit($word)) $word = '(?:' . $word . '|' . number_format($word) . ')';
637 637
             if (preg_match('/(' . $word . ')/', $lcbody, $matches)) {
638
-                $wordpos = strpos( $lcbody, $matches[0] );
638
+                $wordpos = strpos($lcbody, $matches[0]);
639 639
                 if ($wordpos) {
640
-                    if ( ($wordpos < $pos) || ($pos==-1) ) {
640
+                    if (($wordpos < $pos) || ($pos == -1)) {
641 641
                         $pos = $wordpos;
642 642
                     }
643 643
                 }
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/homepage/recent-votes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php if ( count($divisions) > 0 ) { ?>
1
+<?php if (count($divisions) > 0) { ?>
2 2
     <h2 style="position: relative;">
3 3
         <?= gettext('Recent Votes') ?>
4 4
         <div class="meta excerpt__category"><a href="/divisions/"><?= gettext('Show all recent votes') ?></a></div>
Please login to merge, or discard this patch.