-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSummary.php
76 lines (57 loc) · 2.46 KB
/
Summary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
# Summary
$file = $website["Data"]["Files"]["summary"];
if (file_exists($file) == True) {
# Read the year summary file
$contents = $File -> Contents($file);
# Define some style templates
$span = HTML::Element("span", "{}", "", $website["Style"]["text_highlight"]);
$span_bold = HTML::Element("span", "{}", 'style="font-weight: bold;"');
$span_bold_color = HTML::Element("span", "{}", 'style="font-weight: bold;"', $website["Style"]["text_highlight"]);
$margin = HTML::Element("span", "{}", 'style="margin-left: 3%;"');
if ($contents["lines"] != []) {
# Add a bold style to the first line
$contents["lines"][0] = Text::Format($span_bold, $contents["lines"][0]);
$i = 0;
foreach ($contents["lines"] as $line) {
# Paint date time text with parenthesis
$line = preg_replace("/\([0-9][0-9]\:[0-9][0-9] [0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]\)/i", Text::Format($span, "$0"), $line);
# Paint date time text
$line = preg_replace("/[0-9][0-9]\:[0-9][0-9] [0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]/i", Text::Format($span, "$0"), $line);
# Paint done things texts on headers
preg_match("/^[a-zA-Z].*: /i", $line, $matches);
foreach ($matches as $match) {
$match = str_replace(": ", "", $match);
$line = str_replace($match, Text::Format($span_bold, $match), $line);
}
# Paint list headers
$line = preg_replace("/^.*:$/i", Text::Format($span_bold, "$0"), $line, 1);
# Replace tab characters with margin-left
$line = preg_replace("/\t{1}/i", Text::Format($margin, "$0"), $line);
$contents["lines"][$i] = $line;
$i++;
}
}
# Add the lines from the year summary file to the tab content string
$contents["string"] = Text::From_Array($contents["lines"]);
# Linkfy the contents to transform any link texts into actual links
$contents["string"] = Linkfy($contents["string"]);
# Add the tab to the dictionary of tab templates
$website["tabs"]["templates"]["summary"] = [
"name" => $website["Language texts"]["summary, title()"],
"text_style" => "text-align: left;",
"icon" => "clipboard",
"file" => $file,
"empty_message" => Text::Format($website["Language texts"]["the_{}_text_has_not_been_created_yet"], $website["Language texts"]["summary, title()"]),
"content" => $contents["string"]
];
}
if (
file_exists($file) == False or
file_exists($file) == True and
$File -> Contents($file)["lines"] == []
) {
# Define the tab to be removed if the file is empty
array_push($website["tabs"]["To remove"], "summary");
}
?>