aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2015-07-06 22:42:14 +0200
committerChristian Weiske <cweiske@cweiske.de>2015-07-06 22:42:35 +0200
commit93ef642c25d65519b334fecad56bf6567eeb733b (patch)
tree3b20360b66f99843498efe2ce38cdcab20d1689a
parentc87f5bbf4f85b875c96d0953c25c2ca824b534d5 (diff)
downloadphorkie-93ef642c25d65519b334fecad56bf6567eeb733b.tar.gz
phorkie-93ef642c25d65519b334fecad56bf6567eeb733b.zip
single file edit: jump to file after saving
-rw-r--r--data/templates/display-file.htm2
-rw-r--r--data/templates/edit.htm2
-rw-r--r--src/phorkie/File.php10
-rw-r--r--www/edit.php14
4 files changed, 21 insertions, 7 deletions
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 @@
<a class="btn btn-mini" href="{{toolinfo.getLink(file)}}" style="float: right;">{{toolinfo.getTitle}}</a>
{% endfor %}
<a class="btn btn-mini" href="{{repo.getLink('edit', file.getFilename)}}" style="float: right;" title="edit"><i class="icon-edit"></i></a>
- <h3 id="{{file.getFilename|replace({' ': '-'})}}">{{file.getFilename}}<a class="anchorlink" href="{{repo.getLink('display')}}#{{file.getFilename|replace({' ': '-'})}}"></a></h3>
+ <h3 id="{{file.getAnchorName}}">{{file.getFilename}}<a class="anchorlink" href="{{repo.getLink('display')}}#{{file.getAnchorName}}"></a></h3>
</div>
{{file.getRenderedContent(toolres)|raw}}
</div>
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 %}
<div class="content-padding-fix"></div>
-<form method="post" action="{{repo.getLink('edit')}}" enctype="multipart/form-data" class="form-horizontal">
+<form method="post" action="{{repo.getLink('edit', singlefile.getFilename)}}" enctype="multipart/form-data" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="description">Description</label>
<div class="controls">
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
@@ -39,6 +39,16 @@ class File
}
/**
+ * Get the filename usable as HTML anchor.
+ *
+ * @return string
+ */
+ function getAnchorName()
+ {
+ return str_replace(' ', '-', $this->getFilename());
+ }
+
+ /**
* Return the full path to the file
*
* @return string
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(