-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
183 lines (149 loc) · 7.82 KB
/
index.php
File metadata and controls
183 lines (149 loc) · 7.82 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
use General\Test;
require_once( __DIR__ . '/config/config.php' );
####################################
$test = new Test();
$includedFiles = $_FILEREPOSITORY->getAllIncludedFiles();
$currentFile = $_FILEREPOSITORY->getCurrentFile();
$currentPath = $currentFile->getPath();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHP Precompiler/Caching</title>
<link rel="stylesheet" href="src/assets/stylesheets/css/style.min.css">
</head>
<body>
<section class="container-xxl">
<div class="row vstack row-gap-3 py-5">
<div class="col-12">
<h2>Call to function render() inside the Test class:</h2>
<?php
// How does isolation work in PHP? Which generally defined variables/constants/... can I access inside a class?
echo $test->render();
?>
</div>
<div class="col-12 bg-info p-3">
<h2>Directly including the snippet:</h2>
<?php include __DIR__ . '/views/testView.php'; ?>
</div>
<div class="col-12 bg-black text-light p-3">
<div>
<div class="mb-3">
<h2 class="fw-semibold text-danger">Output of the current file:</h2>
<small class="bg-white text-muted px-2">(<?= $currentPath; ?>)</small>
</div>
<div class="mb-3">
<?php
if ( !empty( $currentFile ) ) {
$content = $currentFile->getContent();
if ( !empty( $content ) ) {
?>
<div id="accordionCurrentFileContent" class="accordion">
<div class="accordion-item">
<h4 id="headingCurrentFile" class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-currentFile" aria-expanded="true" aria-controls="collapse-currentFile">
Currently viewed file content
</button>
</h4>
<div id="collapse-currentFile" class="accordion-collapse collapse" aria-labelledby="headingCurrentFile" data-bs-parent="#accordionCurrentFileContent">
<div class="accordion-body"><?= $content; ?></div>
</div>
</div>
</div>
<?php
} else {
echo '<p class="m-0">File has no content.</p>';
}
}
?>
</div>
<div class="mb-3">
<div class="mb-3">
<h3 class="fw-semibold text-warning">Includes found in file:</h3>
<small class="bg-white text-muted px-2">(<?= $currentPath; ?>)</small>
</div>
<?php
$currentIncludedFiles = $_FILEREPOSITORY->getFilesFromIncludes( $currentFile );
if ( !empty( $currentIncludedFiles ) ): ?>
<div id="accordionIncludesCurrent" class="accordion">
<?php foreach ( $currentIncludedFiles as $index => $include ): ?>
<div class="accordion-item">
<h4 id="heading<?= $index; ?>" class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-current<?= $index; ?>" aria-expanded="true" aria-controls="collapse-current<?= $index; ?>">
<?= $include->getPath(); ?>
</button>
</h4>
<div id="collapse-current<?= $index; ?>" class="accordion-collapse collapse" aria-labelledby="heading<?= $index; ?>" data-bs-parent="#accordionIncludesCurrent">
<div class="accordion-body"><?= $include->getContent(); ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php else:
echo '<p>No includes found.</p>';
endif;
?>
</div>
<div>
<div class="mb-3">
<h3 class="fw-semibold text-warning">Combine includes with parent file:</h3>
<small class="bg-white text-muted px-2">(<?= $currentPath; ?>)</small>
</div>
<div class="code-container bg-light p-3 rounded" style="max-height: 500px; overflow: auto;">
<?php
// Prüfen, ob bereits ein Cache existiert
if ( $_CACHE->has( $currentPath ) ) {
// Gecachten Inhalt laden
$content = $_CACHE->get( $currentPath );
echo 'Aus Cache geladen!';
} else {
// Inhalt neu generieren
$content = $currentFile->writeIncludesIntoFile();
if ( $content !== FALSE ) {
// Im Cache speichern
$_CACHE->set( $currentPath, $content );
echo 'Neu generiert und gecacht!';
}
}
// Inhalt verwenden
if ( $content !== FALSE ) {
/* eval('?>' . $content); */
echo highlight_string( $content, TRUE );
}
?>
</div>
</div>
</div>
</div>
<div class="col-12 bg-black text-light p-3">
<h2 class="fw-semibold text-danger">Read file and show its contents:</h2>
<div class="mb-3">
<h3 class="fw-semibold text-warning">Includes found:</h3>
<?php if ( !empty( $includedFiles ) ): ?>
<div id="accordionIncludes" class="accordion">
<?php foreach ( $includedFiles as $index => $include ): ?>
<div class="accordion-item">
<h4 id="heading<?= $index; ?>" class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse<?= $index; ?>" aria-expanded="true" aria-controls="collapse<?= $index; ?>">
<?= $include->getPath(); ?>
</button>
</h4>
<div id="collapse<?= $index; ?>" class="accordion-collapse collapse" aria-labelledby="heading<?= $index; ?>" data-bs-parent="#accordionIncludes">
<div class="accordion-body"><?= $include->getContent(); ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php else:
echo '<p>No includes found.</p>';
endif;
?>
</div>
</div>
</div>
</section>
<script src="src/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="src/assets/js/index.js" type="text/javascript"></script>
</body>
</html>