Failed Conditions
Pull Request — master (#1327)
by Nick
11:49
created
classes/Homepage.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
         $gid = $featured->get_gid();
58 58
         $gidCheck = new Gid($gid);
59 59
         $gid = $gidCheck->checkForRedirect();
60
-        if ( $gid ) {
60
+        if ($gid) {
61 61
             $title = $featured->get_title();
62 62
             $context = $featured->get_context();
63 63
             $related = $featured->get_related();
64 64
             $item = $this->getFeaturedDebate($gid, $title, $context, $related);
65 65
         } else {
66 66
             $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none');
67
-            if ( isset($item['data']) && count($item['data']) ) {
67
+            if (isset($item['data']) && count($item['data'])) {
68 68
                 $item = $item['data'][0];
69 69
                 $more_url = new Url('debates');
70 70
                 $item['more_url'] = $more_url->generate();
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         $item['featured'] = true;
96 96
 
97 97
         $related_debates = array();
98
-        foreach ( $related as $related_gid ) {
99
-            if ( $related_gid ) {
98
+        foreach ($related as $related_gid) {
99
+            if ($related_gid) {
100 100
                 $related_item = $debatelist->display('featured_gid', array('gid' => $related_gid), 'none');
101 101
                 $related_debates[] = $related_item['data'];
102 102
             }
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 
122 122
         $recent_content = array();
123 123
 
124
-        foreach ( $this->recent_types as $class => $recent ) {
124
+        foreach ($this->recent_types as $class => $recent) {
125 125
             $class = "\\$class";
126 126
             $instance = new $class();
127 127
             $more_url = new Url($recent[1]);
128
-            if ( $recent[0] == 'recent_pbc_debates' ) {
129
-                $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') );
128
+            if ($recent[0] == 'recent_pbc_debates') {
129
+                $content = array('data' => $instance->display($recent[0], array('num' => 5), 'none'));
130 130
             } else {
131 131
                 $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none');
132
-                if ( isset($content['data']) && count($content['data']) ) {
132
+                if (isset($content['data']) && count($content['data'])) {
133 133
                     $content = $content['data'][0];
134 134
                 } else {
135 135
                     $content = array();
136 136
                 }
137 137
             }
138
-            if ( $content ) {
138
+            if ($content) {
139 139
                 $content['more_url'] = $more_url->generate();
140 140
                 $content['desc'] = $recent[2];
141 141
                 $recent_content[] = $content;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             WHERE event_date >= :date
155 155
             AND deleted = 0
156 156
             ORDER BY event_date, chamber, pos",
157
-            array( ':date' => $date )
157
+            array(':date' => $date)
158 158
         );
159 159
 
160 160
         if (!$q->rows()) {
Please login to merge, or discard this patch.
classes/Utility/Hansard.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         $parts = parse_url($url);
16 16
         parse_str($parts['query'], $query);
17 17
 
18
-        if ( $query['id'] ) {
18
+        if ($query['id']) {
19 19
             if (strpos($parts['path'], 'lords') !== false) {
20 20
                 $gid = 'uk.org.publicwhip/lords/';
21 21
             } elseif (strpos($parts['path'], 'whall') !== false) {
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
     public static function gid_to_url($gid) {
33
-        if ( !$gid ) {
33
+        if (!$gid) {
34 34
             return '';
35 35
         }
36 36
         global $hansardmajors;
37 37
         $db = new \ParlDB();
38 38
 
39
-        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ));
39
+        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
40 40
         $url_gid = fix_gid_from_db($gid);
41 41
         $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q->field(0, 'major')]['page']);
42 42
         $url->insert(array('id' => $url_gid));
Please login to merge, or discard this patch.
classes/SectionView/NiView.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
     protected function getSearchSections() {
34 34
         return array(
35
-            array( 'section' => 'ni' )
35
+            array('section' => 'ni')
36 36
         );
37 37
     }
38 38
 
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 
53 53
         $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none');
54 54
         $MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront');
55
-        $MOREURL->insert( array( 'more' => 1 ) );
55
+        $MOREURL->insert(array('more' => 1));
56 56
 
57 57
         // this makes sure that we don't repeat this debate in the list below
58 58
         $random_debate = NULL;
59
-        if ( isset($debates['data']) && count($debates['data']) ) {
59
+        if (isset($debates['data']) && count($debates['data'])) {
60 60
             $random_debate = $debates['data'][0];
61 61
         }
62 62
 
63 63
         $recent = array();
64
-        if ( isset($debates['data']) && count($debates['data']) ) {
64
+        if (isset($debates['data']) && count($debates['data'])) {
65 65
             // at the start of a session there may be less than 6
66 66
             // debates
67 67
             $max = 6;
68
-            if ( count($debates['data']) < 6 ) {
68
+            if (count($debates['data']) < 6) {
69 69
                 $max = count($debates['data']);
70 70
             }
71
-            for ( $i = 1; $i < $max; $i++ ) {
71
+            for ($i = 1; $i < $max; $i++) {
72 72
                 $debate = $debates['data'][$i];
73 73
                 $debate['desc'] = "Northern Ireland Assembly debates";
74 74
                 $debate['more_url'] = $MOREURL->generate();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         }
78 78
 
79 79
         $featured = array();
80
-        if ( $random_debate ) {
80
+        if ($random_debate) {
81 81
             $featured = $random_debate;
82 82
             $featured['more_url'] = $MOREURL->generate();
83 83
             $featured['desc'] = 'Northern Ireland Assembly debate';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $data['featured'] = $featured;
89
-        $data['debates'] = array( 'recent' => $recent);
89
+        $data['debates'] = array('recent' => $recent);
90 90
 
91 91
         $data['regional'] = $this->getMLAList();
92 92
         $data['template'] = 'ni/index';
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/comments_recent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $date = format_date($date, SHORTDATEFORMAT);
34 34
         $time = format_time($time, TIMEFORMAT);
35 35
 
36
-        $count = $n+1;
36
+        $count = $n + 1;
37 37
 
38 38
         $USERURL->insert(array('u'=>$comment['user_id']));
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     if ($this_page == 'home') {
48 48
         $MOREURL = new \MySociety\TheyWorkForYou\Url('comments_recent');
49 49
         ?>
50
-                        <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p>
50
+                        <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments']) + 1; ?>">See more annotations posted recently</a></p>
51 51
 <?php
52 52
     }
53 53
     if ($this_page != 'home') $PAGE->page_links($data);
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/calendar_date.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         print "<h2 class='calendar'>$chamber";
26 26
         if (in_array($major[$i], $data['majors'])) {
27 27
             $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']);
28
-            $URL->insert( array( 'd' => $date ) );
28
+            $URL->insert(array('d' => $date));
29 29
             print ' &nbsp; <a href="' . $URL->generate() . '">See this day &rarr;</a>';
30 30
         }
31 31
         print "</h2>\n";
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/hansard_search.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 if (isset ($data['rows']) && count($data['rows']) > 0) {
67 67
 
68 68
     echo '<dl id="searchresults">';
69
-    for ($i=0; $i<count($data['rows']); $i++) {
69
+    for ($i = 0; $i < count($data['rows']); $i++) {
70 70
 
71 71
         $row = $data['rows'][$i];
72 72
         echo '<dt><a href="', $row['listurl'], '">';
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
         }
80 80
         if (isset($row['collapsed']) && $row['collapsed'] && $row['subsection_id']) {
81 81
             $URL = new \MySociety\TheyWorkForYou\Url('search');
82
-            $URL->insert(array('s' => $info['s'] . " segment:$row[subsection_id]" ));
82
+            $URL->insert(array('s' => $info['s'] . " segment:$row[subsection_id]"));
83 83
             echo ' <a href="', $URL->generate(), '">See ', $row['collapsed'],
84
-            ' other result', $row['collapsed']>1?'s':'', ' from this ',
84
+            ' other result', $row['collapsed'] > 1 ? 's' : '', ' from this ',
85 85
             $hansardmajors[$row['major']]['singular'], '</a>';
86 86
         }
87 87
         echo '</small>';
88 88
         if ($match = get_http_var('match')) {
89
-            echo ' &ndash; <a href="/search/record.php?result=', $row['gid'] , '&amp;match=', _htmlspecialchars($match), '">This is the correct match</a>';
89
+            echo ' &ndash; <a href="/search/record.php?result=', $row['gid'], '&amp;match=', _htmlspecialchars($match), '">This is the correct match</a>';
90 90
         }
91 91
         echo '</dt> <dd><p>';
92 92
         if (isset($row['speaker']) && count($row['speaker'])) {
Please login to merge, or discard this patch.
www/includes/easyparliament/page.php 1 patch
Spacing   +39 added lines, -39 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() . "\">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.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
 
134
-    public function stripe_end ($contents = array(), $extra = '') {
134
+    public function stripe_end($contents = array(), $extra = '') {
135 135
         // $contents is an array containing 0 or more hashes.
136 136
         // Each hash has two values, 'type' and 'content'.
137 137
         // 'Type' could be one of these:
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     public function include_sidebar_template($sidebarname) {
235 235
         global $this_page, $DATA;
236 236
 
237
-            $sidebarpath = INCLUDESPATH.'easyparliament/sidebars/'.$sidebarname.'.php';
237
+            $sidebarpath = INCLUDESPATH . 'easyparliament/sidebars/' . $sidebarname . '.php';
238 238
 
239 239
             if (file_exists($sidebarpath)) {
240 240
                 include $sidebarpath;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     }
243 243
 
244 244
 
245
-    public function block_start($data=array()) {
245
+    public function block_start($data = array()) {
246 246
         // Starts a 'block' div, used mostly on the home page,
247 247
         // on the MP page, and in the sidebars.
248 248
         // $data is a hash like this:
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         if (is_string($message)) {
390 390
             // Sometimes we're just sending a single line to this function
391 391
             // rather like the bigger array...
392
-            $message = array (
392
+            $message = array(
393 393
                 'text' => $message
394 394
             );
395 395
         }
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
         // if the page has started then we're most likely in an old school page
398 398
         // so we should just print out the error, otherwise stick it in the error
399 399
         // global which will then be displayed by the header template
400
-        if ( $this->page_started() ) {
400
+        if ($this->page_started()) {
401 401
             $this->message($message, 'error');
402 402
         } else {
403
-            if ( !isset($page_errors) ) {
403
+            if (!isset($page_errors)) {
404 404
                 $page_errors = array();
405 405
             }
406
-            $page_errors[]  = $message;
406
+            $page_errors[] = $message;
407 407
         }
408 408
 
409 409
         if ($fatal) {
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
 
423
-    public function message($message, $class='') {
423
+    public function message($message, $class = '') {
424 424
         // Generates a very simple but common page content.
425 425
         // Used for when a user logs out, or votes, or any simple thing
426 426
         // where there's a little message and probably a link elsewhere.
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
             if ($page_title != '') {
499 499
                 $page_title .= ': ';
500 500
             }
501
-            $page_title .= format_date ($info['date'], SHORTDATEFORMAT);
501
+            $page_title .= format_date($info['date'], SHORTDATEFORMAT);
502 502
         }
503 503
 
504 504
         if ($page_title != '') {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 
554 554
         if (isset($nextprev['up'])) {
555 555
 
556
-            $uplink = '<span class="up"><a href="' .  $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>';
556
+            $uplink = '<span class="up"><a href="' . $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>';
557 557
             if (get_http_var('s')) {
558 558
                 $URL = new \MySociety\TheyWorkForYou\Url($this_page);
559 559
                 $uplink .= '<br><a href="' . $URL->generate() . '">Remove highlighting</a>';
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             $next = $nextprev['next'];
569 569
 
570 570
             if (isset($next['url'])) {
571
-                $nextlink = '<a href="' .  $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' &raquo;</a>';
571
+                $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' &raquo;</a>';
572 572
             } else {
573 573
                 $nextlink = $next['body'] . ' &raquo;';
574 574
             }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
     }
586 586
 
587 587
 
588
-    public function search_form($value='') {
588
+    public function search_form($value = '') {
589 589
         global $SEARCHENGINE;
590 590
         // Search box on the search page.
591 591
         // If $value is set then it will be displayed in the form.
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             }
616 616
 
617 617
         echo '<div class="mainsearchbox">';
618
-        if ($wtt<2) {
618
+        if ($wtt < 2) {
619 619
                 echo '<form action="', $URL->generate(), '" method="get">';
620 620
                 if (get_http_var('o')) {
621 621
                     echo '<input type="hidden" name="o" value="', _htmlentities(get_http_var('o')), '">';
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                     echo '<input type="hidden" name="house" value="', _htmlentities(get_http_var('house')), '">';
625 625
                 }
626 626
                 echo '<input type="text" name="q" value="', _htmlentities($value), '" size="50"> ';
627
-                echo '<input type="submit" value=" ', ($wtt?'Modify search':'Search'), ' ">';
627
+                echo '<input type="submit" value=" ', ($wtt ? 'Modify search' : 'Search'), ' ">';
628 628
                 $URL = new \MySociety\TheyWorkForYou\Url('search');
629 629
             $URL->insert(array('adv' => 1));
630 630
                 echo '&nbsp;&nbsp; <a href="' . $URL->generate() . '">More&nbsp;options</a>';
@@ -646,16 +646,16 @@  discard block
 block discarded – undo
646 646
                     $ordering = 'd';
647 647
                 }
648 648
 
649
-                if ($ordering=='r') {
649
+                if ($ordering == 'r') {
650 650
                 print '<strong>Sorted by relevance</strong>';
651 651
                 } else {
652 652
                 printf("<a href='%s'>Sort by relevance</a>", $orderUrl->generate('html', array('o'=>'r')));
653 653
                 }
654 654
 
655 655
                 print "&nbsp;|&nbsp;";
656
-                if ($ordering=='d') {
656
+                if ($ordering == 'd') {
657 657
                 print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">oldest</a>';
658
-                } elseif ($ordering=='o') {
658
+                } elseif ($ordering == 'o') {
659 659
                 print '<strong>Sorted by date:</strong> <a href="' . $orderUrl->generate('html', array('o'=>'d')) . '">newest</a> / <strong>oldest</strong>';
660 660
                 } else {
661 661
                 printf("Sort by date: <a href='%s'>newest</a> / <a href='%s'>oldest</a>",
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                 }
664 664
 
665 665
             print "&nbsp;|&nbsp;";
666
-            if ($ordering=='p') {
666
+            if ($ordering == 'p') {
667 667
                 print '<strong>Use by person</strong>';
668 668
             } else {
669 669
                 printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o'=>'p')));
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
         include_once INCLUDESPATH . 'easyparliament/templates/html/search_advanced.php';
688 688
     }
689 689
 
690
-    public function login_form ($errors = array()) {
690
+    public function login_form($errors = array()) {
691 691
         // Used for /user/login/ and /user/prompt/
692 692
         // $errors is a hash of potential errors from a previous log in attempt.
693 693
         ?>
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     public function glossary_atoz(&$GLOSSARY) {
792 792
     // Print out a nice list of lettered links to glossary pages
793 793
 
794
-        $letters = array ();
794
+        $letters = array();
795 795
 
796 796
         foreach ($GLOSSARY->alphabet as $letter => $eps) {
797 797
             // if we're writing out the current letter (list or item)
@@ -824,14 +824,14 @@  discard block
 block discarded – undo
824 824
                     <div class="letters">
825 825
                         <ul>
826 826
     <?php
827
-        for ($n=0; $n<13; $n++) {
827
+        for ($n = 0; $n < 13; $n++) {
828 828
             print $letters[$n];
829 829
         }
830 830
         ?>
831 831
                         </ul>
832 832
                         <ul>
833 833
     <?php
834
-        for ($n=13; $n<26; $n++) {
834
+        for ($n = 13; $n < 26; $n++) {
835 835
             print $letters[$n];
836 836
         }
837 837
         ?>
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 
851 851
         // add some extra controls for the administrators
852 852
         if ($this_page == "admin_glossary") {
853
-            print "<a id=\"gl".$term['glossary_id']."\"></a>";
853
+            print "<a id=\"gl" . $term['glossary_id'] . "\"></a>";
854 854
             print "<h3>" . $term['title'] . "</h3>";
855 855
             $URL = new \MySociety\TheyWorkForYou\Url('admin_glossary');
856 856
             $URL->insert(array("delete_confirm" => $term['glossary_id']));
857 857
             $delete_url = $URL->generate();
858
-            $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>";
858
+            $admin_links = "<br><small><a href=\"" . $delete_url . "\">delete</a></small>";
859 859
         }
860 860
         else {
861 861
             $admin_links = "";
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
             // Add a direct search link for current glossary item
879 879
             $URL = new \MySociety\TheyWorkForYou\Url('search');
880 880
             // remember to quote the term for phrase matching in search
881
-            $URL->insert(array('s' => '"'.$term['title'].'"'));
881
+            $URL->insert(array('s' => '"' . $term['title'] . '"'));
882 882
             $search_url = $URL->generate();
883
-            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']);
883
+            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']);
884 884
         }
885 885
     }
886 886
 
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 
956 956
             // Generate all the page links.
957 957
             $URL = new \MySociety\TheyWorkForYou\Url($this_page);
958
-            $URL->insert( array('wtt' => get_http_var('wtt')) );
958
+            $URL->insert(array('wtt' => get_http_var('wtt')));
959 959
             if (isset($pagedata['s'])) {
960 960
                 # XXX: Should be taken out in *one* place, not here + search_form etc.
961 961
                 $value = $pagedata['s'];
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 
1094 1094
                 $body = trim_characters($report['body'], 0, 40);
1095 1095
 
1096
-                $tabledata['rows'][] = array (
1096
+                $tabledata['rows'][] = array(
1097 1097
                     _htmlentities($report['firstname'] . ' ' . $report['lastname']),
1098 1098
                     _htmlentities($body),
1099 1099
                     $report['reported'],
@@ -1124,13 +1124,13 @@  discard block
 block discarded – undo
1124 1124
         // $page is the name of the page the dates should link to.
1125 1125
 
1126 1126
         // Create array containing abbreviations of days of week.
1127
-        $daysOfWeek = array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
1127
+        $daysOfWeek = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
1128 1128
 
1129 1129
         // What is the first day of the month in question?
1130
-        $firstDayOfMonth = mktime(0,0,0,$month,1,$year);
1130
+        $firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year);
1131 1131
 
1132 1132
         // How many days does this month contain?
1133
-        $numberDays = date('t',$firstDayOfMonth);
1133
+        $numberDays = date('t', $firstDayOfMonth);
1134 1134
 
1135 1135
         // Retrieve some information about the first day of the
1136 1136
         // month in question.
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 
1212 1212
             // Is the $currentDay a member of $dateArray? If so,
1213 1213
             // the day should be linked.
1214
-            if (in_array($currentDay,$dateArray)) {
1214
+            if (in_array($currentDay, $dateArray)) {
1215 1215
 
1216 1216
                 $date = sprintf("%04d-%02d-%02d", $year, $month, $currentDay);
1217 1217
 
@@ -1312,8 +1312,8 @@  discard block
 block discarded – undo
1312 1312
         // Returns HTML suitable for putting in the sidebar on Admin pages.
1313 1313
         global $this_page, $DATA;
1314 1314
 
1315
-        $pages = array ('admin_home',
1316
-                'admin_comments','admin_trackbacks', 'admin_searchlogs', 'admin_popularsearches', 'admin_failedsearches',
1315
+        $pages = array('admin_home',
1316
+                'admin_comments', 'admin_trackbacks', 'admin_searchlogs', 'admin_popularsearches', 'admin_failedsearches',
1317 1317
                 'alert_stats', 'admin_statistics', 'admin_reportstats',
1318 1318
                 'admin_commentreports', 'admin_glossary', 'admin_glossary_pending', 'admin_badusers',
1319 1319
                 'admin_photos', 'admin_mpurls', 'admin_policies', 'admin_banner', 'admin_featured', 'admin_topics'
Please login to merge, or discard this patch.
www/includes/easyparliament/commentlist.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     }
43 43
 
44 44
 
45
-    public function display ($view, $args=array(), $format='html') {
45
+    public function display($view, $args = array(), $format = 'html') {
46 46
         // $view is what we're viewing by:
47 47
         //	'ep' is all the comments attached to an epobject.
48 48
         //	'user' is all the comments written by a user.
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 
61 61
         if ($view == 'ep' || $view == 'user' || $view == 'recent' || $view == 'search' || $view == 'dates') {
62 62
             // What function do we call for this view?
63
-            $function = '_get_data_by_'.$view;
63
+            $function = '_get_data_by_' . $view;
64 64
             // Get all the dta that's to be rendered.
65 65
             $data = $this->$function($args);
66 66
 
67 67
         } else {
68 68
             // Don't have a valid $view;
69
-            $PAGE->error_message ("You haven't specified a view type.");
69
+            $PAGE->error_message("You haven't specified a view type.");
70 70
             return false;
71 71
         }
72 72
 
@@ -85,29 +85,29 @@  discard block
 block discarded – undo
85 85
         return true;
86 86
     }
87 87
 
88
-    public function render($data, $format='html', $template='comments') {
89
-        include (INCLUDESPATH."easyparliament/templates/$format/$template.php");
88
+    public function render($data, $format = 'html', $template = 'comments') {
89
+        include (INCLUDESPATH . "easyparliament/templates/$format/$template.php");
90 90
     }
91 91
 
92 92
     public function _get_data_by_ep($args) {
93 93
         // Get all the data attached to an epobject.
94 94
         global $PAGE;
95 95
 
96
-        twfy_debug (get_class($this), "getting data by epobject");
96
+        twfy_debug(get_class($this), "getting data by epobject");
97 97
 
98 98
         // What we return.
99 99
         $data = array();
100 100
         if (!is_numeric($args['epobject_id'])) {
101
-            $PAGE->error_message ("Sorry, we don't have a valid epobject id");
101
+            $PAGE->error_message("Sorry, we don't have a valid epobject id");
102 102
             return $data;
103 103
         }
104 104
 
105 105
         // For getting the data.
106
-        $input = array (
107
-            'amount' => array (
106
+        $input = array(
107
+            'amount' => array(
108 108
                 'user' => true
109 109
             ),
110
-            'where' => array (
110
+            'where' => array(
111 111
                 'comments.epobject_id=' => $args['epobject_id'],
112 112
                 #'visible=' => '1'
113 113
             ),
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
         // comments by things in $args?
136 136
         global $PAGE;
137 137
 
138
-        twfy_debug (get_class($this), "getting data by user");
138
+        twfy_debug(get_class($this), "getting data by user");
139 139
 
140 140
         // What we return.
141 141
         $data = array();
142 142
 
143 143
         if (!is_numeric($args['user_id'])) {
144
-            $PAGE->error_message ("Sorry, we don't have a valid user id");
144
+            $PAGE->error_message("Sorry, we don't have a valid user id");
145 145
             return $data;
146 146
         }
147 147
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
             $num = 10;
152 152
         }
153 153
 
154
-        if (isset($args['page']) && is_numeric($args['page']) && $args['page']>1) {
154
+        if (isset($args['page']) && is_numeric($args['page']) && $args['page'] > 1) {
155 155
             $page = $args['page'];
156 156
         } else {
157 157
             $page = 1;
158 158
         }
159 159
 
160
-        $limit = $num*($page-1) . ',' . $num;
160
+        $limit = $num * ($page - 1) . ',' . $num;
161 161
 
162 162
         // We're getting the most recent comments posted to epobjects.
163 163
         // We're grouping them by epobject so we can just link to each hansard thing once.
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 
194 194
         if ($q->rows() > 0) {
195 195
 
196
-            for ($n=0; $n<$q->rows(); $n++) {
196
+            for ($n = 0; $n < $q->rows(); $n++) {
197 197
 
198 198
                 // All the basic stuff...
199
-                $comments[$n] = array (
199
+                $comments[$n] = array(
200 200
                     'comment_id'		=> $q->field($n, 'comment_id'),
201 201
                     'posted'			=> $q->field($n, 'posted'),
202 202
                     'total_comments'	=> $q->field($n, 'total_comments'),
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
                 );
209 209
 
210 210
                 // Add the URL...
211
-                $urldata = array (
211
+                $urldata = array(
212 212
                     'major' 		=> $q->field($n, 'major'),
213 213
                     'gid'			=> $q->field($n, 'gid'),
214 214
                     'comment_id'	=> $q->field($n, 'comment_id'),
@@ -234,14 +234,14 @@  discard block
 block discarded – undo
234 234
 
235 235
                 $commentbodies = array();
236 236
 
237
-                for ($n=0; $n<$r->rows(); $n++) {
238
-                    $commentbodies[ $r->field($n, 'comment_id') ] = $r->field($n, 'body');
237
+                for ($n = 0; $n < $r->rows(); $n++) {
238
+                    $commentbodies[$r->field($n, 'comment_id')] = $r->field($n, 'body');
239 239
                 }
240 240
 
241 241
                 // This does rely on both this and the previous query returning
242 242
                 // stuff in the same order...
243 243
                 foreach ($comments as $n => $commentdata) {
244
-                    $comments[$n]['body'] = $commentbodies[ $comments[$n]['comment_id'] ];
244
+                    $comments[$n]['body'] = $commentbodies[$comments[$n]['comment_id']];
245 245
                 }
246 246
             }
247 247
         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         // $args should contain 'num', indicating how many to get.
262 262
         // and perhaps pid too, for a particular person
263 263
 
264
-        twfy_debug (get_class($this), "getting data by recent");
264
+        twfy_debug(get_class($this), "getting data by recent");
265 265
 
266 266
         // What we return.
267 267
         $data = array();
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             $page = 1;
279 279
         }
280 280
 
281
-        $limit = $num*($page-1) . ',' . $num;
281
+        $limit = $num * ($page - 1) . ',' . $num;
282 282
 
283 283
         $where = array(
284 284
             'visible=' => '1'
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
         if (isset($args['pid']) && is_numeric($args['pid'])) {
287 287
             $where['person_id='] = $args['pid'];
288 288
         }
289
-        $input = array (
290
-            'amount' => array (
289
+        $input = array(
290
+            'amount' => array(
291 291
                 'user' => true
292 292
             ),
293 293
             'where'  => $where,
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
             $data['pid'] = $args['pid'];
306 306
             $q = 'SELECT title, given_name, family_name, lordofname, house FROM member m, person_names p WHERE m.person_id=p.person_id AND p.type="name" AND left_house="9999-12-31" AND m.person_id = :pid';
307 307
             $q = $this->db->query($q, array(':pid' => $args['pid']));
308
-            $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0,'lordofname'));
308
+            $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0, 'lordofname'));
309 309
             $q = 'SELECT COUNT(*) AS count FROM comments,hansard WHERE visible=1 AND comments.epobject_id = hansard.epobject_id and hansard.person_id = :pid';
310 310
             $params[':pid'] = $args['pid'];
311 311
         } else {
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
   public function _get_data_by_dates($args) {
320 320
     // $args should contain start_date and end_date
321 321
 
322
-        twfy_debug (get_class($this), "getting data by recent");
322
+        twfy_debug(get_class($this), "getting data by recent");
323 323
         $data = array();
324 324
         $where = array(
325 325
             'visible=' => '1',
326 326
             'date(posted)>=' => $args['start_date'],
327 327
             'date(posted)<=' => $args['end_date']
328 328
         );
329
-        $input = array (
330
-            'amount' => array (
329
+        $input = array(
330
+            'amount' => array(
331 331
                 'user' => true
332 332
             ),
333 333
             'where'  => $where,
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     public function _get_data_by_search($args) {
342 342
         // $args should contain 'num', indicating how many to get.
343 343
 
344
-        twfy_debug (get_class($this), "getting data by search");
344
+        twfy_debug(get_class($this), "getting data by search");
345 345
 
346 346
         // What we return.
347 347
         $data = array();
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
             $page = 1;
359 359
         }
360 360
 
361
-        $limit = $num*($page-1) . ',' . $num;
361
+        $limit = $num * ($page - 1) . ',' . $num;
362 362
 
363
-        $input = array (
364
-            'amount' => array (
363
+        $input = array(
364
+            'amount' => array(
365 365
                 'user'=> true
366 366
             ),
367
-            'where'  => array (
367
+            'where'  => array(
368 368
                 'comments.body LIKE' => "%$args[s]%"
369 369
             ),
370 370
             'order' => 'posted DESC',
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
         // It returns the URL for the comment.
392 392
 
393 393
         $major 		= $urldata['major'];
394
-        $gid 		= $urldata['gid'];
394
+        $gid = $urldata['gid'];
395 395
         $comment_id = $urldata['comment_id'];
396 396
         $user_id = isset($urldata['user_id']) ? $urldata['user_id'] : false;
397 397
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
         $URL = new \MySociety\TheyWorkForYou\Url($page);
406 406
 
407 407
         $gid = fix_gid_from_db($gid); // In includes/utility.php
408
-        $URL->insert(array('id' => $gid ));
408
+        $URL->insert(array('id' => $gid));
409 409
         if ($user_id) {
410 410
             $URL->insert(array('u' => $user_id));
411 411
         }
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
         $limit = isset($input['limit']) ? $input['limit'] : '';
484 484
 
485 485
         // The fields to fetch from db. 'table' => array ('field1', 'field2').
486
-        $fieldsarr = array (
487
-            'comments' => array ('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'),
488
-            'hansard' => array ('major', 'gid')
486
+        $fieldsarr = array(
487
+            'comments' => array('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'),
488
+            'hansard' => array('major', 'gid')
489 489
         );
490 490
 
491 491
         // Yes, we need the gid of a comment's associated hansard object
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 
497 497
         // Add on the stuff for getting a user's details.
498 498
         if (isset($amount['user']) && $amount['user'] == true) {
499
-            $fieldsarr['users'] = array ('firstname', 'lastname', 'user_id');
499
+            $fieldsarr['users'] = array('firstname', 'lastname', 'user_id');
500 500
             // Like doing "FROM comments, users" but it's easier to add
501 501
             // an "INNER JOIN..." automatically to the query.
502 502
             $join .= ' INNER JOIN users ON comments.user_id = users.user_id ';
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
             $fieldsarr['epobject'] = array('body');
508 508
         }
509 509
 
510
-        $fieldsarr2 = array ();
510
+        $fieldsarr2 = array();
511 511
         // Construct the $fields clause.
512 512
         foreach ($fieldsarr as $table => $tablesfields) {
513 513
             foreach ($tablesfields as $n => $field) {
@@ -518,13 +518,13 @@  discard block
 block discarded – undo
518 518
                 if ($table == 'epobject' && $field == 'body') {
519 519
                     $field .= ' AS hbody';
520 520
                 }
521
-                $fieldsarr2[] = $table.'.'.$field;
521
+                $fieldsarr2[] = $table . '.' . $field;
522 522
             }
523 523
         }
524 524
         $fields = implode(', ', $fieldsarr2);
525 525
 
526 526
 
527
-        $wherearr2 = array ();
527
+        $wherearr2 = array();
528 528
         $params = array();
529 529
         $i = 0;
530 530
         // Construct the $where clause.
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             $params[":where$i"] = $val;
534 534
             $i++;
535 535
         }
536
-        $where = implode (" AND ", $wherearr2);
536
+        $where = implode(" AND ", $wherearr2);
537 537
 
538 538
         if ($order != '') {
539 539
             $order = "ORDER BY $order";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         }
545 545
 
546 546
         // Finally, do the query!
547
-        $q = $this->db->query ("SELECT $fields
547
+        $q = $this->db->query("SELECT $fields
548 548
                         FROM 	comments
549 549
                         $join
550 550
                         WHERE $where
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                         ", $params);
554 554
 
555 555
         // Format the data into an array for returning.
556
-        $data = array ();
556
+        $data = array();
557 557
 
558 558
         if ($q->rows() > 0) {
559 559
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
             // We'll generate permalinks for each comment.
564 564
             // Assuming every comment is from the same major...
565 565
 
566
-            for ($n=0; $n<$q->rows(); $n++) {
566
+            for ($n = 0; $n < $q->rows(); $n++) {
567 567
 
568 568
                 // Put each row returned into its own array in $data.
569 569
                 foreach ($fieldsarr as $table => $tablesfields) {
Please login to merge, or discard this patch.
www/includes/easyparliament/init.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 First some things to help make our PHP nicer and betterer
5 5
 ********************************************************************************/
6 6
 
7
-error_reporting (E_ALL);
7
+error_reporting(E_ALL);
8 8
 
9 9
 /********************************************************************************
10 10
 Now some constants that are the same for live and dev versions
@@ -12,22 +12,22 @@  discard block
 block discarded – undo
12 12
 ********************************************************************************/
13 13
 
14 14
 // In case we need to switch these off globally at some point...
15
-define ("ALLOWCOMMENTS", true);
16
-define ("ALLOWTRACKBACKS", true);
15
+define("ALLOWCOMMENTS", true);
16
+define("ALLOWTRACKBACKS", true);
17 17
 
18 18
 // These variables are so we can keep date/time formats consistent across the site
19 19
 // and change them easily.
20 20
 // Formats here: http://www.php.net/manual/en/function.date.php
21
-define ("LONGERDATEFORMAT",		"l, j F Y");// Monday, 31 December 2003
22
-define ("LONGDATEFORMAT", 		"j F Y"); 	// 31 December 2003
23
-define ("SHORTDATEFORMAT", 		"j M Y");	// 31 Dec 2003
24
-define ("TIMEFORMAT", 			"g:i a");	// 11:59 pm
21
+define("LONGERDATEFORMAT", "l, j F Y"); // Monday, 31 December 2003
22
+define("LONGDATEFORMAT", "j F Y"); // 31 December 2003
23
+define("SHORTDATEFORMAT", "j M Y"); // 31 Dec 2003
24
+define("TIMEFORMAT", "g:i a"); // 11:59 pm
25 25
 
26
-define ("SHORTDATEFORMAT_SQL",	"%e %b %Y"); // 31 Dec 2003
27
-define ("TIMEFORMAT_SQL", 		"%l:%i %p"); // 11:59 PM
26
+define("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003
27
+define("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM
28 28
 
29 29
 // Where we store the postcode of users if they search for an MP by postcode.
30
-define ('POSTCODE_COOKIE', 		'eppc');
30
+define('POSTCODE_COOKIE', 'eppc');
31 31
 
32 32
 /********************************************************************************
33 33
 And now all the files we'll include on every page.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 twfy_debug_timestamp("after including utility.php");
42 42
 
43 43
 // Set the default timezone
44
-if(function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
44
+if (function_exists('date_default_timezone_set')) date_default_timezone_set(TIMEZONE);
45 45
 
46 46
 // Only do clever things with errors if we're not testing, otherwise show as default
47 47
 
@@ -70,40 +70,40 @@  discard block
 block discarded – undo
70 70
 
71 71
 // The time the page starts, so we can display the total at the end.
72 72
 // getmicrotime() is in utiltity.php.
73
-define ("STARTTIME", getmicrotime());
73
+define("STARTTIME", getmicrotime());
74 74
 if (!isset($_SERVER['WINDIR'])) {
75 75
     $rusage = getrusage();
76
-    define ('STARTTIMES', $rusage['ru_stime.tv_sec']*1000000 + $rusage['ru_stime.tv_usec']);
77
-    define ('STARTTIMEU', $rusage['ru_utime.tv_sec']*1000000 + $rusage['ru_utime.tv_usec']);
76
+    define('STARTTIMES', $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec']);
77
+    define('STARTTIMEU', $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec']);
78 78
 }
79 79
 
80 80
 $DATA = new \MySociety\TheyWorkForYou\Data;
81 81
 
82 82
 class ParlDB extends \MySociety\TheyWorkForYou\Db\Connection {
83 83
     public function __construct() {
84
-        $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
84
+        $this->init(OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
85 85
     }
86 86
 }
87 87
 
88 88
 $filter = new \MySociety\TheyWorkForYou\Utility\LibFilter;
89 89
 
90
-include_once (INCLUDESPATH."easyparliament/user.php");
90
+include_once (INCLUDESPATH . "easyparliament/user.php");
91 91
 
92 92
 // Test to see if this is a new-style template using the renderer class.
93
-if (! isset($new_style_template) OR $new_style_template !== TRUE) {
93
+if (!isset($new_style_template) OR $new_style_template !== TRUE) {
94 94
 
95 95
     // This is an old-style page. Use the old page classes.
96
-    include_once (INCLUDESPATH."easyparliament/page.php");
96
+    include_once (INCLUDESPATH . "easyparliament/page.php");
97 97
 
98 98
 }
99 99
 
100
-include_once (INCLUDESPATH."easyparliament/hansardlist.php");
101
-include_once (INCLUDESPATH."dbtypes.php");
102
-include_once (INCLUDESPATH."easyparliament/commentlist.php");
103
-include_once (INCLUDESPATH."easyparliament/comment.php");
104
-include_once (INCLUDESPATH."easyparliament/trackback.php");
100
+include_once (INCLUDESPATH . "easyparliament/hansardlist.php");
101
+include_once (INCLUDESPATH . "dbtypes.php");
102
+include_once (INCLUDESPATH . "easyparliament/commentlist.php");
103
+include_once (INCLUDESPATH . "easyparliament/comment.php");
104
+include_once (INCLUDESPATH . "easyparliament/trackback.php");
105 105
 
106 106
 // Added in as new module by Richard Allan MP
107
-include_once (INCLUDESPATH."easyparliament/alert.php");
107
+include_once (INCLUDESPATH . "easyparliament/alert.php");
108 108
 
109 109
 twfy_debug_timestamp("at end of init.php");
Please login to merge, or discard this patch.