Skip to content

Commit 98f35b2

Browse files
committed
I updated various dictionary keys and improved various code comments to make it more beautiful and organized.
On the year websites, I added the new tabs "Game sessions played" and "Goodbye". The "Goodbye" tab is to show the goodbye text for the year.
1 parent f22141d commit 98f35b2

File tree

94 files changed

+2741
-19638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2741
-19638
lines changed

Diff for: Additional folders.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
];
1919

2020
# "Done tasks" folder
21-
$folder_name = $website["texts"]["done_tasks"][$local_language];
21+
$folder_name = $website["Texts"]["done_tasks"][$local_language];
2222
$key = "done_tasks";
2323

2424
$folders["Mega"]["Notepad"]["Years"][$year][$local_language][$key] = [
2525
"root" => $folders["Mega"]["Notepad"]["Years"][$year][$local_language]["root"].$folder_name."/"
2626
];
2727

2828
# "Watched media" folder
29-
$folder_name = $website["texts"]["watched_media"][$local_language];
29+
$folder_name = $website["Texts"]["watched_media"][$local_language];
3030
$key = "watched_media";
3131

3232
$folders["Mega"]["Notepad"]["Years"][$year][$local_language][$key] = [

Diff for: Classes/Date.php

+110-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
# Date.php
44

55
class Date extends Class_ {
6+
# Define the static "texts" variable
7+
static $texts;
8+
69
public function __construct() {
10+
global $folders;
11+
global $JSON;
12+
713
parent::__construct(self::class);
14+
15+
# Read the "Texts.json" file of the "Date" Python module
16+
static::$texts = $JSON -> To_PHP($folders["Apps"]["Module files"]["Utility"]["Date"]["Texts"]);
817
}
918

1019
public static function Now($string = "", $format = "", $object = "") {
@@ -33,11 +42,11 @@ public static function Now($string = "", $format = "", $object = "") {
3342
]
3443
];
3544

36-
foreach ($website["texts"]["date_format"] as $text) {
45+
foreach ($website["Texts"]["date_format"] as $text) {
3746
$date[$text] = $object -> format($text);
3847
}
3948

40-
foreach ($website["texts"]["date_time_format"] as $text) {
49+
foreach ($website["Texts"]["date_time_format"] as $text) {
4150
$date[$text] = $object -> format($text);
4251
}
4352

@@ -54,6 +63,105 @@ public static function From_Unix($datetime, $timestamp) {
5463
return $datetime;
5564
}
5665

66+
public static function Make_Time_Text($date) {
67+
global $website;
68+
global $Language;
69+
70+
# Transform the text key into a dictionary if it is a string
71+
if (
72+
isset($date["Text"]) &&
73+
is_string($date["Text"])
74+
) {
75+
$date["Text"] = [];
76+
}
77+
78+
if (isset($date["Difference"]) == False) {
79+
$date = [
80+
"Text" => [],
81+
"Difference" => $date
82+
];
83+
}
84+
85+
foreach ($website["languages"]["small"] as $language) {
86+
$date["Text"][$language] = "";
87+
}
88+
89+
# Define the keys and remove the "Text" key
90+
$keys = array_keys($date["Difference"]);
91+
92+
# List the keys to remove
93+
$keys_to_remove = [
94+
"Before",
95+
"After",
96+
"Object",
97+
"Difference",
98+
"Unit texts",
99+
"Text"
100+
];
101+
102+
# Remove the unused keys
103+
foreach ($keys_to_remove as $key_to_remove) {
104+
if (in_array($key_to_remove, $keys)) {
105+
$key_index = array_search($key_to_remove, $keys);
106+
107+
unset($keys[$key_index]);
108+
}
109+
}
110+
111+
$languages = $website["languages"]["small"];
112+
$languages = array_diff($languages, ["general"]);
113+
114+
# Make the time texts per language
115+
foreach ($keys as $key) {
116+
foreach ($languages as $language) {
117+
# If the key is the last one and the number of time attributes is 2 or more than 2, add the "and " text
118+
if ($key == end($keys)) {
119+
if (
120+
count($keys) > 2 or
121+
count($keys) == 2
122+
) {
123+
$date["Text"][$language] .= $website["Texts"]["and"][$language]." ";
124+
}
125+
}
126+
127+
# Define the text key
128+
$text_key = strtolower($key);
129+
130+
$number = $date["Difference"][$key];
131+
$singular = substr($text_key, 0, strlen($text_key) - 1);
132+
$plural = $text_key;
133+
134+
$text_key = Text::By_Number($number, $singular, $plural);
135+
136+
# Define the time text
137+
$text = self::$texts[$text_key][$language];
138+
139+
if (isset($date["Unit texts"])) {
140+
$text = $date["Unit texts"][$key][$language];
141+
}
142+
143+
# Add the number and the time text (plural or singular)
144+
$date["Text"][$language] .= $date["Difference"][$key]." ".$text;
145+
146+
# If the number of time attributes is equal to 2, add a space
147+
if (count($keys) == 2) {
148+
$date["Text"][$language] .= " ";
149+
}
150+
151+
# If the key is not the last one
152+
# And the number of time attributes is more than 2, add the ", " text (comma)
153+
if (
154+
$key != end($keys) &&
155+
count($keys) > 2
156+
) {
157+
$date["Text"][$language] .= ", ";
158+
}
159+
}
160+
}
161+
162+
return $date["Text"];
163+
}
164+
57165
public static function Create_Years_List($mode = "array", $start = 2018, $plus = 0, $function = "string", $string_format = Null) {
58166
$array = [];
59167

Diff for: Classes/File.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ public function Extension($file, $add_dot = True) {
4040
}
4141

4242
public function Create($file) {
43-
43+
if (
44+
$this -> switches["testing"] == False and
45+
$this -> Exist($file) == False
46+
) {
47+
fopen($file, "w");
48+
}
4449
}
4550

4651
public function Delete($file) {

Diff for: Classes/Global_Switches.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function __construct() {
1313
];
1414

1515
# Global Switches dictionary
16-
$this -> switches = $this -> JSON_To_PHP($folders["mega"]["php"]["classes"]["text_files"]["switches"]);
16+
$this -> switches = $this -> JSON_To_PHP($folders["Mega"]["PHP"]["Classes"]["Text files"]["Switches"]);
1717
}
1818

1919
public function JSON_To_PHP($file) {
@@ -47,7 +47,7 @@ public function Switch($switches = Null) {
4747
}
4848
}
4949

50-
$this -> Edit($folders["mega"]["php"]["classes"]["text_files"]["switches"], $switches);
50+
$this -> Edit($folders["Mega"]["PHP"]["Classes"]["Text files"]["Switches"], $switches);
5151

5252
return True;
5353
}

Diff for: Classes/HTML.php

+32-27
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
class HTML extends Class_ {
66
public function __construct() {
7-
global $folders;
8-
97
parent::__construct(self::class);
10-
11-
$this -> folders = $folders;
128
}
139

1410
public static function Element($element, $text = "", $attributes = "", $class = "", $tab = []) {
@@ -41,7 +37,10 @@ public static function Element($element, $text = "", $attributes = "", $class =
4137
$tabs["text"] .= "\t\t";
4238
}
4339

44-
if (isset($tab["one"]) == False and in_array($element, $self_closing_elements) == True) {
40+
if (
41+
isset($tab["one"]) == False and
42+
in_array($element, $self_closing_elements) == True
43+
) {
4544
if (isset($tab["tab"]) == False) {
4645
$tabs["first"] .= "\t";
4746
}
@@ -53,7 +52,10 @@ public static function Element($element, $text = "", $attributes = "", $class =
5352

5453
$tabs["text_less_one"] = substr_replace($tabs["text"], "", -1);
5554

56-
if (isset($tab["tab"]) == True and substr_count($tab["tab"], "\t") == 2) {
55+
if (
56+
isset($tab["tab"]) == True and
57+
substr_count($tab["tab"], "\t") == 2
58+
) {
5759
$tabs["text_less_one"] = $tabs["text"];
5860
}
5961

@@ -100,7 +102,7 @@ public static function Image($source, $class = "", $attributes = "") {
100102
global $website;
101103

102104
if ($class == "") {
103-
$class = $website["data"]["style"]["img"]["theme"]["dark"]." ".$website["style"]["box_shadow"]["theme"]["light"];
105+
$class = $website["Data"]["Style"]["img"]["theme"]["dark"]." ".$website["Style"]["box_shadow"]["theme"]["light"];
104106
}
105107

106108
return HTML::Element("img", "", 'src="'.$source.'"'.$attributes, $class);
@@ -135,15 +137,15 @@ function ($key) {
135137
public static function Button($text = "", $attributes = "", $class = "", $heading = "h3") {
136138
global $website;
137139

138-
$class = $website["style"]["button"]["theme"]["light"].$class;
140+
$class = $website["Style"]["button"]["theme"]["light"].$class;
139141

140142
$text_attributes = "";
141143

142144
if ($heading == "h3") {
143145
$text_attributes = 'style="font-weight: bold;"';
144146
}
145147

146-
$text = HTML::Element($heading, "\n\t\t".$text."\n\t\t", $text_attributes, "text_size ".$website["style"]["text"]["theme"]["dark"])."\n";
148+
$text = HTML::Element($heading, "\n\t\t".$text."\n\t\t", $text_attributes, "text_size ".$website["Style"]["text"]["theme"]["dark"])."\n";
147149

148150
$button = "\n\n\t".HTML::Element("button", "\n\t\t".$text."\t", $attributes, "w3-btn ".$class);
149151

@@ -164,7 +166,7 @@ public static function Tab_Button($tab) {
164166
}
165167

166168
$button = '<!-- "'.$tab["name"].'" button -->'."\n".
167-
"\t".'<span id="button_'.($i + 1).'" class="tab_button">'."\n\t\t".self::Button("\n\t\t\t\t".$tab["name_icon"]."\n\t\t\t", ' onclick="Open_Tab(\''.strtolower($tab["id"]).'\');" style="border-radius: 50px;'.$tab["button_style"].'"', "w3-btn ".$website["style"]["button"]["theme"]["light"].$tab["button_class"], "h2")."\n\t"."</span>";
169+
"\t".'<span id="button_'.($i + 1).'" class="tab_button">'."\n\t\t".self::Button("\n\t\t\t\t".$tab["name_icon"]."\n\t\t\t", ' onclick="Open_Tab(\''.strtolower($tab["id"]).'\');" style="border-radius: 50px;'.$tab["button_style"].'"', "w3-btn ".$website["Style"]["button"]["theme"]["light"].$tab["button_class"], "h2")."\n\t"."</span>";
168170

169171
return $button;
170172
}
@@ -174,21 +176,21 @@ public static function Generate_Buttons() {
174176
global $Language;
175177
global $i;
176178

177-
$show_text = HTML::Element("h2", "\n\t\t".$website["icons"]["bars"]."\n\t", "", "text_size")."\n";
179+
$show_text = HTML::Element("h2", "\n\t\t".$website["Icons"]["bars"]."\n\t", "", "text_size")."\n";
178180
$hide_text = HTML::Element("h4", "\n\t\t"."X"."\n\t\t", 'style="font-weight: bold;"', "text_size")."\n";
179181

180-
$border_color = $website["style"]["border_color"];
182+
$border_color = $website["Style"]["border_color"];
181183

182184
$buttons = [
183185
"list" => [],
184186

185187
"hamburger_menu" => "\n"."<!-- Open hamburger menu button -->"."\n".
186-
HTML::Element("button", "\n\t".$show_text, 'id="hamburger_menu_button" onclick="Show_Hamburger_Menu();" style="position: fixed; left: 0%;"', "w3-btn ".$website["style"]["button"]["theme"]["light"]." w3-animate-zoom")."\n".
188+
HTML::Element("button", "\n\t".$show_text, 'id="hamburger_menu_button" onclick="Show_Hamburger_Menu();" style="position: fixed; left: 0%;"', "w3-btn ".$website["Style"]["button"]["theme"]["light"]." w3-animate-zoom")."\n".
187189
"\n"."<!--- Hamburger menu -->"."\n".
188-
'<div id="hamburger_menu" class="w3-container w3-animate-left '.$website["style"]["background"]["theme"]["normal"]." ".$website["style"]["border_4px"]["theme"][$border_color]." ".$website["style"]["border_radius"].'" style="padding: 1%; position: fixed; display: none;">'."\n\n".
190+
'<div id="hamburger_menu" class="w3-container w3-animate-left '.$website["Style"]["background"]["theme"]["normal"]." ".$website["Style"]["border_4px"]["theme"][$border_color]." ".$website["Style"]["border_radius"].'" style="padding: 1%; position: fixed; display: none;">'."\n\n".
189191
"\t".'<!-- Hide hamburger menu button -->'."\n".
190-
"\t".HTML::Element("button", "\n\t\t".$hide_text."\t", ' onclick="Hide_Hamburger_Menu();" style="float: right; padding: 2px 14px 3px 14px !important;"', "w3-btn ".$website["style"]["button"]["theme"]["light"])."\n\n".
191-
"\t".HTML::Element("h2", $website["language_texts"]["tab_menu"].": ", 'style="font-weight: bold;"', "text_size ".$website["style"]["text_highlight"])."\n\n".
192+
"\t".HTML::Element("button", "\n\t\t".$hide_text."\t", ' onclick="Hide_Hamburger_Menu();" style="float: right; padding: 2px 14px 3px 14px !important;"', "w3-btn ".$website["Style"]["button"]["theme"]["light"])."\n\n".
193+
"\t".HTML::Element("h2", $website["Language texts"]["tab_menu"].": ", 'style="font-weight: bold;"', "text_size ".$website["Style"]["text_highlight"])."\n\n".
192194
"\t"."<br />"."\n\n".
193195
'<div style="overflow-y: auto; overflow-x: hidden; max-height: 80vh;">'."\n"
194196
];
@@ -216,7 +218,7 @@ public static function Generate_Buttons() {
216218
foreach($buttons["list"] as $button) {
217219
$buttons["hamburger_menu"] .= "\t".$button;
218220

219-
if ($button != array_reverse($buttons["list"])[0]) {
221+
if ($button != end($buttons["list"])) {
220222
$buttons["hamburger_menu"] .= "\n\n";
221223
}
222224
}
@@ -292,7 +294,7 @@ public static function Generate_Buttons_List($tab = [], $remove = "", $center =
292294
$string .= $tab["button"];
293295
}
294296

295-
$string .= $website["elements"]["hr_1px"]["theme"][$website["style"]["border_color"]];
297+
$string .= $website["elements"]["hr_1px"]["theme"][$website["Style"]["border_color"]];
296298

297299
if ($center == True) {
298300
$string .= "</center>";
@@ -332,7 +334,7 @@ public static function Tab_Info($tab, $i) {
332334
# If file is empty, use empty message text
333335
if ($contents["lines"] == []) {
334336
if (isset($tab["empty_message"]) == False) {
335-
$tab["empty_message"] = $website["language_texts"]["this_file_does_not_exist_{}"];
337+
$tab["empty_message"] = $website["Language texts"]["this_file_does_not_exist_{}"];
336338
}
337339

338340
$tab["content"] = $tab["empty_message"];
@@ -344,7 +346,7 @@ public static function Tab_Info($tab, $i) {
344346
}
345347

346348
else {
347-
$tab["content"] = self::Element("span", $tab["content"], "", $website["data"]["style"]["text_highlight"]);
349+
$tab["content"] = self::Element("span", $tab["content"], "", $website["Data"]["Style"]["text_highlight"]);
348350
}
349351

350352
# Define tab name in the user language
@@ -368,19 +370,22 @@ public static function Tab_Info($tab, $i) {
368370
# Define title if it is not present
369371
if (isset($tab["title"]) == False) {
370372
if (str_contains($tab["name"], ": ") == False) {
371-
$tab["title"] = $tab["name"].": ".$website["icons"][$tab["icon"]];
373+
$tab["title"] = $tab["name"].": ".$website["Icons"][$tab["icon"]];
372374
}
373375

374376
if (str_contains($tab["name"], ": ") == True) {
375-
$tab["title"] = $tab["name"].": ".$website["icons"][$tab["icon"]];
377+
$tab["title"] = $tab["name"].": ".$website["Icons"][$tab["icon"]];
376378
}
377379
}
378380

379-
$tab["name_icon"] = $tab["name"].": ".$website["icons"][$tab["icon"]];
381+
$tab["name_icon"] = $tab["name"].": ".$website["Icons"][$tab["icon"]];
380382

381383
# Define tab content with content file
382-
if (isset($tab["content"]) == False and isset($tab["template"]) == False) {
383-
$tab["content_file"] = $website["data"]["folders"]["php"]["tabs"].($i + 1).".php";
384+
if (
385+
isset($tab["content"]) == False and
386+
isset($tab["template"]) == False
387+
) {
388+
$tab["content_file"] = $website["Data"]["Folders"]["PHP"]["Tabs"].($i + 1).".php";
384389

385390
if (file_exists($tab["content_file"]) == False) {
386391
$File -> Edit($tab["content_file"], "<?php "."\n\n\n\n"."?>", "w");
@@ -450,14 +455,14 @@ public static function Generate_Tabs($tabs_data = Null, $buttons = True, $all_bu
450455
$tab = self::Tab_Info($tab, $tabs["ID"]);
451456

452457
# Define CSS class
453-
$tab["class"] = $website["style"]["tab"]["black"];
458+
$tab["class"] = $website["Style"]["tab"]["black"];
454459

455460
if (isset($tab["content"]) == True) {
456461
$tab["content"] .= "\n";
457462
}
458463

459464
# Generate the tab HTML
460-
$tab["content"] = "<center>".self::Tab($tab)."</center>";
465+
$tab["content"] = "<center>"."\n\n".self::Tab($tab)."\n\n"."</center>";
461466

462467
# Add tab to the tabs array
463468
array_push($tabs["List"], $tab["name"]);

0 commit comments

Comments
 (0)