Skip to content

Commit 3c361c6

Browse files
authored
Merge pull request #180 from Mdwiki-TD/update_new
Update new
2 parents 13855fd + f571fe5 commit 3c361c6

File tree

16 files changed

+68
-64
lines changed

16 files changed

+68
-64
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ composer.lock
5151
phpunit.xml.dist
5252
phpunit.xml.z
5353
run.sh
54+
/src/.claude
55+
src/Plan.md
56+
tt.md

src/Tables/langcode.php

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

4847
use Tables\Main\MainTables;
4948

src/Tables/sql_tables.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use function Tables\SqlTables\load_translate_type;
1313
use function Tables\SqlTables\make_views_by_lang_target;
1414
15-
include_once __DIR__ . '/Tables/sql_tables.php'; // Tables::$s_cat_titles Tables::$s_cat_to_camp Tables::$s_camp_to_cat
1615
*/
1716
//---
1817
use function SQLorAPI\GetDataTab\get_td_or_sql_translate_type;

src/head.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ function get_host()
6363
"$hoste/ajax/libs/bootstrap-select/1.14.0-beta3/css/bootstrap-select.css",
6464
"$hoste/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css",
6565

66-
// "$hoste/ajax/libs/datatables.net-bs5/1.13.5/dataTables.bootstrap5.css",
67-
"$hoste/ajax/libs/datatables.net-bs5/2.2.2/dataTables.bootstrap5.css",
66+
// "$hoste/ajax/libs/datatables.net-bs5/1.13.5/dataTables.bootstrap5.min.css",
67+
"$hoste/ajax/libs/datatables.net-bs5/2.2.2/dataTables.bootstrap5.min.css",
6868
"$hoste/ajax/libs/datatables.net-responsive-bs5/3.0.4/responsive.bootstrap5.min.css",
6969

7070
"/Translation_Dashboard/css/mobile_format.css",
@@ -81,11 +81,11 @@ function get_host()
8181

8282
// "$hoste/ajax/libs/datatables.net/2.1.1/jquery.dataTables.min.js",
8383
// "$hoste/ajax/libs/datatables.net-bs5/1.13.5/dataTables.bootstrap5.min.js",
84-
"$hoste/ajax/libs/datatables.net/2.2.2/dataTables.js",
84+
"$hoste/ajax/libs/datatables.net/2.2.2/dataTables.min.js",
8585
"$hoste/ajax/libs/datatables.net-bs5/2.2.2/dataTables.bootstrap5.min.js",
8686

8787
// "$hoste/ajax/libs/datatables.net-fixedheader/3.4.0/dataTables.fixedHeader.min.js",
88-
"$hoste/ajax/libs/datatables-responsive/3.0.4/dataTables.responsive.js",
88+
"$hoste/ajax/libs/datatables-responsive/3.0.4/dataTables.responsive.min.js",
8989

9090
"/Translation_Dashboard/js/to.js",
9191
"/Translation_Dashboard/js/login.js",

