diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-03-28 17:24:44 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-03-28 17:24:44 +0200 |
| commit | cec8f61ab84122a3f4b0702aaad6f7a141f99f7b (patch) | |
| tree | 829ccddf19eaf25ebf918632228eb96088b250d4 /www/edit.php | |
| parent | 2f7659becb40e457872fc45f59ad81bff439722f (diff) | |
| download | phorkie-cec8f61ab84122a3f4b0702aaad6f7a141f99f7b.tar.gz phorkie-cec8f61ab84122a3f4b0702aaad6f7a141f99f7b.zip | |
editing works basically
Diffstat (limited to 'www/edit.php')
| -rw-r--r-- | www/edit.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/www/edit.php b/www/edit.php index d86df41..3bcec6e 100644 --- a/www/edit.php +++ b/www/edit.php @@ -8,6 +8,48 @@ require_once 'www-header.php'; $repo = new Repository(); $repo->loadFromRequest(); +if (isset($_POST['files'])) { + $vc = $repo->getVc(); + $repo->setDescription($_POST['description']); + + $bChanged = false; + foreach ($_POST['files'] as $num => $arFile) { + if (!isset($arFile['original_name']) + || !$repo->hasFile($arFile['original_name']) + ) { + //FIXME: Show error message + continue; + } + //FIXME: fix file names from .. and ./ + if ($arFile['original_name'] != $arFile['name']) { + //FIXME: what to do with overwrites? + $vc->getCommand('mv') + ->addArgument($arFile['original_name']) + ->addArgument($arFile['name']) + ->execute(); + $bChanged = true; + } + $file = $repo->getFileByName($arFile['name']); + if ($file->getContent() != $arFile['content']) { + file_put_contents($file->getPath(), $arFile['content']); + $command = $vc->getCommand('add') + ->addArgument($file->getFilename()) + ->execute(); + $bChanged = true; + } + } + + if ($bChanged) { + $vc->getCommand('commit') + ->setOption('message', '') + ->setOption('allow-empty-message') + ->setOption('author', 'Anonymous <anonymous@phorkie>') + ->execute(); + } + + redirect($repo->getLink('display')); +} + render( 'edit', array( |
