Skip to content

Commit 683cc12

Browse files
committed
Automated linting with php-cs-fixer.
1 parent e835799 commit 683cc12

13 files changed

Lines changed: 650 additions & 546 deletions

‎database_wizard.php‎

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/**
44
* \file
55
* \brief Create / Edit database connection
6-
*
6+
*
77
* Call: database_wizard.php
8-
*
8+
*
99
* PHP version 8.1
10-
*
10+
*
1111
* @category User_Interface
1212
* @package Lwt
1313
* @author HugoFara <hugo.farajallah@protonmail.com>
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* A connection to database stored as an object.
25-
*
25+
*
2626
* @category Database
2727
* @package Lwt
2828
* @author HugoFara <hugo.farajallah@protonmail.com>
@@ -54,15 +54,19 @@ class Database_Connection
5454

5555
/**
5656
* Build a new connection object.
57-
*
57+
*
5858
* @param string $server Server name
5959
* @param string $userid User ID
6060
* @param string $passwd Password for this user
6161
* @param string $dbname Database name
6262
* @param string $socket Socket to use
6363
*/
64-
function __construct(
65-
$server = "", $userid = "", $passwd = "", $dbname = "", $socket = ""
64+
public function __construct(
65+
$server = "",
66+
$userid = "",
67+
$passwd = "",
68+
$dbname = "",
69+
$socket = ""
6670
) {
6771
$this->server = $server;
6872
$this->userid = $userid;
@@ -73,11 +77,11 @@ function __construct(
7377

7478
/**
7579
* Load data from a PHP file.
76-
*
80+
*
7781
* The file is usually connect.inc.php or equivalent.
78-
*
82+
*
7983
* @param string $file_name PHP file to load data from.
80-
*
84+
*
8185
* @return void
8286
*/
8387
public function loadFile(string $file_name)
@@ -118,9 +122,9 @@ public function getAsText(): string
118122

119123
/**
120124
* Save the connection to the file connect.inc.php.
121-
*
125+
*
122126
* @param Database_Connection $conn Connection object.
123-
*
127+
*
124128
* @return void
125129
*/
126130
function writeToFile($conn)
@@ -132,9 +136,9 @@ function writeToFile($conn)
132136

133137
/**
134138
* Execute operation.
135-
*
139+
*
136140
* @param string $op Operation to execute.
137-
*
141+
*
138142
* @return void
139143
*/
140144
function doOperation($op)
@@ -151,8 +155,8 @@ function doOperation($op)
151155
$passwd = "";
152156
$dbname = (string) $_SERVER['SERVER_NAME'];
153157
$socket = "";
154-
} else if ($op == "Check") {
155-
$server = getreq("server");
158+
} elseif ($op == "Check") {
159+
$server = getreq("server");
156160
$userid = getreq("userid");
157161
$passwd = getreq("passwd");
158162
$dbname = getreq("dbname");
@@ -164,18 +168,26 @@ function doOperation($op)
164168
try {
165169
if ($socket != "") {
166170
$success = mysqli_real_connect(
167-
$conn, $server, $userid, $passwd, $dbname,
171+
$conn,
172+
$server,
173+
$userid,
174+
$passwd,
175+
$dbname,
168176
socket: $socket
169177
);
170178
} else {
171179
$success = mysqli_real_connect(
172-
$conn, $server, $userid, $passwd, $dbname
180+
$conn,
181+
$server,
182+
$userid,
183+
$passwd,
184+
$dbname
173185
);
174186
}
175187
if (!$success) {
176188
$message = "Can't connect!";
177-
} else if (mysqli_errno($conn) != 0) {
178-
$message = "ERROR: " . mysqli_error($conn) .
189+
} elseif (mysqli_errno($conn) != 0) {
190+
$message = "ERROR: " . mysqli_error($conn) .
179191
" error number: " . mysqli_errno($conn);
180192
} else {
181193
$message = "Connection established with success!";
@@ -184,15 +196,19 @@ function doOperation($op)
184196
$message = (string)$exept;
185197
}
186198
}
187-
} else if ($op == "Change") {
188-
$server = getreq("server");
199+
} elseif ($op == "Change") {
200+
$server = getreq("server");
189201
$userid = getreq("userid");
190202
$passwd = getreq("passwd");
191203
$dbname = getreq("dbname");
192204
$socket = getreq("socket");
193205
}
194206
$conn = new Database_Connection(
195-
$server, $userid, $passwd, $dbname, $socket
207+
$server,
208+
$userid,
209+
$passwd,
210+
$dbname,
211+
$socket
196212
);
197213
if ($op == "Change") {
198214
writeToFile($conn);
@@ -202,13 +218,13 @@ function doOperation($op)
202218

203219
/**
204220
* Generate a form to edit the connection.
205-
*
221+
*
206222
* @param Database_Connection $conn Database connection object
207223
* @param string|null $error_message Error message to display
208-
*
224+
*
209225
* @return void
210226
*/
211-
function displayForm($conn, $error_message=null)
227+
function displayForm($conn, $error_message = null)
212228
{
213229
pagestart_kernel_nobody("Database Connection Wizard");
214230
if ($error_message != null) {
@@ -257,7 +273,7 @@ function displayForm($conn, $error_message=null)
257273

258274
/**
259275
* Display the main form, filled with data from an existing connection file.
260-
*
276+
*
261277
* @return void
262278
*/
263279
function editConnection()
@@ -270,7 +286,7 @@ function editConnection()
270286

271287
/**
272288
* Display the main form blank.
273-
*
289+
*
274290
* @return void
275291
*/
276292
function createNewConnection()
@@ -280,7 +296,7 @@ function createNewConnection()
280296

281297
if (getreq('op') != '') {
282298
doOperation(getreq('op'));
283-
} else if (file_exists('connect.inc.php')) {
299+
} elseif (file_exists('connect.inc.php')) {
284300
editConnection();
285301
} else {
286302
createNewConnection();

‎delete_mword.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/**
44
* \file
55
* \brief Delete an expression
6-
*
6+
*
77
* Call: delete_mword.php?wid=[wordid]&tid=[textid]
8-
*
8+
*
99
* PHP version 8.1
10-
*
10+
*
1111
* @category Helper_Frame
1212
* @package Lwt
1313
* @author LWT Project <lwt-project@hotmail.com>
@@ -37,7 +37,7 @@
3737
$('.word<?php echo $wid; ?>', context).each(function(){
3838
sid = $(this).parent();
3939
$(this).remove();
40-
<?php
40+
<?php
4141
if (! $showAll) { ?>
4242
$('*',sid).removeClass('hide');
4343
$('.mword', sid).each(function(){

‎delete_word.php‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/**
44
* \file
55
* \brief Delete a word
6-
*
6+
*
77
* Call: delete_word.php?wid=[wordid]&tid=[textid]
8-
*
8+
*
99
* PHP version 8.1
10-
*
10+
*
1111
* @category Helper_Frame
1212
* @author LWT Project <lwt-project@hotmail.com>
1313
* @since 1.0.3
@@ -17,12 +17,12 @@
1717

1818
/**
1919
* Return the term corresponding to the ID.
20-
*
20+
*
2121
* @param string $wid ID of the word
22-
*
22+
*
2323
* @return string A word
24-
*
25-
* @global string $tbpref
24+
*
25+
* @global string $tbpref
2626
*/
2727
function get_term($wid)
2828
{
@@ -37,38 +37,38 @@ function get_term($wid)
3737

3838
/**
3939
* Edit the word from the database.
40-
*
40+
*
4141
* @param string $wid ID of the word to delete
42-
*
42+
*
4343
* @return string Some edit message, number of affected rows or error message
44-
*
45-
* @global string $tbpref
44+
*
45+
* @global string $tbpref
4646
*/
4747
function delete_word_from_database($wid)
4848
{
4949
global $tbpref;
5050
$m1 = runsql(
5151
'DELETE FROM ' . $tbpref . 'words
52-
WHERE WoID = ' . $wid,
52+
WHERE WoID = ' . $wid,
5353
''
5454
);
5555
adjust_autoincr('words', 'WoID');
5656
runsql(
5757
"UPDATE " . $tbpref . "textitems2
5858
SET Ti2WoID = 0
59-
WHERE Ti2WordCount=1 AND Ti2WoID = " . $wid,
59+
WHERE Ti2WordCount=1 AND Ti2WoID = " . $wid,
6060
''
6161
);
6262
return $m1;
6363
}
6464

6565
/**
6666
* Do the JavaScript action for changing display of the word.
67-
*
67+
*
6868
* @param string $wid ID of the word to delete
6969
* @param int $tid Text ID
70-
*
71-
* @return void
70+
*
71+
* @return void
7272
*/
7373
function delete_word_javascript($wid, $tid)
7474
{
@@ -118,12 +118,12 @@ function delete_word(wid) {
118118

119119
/**
120120
* Make the HTML content of the page when deleting a word.
121-
*
121+
*
122122
* @param int $tid Text ID
123123
* @param string $wid ID of the word to delete
124124
* @param string $term The deleted word
125125
* @param string $m1 Some edit message, number of affected rows or error message
126-
*
126+
*
127127
* @return void
128128
*/
129129
function delete_word_page_content($tid, $wid, $term, $m1)
@@ -139,15 +139,15 @@ function delete_word_page_content($tid, $wid, $term, $m1)
139139
* Complete workflow for deleting a word.
140140
* It edits the database, show the success message
141141
* and do JavaScript action to change its display.
142-
*
142+
*
143143
* @param int $textid ID of the affected text
144144
* @param string $wordid ID of the word to delete
145-
*
145+
*
146146
* @return void
147-
*
147+
*
148148
* @since 2.0.4-fork
149149
*/
150-
function do_delete_word($textid, $wordid)
150+
function do_delete_word($textid, $wordid)
151151
{
152152
$term = get_term($wordid);
153153
$m1 = delete_word_from_database($wordid);

0 commit comments

Comments
 (0)