aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2015-07-14 08:05:03 +0200
committerChristian Weiske <cweiske@cweiske.de>2015-07-14 08:05:03 +0200
commit4137e993d11e926ae28343c1eeac1a46977efd47 (patch)
tree940cd55b0d48d54692ee999010ce0823a9085e4c
parent808a3a5857c77ef99605fdfdde9b31b5c02e22c6 (diff)
downloadphorkie-4137e993d11e926ae28343c1eeac1a46977efd47.tar.gz
phorkie-4137e993d11e926ae28343c1eeac1a46977efd47.zip
jump to correct hash after renaming a file
-rw-r--r--src/phorkie/Repository/Post.php10
-rw-r--r--www/edit.php9
2 files changed, 18 insertions, 1 deletions
diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php
index 7a373aa..b9489e7 100644
--- a/src/phorkie/Repository/Post.php
+++ b/src/phorkie/Repository/Post.php
@@ -13,6 +13,12 @@ class Repository_Post
*/
public $newfileName;
+ /**
+ * List of files that have been renamed.
+ *
+ * @var array
+ */
+ public $renameMap = array();
public function __construct(Repository $repo = null)
@@ -48,6 +54,9 @@ class Repository_Post
$bChanged = true;
}
+ $this->renameMap = array();
+ $this->newfileName = null;
+
foreach ($postData['files'] as $num => $arFile) {
$bUpload = false;
if ($_FILES['files']['error'][$num]['upload'] == 0) {
@@ -102,6 +111,7 @@ class Repository_Post
->addArgument($name)
->execute();
$bCommit = true;
+ $this->renameMap[$originalName] = $name;
} else {
$name = $originalName;
}
diff --git a/www/edit.php b/www/edit.php
index e7e6fbc..1ced7b6 100644
--- a/www/edit.php
+++ b/www/edit.php
@@ -22,7 +22,14 @@ $repopo = new Repository_Post($repo);
if ($repopo->process($_POST, $_SESSION)) {
$anchor = '';
if ($file instanceof File) {
- $anchor = '#' . $file->getAnchorName();
+ if (isset($repopo->renameMap[$file->getFilename()])) {
+ $anchor = '#'
+ . $repo->getFileByName(
+ $repopo->renameMap[$file->getFilename()]
+ )->getAnchorName();
+ } else {
+ $anchor = '#' . $file->getAnchorName();
+ }
} else if ($file === 'newfile' && $repopo->newfileName) {
$anchor = '#' . $repo->getFileByName($repopo->newfileName)->getAnchorName();
}