File: compose.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 (78 lines) | stat: -rw-r--r-- 2,476 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
73
74
75
76
77
78
<?php
require_once 'diogenes.common.inc.php';
require_once 'diogenes.admin.inc.php';
require_once 'diogenes.text.inc.php';
require_once 'Barrel/Page.php';
require_once 'Barrel/File.php';

if (!isset($_REQUEST['dir']) && !isset($_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 "update":
  // update the current file with form contents
  if (isset($_REQUEST['file_content'])) {
    $page->info(__("Commiting changes to file") . " $file");
    $content = trim(stripslashes($_REQUEST['file_content']));
    $content = str_replace("\n    ","\n",$content);
    $content = phpUnprotect(htmltoXhtml($content));
    $message = empty($_REQUEST['message']) ? "updated using HTML composer" : stripslashes($_REQUEST['message']);
    $rcs->commit($dir,$file,$content,$message);
  }

  break;
}

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

// protect PHP code and XHTML tags
$rawdoc = file_get_contents($myfile);
$protdoc = xhtmlToHtml(phpProtect($rawdoc));

// smarty assignments
$page->assign('post',$page->script_self());
$page->assign('dir',$dir);
$page->assign('dirloc',$page->urlBarrel($bbarrel->alias,$bbarrel->vhost,$bpage->getLocation()));

$page->assign('file',$file);
$page->assign('file_content',chunk_split(base64_encode($protdoc)));
$page->assign('msg_log',__("log message"));

// build toolbars
$page->toolbar(__("Page"), $bpage->make_toolbar($page));
$page->toolbar(__("File"), $bfile->make_toolbar(true));

$auxpage = new DiogenesBarrel("/".$bbarrel->alias."/". $bpage->getLocation());

switch ($globals->html_editor) {
case "ekit":
  $page->assign('greeting', "Ekit - ". $bpage->getLocation($file)." - {$rev['rev']}");
  $page->assign('cssfiles', array_pop($auxpage->sheets));
  $page->display('admin-ekit.tpl'); 
  break;
case "kafenio": default:
  $page->assign('greeting', "Kafenio - ". $bpage->getLocation($file)." - {$rev['rev']}");
  $page->assign('cssfiles', implode(",", $auxpage->sheets));
  $page->display('admin-kafenio.tpl'); 
  break;
}
?>