single file edit: jump to file after saving
[phorkie.git] / www / edit.php
1 <?php
2 namespace phorkie;
3 /**
4  * Edit paste contents
5  */
6 $reqWritePermissions = true;
7 require_once 'www-header.php';
8
9 $repo = new Repository();
10 $repo->loadFromRequest();
11
12 $file = null;
13 if (isset($_GET['file'])) {
14     $file = $repo->getFileByName($_GET['file']);
15 }
16
17 $repopo = new Repository_Post($repo);
18 if ($repopo->process($_POST, $_SESSION)) {
19     $anchor = '';
20     if ($file !== null) {
21         $anchor = '#' . $file->getAnchorName();
22     }
23     redirect($repo->getLink('display', null, true) . $anchor);
24 }
25
26 render(
27     'edit',
28     array(
29         'repo' => $repo,
30         'singlefile' => $file,
31         'dh'   => new \Date_HumanDiff(),
32         'htmlhelper' => new HtmlHelper(),
33     )
34 );
35 ?>