Completed
Pull Request — master (#1322)
by Nick
11:36 queued 06:31
created
www/docs/boundaries/index.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         WHERE constituency IN ('" . join("','", $a) . "')
70 70
         AND ( ( house = 3 and left_house = '2011-03-24' ) or ( house = 4 and left_house = '2011-03-23') )");
71 71
     $mreg = array();
72
-    for ($i=0; $i<$q->rows(); $i++) {
72
+    for ($i = 0; $i < $q->rows(); $i++) {
73 73
         $cons = $q->field($i, 'constituency');
74 74
         $house = $q->field($i, 'house');
75 75
         if (($house == 4 && $cons == $current['SPC']) || ($house == 3 && $cons == $current['NIE'])) {
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 <li>You were in the <strong><?=$current['SPC']?></strong> constituency, in the <strong><?=$current['SPE']?></strong> region; your constituency MSP was <a href='<?=$mp_url?>'><?=$name?></a>, and your regional MSPs were <?php
135 135
         foreach ($mreg as $k => $n) {
136 136
             print "<a href='/msp/" . make_member_url($n, '', 4) . "'>$n</a>";
137
-            if ($k < count($mreg)-2) print ', ';
138
-            elseif ($k == count($mreg)-2) print ' and ';
137
+            if ($k < count($mreg) - 2) print ', ';
138
+            elseif ($k == count($mreg) - 2) print ' and ';
139 139
         }
140 140
         echo '.</li>';
141 141
     } elseif ($country == 'N') {
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
 if ($pc) {
22 22
     # current will have WMC key. If Scottish, has SPC and SPE too. If NI, has NIE.
23 23
     $mapit = mapit_call('postcode', $pc);
24
-    if (is_object($mapit)) { # RABX error returns an object
24
+    if (is_object($mapit)) {
25
+# RABX error returns an object
25 26
         print '<p class="error">Afraid we couldn&rsquo;t find that postcode.</p>';
26 27
         $pc = '';
27 28
     }
@@ -42,7 +43,8 @@  discard block
 block discarded – undo
42 43
     if (array_key_exists('SPC', $current)) {
43 44
         $a = array($current['SPC'], $current['SPE']);
44 45
         $country = 'S';
45
-    } else {
46
+    }
47
+    else {
46 48
         $a = array($current['NIE']);
47 49
         $country = 'N';
48 50
     }
@@ -74,7 +76,8 @@  discard block
 block discarded – undo
74 76
         $house = $q->field($i, 'house');
75 77
         if (($house == 4 && $cons == $current['SPC']) || ($house == 3 && $cons == $current['NIE'])) {
76 78
             $name = $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name');
77
-        } elseif ($house == 4 && $cons == $current['SPE']) {
79
+        }
80
+        elseif ($house == 4 && $cons == $current['SPE']) {
78 81
             $mreg[] = $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name');
79 82
         }
80 83
     }
@@ -122,9 +125,11 @@  discard block
 block discarded – undo
122 125
 <?php
123 126
     if (count($new)) {
124 127
         print "<li>For the Parliament election, you are in the <strong>$new[SPC]</strong> constituency, in the <strong>$new[SPE]</strong> region.";
125
-    } elseif ($country == 'N') {
128
+    }
129
+    elseif ($country == 'N') {
126 130
         print "<li>For the Assembly election, you are in the <strong>$current[WMC]</strong> constituency.";
127
-    } else {
131
+    }
132
+    else {
128 133
         print '<li>We cannot look up the constituency for the election for some reason, sorry.';
129 134
     }
130 135
 
@@ -134,11 +139,16 @@  discard block
 block discarded – undo
134 139
 <li>You were in the <strong><?=$current['SPC']?></strong> constituency, in the <strong><?=$current['SPE']?></strong> region; your constituency MSP was <a href='<?=$mp_url?>'><?=$name?></a>, and your regional MSPs were <?php
135 140
         foreach ($mreg as $k => $n) {
136 141
             print "<a href='/msp/" . make_member_url($n, '', 4) . "'>$n</a>";
137
-            if ($k < count($mreg)-2) print ', ';
138
-            elseif ($k == count($mreg)-2) print ' and ';
142
+            if ($k < count($mreg)-2) {
143
+                print ', ';
144
+            }
145
+            elseif ($k == count($mreg)-2) {
146
+                print ' and ';
147
+            }
139 148
         }
140 149
         echo '.</li>';
141
-    } elseif ($country == 'N') {
150
+    }
151
+    elseif ($country == 'N') {
142 152
         $mp_url = '/mla/' . make_member_url($name, '', 3);
143 153
 ?>
144 154
 <li>You were in the <strong><?=$current['NIE']?></strong> constituency; your constituency MLA was <a href='<?=$mp_url?>'><?=$name?></a>.</li>
Please login to merge, or discard this patch.
www/docs/wikipedia/index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 preg_match_all('#<li>.*? \(<a[^>]*>hist</a>\) \(<a href=".*?title=(.*?)&.*?oldid=(.*?)"[^>]*>diff</a>\)  <a[^>]*>(.*?)</a> .*?</li>#', $file, $m, PREG_SET_ORDER);
52 52
 foreach ($m as $row) {
53 53
     $file = file_get_contents("cache/$row[1].$row[2]");
54
-    $file = str_replace(array("\xe2\x86\x90","\xe2\x86\x92"), array('&larr;', '&rarr;'), $file);
54
+    $file = str_replace(array("\xe2\x86\x90", "\xe2\x86\x92"), array('&larr;', '&rarr;'), $file);
55 55
     print "<h3>$row[3]</h3>";
56 56
     if (preg_match('#<table.*?</table>#s', $file, $m))
57 57
         print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
     '212.35.252.2' => 'Liberal Democrats',
10 10
 );
11 11
 $ip = get_http_var('ip');
12
-if (!array_key_exists($ip, $site))
12
+if (!array_key_exists($ip, $site)) {
13 13
     $ip = '194.60.38.10';
14
+}
14 15
 
15 16
 $this_page = 'wikipedia';
16 17
 $DATA->set_page_metadata($this_page, 'title', 'Latest 100 changes to Wikipedia by non-logged-in computers in ' . $site[$ip]);
@@ -28,10 +29,12 @@  discard block
 block discarded – undo
28 29
 <p align="center"><?php
29 30
 $out = array();
30 31
 foreach ($site as $k => $v) {
31
-    if ($k == $ip)
32
-        $o = "<strong>$v</strong>";
33
-    else
34
-        $o = "<a href=\"./?ip=$k\">$v</a>";
32
+    if ($k == $ip) {
33
+            $o = "<strong>$v</strong>";
34
+    }
35
+    else {
36
+            $o = "<a href=\"./?ip=$k\">$v</a>";
37
+    }
35 38
     $out[] = $o;
36 39
 }
37 40
 print join(' | ', $out);
@@ -53,11 +56,13 @@  discard block
 block discarded – undo
53 56
     $file = file_get_contents("cache/$row[1].$row[2]");
54 57
     $file = str_replace(array("\xe2\x86\x90","\xe2\x86\x92"), array('&larr;', '&rarr;'), $file);
55 58
     print "<h3>$row[3]</h3>";
56
-    if (preg_match('#<table.*?</table>#s', $file, $m))
57
-        print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
58
-    elseif (preg_match('#<div class="firstrevisionheader.*?</div>#s', $file, $m))
59
-        print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
60
-}
59
+    if (preg_match('#<table.*?</table>#s', $file, $m)) {
60
+            print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
61
+    }
62
+    elseif (preg_match('#<div class="firstrevisionheader.*?</div>#s', $file, $m)) {
63
+            print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
64
+    }
65
+    }
61 66
 
62 67
 $PAGE->stripe_end();
63 68
 $PAGE->page_end();
Please login to merge, or discard this patch.
www/docs/news/index.php 1 patch
Braces   +25 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,10 +9,14 @@  discard block
 block discarded – undo
9 9
 if (preg_match("#/(\d\d\d\d)/(\d\d)/(\d\d)/([a-z0-9_]+)(\.php)?$#", $uri, $matches)) {
10 10
     // Individual item
11 11
     list($all, $year, $month, $day, $ref) = $matches;
12
-    if ($ref == "please_build_on_") $ref = "new_full_source_";
12
+    if ($ref == "please_build_on_") {
13
+        $ref = "new_full_source_";
14
+    }
13 15
     foreach ($all_news as $id => $news_row) {
14 16
         list($title, $content, $date) = $news_row;
15
-        if (news_format_ref($title) != $ref) continue;
17
+        if (news_format_ref($title) != $ref) {
18
+            continue;
19
+        }
16 20
 
17 21
         $this_page = 'sitenews_individual';
18 22
         $DATA->set_page_metadata($this_page, 'title', $title);
@@ -20,7 +24,9 @@  discard block
 block discarded – undo
20 24
         $PAGE->stripe_start();
21 25
         print news_format_body($content);
22 26
         print "<p>Posted on " . format_date(substr($date, 0, 10), LONGDATEFORMAT) . " at " . substr($date, 11);
23
-        if (isset($news_row[3])) print " by $news_row[3]";
27
+        if (isset($news_row[3])) {
28
+            print " by $news_row[3]";
29
+        }
24 30
         print " | <a href=\"" . news_individual_link($date, $title) . "\">Link to this</a>";
25 31
         break;
26 32
     }
@@ -28,7 +34,8 @@  discard block
 block discarded – undo
28 34
         $PAGE->page_start();
29 35
         $PAGE->stripe_start();
30 36
     }
31
-} elseif (preg_match("#/(\d\d\d\d)/(\d\d)/?(index.php)?$#", $uri, $matches)) {
37
+}
38
+elseif (preg_match("#/(\d\d\d\d)/(\d\d)/?(index.php)?$#", $uri, $matches)) {
32 39
     // Month index
33 40
     list($all, $year, $month) = $matches;
34 41
     $this_page = 'sitenews_date';
@@ -37,28 +44,37 @@  discard block
 block discarded – undo
37 44
     $PAGE->stripe_start();
38 45
     foreach (array_reverse($all_news) as $id => $news_row) {
39 46
         list($title, $content, $date) = $news_row;
40
-        if (substr($date, 0, 7) != "$year-$month") continue;
47
+        if (substr($date, 0, 7) != "$year-$month") {
48
+            continue;
49
+        }
41 50
         print "<h3>" . format_date(substr($date, 0, 10), LONGDATEFORMAT) . "</h3>";
42 51
         print "<h4>" . $title . "</h4>";
43 52
         print news_format_body($content);
44 53
         print "<p>Posted at " . substr($date, 11);
45
-        if (isset($news_row[3])) print " by $news_row[3]";
54
+        if (isset($news_row[3])) {
55
+            print " by $news_row[3]";
56
+        }
46 57
         print " | <a href=\"" . news_individual_link($date, $title) . "\">Link to this</a>";
47 58
     }
48
-} else {
59
+}
60
+else {
49 61
     // Front page /news
50 62
     $this_page = 'sitenews';
51 63
     $PAGE->page_start();
52 64
     $PAGE->stripe_start();
53 65
     $c = 0;
54 66
     foreach ($all_news as $id => $news_row) {
55
-        if ($c++ == 10) break;
67
+        if ($c++ == 10) {
68
+            break;
69
+        }
56 70
         list($title, $content, $date) = $news_row;
57 71
         print "<h3>" . format_date(substr($date, 0, 10), LONGDATEFORMAT) . "</h3>";
58 72
         print "<h4>" . $title . "</h4>";
59 73
         print news_format_body($content);
60 74
         print "<p>Posted at " . substr($date, 11);
61
-        if (isset($news_row[3])) print " by $news_row[3]";
75
+        if (isset($news_row[3])) {
76
+            print " by $news_row[3]";
77
+        }
62 78
         print " | <a href=\"" . news_individual_link($date, $title) . "\">Link to this</a>";
63 79
     }
64 80
 }
Please login to merge, or discard this patch.
www/docs/news/sidebar_archives.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
 
13 13
     $ym = substr($date, 0, 7);
14 14
     if ($ym != $last) {
15
-        $url = WEBPATH . "news/archives/".str_replace("-", "/", $ym);
16
-        print "<a href=\"$url\">".format_date($ym."-01", "F Y")."</a>";
15
+        $url = WEBPATH . "news/archives/" . str_replace("-", "/", $ym);
16
+        print "<a href=\"$url\">" . format_date($ym . "-01", "F Y") . "</a>";
17 17
         print "<br>";
18 18
         $last = $ym;
19 19
     }
Please login to merge, or discard this patch.
www/docs/video/submit.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,11 +18,16 @@  discard block
 block discarded – undo
18 18
 $htime = $q->field(0, 'htime');
19 19
 $atime = $q->field(0, 'atime');
20 20
 $adate = $q->field(0, 'adate');
21
-if ($atime) $htime = $atime;
22
-if ($adate) $hdate = $adate;
21
+if ($atime) {
22
+    $htime = $atime;
23
+}
24
+if ($adate) {
25
+    $hdate = $adate;
26
+}
23 27
 
24
-if (!$hdate || !$htime || !$time)
28
+if (!$hdate || !$htime || !$time) {
25 29
     exit;
30
+}
26 31
 
27 32
 $videodb = \MySociety\TheyWorkForYou\Utility\Video::dbConnect();
28 33
 if (!$file) {
@@ -50,7 +55,8 @@  discard block
 block discarded – undo
50 55
 if ($THEUSER->isloggedin()) {
51 56
     $user_id = $THEUSER->user_id();
52 57
     $q = $db->query("insert into video_timestamps (gid, user_id, adate, atime) values ('$q_gid', $user_id, '$new_date', '$new_time') on duplicate key update adate=VALUES(adate),atime=VALUES(atime),deleted=0");
53
-} else {
58
+}
59
+else {
54 60
     $q = $db->query("insert into video_timestamps (gid, adate, atime) values ('$q_gid', '$new_date', '$new_time')");
55 61
 }
56 62
 $new_id = $q->insert_id();
Please login to merge, or discard this patch.
www/docs/video/next.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $major = intval(get_http_var('major'));
8 8
 if (!$major) $major = 1;
9 9
 
10
-if ($action == 'next' || $action=='nextneeded') {
10
+if ($action == 'next' || $action == 'nextneeded') {
11 11
     $gid = get_http_var('gid');
12 12
     $file = intval(get_http_var('file'));
13 13
     $time = intval(get_http_var('time'));
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     $q = $db->query("select gid, hpos from hansard
28 28
         where hpos>$hpos and hdate='$hdate' and major=$major
29 29
         and (htype=12 or htype=13) "
30
-        . ($action=='nextneeded'?'and video_status in (1,3)':'') . "
30
+        . ($action == 'nextneeded' ? 'and video_status in (1,3)' : '') . "
31 31
         ORDER BY hpos LIMIT 1");
32 32
     if (!$q->rows()) {
33 33
         $PAGE->page_start();
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     } else {
42 42
         $new_gid = $q->field(0, 'gid');
43 43
         $new_hpos = $q->field(0, 'hpos');
44
-        if ($action=='nextneeded') {
44
+        if ($action == 'nextneeded') {
45 45
             $q = $db->query("select adate, atime from hansard, video_timestamps
46 46
                 where hansard.gid = video_timestamps.gid and deleted=0
47 47
                     and hpos<$new_hpos and hdate='$hdate' and major=$major
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
 $action = get_http_var('action');
6 6
 $pid = intval(get_http_var('pid'));
7 7
 $major = intval(get_http_var('major'));
8
-if (!$major) $major = 1;
8
+if (!$major) {
9
+    $major = 1;
10
+}
9 11
 
10 12
 if ($action == 'next' || $action=='nextneeded') {
11 13
     $gid = get_http_var('gid');
@@ -38,7 +40,8 @@  discard block
 block discarded – undo
38 40
 ;-)</p>';
39 41
         $PAGE->stripe_end();
40 42
         $PAGE->page_end();
41
-    } else {
43
+    }
44
+    else {
42 45
         $new_gid = $q->field(0, 'gid');
43 46
         $new_hpos = $q->field(0, 'hpos');
44 47
         if ($action=='nextneeded') {
@@ -59,7 +62,8 @@  discard block
 block discarded – undo
59 62
         $new_gid = fix_gid_but_leave_section($new_gid);
60 63
         header('Location: /video/?from=next&file=' . $file . '&gid=' . $new_gid . '&start=' . $time);
61 64
     }
62
-} elseif ($action == 'random' && $pid) {
65
+}
66
+elseif ($action == 'random' && $pid) {
63 67
     $db = new ParlDB;
64 68
     $q = $db->query("select gid from hansard
65 69
         where video_status in (1,3) and major=:major
@@ -68,7 +72,8 @@  discard block
 block discarded – undo
68 72
         ORDER BY RAND() LIMIT 1", array(':major' => $major, ':pid' => $pid));
69 73
     $new_gid = fix_gid_but_leave_section($q->field(0, 'gid'));
70 74
     header('Location: /video/?from=random&pid=' . $pid . '&gid=' . $new_gid);
71
-} elseif ($action == 'random') {
75
+}
76
+elseif ($action == 'random') {
72 77
     $db = new ParlDB;
73 78
     $q = $db->query("select gid, hpos, hdate from hansard
74 79
         where video_status in (1,3) and major=:major
@@ -96,7 +101,8 @@  discard block
 block discarded – undo
96 101
     */
97 102
     $gid = fix_gid_but_leave_section($gid);
98 103
     header('Location: /video/?from=random&gid=' . $gid);
99
-} else {
104
+}
105
+else {
100 106
     # Illegal action
101 107
 }
102 108
 
Please login to merge, or discard this patch.
www/docs/video/distance.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
     $want['hpos'] = $q->field(0, 'hpos');
56 56
 
57 57
     $LIST = new DEBATELIST;
58
-        $args = array (
58
+        $args = array(
59 59
             's' => $search,
60 60
             'p' => 1,
61 61
             'num' => 200,
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@
 block discarded – undo
19 19
 if ($search = get_http_var('s')) {
20 20
     search_box($file);
21 21
     day_speeches($search, $gid_type, $gid_date);
22
-} else { ?>
22
+}
23
+else { ?>
23 24
 <p>If the playing speech appears to be in completely the wrong place,
24 25
 enter the speaking MP's name and/or something they're saying in this search box
25 26
 to search the day's speeches. Find the correct speech and it will say how
Please login to merge, or discard this patch.
www/docs/written-answers-and-statements/index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 $view = new MySociety\TheyWorkForYou\SectionView\WransView();
12 12
 $data = $view->display();
13 13
 if ($data) {
14
-    if ( $data['template'] ) {
14
+    if ($data['template']) {
15 15
         $template = $data['template'];
16 16
     } else {
17 17
         $template = 'section/section';
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@
 block discarded – undo
13 13
 if ($data) {
14 14
     if ( $data['template'] ) {
15 15
         $template = $data['template'];
16
-    } else {
16
+    }
17
+    else {
17 18
         $template = 'section/section';
18 19
     }
19 20
     MySociety\TheyWorkForYou\Renderer::output($template, $data);
Please login to merge, or discard this patch.
www/docs/departments/questions.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (!$dept) {
13 13
 } else {
14
-    $dept = strtolower(str_replace('_',' ',$dept));
14
+    $dept = strtolower(str_replace('_', ' ', $dept));
15 15
     $q = $db->query('select epobject.epobject_id from hansard,epobject
16 16
         where hansard.epobject_id=epobject.epobject_id and major=3 and section_id=0
17 17
         and hdate>(select max(hdate) from hansard where major=3) - interval 7 day
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
             ':dept' => $dept
20 20
         ));
21 21
     $ids = array();
22
-    for ($i=0; $i<$q->rows(); $i++) {
22
+    for ($i = 0; $i < $q->rows(); $i++) {
23 23
         $ids[] = $q->field($i, 'epobject_id');
24 24
     }
25 25
 
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
         and section_id in (' . join(',', $ids) . ')
31 31
         order by body');
32 32
     print '<ul>';
33
-    for ($i=0; $i<$q->rows(); $i++) {
34
-        print '<li><a href="/wrans/?id=' . fix_gid_from_db($q->field($i, 'gid')). '">' . $q->field($i, 'body'). '</a>';
33
+    for ($i = 0; $i < $q->rows(); $i++) {
34
+        print '<li><a href="/wrans/?id=' . fix_gid_from_db($q->field($i, 'gid')) . '">' . $q->field($i, 'body') . '</a>';
35 35
         print '</li>';
36 36
     }
37 37
     print '</ul>';
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
 $db = new ParlDB;
11 11
 
12 12
 if (!$dept) {
13
-} else {
13
+}
14
+else {
14 15
     $dept = strtolower(str_replace('_',' ',$dept));
15 16
     $q = $db->query('select epobject.epobject_id from hansard,epobject
16 17
         where hansard.epobject_id=epobject.epobject_id and major=3 and section_id=0
Please login to merge, or discard this patch.