@@ -37,7 +37,7 @@ |
||
37 | 37 | $desc->long_name, |
38 | 38 | $desc->description, |
39 | 39 | kw_array_to_str($desc->sci_kw), |
40 | - empty($desc->url)?'':"<a href=$desc->url>View</a>", |
|
40 | + empty($desc->url) ? '' : "<a href=$desc->url>View</a>", |
|
41 | 41 | 'Yes' |
42 | 42 | ); |
43 | 43 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | // close() closes the connection. |
45 | 45 | |
46 | 46 | class BoincDb { |
47 | - static $instance; // a DbConn object, or null |
|
48 | - static $dbnum; // which replica we're connected to |
|
47 | + static $instance; // a DbConn object, or null |
|
48 | + static $dbnum; // which replica we're connected to |
|
49 | 49 | |
50 | 50 | // connect to DB $dbnum (0, 1, ...) |
51 | 51 | // If the requested DB doesn't exist or connection fails, connect to DB 0. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | self::$instance = null; |
57 | 57 | $config = get_config(); |
58 | 58 | if ($dbnum) { |
59 | - $r = $dbnum==1?'':strval($dbnum); |
|
59 | + $r = $dbnum == 1 ? '' : strval($dbnum); |
|
60 | 60 | $host = parse_config($config, sprintf('<replica%s_db_host>', $r)); |
61 | 61 | $name = parse_config($config, sprintf('<replica%s_db_name>', $r)); |
62 | 62 | $user = parse_config($config, sprintf('<replica%s_db_user>', $r)); |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | $db = BoincDb::get(); |
205 | 205 | return $db->update($this, 'user', $clause); |
206 | 206 | } |
207 | - static function enum($where_clause, $order_clause=null) { |
|
207 | + static function enum($where_clause, $order_clause = null) { |
|
208 | 208 | $db = BoincDb::get(); |
209 | 209 | return $db->enum('user', 'BoincUser', $where_clause, $order_clause); |
210 | 210 | } |
211 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
211 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
212 | 212 | $db = BoincDb::get(); |
213 | 213 | return $db->enum_fields( |
214 | 214 | 'user', 'BoincUser', $fields, $where_clause, $order_clause |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $db = BoincDb::get(); |
259 | 259 | return $db->update($this, 'team', $clause); |
260 | 260 | } |
261 | - static function enum($where_clause, $order_clause=null) { |
|
261 | + static function enum($where_clause, $order_clause = null) { |
|
262 | 262 | $db = BoincDb::get(); |
263 | 263 | return $db->enum('team', 'BoincTeam', $where_clause, $order_clause); |
264 | 264 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $db = BoincDb::get(); |
284 | 284 | return $db->max('team', $field); |
285 | 285 | } |
286 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
286 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
287 | 287 | $db = BoincDb::get(); |
288 | 288 | return $db->enum_fields( |
289 | 289 | 'team', 'BoincTeam', $fields, $where_clause, $order_clause |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | $db = BoincDb::get(); |
322 | 322 | return $db->delete($this, 'host'); |
323 | 323 | } |
324 | - static function enum($where_clause, $order_clause=null) { |
|
324 | + static function enum($where_clause, $order_clause = null) { |
|
325 | 325 | $db = BoincDb::get(); |
326 | 326 | return $db->enum('host', 'BoincHost', $where_clause, $order_clause); |
327 | 327 | } |
328 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
328 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
329 | 329 | $db = BoincDb::get(); |
330 | 330 | return $db->enum_fields( |
331 | 331 | 'host', 'BoincHost', $fields, $where_clause, $order_clause |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $db = BoincDb::get(); |
363 | 363 | return $db->enum('result', 'BoincResult', $where_clause); |
364 | 364 | } |
365 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
365 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
366 | 366 | $db = BoincDb::get(); |
367 | 367 | return $db->enum_fields( |
368 | 368 | 'result', 'BoincResult', $fields, $where_clause, $order_clause |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $db = BoincDb::get(); |
412 | 412 | return $db->enum('workunit', 'BoincWorkunit', $where_clause); |
413 | 413 | } |
414 | - static function enum_fields($fields, $where_clause, $order_clause=null) { |
|
414 | + static function enum_fields($fields, $where_clause, $order_clause = null) { |
|
415 | 415 | $db = BoincDb::get(); |
416 | 416 | return $db->enum_fields('workunit', 'BoincWorkunit', $fields, $where_clause, $order_clause); |
417 | 417 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $db = BoincDb::get(); |
454 | 454 | return $db->update($this, 'app', $clause); |
455 | 455 | } |
456 | - static function sum($field, $clause=null) { |
|
456 | + static function sum($field, $clause = null) { |
|
457 | 457 | $db = BoincDb::get(); |
458 | 458 | return $db->sum('app', $field, $clause); |
459 | 459 | } |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | $db = BoincDb::get(); |
512 | 512 | return $db->insert('profile', $clause); |
513 | 513 | } |
514 | - static function enum($where_clause=null, $order_clause=null) { |
|
514 | + static function enum($where_clause = null, $order_clause = null) { |
|
515 | 515 | $db = BoincDb::get(); |
516 | 516 | return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause); |
517 | 517 | } |
518 | - static function enum_fields($fields, $where_clause=null, $order_clause=null) { |
|
518 | + static function enum_fields($fields, $where_clause = null, $order_clause = null) { |
|
519 | 519 | $db = BoincDb::get(); |
520 | 520 | return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause); |
521 | 521 | } |
@@ -910,12 +910,12 @@ discard block |
||
910 | 910 | return $db->enum('consent', 'BoincConsent', $where_clause); |
911 | 911 | } |
912 | 912 | |
913 | - static function insert ($clause) { |
|
913 | + static function insert($clause) { |
|
914 | 914 | $db = BoincDb::get(); |
915 | 915 | return $db->insert('consent', $clause); |
916 | 916 | } |
917 | 917 | |
918 | - static function update ($clause) { |
|
918 | + static function update($clause) { |
|
919 | 919 | $db = BoincDb::get(); |
920 | 920 | return $db->update_aux('consent', $clause); |
921 | 921 | } |
@@ -940,17 +940,17 @@ discard block |
||
940 | 940 | return $db->lookup('consent_type', 'BoincConsentType', $clause); |
941 | 941 | } |
942 | 942 | |
943 | - static function enum($where_clause, $order_clause=null) { |
|
943 | + static function enum($where_clause, $order_clause = null) { |
|
944 | 944 | $db = BoincDb::get(); |
945 | 945 | return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause); |
946 | 946 | } |
947 | 947 | |
948 | - static function insert ($clause) { |
|
948 | + static function insert($clause) { |
|
949 | 949 | $db = BoincDb::get(); |
950 | 950 | return $db->insert('consent_type', $clause); |
951 | 951 | } |
952 | 952 | |
953 | - static function update ($clause) { |
|
953 | + static function update($clause) { |
|
954 | 954 | $db = BoincDb::get(); |
955 | 955 | return $db->update_aux('consent_type', $clause); |
956 | 956 | } |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | return $db->lookup('latest_consent', 'BoincLatestConsent', $clause); |
977 | 977 | } |
978 | 978 | |
979 | - static function enum($where_clause, $order_clause=null) { |
|
979 | + static function enum($where_clause, $order_clause = null) { |
|
980 | 980 | $db = BoincDb::get(); |
981 | 981 | return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause); |
982 | 982 | } |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | // apply this to any user-supplied strings used in queries |
988 | 988 | // |
989 | 989 | function boinc_real_escape_string($x) { |
990 | - if (version_compare(phpversion(),"4.3.0")>=0) { |
|
990 | + if (version_compare(phpversion(), "4.3.0") >= 0) { |
|
991 | 991 | return BoincDb::escape_string($x); |
992 | 992 | } else { |
993 | 993 | $x = str_replace("'", "\'", $x); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $host = BoincHost::lookup_id($res->hostid); |
36 | 36 | $hosts[$res->hostid] = $host; |
37 | 37 | } |
38 | - $fpops = $res->cpu_time * $host->p_fpops; |
|
38 | + $fpops = $res->cpu_time*$host->p_fpops; |
|
39 | 39 | $samples[] = $res->cpu_time; |
40 | 40 | //$fpops /= 1e9; |
41 | 41 | //echo "$res->cpu_time $fpops\n"; |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | function show($samples) { |
48 | - $x = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; |
|
48 | + $x = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
|
49 | 49 | foreach ($samples as $s) { |
50 | 50 | $x[(int)log10($s)] += 1; |
51 | 51 | } |
52 | - for ($i=0; $i<16; $i++) { |
|
52 | + for ($i = 0; $i < 16; $i++) { |
|
53 | 53 | echo sprintf("%d: %d\n", $i, $x[$i]); |
54 | 54 | } |
55 | 55 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $user_submit = BoincUserSubmit::lookup_userid($user->id); |
159 | 159 | if (!$user_submit) return null; |
160 | 160 | $a = array(); |
161 | - foreach($apps as $app) { |
|
161 | + foreach ($apps as $app) { |
|
162 | 162 | if ($user_submit->submit_all) { |
163 | 163 | $a[] = $app; |
164 | 164 | } else { |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | $input_url = get_str('input_url'); |
236 | 236 | if (!$input_url) error_page("missing input URL"); |
237 | 237 | $param_lo = (double)get_str('param_lo'); |
238 | - if ($param_lo<0 || $param_lo>60) error_page("param lo must be in 0..60"); |
|
238 | + if ($param_lo < 0 || $param_lo > 60) error_page("param lo must be in 0..60"); |
|
239 | 239 | $param_hi = (double)get_str('param_hi'); |
240 | - if ($param_hi<0 || $param_hi>60 || $param_hi <= $param_lo) { |
|
240 | + if ($param_hi < 0 || $param_hi > 60 || $param_hi <= $param_lo) { |
|
241 | 241 | error_page("param hi must be in 0..60 and > param lo"); |
242 | 242 | } |
243 | 243 | $param_inc = (double)get_str('param_inc'); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $f->source = $input_url; |
255 | 255 | $f->mode = 'semilocal'; |
256 | 256 | |
257 | - for ($x=$param_lo; $x<$param_hi; $x += $param_inc) { |
|
257 | + for ($x = $param_lo; $x < $param_hi; $x += $param_inc) { |
|
258 | 258 | $job = new StdClass; |
259 | 259 | $job->rsc_fpops_est = $x*1e9; |
260 | 260 | $job->command_line = "--t $x"; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | "status", |
344 | 344 | "Canonical instance<br><p class=\"text-muted\">click to see result page on BOINC server</p>" |
345 | 345 | ); |
346 | - foreach($batch->jobs as $job) { |
|
346 | + foreach ($batch->jobs as $job) { |
|
347 | 347 | $id = (int)$job->id; |
348 | 348 | $resultid = (int)$job->canonical_instance_id; |
349 | 349 | if ($resultid) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | "Instance ID<br><p class=\"text-muted\">click for result page on BOINC server</p>", |
387 | 387 | "State", "Output files" |
388 | 388 | ); |
389 | - foreach($reply->instances as $inst) { |
|
389 | + foreach ($reply->instances as $inst) { |
|
390 | 390 | echo "<tr> |
391 | 391 | <td><a href=result.php?resultid=$inst->id>$inst->id</a></td> |
392 | 392 | <td>$inst->state</td> |
@@ -31,7 +31,7 @@ |
||
31 | 31 | function reg_form() { |
32 | 32 | $config = get_config(); |
33 | 33 | $disable_acct = parse_bool($config, "disable_account_creation"); |
34 | - page_head("Register", null, null, null, boinc_recaptcha_get_head_extra()); |
|
34 | + page_head("Register", null, null, null, boinc_recaptcha_get_head_extra()); |
|
35 | 35 | echo "<h3>Create an account</h3>"; |
36 | 36 | form_start("create_account_action.php", "post"); |
37 | 37 | create_account_form(0, "download_software.php"); |
@@ -64,7 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | -form_start("create_account_action.php","post"); |
|
67 | +form_start("create_account_action.php", "post"); |
|
68 | 68 | create_account_form($teamid, $next_url); |
69 | 69 | if (recaptcha_public_key()) { |
70 | 70 | form_general("", boinc_recaptcha_get_html(recaptcha_public_key())); |
@@ -58,10 +58,10 @@ |
||
58 | 58 | //panel(null, 'panel_contents'); |
59 | 59 | } |
60 | 60 | |
61 | -function left(){ |
|
61 | +function left() { |
|
62 | 62 | global $user, $no_web_account_creation, $project_id; |
63 | 63 | panel( |
64 | - $user?tra("Welcome, %1", $user->name):tra("What is %1?", PROJECT), |
|
64 | + $user ?tra("Welcome, %1", $user->name) : tra("What is %1?", PROJECT), |
|
65 | 65 | function() use($user) { |
66 | 66 | global $no_web_account_creation, $project_id; |
67 | 67 | if ($user) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | // If $selection is provided, and if it matches one of the entries in the file, |
33 | 33 | // it will be selected by default. |
34 | 34 | // |
35 | -function show_combo_box($name, $filename, $selection=null) { |
|
35 | +function show_combo_box($name, $filename, $selection = null) { |
|
36 | 36 | echo "<select name=\"$name\" class=\"form-control\">\n"; |
37 | 37 | |
38 | 38 | $file = fopen($filename, "r"); |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | <tr><td colspan=2> |
64 | 64 | <table border=0 cellpadding=5 |
65 | 65 | <tr> |
66 | -<td valign=top><a href=\"" . IMAGE_URL . $profile->userid . '.jpg' . "\"><img src=\"" . IMAGE_URL . $profile->userid . '_sm.jpg' . "\"></a> |
|
66 | +<td valign=top><a href=\"" . IMAGE_URL.$profile->userid.'.jpg'."\"><img src=\"".IMAGE_URL.$profile->userid.'_sm.jpg'."\"></a> |
|
67 | 67 | </td> |
68 | -<td valign=top>" .tra("%1 Your profile picture is shown to the left.", $warning) ." |
|
68 | +<td valign=top>" .tra("%1 Your profile picture is shown to the left.", $warning)." |
|
69 | 69 | <p>". |
70 | -tra("To replace it, click the \"Browse\" button and select a JPEG or PNG file (%1 or less).", "50KB") ."<br /> |
|
70 | +tra("To replace it, click the \"Browse\" button and select a JPEG or PNG file (%1 or less).", "50KB")."<br /> |
|
71 | 71 | <input name=picture type=file><br> |
72 | 72 | <p>". |
73 | -tra("To remove it from your profile, check this box:") . " |
|
73 | +tra("To remove it from your profile, check this box:")." |
|
74 | 74 | <input type=checkbox name=delete_pic> |
75 | 75 | <p> |
76 | 76 | </td></tr>"; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | end_table(); |
79 | 79 | echo "</td></tr>"; |
80 | 80 | } else { |
81 | - rowify(tra("If you would like include a picture with your profile, click the \"Browse\" button and select a JPEG or PNG file. Please select images of %1 or less.", "50KB") . " |
|
81 | + rowify(tra("If you would like include a picture with your profile, click the \"Browse\" button and select a JPEG or PNG file. Please select images of %1 or less.", "50KB")." |
|
82 | 82 | <p> |
83 | 83 | <input name=picture type=file> |
84 | 84 | "); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | row1(tra("Language")); |
94 | 94 | echo "<tr><td> |
95 | 95 | <p>" . |
96 | - tra("Select the language in which your profile is written:") . " |
|
96 | + tra("Select the language in which your profile is written:")." |
|
97 | 97 | <p> |
98 | 98 | "; |
99 | 99 | if (isset($profile->language)) { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | if (recaptcha_public_key()) { |
110 | 110 | table_row(boinc_recaptcha_get_html(recaptcha_public_key())); |
111 | 111 | } |
112 | - table_row("<p><input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Create/edit profile") ."\" name=\"submit\">"); |
|
112 | + table_row("<p><input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Create/edit profile")."\" name=\"submit\">"); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // Returns an array containing: |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | // Determine if the filetype uploaded is supported. |
125 | 125 | // TODO: Change these to constants. |
126 | - switch($size[2]) { |
|
126 | + switch ($size[2]) { |
|
127 | 127 | case '2': // JPEG |
128 | 128 | $image = imageCreateFromJPEG($fileName); |
129 | 129 | break; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | function show_description() { |
162 | 162 | echo " |
163 | - <p>" .tra("Your %1 profile %2 lets you share your opinions and background with the %3 community.", "<b>", "</b>", PROJECT) . " |
|
163 | + <p>" .tra("Your %1 profile %2 lets you share your opinions and background with the %3 community.", "<b>", "</b>", PROJECT)." |
|
164 | 164 | <p> |
165 | 165 | "; |
166 | 166 | } |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | row1(show_profile_heading1()); |
179 | 179 | rowify(show_profile_question1().bbcode_info()); |
180 | 180 | show_textarea("response1", $response1); |
181 | - row1( show_profile_heading2()); |
|
182 | - rowify( show_profile_question2().bbcode_info()); |
|
181 | + row1(show_profile_heading2()); |
|
182 | + rowify(show_profile_question2().bbcode_info()); |
|
183 | 183 | show_textarea("response2", $response2); |
184 | 184 | show_language_selection($profile); |
185 | 185 | } |
186 | 186 | |
187 | 187 | function show_textarea($name, $text) { |
188 | - rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">" . $text . "</textarea>"); |
|
188 | + rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">".$text."</textarea>"); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // $profile is null if user doesn't already have a profile. |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | $delete_pic = "off"; |
230 | 230 | } |
231 | 231 | |
232 | - if (strlen($response1)==0 && |
|
233 | - strlen($response2)==0 && |
|
232 | + if (strlen($response1) == 0 && |
|
233 | + strlen($response2) == 0 && |
|
234 | 234 | $delete_pic != "on" && |
235 | 235 | !is_uploaded_file($_FILES['picture']['tmp_name']) |
236 | 236 | ) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $profile->verification = 0; |
245 | 245 | } |
246 | 246 | |
247 | - $profile ? $has_picture = $profile->has_picture: $has_picture = false; |
|
247 | + $profile ? $has_picture = $profile->has_picture : $has_picture = false; |
|
248 | 248 | |
249 | 249 | if (is_uploaded_file($_FILES['picture']['tmp_name'])) { |
250 | 250 | $has_picture = true; |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | |
260 | 260 | // Write the original image file to disk. |
261 | 261 | // TODO: define a constant for image quality. |
262 | - ImageJPEG($images[0], IMAGE_PATH . $user->id . '.jpg'); |
|
263 | - ImageJPEG($images[1], IMAGE_PATH . $user->id . '_sm.jpg'); |
|
262 | + ImageJPEG($images[0], IMAGE_PATH.$user->id.'.jpg'); |
|
263 | + ImageJPEG($images[1], IMAGE_PATH.$user->id.'_sm.jpg'); |
|
264 | 264 | } |
265 | 265 | $response1 = sanitize_html($response1); |
266 | 266 | $response2 = sanitize_html($response2); |
267 | 267 | |
268 | - $has_picture = $has_picture?1:0; |
|
268 | + $has_picture = $has_picture ? 1 : 0; |
|
269 | 269 | if ($profile) { |
270 | 270 | $query = " response1 = '".BoincDb::escape_string($response1)."'," |
271 | 271 | ." response2 = '".BoincDb::escape_string($response2)."'," |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | page_tail(); |
308 | 308 | } |
309 | 309 | |
310 | -function show_profile_form($profile, $warning=null) { |
|
310 | +function show_profile_form($profile, $warning = null) { |
|
311 | 311 | if ($profile) { |
312 | 312 | page_head(tra("Edit your profile"), null, null, null, boinc_recaptcha_get_head_extra()); |
313 | 313 | } else { |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | // prefix for links; needed for pages not in top dir |
142 | 142 | $user, |
143 | 143 | // logged-in user, if any |
144 | - $fixed=false, |
|
144 | + $fixed = false, |
|
145 | 145 | // if true, navbar is fixed at top of page. |
146 | 146 | // NOTE: if you do this, you must set a global var $fixed_navbar |
147 | 147 | // to true at compile time |
148 | 148 | // (it needs to be set when page_head() is called). |
149 | - $inverse=false |
|
149 | + $inverse = false |
|
150 | 150 | // white on black? |
151 | 151 | ) { |
152 | 152 | $master_url = master_url(); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | // output a panel. |
247 | 247 | // $content_func is a function that generates the panel contents |
248 | 248 | // |
249 | -function panel($title, $content_func, $class="panel-primary", $body_class="") { |
|
249 | +function panel($title, $content_func, $class = "panel-primary", $body_class = "") { |
|
250 | 250 | echo sprintf('<div class="panel %s"> |
251 | 251 | ', $class |
252 | 252 | ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | // $left_width is the width of left column in 1/12 units. |
274 | 274 | // $arg is passed to the functions. |
275 | 275 | // |
276 | -function grid($top_func, $left_func, $right_func, $left_width=6, $arg=null) { |
|
276 | +function grid($top_func, $left_func, $right_func, $left_width = 6, $arg = null) { |
|
277 | 277 | echo ' |
278 | 278 | <div class="container-fluid"> |
279 | 279 | '; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | </div> |
289 | 289 | '; |
290 | 290 | } |
291 | - $right_width = 12-$left_width; |
|
291 | + $right_width = 12 - $left_width; |
|
292 | 292 | echo ' |
293 | 293 | <div class="row"> |
294 | 294 | <div class="col-sm-'.$left_width.'"> |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | // use extra = "name=x" |
313 | 313 | // call forum_focus(x, foo) after defining the field |
314 | 314 | // |
315 | -function form_start($action, $method='get', $extra='') { |
|
315 | +function form_start($action, $method = 'get', $extra = '') { |
|
316 | 316 | echo sprintf( |
317 | 317 | '<div class="container-fluid"> |
318 | 318 | <form class="form-horizontal" method="%s" action="%s" %s>' |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | // just the input field |
345 | 345 | // |
346 | 346 | function form_input_text_field( |
347 | - $name, $value='', $type='text', $attrs='', $extra='' |
|
347 | + $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
348 | 348 | ) { |
349 | 349 | return sprintf( |
350 | 350 | '<input %s type="%s" class="form-control" name="%s" value="%s">%s', |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | // the whole row |
356 | 356 | // |
357 | 357 | function form_input_text( |
358 | - $label, $name, $value='', $type='text', $attrs='', $extra='' |
|
358 | + $label, $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
359 | 359 | ) { |
360 | 360 | echo sprintf(' |
361 | 361 | <div class="form-group"> |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | ); |
384 | 384 | } |
385 | 385 | |
386 | -function form_input_textarea($label, $name, $value='', $nrows=4) { |
|
386 | +function form_input_textarea($label, $name, $value = '', $nrows = 4) { |
|
387 | 387 | echo sprintf(' |
388 | 388 | <div class="form-group"> |
389 | 389 | <label align=right class="%s" for="%s">%s</label> |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | // $items is either a string of <option> elements, |
401 | 401 | // or an array of [value, name] pairs |
402 | 402 | // |
403 | -function form_select($label, $name, $items, $selected=null) { |
|
403 | +function form_select($label, $name, $items, $selected = null) { |
|
404 | 404 | echo sprintf(' |
405 | 405 | <div class="form-group"> |
406 | 406 | <label align=right class="%s" for="%s">%s</label> |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | foreach ($items as $i) { |
414 | 414 | echo sprintf( |
415 | 415 | '<option %s value=%s>%s</option>', |
416 | - ($i[0]==$selected)?'selected':'', |
|
416 | + ($i[0] == $selected) ? 'selected' : '', |
|
417 | 417 | $i[0], $i[1] |
418 | 418 | ); |
419 | 419 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | // same, for multiple select. |
427 | 427 | // $selected, if non-null, is a list of selected values |
428 | 428 | // |
429 | -function form_select_multiple($label, $name, $items, $selected=null, $size=0) { |
|
429 | +function form_select_multiple($label, $name, $items, $selected = null, $size = 0) { |
|
430 | 430 | echo sprintf(' |
431 | 431 | <div class="form-group"> |
432 | 432 | <label align=right class="%s" for="%s">%s</label> |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | foreach ($items as $i) { |
439 | 439 | echo sprintf( |
440 | 440 | '<option %s value=%s>%s</option>', |
441 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
441 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
442 | 442 | $i[0], $i[1] |
443 | 443 | ); |
444 | 444 | } |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | |
448 | 448 | // return a list of strings for checkbox items |
449 | 449 | // |
450 | -function checkbox_item_strings($items, $attrs='') { |
|
450 | +function checkbox_item_strings($items, $attrs = '') { |
|
451 | 451 | $x = []; |
452 | 452 | foreach ($items as $i) { |
453 | 453 | $x[] = sprintf('<input %s type="checkbox" name="%s" %s> %s |
454 | 454 | ', |
455 | - $attrs, $i[0], $i[2]?"checked":"", $i[1] |
|
455 | + $attrs, $i[0], $i[2] ? "checked" : "", $i[1] |
|
456 | 456 | ); |
457 | 457 | } |
458 | 458 | return $x; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | |
461 | 461 | // $items is list of (name, label, checked) |
462 | 462 | // |
463 | -function form_checkboxes($label, $items, $attrs='') { |
|
463 | +function form_checkboxes($label, $items, $attrs = '') { |
|
464 | 464 | echo sprintf(' |
465 | 465 | <div class="form-group"> |
466 | 466 | <label align=right class="%s">%s</label> |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | // |
480 | 480 | function form_radio_buttons( |
481 | 481 | $label, $name, $items, $selected, |
482 | - $assign_ids=false // assign IDs to buttons based on names |
|
482 | + $assign_ids = false // assign IDs to buttons based on names |
|
483 | 483 | ) { |
484 | 484 | echo sprintf(' |
485 | 485 | <div class="form-group"> |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS |
490 | 490 | ); |
491 | 491 | foreach ($items as $i) { |
492 | - $checked = ($selected == $i[0])?"checked":""; |
|
492 | + $checked = ($selected == $i[0]) ? "checked" : ""; |
|
493 | 493 | if ($assign_ids) { |
494 | 494 | $id = sprintf('id="%s_%s"', $name, $i[0]); |
495 | 495 | } else { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | '; |
528 | 528 | } |
529 | 529 | |
530 | -function form_submit($text, $attrs='') { |
|
530 | +function form_submit($text, $attrs = '') { |
|
531 | 531 | form_general( |
532 | 532 | "", |
533 | 533 | sprintf( |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | ); |
538 | 538 | } |
539 | 539 | |
540 | -function form_checkbox($label, $name, $checked=false) { |
|
540 | +function form_checkbox($label, $name, $checked = false) { |
|
541 | 541 | echo sprintf(' |
542 | 542 | <div class="form-group"> |
543 | 543 | <label align=right class="%s">%s</label> |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | <input type="checkbox" name="%s" %s> |
550 | 550 | </div> |
551 | 551 | </div> |
552 | - ', $name, $checked?"checked":"" |
|
552 | + ', $name, $checked ? "checked" : "" |
|
553 | 553 | ); |
554 | 554 | } |
555 | 555 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | // $selected is the list of selected values. |
578 | 578 | // $extra is e.g. id=foo |
579 | 579 | // |
580 | -function form_select2_multi($label, $name, $items, $selected=null, $extra='') { |
|
580 | +function form_select2_multi($label, $name, $items, $selected = null, $extra = '') { |
|
581 | 581 | echo sprintf(' |
582 | 582 | <div class="form-group"> |
583 | 583 | <label align=right class="%s" for="%s">%s</label> |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | foreach ($items as $i) { |
590 | 590 | echo sprintf( |
591 | 591 | '<option %s value=%s>%s</option>', |
592 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
592 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
593 | 593 | $i[0], $i[1] |
594 | 594 | ); |
595 | 595 | } |