Skip to content

Commit af1ef69

Browse files
authored
Merge pull request #173 from Mdwiki-TD/update_new
Refactor includes and namespaces, consolidate init logic
2 parents f8bb201 + 60615d3 commit af1ef69

35 files changed

+176
-187
lines changed

src/404.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
http_response_code(404);
3-
4-
// Include header
3+
//---
4+
include_once __DIR__ . '/include_all.php';
55
include_once __DIR__ . '/header.php';
66
//---
77
function print_h3_title($h3_title)

src/Tables/include.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?PHP
22
/*
3-
include_once __DIR__ . '/tables_dir.php';
43
include_once __DIR__ . '/tables.php';
54
include_once __DIR__ . '/langcode.php';
65
include_once __DIR__ . '/sql_tables.php';
76
*/
7+
8+
include_once __DIR__ . '/tables_dir.php';
9+
810
foreach (glob(__DIR__ . "/*.php") as $filename) {
911
if ($filename == __FILE__) {
1012
continue;

src/Tables/sql_tables.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
include_once __DIR__ . '/Tables/sql_tables.php'; // Tables::$s_cat_titles Tables::$s_cat_to_camp Tables::$s_camp_to_cat
1616
*/
1717
//---
18-
include_once __DIR__ . '/../actions/load_request.php';
19-
include_once __DIR__ . '/../api_or_sql/index.php';
20-
//---
2118
use function SQLorAPI\GetDataTab\get_td_or_sql_translate_type;
2219
use function SQLorAPI\GetDataTab\get_td_or_sql_categories;
2320
use function SQLorAPI\GetDataTab\get_td_or_sql_settings;

src/Tables/tables.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
error_reporting(E_ALL);
1919
};
2020
//---
21-
include_once __DIR__ . '/../api_or_sql/index.php';
2221

2322
use function SQLorAPI\GetDataTab\get_td_or_sql_titles_infos;
2423
use function Tables\TablesDir\open_td_Tables_file;

src/api_or_sql/index.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
$use_td_api = $_GET['use_td_api'] != "x";
2424
}
2525

