From: Christian Weiske Date: Mon, 6 Jul 2015 20:42:14 +0000 (+0200) Subject: single file edit: jump to file after saving X-Git-Tag: v0.6.0~10 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/93ef642c25d65519b334fecad56bf6567eeb733b single file edit: jump to file after saving --- diff --git a/data/templates/display-file.htm b/data/templates/display-file.htm index 67a584b..adffbc7 100644 --- a/data/templates/display-file.htm +++ b/data/templates/display-file.htm @@ -5,7 +5,7 @@ {{toolinfo.getTitle}} {% endfor %} -

{{file.getFilename}}

+

{{file.getFilename}}

{{file.getRenderedContent(toolres)|raw}} diff --git a/data/templates/edit.htm b/data/templates/edit.htm index 401ed00..870ef23 100644 --- a/data/templates/edit.htm +++ b/data/templates/edit.htm @@ -7,7 +7,7 @@ {% block content %}
-
+
diff --git a/src/phorkie/File.php b/src/phorkie/File.php index 9eb7fa7..2afda4c 100644 --- a/src/phorkie/File.php +++ b/src/phorkie/File.php @@ -38,6 +38,16 @@ class File return $this->path; } + /** + * Get the filename usable as HTML anchor. + * + * @return string + */ + function getAnchorName() + { + return str_replace(' ', '-', $this->getFilename()); + } + /** * Return the full path to the file * diff --git a/www/edit.php b/www/edit.php index e95ca3f..33b22c2 100644 --- a/www/edit.php +++ b/www/edit.php @@ -9,16 +9,20 @@ require_once 'www-header.php'; $repo = new Repository(); $repo->loadFromRequest(); -$repopo = new Repository_Post($repo); -if ($repopo->process($_POST, $_SESSION)) { - redirect($repo->getLink('display', null, true)); -} - $file = null; if (isset($_GET['file'])) { $file = $repo->getFileByName($_GET['file']); } +$repopo = new Repository_Post($repo); +if ($repopo->process($_POST, $_SESSION)) { + $anchor = ''; + if ($file !== null) { + $anchor = '#' . $file->getAnchorName(); + } + redirect($repo->getLink('display', null, true) . $anchor); +} + render( 'edit', array(