Repository navigation
Expand file tree
/
Copy pathexamples.php
More file actions
149 lines (136 loc) · 4.78 KB
/
Copy pathexamples.php
File metadata and controls
149 lines (136 loc) · 4.78 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
include_once('includes/common.php');
$example = isset($_GET['example']) ? $_GET['example'] : null;
$safeExample = htmlspecialchars((string) $example, ENT_QUOTES, 'UTF-8');
$h2 = _('Liturgical Calendar as an HTML table produced by Javascript');
// Keep this markup in step with examples/javascript/index.html, which is the same page
// standalone: the examples/ directory is a symlink to the examples repo, so main.js is
// always that repo's current copy while this host markup is a separate, local duplicate.
// Two rows, as there: the rite, calendar, locale, year type and year inputs land in
// #calendarOptions, and the five General Roman parameters in #generalRomanOptions.
$JAVASCRIPT_EXAMPLE_CONTENTS = <<<EOT
<form id="litcalForm">
<h2 class="mb-4">{$h2}</h2>
<div class="row mb-3" id="calendarOptions"></div>
<div class="row mb-4" id="generalRomanOptions"></div>
</form>
<div id="litcalWebcalendar"></div>
<table id="LitCalMessages">
<thead></thead>
<tbody></tbody>
</table>
<script type="importmap">
{
"imports": {
"@liturgical-calendar/components-js": "https://cdn.jsdelivr.net/npm/@liturgical-calendar/components-js@2.11.0/+esm"
}
}
</script>
<script type="module" src="examples/javascript/main.js"></script>
EOT;
$FULLCALENDAR_MESSAGES_FIRST = <<<EOT
<table id="LitCalMessages">
<thead></thead>
<tbody></tbody>
</table>
<div id='calendar'></div>
EOT;
$FULLCALENDAR_CALENDAR_FIRST = <<<EOT
<div id='calendar'></div>
<table id="LitCalMessages">
<thead></thead>
<tbody></tbody>
</table>
EOT;
// Keep this markup in step with examples/fullcalendar/month-view.html and messages.html,
// which are the same page standalone, for the same reason as the JavaScript example above.
$FULLCALENDAR_EXAMPLE_CONTENTS = <<<EOT
<div id="spinnerWrapper">
<div class="lds-roller">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<header>
<div id="calendarOptions" class="row mb-3"></div>
<div id="generalRomanOptions" class="row mb-4"></div>
</header>
{INTERPOLATE}
<script type="importmap">
{
"imports": {
"@fullcalendar/core": "https://cdn.skypack.dev/@fullcalendar/core@6.1.19",
"@fullcalendar/core/": "https://cdn.skypack.dev/@fullcalendar/core@6.1.19/",
"@fullcalendar/daygrid": "https://cdn.skypack.dev/@fullcalendar/daygrid@6.1.19",
"@fullcalendar/list": "https://cdn.skypack.dev/@fullcalendar/list@6.1.19",
"@fullcalendar/bootstrap5": "https://cdn.skypack.dev/@fullcalendar/bootstrap5@6.1.19",
"@liturgical-calendar/components-js": "https://cdn.jsdelivr.net/npm/@liturgical-calendar/components-js@2.11.0/+esm"
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script type="module" src="examples/fullcalendar/script.js"></script>
EOT;
$EXAMPLES = [
'PHP' => 'examples/php/index.php',
'JavaScript' => $JAVASCRIPT_EXAMPLE_CONTENTS,
'FullCalendar' => strtr($FULLCALENDAR_EXAMPLE_CONTENTS, [
'{INTERPOLATE}' => $FULLCALENDAR_CALENDAR_FIRST
]),
'FullCalendarMessages' => strtr($FULLCALENDAR_EXAMPLE_CONTENTS, [
'{INTERPOLATE}' => $FULLCALENDAR_MESSAGES_FIRST
])
];
?><!doctype html>
<html lang="<?php echo $i18n->LOCALE; ?>">
<head>
<title><?php
echo _('General Roman Calendar');
?></title>
<?php
include_once('layout/head.php');
// Since JavaScript is not an iframe, we need to ensure the CSS is loaded
if ($example) {
switch ($example) {
case 'JavaScript':
echo '<link rel="stylesheet" href="examples/javascript/styles.css">';
break;
case 'FullCalendar':
case 'FullCalendarMessages':
echo '<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">';
echo '<link href="examples/fullcalendar/styles.css" rel="stylesheet" />';
break;
case 'PHP':
echo '<link href="examples/php/styles.css" rel="stylesheet" />';
break;
}
}
?>
</head>
<body class="sb-nav-fixed production">
<?php
include_once('layout/header.php');
if (array_key_exists($example, $EXAMPLES)) {
switch ($example) {
case 'PHP':
include_once($EXAMPLES[$example]);
break;
case 'JavaScript':
case 'FullCalendar':
case 'FullCalendarMessages':
echo $EXAMPLES[$example];
break;
}
} else {
echo '<h1>' . sprintf(_("Example '%s' not found"), $safeExample) . '</h1>';
}
include_once('layout/footer.php');
?>
</body>
</html>