File: edit.php

package info (click to toggle)
diogenes 0.9.20-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,976 kB
  • ctags: 3,271
  • sloc: php: 12,285; sh: 828; perl: 258; makefile: 137; sql: 85
file content (72 lines) | stat: -rw-r--r-- 2,373 bytes parent folder | download | duplicates (2)
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
<?php
require_once 'diogenes.common.inc.php';
require_once 'diogenes.admin.inc.php';
require_once 'Barrel/Page.php';
require_once 'Barrel/File.php';

if (empty($_REQUEST['dir']) && empty($_REQUEST['file']))
  exit;

// retrieve directory & file info
$dir = $_REQUEST["dir"];
$file = $_REQUEST["file"];
$page = new DiogenesAdmin($dir);

$bbarrel = $page->barrel;
$bpage = Diogenes_Barrel_Page::fromDb($bbarrel, $dir);
$bfile = new Diogenes_Barrel_File($bpage, $file);

// rcs handle
$rcs = $page->getRcs();

// file location & url
$mydir = $bbarrel->spool->spoolPath($dir);
$myfile = $bbarrel->spool->spoolPath($dir,$file);

// process requested action
$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : "";
switch($action)
{
case "set_stylesheet":
  if (isset($_REQUEST['preset_style_sheet'])) {
    $sheet = $_REQUEST['preset_style_sheet'];
    $page->info(__("Copying style sheet") . " $sheet.css");
    $rcs->commit($dir,$file,file_get_contents("{$globals->root}/styles/$sheet.css"), "replaced by $sheet.css");
  }
  break;
 
case "update":
  // update the current file with form contents
  if (isset($_REQUEST['file_content'])) {
    $page->info(__("Commiting changes to file") . " $file");
    $message = empty($_REQUEST['message']) ? "updated using editor" : stripslashes($_REQUEST['message']);
    $rcs->commit($dir,$file,stripslashes($_REQUEST['file_content']),$message);
  }

  break;
}

$rev = array_shift($tmparr = $rcs->logParse($dir,$file));

$page->assign('greeting', __("File editor")." - ". $bpage->getLocation($file). " - {$rev['rev']}");
$page->assign('post',$page->script_self());
$page->assign('dir',$dir);
$page->assign('file',$file);
$page->assign('source',__("File source"));
$page->assign('msg_log',__("log message"));
$page->assign('file_content',htmlspecialchars(file_get_contents($myfile), ENT_NOQUOTES));
$page->assign('submit',__("Submit"));

// menu for stylesheet replacement
if ($file == $globals->cssfile) {
   $page->assign('style_sheets', $globals->style_sheets);
   $page->assign('preset_style_sheet', $globals->barrel_style_sheet);
   $page->assign('msg_set_stylesheet', __("replace by a preset style sheet"));
   $page->assign('msg_replace',__("Replace"));
}

// top toolbar
$page->toolbar(__("Page"), $bpage->make_toolbar($page));
$page->toolbar(__("File"), $bfile->make_toolbar(true));
$page->display('admin-edit.tpl');
?>