Skip to content

Commit d3af52b

Browse files
committed
Add TextDocument as layout for simple text snippet files, such as robots.txt
1 parent 058d330 commit d3af52b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace WebApp\DefaultTheme;
4+
5+
/** Returns the output of the page as a pure text */
6+
class TextDocument extends \WebApp\Layout {
7+
8+
public function __construct($theme, $page) {
9+
parent::__construct($theme, $page);
10+
}
11+
12+
public function renderPage() {
13+
header('Content-Type: text/plain');
14+
$rc = $this->page->getMain();
15+
if ($rc == NULL) $rc = '';
16+
if (!is_string($rc)) {
17+
if (is_array($rc)) $rc = implode("\n", $rc);
18+
else $rc = 'Invalid content detected.';
19+
}
20+
return $rc;
21+
}
22+
}
23+

0 commit comments

Comments
 (0)