* improved - after adding a page, return to the calling url
[diogenes.git] / include / admin / edit.php
CommitLineData
6855525e
JL
1<?php
2require_once 'diogenes.common.inc.php';
3require_once 'diogenes.admin.inc.php';
4require_once 'Barrel/Page.php';
5require_once 'Barrel/File.php';
6
7if (empty($_REQUEST['dir']) && empty($_REQUEST['file']))
8 exit;
9
10// retrieve directory & file info
11$dir = $_REQUEST["dir"];
12$file = $_REQUEST["file"];
13$page = new DiogenesAdmin($dir);
14
15$bbarrel = $page->barrel;
16$bpage = Diogenes_Barrel_Page::fromDb($bbarrel, $dir);
17$bfile = new Diogenes_Barrel_File($bpage, $file);
18
19// rcs handle
20$rcs = $page->getRcs();
21
22// file location & url
23$mydir = $bbarrel->spool->spoolPath($dir);
24$myfile = $bbarrel->spool->spoolPath($dir,$file);
25
26// process requested action
27$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : "";
28switch($action)
29{
eb413b12
JL
30case "set_stylesheet":
31 if (isset($_REQUEST['preset_style_sheet'])) {
32 $sheet = $_REQUEST['preset_style_sheet'];
33 $page->info(__("Copying style sheet") . " $sheet.css");
34 $rcs->commit($dir,$file,file_get_contents("{$globals->root}/styles/$sheet.css"), "replaced by $sheet.css");
35 }
36 break;
37
6855525e
JL
38case "update":
39 // update the current file with form contents
40 if (isset($_REQUEST['file_content'])) {
41 $page->info(__("Commiting changes to file") . " $file");
42 $message = empty($_REQUEST['message']) ? "updated using editor" : stripslashes($_REQUEST['message']);
43 $rcs->commit($dir,$file,stripslashes($_REQUEST['file_content']),$message);
44 }
45
46 break;
47}
48
49$rev = array_shift($tmparr = $rcs->logParse($dir,$file));
50
51$page->assign('greeting', __("File editor")." - ". $bpage->getLocation($file). " - {$rev['rev']}");
52$page->assign('post',$page->script_self());
53$page->assign('dir',$dir);
54$page->assign('file',$file);
55$page->assign('source',__("File source"));
56$page->assign('msg_log',__("log message"));
57$page->assign('file_content',htmlspecialchars(file_get_contents($myfile), ENT_NOQUOTES));
58$page->assign('submit',__("Submit"));
59
eb413b12
JL
60// menu for stylesheet replacement
61if ($file == $globals->cssfile) {
62 $page->assign('style_sheets', $globals->style_sheets);
63 $page->assign('preset_style_sheet', $globals->barrel_style_sheet);
81246c57 64 $page->assign('msg_set_stylesheet', __("replace by a preset style sheet"));
eb413b12
JL
65 $page->assign('msg_replace',__("Replace"));
66}
67
6855525e 68// top toolbar
d0b659f7 69$page->toolbar(__("Page"), $bpage->make_toolbar($page));
6855525e
JL
70$page->toolbar(__("File"), $bfile->make_toolbar(true));
71$page->display('admin-edit.tpl');
72?>