root/components/static.php @ 122

Revision 122, 1.5 KB (checked in by dez, 7 years ago)

Adds editing of static content
Changes branding and footer backgrounds for IE<7 - fixes #12

Line 
1<?php
2// Static page producer module
3
4// Get the right filename...
5$myfile = $base."static".$path.$language['file'].".txt";
6if (!file_exists($myfile)) {
7    $myfile = $base."static$path.txt";
8    // ...or serve a 404 error
9    if (!file_exists($myfile)) {
10        header("HTTP/1.1 404 Not Found");
11        $smarty->assign("body", file_get_contents($base."static/404.txt"));
12        $smarty->assign("pathlist", array("", "Error"));
13        $smarty->assign("title", "File not found");
14        return;
15    }
16}
17
18// A user must be in the html group in order to edit pages in this component
19$permission = "html";
20
21
22// If we've been asked to save changes and have permission to do so...
23if (@$_REQUEST['action']=="Save" && $session->groups[$permission]) {
24    file_put_contents($myfile, $_REQUEST['body'], LOCK_EX);
25}
26
27if (isset($pathlist[2]))
28    $title = $pathlist[2];
29elseif (isset($pathlist[1]))
30    $title = $pathlist[1];
31else
32    $title = "Static Page Producer";
33
34$body = file_get_contents($myfile);
35$modified = filectime($myfile);
36
37$smarty->assign("title", $title);
38$smarty->assign("modified", date("r", $modified));
39
40
41// Editing static pages - does the user have permission?
42if (isset($session->groups[$permission])) {
43// display Edit link on page
44    $smarty->assign("editable", true);
45// load the editing template
46    if (@$_REQUEST['action']=="edit") {
47        $smarty->assign("editcontent", htmlentities($body));
48        $body = $smarty->fetch('static_edit.tpl');
49        $smarty->assign("action", $_REQUEST['action']);
50    }
51}
52
53$smarty->assign("body", $body);
54
55?>
Note: See TracBrowser for help on using the browser.