Skip to content

Commit 93f5147

Browse files
authored
Merge pull request #176 from Mdwiki-TD/update_new
.
2 parents 190d694 + c90d77b commit 93f5147

File tree

13 files changed

+44
-48
lines changed

13 files changed

+44
-48
lines changed

src/Tables/include.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
include_once __DIR__ . '/sql_tables.php';
66
*/
77

8-
include_once __DIR__ . '/tables_dir.php';
9-
108
foreach (glob(__DIR__ . "/*.php") as $filename) {
11-
if ($filename == __FILE__) {
9+
if ($filename == __FILE__ || basename($filename) == 'langcode.php') {
1210
continue;
1311
}
1412
include_once $filename;
1513
}
14+
15+
include_once __DIR__ . '/langcode.php';

src/Tables/langcode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"zh-yue" : "yue"
4444
*/
4545
// ---
46-
require_once __DIR__ . '/tables.php';
46+
// require_once __DIR__ . '/tables.php';
4747

4848
use Tables\Main\MainTables;
4949

src/actions/curl_api.php renamed to src/api_calls/curl_api.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22

3-
namespace Actions\CurlApi;
3+
namespace APICalls\CurlApi;
44
/*
55
Usage:
6-
require_once __DIR__ . '/../actions/curl_api.php';
7-
use function Actions\CurlApi\post_url_params_result;
6+
use function APICalls\CurlApi\post_url_params_result;
87
*/
98

109
use function TD\Render\TestPrint\test_print;

src/actions/mdwiki_api.php renamed to src/api_calls/mdwiki_api.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace Actions\MdwikiApi;
3+
namespace APICalls\MdwikiApi;
44
/*
55
Usage:
6-
use function Actions\MdwikiApi\get_mdwiki_url_with_params;
6+
use function APICalls\MdwikiApi\get_mdwiki_url_with_params;
77
*/
88

99
use function TD\Render\TestPrint\test_print;
@@ -13,18 +13,22 @@ function post_url_mdwiki(string $endPoint, array $params = []): string
1313
$usr_agent = "WikiProjectMed Translation Dashboard/1.0 (https://mdwiki.toolforge.org/; [email protected])";
1414

1515
$ch = curl_init();
16-
17-
curl_setopt($ch, CURLOPT_URL, $endPoint);
18-
curl_setopt($ch, CURLOPT_POST, true);
19-
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
20-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
21-
// curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
22-
// curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
23-
curl_setopt($ch, CURLOPT_USERAGENT, $usr_agent);
24-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
25-
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
26-
16+
// ---
17+
curl_setopt_array($ch, [
18+
CURLOPT_URL => $endPoint,
19+
CURLOPT_POST => true,
20+
CURLOPT_POSTFIELDS => http_build_query($params),
21+
CURLOPT_RETURNTRANSFER => true,
22+
CURLOPT_USERAGENT => $usr_agent,
23+
CURLOPT_CONNECTTIMEOUT => 5,
24+
CURLOPT_TIMEOUT => 5,
25+
// لاستخدام ملفات الكوكيز عند الحاجة:
26+
// CURLOPT_COOKIEJAR => "cookie.txt",
27+
// CURLOPT_COOKIEFILE => "cookie.txt",
28+
]);
29+
// ---
2730
$output = curl_exec($ch);
31+
// ---
2832
$url = "{$endPoint}?" . http_build_query($params);
2933
// ---
3034
// remove "&format=json" from $url then make it link <a href="$url2">

src/actions/mdwiki_sql.php renamed to src/api_calls/mdwiki_sql.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
namespace Actions\MdwikiSql;
3+
namespace APICalls\MdwikiSql;
44
/*
55
Usage:
6-
use function Actions\MdwikiSql\fetch_query;
7-
use function Actions\MdwikiSql\execute_query;
6+
use function APICalls\MdwikiSql\fetch_query;
7+
use function APICalls\MdwikiSql\execute_query;
88
*/
99

1010
if (isset($_REQUEST['test']) || isset($_COOKIE['test'])) {

src/actions/wiki_api.php renamed to src/api_calls/wiki_api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
namespace Actions\WikiApi;
3+
namespace APICalls\WikiApi;
44
/*
55
Usage:
6-
use function Actions\WikiApi\make_view_by_number;
7-
use function Actions\WikiApi\get_views;
6+
use function APICalls\WikiApi\make_view_by_number;
7+
use function APICalls\WikiApi\get_views;
88
*/
99

1010
function make_view_by_number($target, $numb, $lang, $pupdate)

src/api_or_sql/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
1212
*/
1313

14-
use function Actions\MdwikiSql\fetch_query;
15-
use function Actions\TDApi\get_td_api;
14+
use function APICalls\MdwikiSql\fetch_query;
15+
use function APICalls\TDApi\get_td_api;
1616
use function TD\Render\TestPrint\test_print;
1717

1818
$settings_tabe = array_column(get_td_api(['get' => 'settings']), 'value', 'title');

src/include_all.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
include_once __DIR__ . '/include_first/include.php';
99

10-
foreach (glob(__DIR__ . "/actions/*.php") as $filename) {
10+
foreach (glob(__DIR__ . "/api_calls/*.php") as $filename) {
1111
include_once $filename;
1212
}
1313

src/Tables/tables_dir.php renamed to src/include_first/tables_dir.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,13 @@
1515

1616
use function TD\Render\TestPrint\test_print;
1717

18-
$tables_dir = __DIR__ . '/../../td/Tables';
19-
//---
20-
if (substr($tables_dir, 0, 2) == 'I:') {
21-
$tables_dir = 'I:/mdwiki/mdwiki/public_html/td/Tables';
22-
}
23-
//---
24-
if (!getenv('tables_dir')) {
25-
// set env
26-
putenv('tables_dir=' . $tables_dir);
27-
}
28-
2918
function open_td_Tables_file($path, $echo = true)
3019
{
31-
global $tables_dir;
20+
$tables_dir = getenv("HOME") . '/public_html/td/Tables';
21+
//---
22+
if (substr($tables_dir, 0, 2) == 'I:') {
23+
$tables_dir = 'I:/mdwiki/mdwiki/public_html/td/Tables';
24+
}
3225
//---
3326
$file_path = "$tables_dir/$path";
3427
//---

src/leaderboard/subs/lead_help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use Tables\Main\MainTables;
1717
use Tables\SqlTables\TablesSql;
18-
use function Actions\WikiApi\make_view_by_number;
18+
use function APICalls\WikiApi\make_view_by_number;
1919
use function TD\Render\Html\make_cat_url;
2020
use function TD\Render\Html\make_mdwiki_title;
2121
use function TD\Render\Html\make_target_url;

0 commit comments

Comments
 (0)