26-
include_once __DIR__ . '/get_lead.php';
27-
include_once __DIR__ . '/data_tab.php';
28-
include_once __DIR__ . '/process_data.php';
29-
include_once __DIR__ . '/top.php';
30-
include_once __DIR__ . '/funcs.php';
31-
3226
function isvalid($str)
3327
{
3428
return !empty($str) && strtolower($str) != "all";

src/header.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,11 @@
1212
//---
1313
include_once __DIR__ . '/userinfos_wrap.php';
1414
//---
15-
if (isset($GLOBALS['global_username']) && $GLOBALS['global_username'] != '') {
16-
$global_username = $GLOBALS['global_username'];
17-
} else {
18-
$GLOBALS['global_username'] = '';
19-
}
20-
//---
21-
include_once __DIR__ . '/renders/include.php';
15+
include_once __DIR__ . '/include_first/include.php';
2216
//---
2317
include_once __DIR__ . '/head.php';
24-
include_once __DIR__ . '/td_api_wrap/td_api.php';
25-
include_once __DIR__ . '/Tables/tables_dir.php';
26-
include_once __DIR__ . '/actions/mdwiki_sql.php';
27-
include_once __DIR__ . '/actions/html.php';
28-
include_once __DIR__ . '/api_or_sql/index.php';
2918
//---
30-
use function Actions\Html\banner_alert;
19+
use function TD\Render\Html\banner_alert;
3120
use function SQLorAPI\Funcs\get_coordinator;
3221
//---
3322
$coordinators = array_column(get_coordinator(), 'user');
@@ -43,7 +32,8 @@
4332
//---
4433
$coord_tools = "";
4534
//---
46-
if (in_array($GLOBALS['global_username'], $coordinators)) {
35+
// if (in_array($GLOBALS['global_username'], $coordinators)) {
36+
if ($GLOBALS['user_in_coord'] === true) {
4737
$coord_tools = '<a href="/tdc/index.php" class="nav-link py-2 px-0 px-lg-2"><span class="navtitles"></span> <i class="bi bi-tools me-1"></i> Coordinator Tools</a>';
4838
};
4939
//---

src/include_all.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?PHP
2+
3+
// foreach (glob(__DIR__ . "/*.php") as $filename) {
4+
// if ($filename == __FILE__) continue;
5+
// include_once $filename;
6+
// }
7+
8+
include_once __DIR__ . '/include_first/include.php';
9+
10+
foreach (glob(__DIR__ . "/actions/*.php") as $filename) {
11+
include_once $filename;
12+
}
13+
14+
foreach (glob(__DIR__ . "/td_api_wrap/*.php") as $filename) {
15+
include_once $filename;
16+
}
17+
18+
foreach (glob(__DIR__ . "/api_or_sql/*.php") as $filename) {
19+
include_once $filename;
20+
}
21+
22+
include_once __DIR__ . "/Tables/include.php";
23+
24+
include_once __DIR__ . '/leaderboard/include_leaderboards.php';
25+
26+
include_once __DIR__ . '/results/include.php';
File renamed without changes.

src/actions/html.php renamed to src/include_first/html.php

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

3-
namespace Actions\Html;
3+
namespace TD\Render\Html;
44
/*
55
https://live.datatables.net/lopevege/1/edit
66
77
Usage:
8-
use function Actions\Html\banner_alert;
9-
use function Actions\Html\login_card;
10-
use function Actions\Html\makeCard;
11-
use function Actions\Html\makeColSm4;
12-
use function Actions\Html\makeDropdown;
13-
use function Actions\Html\make_cat_url;
14-
use function Actions\Html\make_col_sm_body;
15-
use function Actions\Html\make_datalist_options;
16-
use function Actions\Html\make_drop;
17-
use function Actions\Html\make_form_check_input;
18-
use function Actions\Html\make_input_group;
19-
use function Actions\Html\make_input_group_no_col;
20-
use function Actions\Html\make_mdwiki_title;
21-
use function Actions\Html\make_mdwiki_user_url;
22-
use function Actions\Html\make_modal_fade;
23-
use function Actions\Html\make_project_to_user;
24-
use function Actions\Html\make_talk_url;
25-
use function Actions\Html\make_target_url;
26-
use function Actions\Html\make_translation_url;
8+
use function TD\Render\Html\banner_alert;
9+
use function TD\Render\Html\login_card;
10+
use function TD\Render\Html\makeCard;
11+
use function TD\Render\Html\makeColSm4;
12+
use function TD\Render\Html\makeDropdown;
13+
use function TD\Render\Html\make_cat_url;
14+
use function TD\Render\Html\make_col_sm_body;
15+
use function TD\Render\Html\make_datalist_options;
16+
use function TD\Render\Html\make_drop;
17+
use function TD\Render\Html\make_form_check_input;
18+
use function TD\Render\Html\make_input_group;
19+
use function TD\Render\Html\make_input_group_no_col;
20+
use function TD\Render\Html\make_mdwiki_title;
21+
use function TD\Render\Html\make_mdwiki_user_url;
22+
use function TD\Render\Html\make_modal_fade;
23+
use function TD\Render\Html\make_project_to_user;
24+
use function TD\Render\Html\make_talk_url;
25+
use function TD\Render\Html\make_target_url;
26+
use function TD\Render\Html\make_translation_url;
2727
*/
2828

2929

src/renders/include.php renamed to src/include_first/include.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
include_once __DIR__ . '/renders/include.php';
4+
include_once __DIR__ . '/include_first/include.php';
55
*/
66
foreach (glob(__DIR__ . "/*.php") as $filename) {
77
if ($filename == __FILE__) {

0 commit comments

Comments
 (0)