src/leaderboard/index.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
</style>
1818
HTML;
1919
// ---
20-
$get = filter_input(INPUT_GET, 'get', FILTER_SANITIZE_SPECIAL_CHARS) ?? '';
20+
$get = filter_input(INPUT_GET, 'get', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
2121

22-
$langcode = filter_input(INPUT_GET, 'langcode', FILTER_SANITIZE_SPECIAL_CHARS) ?? '';
23-
$mainlang = filter_input(INPUT_GET, 'lang', FILTER_SANITIZE_SPECIAL_CHARS) ?? 'All';
22+
$langcode = filter_input(INPUT_GET, 'langcode', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
23+
$mainlang = filter_input(INPUT_GET, 'lang', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'All';
2424

25-
$mainuser = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_SPECIAL_CHARS) ?? '';
26-
$year_y = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_SPECIAL_CHARS) ?? 'All';
27-
$camp = filter_input(INPUT_GET, 'camp', FILTER_SANITIZE_SPECIAL_CHARS) ?? 'All';
25+
$user_to_html = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
26+
$user_to_curl = filter_input(INPUT_GET, 'user', FILTER_UNSAFE_RAW) ?? '';
27+
28+
$year_y = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'All';
29+
$camp = filter_input(INPUT_GET, 'camp', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'All';
2830

2931
//---
30-
if ($get == 'users' || !empty($mainuser)) {
32+
if ($get == 'users' || !empty($user_to_curl)) {
3133
// ---
32-
echo users_html($mainlang, $mainuser, $year_y, $camp);
34+
echo users_html($mainlang, $year_y, $camp, $user_to_curl, $user_to_html);
3335
// ---
3436
} elseif ($get == 'langs' || !empty($langcode)) {
3537
// ---
@@ -52,8 +54,8 @@
5254
// ---
5355
} else {
5456
//---
55-
$user_group = filter_input(INPUT_GET, 'project', FILTER_SANITIZE_SPECIAL_CHARS)
56-
?? filter_input(INPUT_GET, 'user_group', FILTER_SANITIZE_SPECIAL_CHARS)
57+
$user_group = filter_input(INPUT_GET, 'project', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
58+
?? filter_input(INPUT_GET, 'user_group', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
5759
?? 'all';
5860
//---
5961
echo main_leaderboard($year_y, $camp, $user_group);

src/leaderboard/subs/lead_help.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ function make_key($Taab)
5050
return $kry;
5151
}
5252

53-
function make_td_fo_user($tabb, $number, $view_number, $word, $page_type = 'users', $tab_ty = 'a', $_user_ = '')
53+
function make_td_fo_user($tabb, $number, $view_number, $word, $page_type, $tab_ty, $user_is_global_username)
5454
{
55+
//---
56+
// $page_type = 'users' or 'langs' only
57+
if ($page_type != 'users' && $page_type != 'langs') {
58+
$page_type = 'users';
59+
};
5560
//---
5661
$catto_camp_new = TablesSql::$s_cat_to_camp;
5762
$articlesto_camps = get_articles_to_camps();
@@ -128,7 +133,7 @@ function make_td_fo_user($tabb, $number, $view_number, $word, $page_type = 'user
128133
//---
129134
// $tralink = make_translation_url($mdtitle, $lang, $tran_type);
130135
$tralink = make_translate_link_medwiki($mdtitle, $lang, $cat, "", $tran_type);
131-
$complete = ($GLOBALS['global_username'] === $_user_) ? "<td data-content='complete'><a target='_blank' href='$tralink'>complete</a></td>" : '';
136+
$complete = ($user_is_global_username) ? "<td data-content='complete'><a target='_blank' href='$tralink'>complete</a></td>" : '';
132137
} else {
133138
$target = trim($tabb['target']);
134139
//---
@@ -177,7 +182,7 @@ function make_td_fo_user($tabb, $number, $view_number, $word, $page_type = 'user
177182
//---
178183
};
179184

180-
function make_table_lead($dd, $tab_type, $views_table, $page_type, $user, $lang)
185+
function make_table_lead($dd, $tab_type, $views_table, $page_type, $user_is_global_username)
181186
{
182187
$total_words = 0;
183188
$total_views = 0;
@@ -191,7 +196,7 @@ function make_table_lead($dd, $tab_type, $views_table, $page_type, $user, $lang)
191196
//---
192197
$tab_views = ($tab_type == 'pending') ? '' : '<th>Views</th>';
193198
$th_Date = ($tab_type == 'pending') ? 'Start date' : 'Date';
194-
$complete = ($tab_type == 'pending' && $GLOBALS['global_username'] === $user) ? '<th>complete!</th>' : '';
199+
$complete = ($tab_type == 'pending' && $user_is_global_username) ? '<th>complete!</th>' : '';
195200
//---
196201
$leadtable = ($tab_type == 'pending') ? 'leadtable2' : 'leadtable';
197202
//---
@@ -244,7 +249,7 @@ function make_table_lead($dd, $tab_type, $views_table, $page_type, $user, $lang)
244249
//---
245250
$total_words += $word;
246251
//---
247-
$table2 .= make_td_fo_user($tabe, $noo, $view_number, $word, $page_type = $page_type, $tab_ty = $tab_type, $_user_ = $user);
252+
$table2 .= make_td_fo_user($tabe, $noo, $view_number, $word, $page_type, $tab_type, $user_is_global_username);
248253
};
249254
//---
250255
$table2 .= <<<HTML
@@ -259,15 +264,15 @@ function make_table_lead($dd, $tab_type, $views_table, $page_type, $user, $lang)
259264
return [$table1, $table2];
260265
}
261266

262-
function make_users_lead($tab, $tab_type, $views_table, $user)
267+
function make_users_lead($tab, $tab_type, $views_table, $user_is_global_username)
263268
{
269+
//---
264270
[$_, $table_pnd] = make_table_lead(
265271
$tab,
266272
$tab_type,
267273
$views_table,
268274
'users',
269-
$user,
270-
""
275+
$user_is_global_username
271276
);
272277
// ---
273278
return [$_, $table_pnd];
@@ -280,8 +285,7 @@ function make_langs_lead($tab, $tab_type, $views_table, $lang)
280285
$tab_type,
281286
$views_table,
282287
'langs',
283-
"",
284-
$lang
288+
false
285289
);
286290
// ---
287291
return [$_, $table_pnd];

src/leaderboard/users.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,37 @@
1717
use function Leaderboard\Subs\FilterForm\lead_row;
1818
use function SQLorAPI\TopData\get_td_or_sql_top_lang_of_users;
1919

20-
function users_html($mainlang, $mainuser, $year_y, $camp)
20+
// users_html($mainlang, $mainuser, $year_y, $camp)
21+
function users_html($mainlang, $year_y, $camp, $user_to_curl, $user_to_html)
2122
{
2223
$output = '';
2324
//---
2425
$mainlang = rawurldecode(str_replace('_', ' ', $mainlang));
2526
//---
2627
// '[{"user":"Mr. Ibrahem","lang":"ar","cnt":14}]'
27-
$user_langs = get_td_or_sql_top_lang_of_users([$mainuser]);
28+
$user_most_langs = get_td_or_sql_top_lang_of_users([$user_to_curl]);
2829
//---
29-
$user_most_lang = $user_langs[0]['lang'] ?? "";
30+
$user_langs = $user_most_langs[0]['lang'] ?? "";
3031
//---
31-
$u_tables = get_users_tables($mainuser, $year_y, $mainlang);
32+
$u_tables = get_users_tables($user_to_curl, $year_y, $mainlang);
3233
//---
3334
$dd = $u_tables['dd'];
3435
$dd_Pending = $u_tables['dd_Pending'];
3536
$table_of_views = $u_tables['table_of_views'];
3637
//---
3738
$count_new = count($dd);
3839
//---
39-
[$table1, $main_table] = make_users_lead($dd, 'translations', $table_of_views, $mainuser);
40+
$user_is_global_username = ($GLOBALS['global_username'] === $user_to_curl) ? true : false;
4041
//---
41-
$user_link = ($user_most_lang) ? make_target_url("User:$mainuser", $user_most_lang, $mainuser) : make_mdwiki_user_url($mainuser);
42+
[$table1, $main_table] = make_users_lead($dd, 'translations', $table_of_views, $user_is_global_username);
4243
//---
43-
$graph = graph_data_new($dd);
44+
$user_link = ($user_langs) ? make_target_url("User:$user_to_curl", $user_langs, $user_to_html) : make_mdwiki_user_url($user_to_html);
4445
//---
45-
$filter_data = ["user" => $mainuser, "lang" => $mainlang, "year" => $year_y, "camp" => $camp];
46+
$filter_data = ["user" => $user_to_curl, "lang" => $mainlang, "year" => $year_y, "camp" => $camp];
4647
//---
4748
$xtools = <<<HTML
4849
<!-- <div class="d-flex align-items-center justify-content-between"> -->
49-
<a href='https://xtools.wmflabs.org/globalcontribs/$mainuser' target='_blank'>
50+
<a href='https://xtools.wmflabs.org/globalcontribs/$user_to_html' target='_blank'>
5051
<!-- <span class='h4'>(XTools)</span> -->
5152
<img src='https://xtools.wmcloud.org/build/images/logo.svg' title='Xtools' width='80px'/>
5253
</a>
@@ -61,6 +62,8 @@ function users_html($mainlang, $mainuser, $year_y, $camp)
6162
</span>
6263
HTML;
6364
//---
65+
$graph = graph_data_new($dd);
66+
//---
6467
$output .= lead_row($table1, $graph, $user_div, $filter_data, "user");
6568
//---
6669
$output .= <<<HTML
@@ -71,7 +74,7 @@ function users_html($mainlang, $mainuser, $year_y, $camp)
7174
</div>
7275
HTML;
7376
//---
74-
[$_, $table_pnd] = make_users_lead($dd_Pending, 'pending', $table_of_views, $mainuser);
77+
[$_, $table_pnd] = make_users_lead($dd_Pending, 'pending', $table_of_views, $user_is_global_username);
7578
//---
7679
$output .= <<<HTML
7780
<br>

src/leaderboard/x.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
use function Leaderboard\Filter\leaderboard_filter;
1313

1414
//---
15-
$year = strtolower(filter_input(INPUT_GET, 'year', FILTER_SANITIZE_SPECIAL_CHARS) ?? 'all');
16-
$camp = strtolower(filter_input(INPUT_GET, 'camp', FILTER_SANITIZE_SPECIAL_CHARS) ?? 'all');
15+
$year = strtolower(filter_input(INPUT_GET, 'year', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'all');
16+
$camp = strtolower(filter_input(INPUT_GET, 'camp', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 'all');
1717

18-
$user_group = filter_input(INPUT_GET, 'project', FILTER_SANITIZE_SPECIAL_CHARS)
19-
?? filter_input(INPUT_GET, 'user_group', FILTER_SANITIZE_SPECIAL_CHARS)
18+
$user_group = filter_input(INPUT_GET, 'project', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
19+
?? filter_input(INPUT_GET, 'user_group', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
2020
?? 'all';
2121
//---
2222
$user_group = strtolower($user_group);

src/loaders/load_request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function load_request()
4141
}
4242
// if (empty($cat)) $cat = "RTT";
4343
//---
44-
$tra_type = filter_input(INPUT_GET, 'type', FILTER_SANITIZE_SPECIAL_CHARS) ?? '';
44+
$tra_type = filter_input(INPUT_GET, 'type', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
4545
//---
4646
$doit = $doit !== "";
4747
//---

src/results/get_results.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function get_results($cat, $camp, $depth, $code): array
6363

6464
// Prepare category URL
6565
$cat2 = "Category:" . str_replace('Category:', '', $cat);
66-
$caturl = "<a href='https://mdwiki.org/wiki/$cat2'>category</a>";
66+
$caturl = "<a href='https://mdwiki.org/wiki/$cat2' target='_blank'>category</a>";
6767

6868
// Generate summary message
69-
$ix = "Found $len_of_all pages in $caturl, $len_of_exists_pages exists, and $len_of_missing_pages missing in (<a href='https://$code.wikipedia.org'>$code</a>), $len_inprocess In process.";
69+
$ix = "Found $len_of_all pages in $caturl, $len_of_exists_pages exists, and $len_of_missing_pages missing in (<a href='https://$code.wikipedia.org' target='_blank'>$code</a>), $len_inprocess In process.";
7070

7171
// Remove in-process items from missing list
7272
if ($len_inprocess > 0) {

0 commit comments

Comments
 (0)